Register to reply

Lab view programming to drive motor

by mrgenius
Tags: drive, motor, programming, view
Share this thread:
mrgenius
#1
Dec8-11, 02:16 AM
P: 6
Hi

I will get straight on to the problem. I want my RC servo motor to run when there is no light from 0-180 degrees and when there is light the motor should stop. I have made a program which reads the voltage from sensor and a program to generate PWM signal witha a timer sepraretly as a basic approach for my task. I would appreciate if any one could give me a good explanation on how to make it (please note im still a beginner)

Thanks !
Attached Thumbnails
motor tester.png   ldr tester.png  
Phys.Org News Partner Science news on Phys.org
Security CTO to detail Android Fake ID flaw at Black Hat
Huge waves measured for first time in Arctic Ocean
Mysterious molecules in space
little
#2
Dec9-11, 04:35 PM
P: 20
I guess I'm a bit confused on what you want help with. You have written code to read the voltage from the sensor and you have written code to make the servo run, correct? You just want to know how to write a conditional statement to make the servo only run when the voltage is zero (i.e. when there is no light)?

Have you used 'case structures' before? It sounds like that might be what you want. You would feed in the voltage from the sensor. The structure would then let you say "if the V=0, move the motor" and "if V=!0, stop the motor". Your signal will likely not be precisely zero so you may want to do something like "in range and coerce" before hand. Set the limits from 0 to what ever the max voltage is when you still consider the light to be off. Then feed the boolean from that to the case structure.
Attached Thumbnails
LVexample.jpg  
mrgenius
#3
Dec10-11, 10:23 AM
P: 6
Hi

Yes you got it right. Now here where I get stuck. What do you mean by programming code for motor. I have done something what I believe is the programming code for motor. I am a beginner so please help me. Thanks !
Attached Thumbnails
Untitlesdasd.png  

little
#4
Dec12-11, 12:12 PM
P: 20
Lab view programming to drive motor

Have you been successful in making the servo motor move at all? How is it connected to the computer?

I don't recognize the LabVIEW functions in your code. The only way I've used servo motors has been with an NI Motion Control card.
mrgenius
#5
Dec12-11, 01:13 PM
P: 6
Hi

I used it using DAQ card-USB-6211. The motor worked fine.
mrgenius
#6
Dec12-11, 01:18 PM
P: 6
But thats not all I want. If I have two different sensors as input separated by a divider, I want the motor to move in the direction of light. For example if right photo sensor had light and left didnt, I want sensor to move in the direction towards left and vice versa.

(Also a small problem is that it move from 0-150 degrees. after 150 degrees it stops , it doesnt move beyond 150 degrees. It just hangs in there. I am not sure if its exact 150, when I say 150 degrees, all i mean is to complete 180 degrees it is few steps away from it where it hangs)
little
#7
Dec13-11, 12:04 PM
P: 20
Ok, I'm still lost on what exactly the problem is. It sounds like you can move the motor with the program but when you have all the stuff in there with the light sensor, nothing is happening. This is how I would propose to troubleshoot the whole thing. Go through these steps and tell me where you get stuck.

1. Write code that moves the motor 180 degrees and execute it. Make sure the motor turns. Make sure you can run the code a second time and the motor turns again. Also make sure you can make the motor turn in the other direction.

2. Write code to read the light sensor and execute it (this would be a separate VI from the above). Make it display the voltage. See that the voltage goes low when the light is off and high when the light is on. Record the voltage when the light is off and when the light is on.

3. Write a very simple conditional statement that just takes a front panel control (a true/false control). If you push "go" then it will make the motor turn. Make sure all of this works.

4. Instead of having the "go" button on the front panel, replace that code with the light sensor code. Just get one sensor working at first. See that the motor turns.

Let me know what number step you get stuck on and I can go into more detail. But I'm worried about the servo only moving 150 degrees. Are you using a servo driver - has it been tuned properly? There are frequently programmable stops too. Make sure none of those are activated.
mrgenius
#8
Dec13-11, 03:23 PM
P: 6
Hi

Thanks a lot for taking your time for me. No you got it wrong, i don't have any trouble shooting with it. The program works like charm !

I have done point 1, 2 and 3 exactly you have described. I am not using any motor driver. I am using DAQ card(USB-6211). I have attached a picture to show that. I don't think it is a big problem if servo motor is not moving beyond 150 Degrees. I will sort it out. I have achieved what I had desired for by your help. Thanks

My second step is to have two input sensors and try to manipulate the rc servo motor. For example Sensor 1 has light and Sensor 2 does not, I want the motor to move in the direction of Sensor 2. Could you help me in how to achieve this please. Thanks
Attached Thumbnails
28112011489.jpg  
mrgenius
#9
Dec20-11, 04:03 PM
P: 6
Hi

I have made a program which the motor will track the light actively. I have made two different programs. 1st program uses DAQ card to drive motor. 2nd Program drives the motor using a motor driver which has a USB attached to computer and it identifies the COM port and runs it.

My next approach is to make Servo motor actively track the light using 2 input sensors. I want the motor to actively track by moving clockwise and anti clockwise direction to track the light. Suppose the left sensor receives low voltage compared to right sensor I want the motor to move towards the direction of left sensor and vice versa. I have attached the file of both program which I have done. Please help !!!
Attached Thumbnails
motor controller2.jpg   motor controller1.jpg  


Register to reply

Related Discussions
Motor selection to drive hydraulic pump Mechanical Engineering 0
Motor torque calculation for lift having chain drive Engineering Systems & Design 1
Linear Drive Motor Electrical Engineering 0
Compost cylinder drive motor General Engineering 1