LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a proximity sensor to turn on a servo motor?

Solved!
Go to solution

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

Download All
0 Kudos
Message 1 of 6
(4,487 Views)

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?

0 Kudos
Message 2 of 6
(4,464 Views)

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.

0 Kudos
Message 3 of 6
(4,444 Views)

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.

Brandon L.
Automation Engineer
0 Kudos
Message 4 of 6
(4,435 Views)

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).

0 Kudos
Message 5 of 6
(4,428 Views)
Solution
Accepted by topic author Herriott

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. 

Brandon L.
Automation Engineer
0 Kudos
Message 6 of 6
(4,411 Views)