09-05-2012 01:49 PM
I am using a proximity sensor to locate and count a an object as it oscillates. As the reference voltage changes I need to change the position of the servo motor. I have developed individual programs, one for the sensor and one to operate the servo motor, however I am have problems combining the two programs.
Attached are the two programs. Are there any recommendations of how to combine the two programs? I am using a DAQ 6210
Solved! Go to Solution.
09-05-2012 09:27 PM
Due to using an old version of labview I can't open your VIs, however a few things that might help.
How does the reference value relate to the servomotor target value?
Have you set the two VIs up as SubVIs?
What have you tried so far?
09-06-2012 09:18 AM
I have been mainly trying to insert the servo program into the case structures used in the counting program. However when I do this the program collecting samples from the prox. sensor pauses everytime the servo should be turned on. The reference voltage is in collected from the prox sensor, (It emits 1.83 volts, when an object passes by the voltage drops to 0 volts.) Using the change in voltage I have developed a method using case structures and local variables to count changes in voltage. Attached is a print screen of both programs in one vi. To reduce the complexity I was thinking it may be easier to run parralel loops. However I am not sure how to make connect them. Ultimately I need to start the servo program when the prox sensor recognizes the first object.
09-06-2012 10:18 AM - edited 09-06-2012 10:21 AM
Hi Herriott,
As mentioned in Hornless.Rhino's post, you will most likely need to bring both VIs into a project and bring them together as sub VIs.
After looking at the two VIs that you posted, it is not completely clear how you want to control the servo motor based on sensor. It appears to me that you have one VI that controls the servo and one VI that reads in voltage from the sensor and adds a count, but it is NOT clear how you want the servo to be controlled.
Can you explain more about what pulse width you want to output and when you want to output that pulse width? From my understanding, you just want to run the servo 2.vi every time you add a one to the count in the Proximity Counter Tack.vi, is this correct?
Also, if possible I would try to avoid using local variables. Something such as queues might be better.
09-06-2012 10:36 AM
Some background....I have a metal arm attached to a chain with revolves around two gears. The drive gear is controlled by a variale rate motor. I sill be using the sensor to calculated the RPM of the arm. Within one revolution I need the servo motor to open and close a mechanism. I have obtain the desired range of motion with the servo by changing the duty cycle between .04 and .12 at a frequency of 50 Hz.
I am trying to control the servo so when the voltage in the sensor changes the servo goes to postion 1 (duty cycle .04) for x milliseconds, then to position 2 (duty cycle .12).
09-07-2012 10:18 AM - edited 09-07-2012 10:19 AM
Herriott,
I have attached a LabVIEW project that combines the two VIs. They are combined in such away that the servo 2.vi is called every time you add one to the count in the Proximity Counter Tack.vi. For information on how to make sub VI please refer to the links in the previous posts on this thread. Again, I am not completely sure how you want to control the servo, but this should get you started so that you can edit the project to fit your needs.