01-06-2014 09:07 PM
I use a serial port to control the stepper motor, and I want to know the position of the motor at any time, so I can know when to stop captuingr image with a CCD.
There is only a serial port, if I accessing the serial port with two loops, the step motor will buzzing.
So, I want to know if there is method to solve the problem.
01-07-2014 04:36 AM
01-07-2014
07:06 AM
- last edited on
05-09-2025
01:01 PM
by
Content Cleaner
The Action Engine is probably the easiest way.
Another way would be to make a Producer/Consumer so that you have another loop that hanldes all of the talking to the stepper motor. The other loops just send commands to it via a queue. You can send data back using notifiers or user events.
01-07-2014 07:17 AM
Do you have any examples that can help me out ?
01-07-2014 08:27 AM
One simple change you can try is to just put the code from the second loop into a timeout event. It will read whenever one of the other events is not running.
And please, get rid of all of those VISA Bytes at Serial Port with the fixed delays. Since the device appears to recieve and send a termination character, you don't need either of them.
Also, clean up your wiring.
01-07-2014
10:51 AM
- last edited on
05-09-2025
01:01 PM
by
Content Cleaner
I have used Semaphors in the past, see my attachment here:
Upper loop polls for data at regular intervals.
Lower loop sends configuration commands as needed.
This is just sandbox code I was playing with to prototype a larger app.
-AK2DM