07-08-2015 11:00 AM
Hello,
That algorithm would definitely serve my purpose. I will give it a try and let you know. It's just that the entire code was readily available and I though I could just make changes here and there to make it do what I needed. But I was wrong. The above algorithm could definitely make my life easier.
I have one other question. Is there a way to call the serial communication code after each mm? Can you guide me to where I could read further.
Thanks,
Rahul
07-08-2015 12:40 PM
Hi Rahul,
Your program is mostly a state machine, and a state machine is a good design pattern to implement the algorithm I described above. You can find more information about state machines here.
You currently have the "Read Serial Port" code in the default state, which is probably not the best place for it. I would put the "Read Serial Port" code into its own state. I would also put the motion code in its own state. Then you can set up an algorithm that loops through the motion state, the read serial port state, and the save to disk state until the program completes a scan.