Lab view programming to drive motor

In summary, the person is trying to make a servo motor move based on whether there is light or not. They are not sure how to make it work and are asking for help.
  • #1
mrgenius
6
0
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 anyone could give me a good explanation on how to make it (please note I am still a beginner)

Thanks !
 

Attachments

  • motor tester.png
    motor tester.png
    23.1 KB · Views: 565
  • ldr tester.png
    ldr tester.png
    20.5 KB · Views: 537
Last edited:
Engineering news on Phys.org
  • #2
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.
 

Attachments

  • LVexample.jpg
    LVexample.jpg
    13.1 KB · Views: 494
  • #3
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 !
 

Attachments

  • Untitlesdasd.png
    Untitlesdasd.png
    16.3 KB · Views: 329
  • #4
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.
 
  • #5
Hi

I used it using DAQ card-USB-6211. The motor worked fine.
 
  • #6
But that's 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 doesn't 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)
 
  • #7
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.
 
  • #8
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 :smile:
 

Attachments

  • 28112011489.jpg
    28112011489.jpg
    37.6 KB · Views: 479
  • #9
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 !
 

Attachments

  • motor controller2.jpg
    motor controller2.jpg
    38.1 KB · Views: 539
  • motor controller1.jpg
    motor controller1.jpg
    17.7 KB · Views: 475

1. How do I use LabVIEW to control a motor?

To use LabVIEW to control a motor, you will need to first connect your motor to a motor driver or controller that is compatible with LabVIEW. Then, you can use the LabVIEW programming interface to create a control program that sends signals to the motor driver to control the motor's speed, direction, and other parameters.

2. What kind of motor drivers are compatible with LabVIEW programming?

LabVIEW is compatible with a variety of motor drivers, including those that use analog, digital, or pulse width modulation (PWM) signals. It is important to check the specifications of your specific motor driver to ensure it is compatible with LabVIEW.

3. Can I use LabVIEW to control multiple motors simultaneously?

Yes, LabVIEW has the capability to control multiple motors simultaneously. This can be achieved by creating separate control programs for each motor and running them simultaneously or by creating a single program that can control multiple motors at once using parallel programming techniques.

4. Do I need any additional hardware to use LabVIEW for motor control?

In addition to a motor driver or controller, you may also need other hardware such as sensors, encoders, or amplifiers to accurately control and monitor your motor using LabVIEW. The specific hardware needed will depend on the type of motor and the application.

5. Is LabVIEW suitable for both simple and complex motor control applications?

Yes, LabVIEW can be used for both simple and complex motor control applications. It offers a user-friendly programming interface for beginners, as well as advanced features and capabilities for more complex control applications. With its modular design and extensive library of functions and toolkits, LabVIEW can be tailored to fit a wide range of motor control needs.

Similar threads

Replies
9
Views
2K
Replies
2
Views
3K
  • Electrical Engineering
Replies
19
Views
306
Replies
7
Views
2K
Replies
16
Views
1K
  • Mechanical Engineering
Replies
6
Views
852
Replies
5
Views
1K
Replies
6
Views
1K
Replies
6
Views
2K
  • Electrical Engineering
Replies
9
Views
1K
Back
Top