12-12-2008 10:15 AM
I am using an USB-6008 to measure the position of an incremental rotary encoder. The function of the system is to use LabView and a USB-6008 (along with other control circuitry) to control a rotary piezo motor and read its position. The movement of the motor is actuated on the front panel of LabView and the relative position of the device is displayed. Speed is relatively slow at about ½ RPM.
The A/Ao and B/Bo signals from the encoder are routed through a quadrature clock converter and sent to the 6008’s counter as a single pulse stream. The conversion from counts to position is conducted in LabView using scaling as per the encoder resolution.
Along with displaying the position, I can also zero the displayed position. So far, my program works as planned. The zeroing is accomplished by inserting a “DaqMX create virtual channel” vi into the program on a case structure set to zeroing button on the front panel. The entire vi is ran in a while loop with shift registers.
Now to my problem. Because I am using an encoder that has 409,600 counts per revolution, I am running into an issue with dither. I have read the article posted about encoders and dither, but would like to hold off on buying a $600 circuit card unless absolutely necessary. Most of the circuitry I have already incorporated into my design.
Because the dither only sends a pulse stream when the motor is not moving, I thought a simple fix may be to turn off the counter when the motor is not being activated. Since activation of the motor is controlled by a button on the front panel vi, I would like to control activation of the counter by this same button.
My attempts to perform this have not been successful. I have tried using an event structure controlled by the motor button. This did not read anything. I tried a case structure, but was also unsuccessful. It only read the scale factor.
I have attached my most recent attempt.
Please help.
THANKS!
12-16-2008 09:23 AM
Hi,
Are you trying to have the counter only count when the motor button is in the true position? The problem with how you have your code currently is that the event structure only will read a value when the button is pressed. So, one way you could go about it is to try using a state machine architecture. You are pretty much already doing this in your program but this might help you in solving how to read from the counter at certain times. The links below show the structure of a state diagram, I would recommend though to try to adjust what you have (because it is very similar) and work on the logic.
Application Design Patterns: State Machines
Also, I the subVIs for the A0_pos_R0 or A0_neg_R0 vis are not included and may be helpful in understanding what is happening in that part of the code.
12-16-2008 11:00 AM
Jordon,
Thanks for the information on the state machines. I have converted all my T/F cases to state machines and shift registers. Much cleaner.
The problem I am still having is that he counter continues to count pulses, even when I am not in a counting state. I actually need to turn off the counter, not just the display. I also need to retain the value last displayed for when I would like to count again. The counter will be representing an angular position. Maybe a fix would be to put the count value into "memory", then when I would like to count the position again, zero the counter and add the original value to it. This seems to be the easiest fix.
Also, in regards to the Ao_Pos vi's, those are for analog outputs that perform other function inside the program. It shouldn't have any bearing on the counting function. Just in case though, I have written a new vi that only has the counting portion. The vi is attached.
Thanks again for your help,
Paul
12-17-2008 12:17 PM
Paul,
I attached a revised example program that uses a state machine architecture and will only have the counter run when the motor is on. Also, I modified the code so that the last count received would be saved and returned in memory. You can easily modify this program though to start the count at zero when the motor on button is pressed.
All you have to do is press the motor boolean control and it will start and stop the counter task. The last count is saved so when you start the motor again it will start at the last count recieved.