Lab view programming to drive motor

Click For Summary

Discussion Overview

The discussion revolves around programming a servo motor to respond to light conditions using LabVIEW, specifically focusing on how to control the motor's movement based on sensor input. Participants explore both basic and advanced functionalities, including conditional statements and multi-sensor setups.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification
  • Homework-related

Main Points Raised

  • One participant seeks guidance on programming a servo motor to operate based on light levels detected by a sensor, indicating they are a beginner.
  • Another participant suggests using case structures to implement conditional logic for motor operation based on sensor voltage readings.
  • A participant confirms they have successfully connected the motor to a DAQ card and have it functioning, but seeks further assistance with more complex sensor integration.
  • There is a proposal to implement two sensors to allow the motor to move towards the direction of light, with a noted issue of the motor not moving beyond 150 degrees.
  • One participant outlines a troubleshooting approach, suggesting steps to verify motor movement and sensor readings, while expressing concern about the servo's limited range of motion.
  • Another participant clarifies that their program is functioning well and expresses a desire to implement a tracking mechanism using two sensors to guide the motor's movement based on light detection.
  • Participants discuss the use of different hardware setups, including a DAQ card and a motor driver, to achieve the desired motor control.

Areas of Agreement / Disagreement

Participants generally agree on the functionality of the existing program but have differing views on the implementation of the dual sensor setup and the issue of the motor's range of motion. The discussion remains unresolved regarding the optimal approach for the tracking mechanism.

Contextual Notes

There are limitations regarding the specific programming techniques and hardware configurations discussed, as well as the potential for programmable stops in the servo that may affect its range of motion.

Who May Find This Useful

This discussion may be useful for beginners in programming with LabVIEW, those interested in motor control applications, and individuals exploring sensor integration for robotics or automation projects.

mrgenius
Messages
6
Reaction score
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: 648
  • ldr tester.png
    ldr tester.png
    20.5 KB · Views: 617
Last edited:
Engineering news on Phys.org
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: 571
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: 409
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.
 
Hi

I used it using DAQ card-USB-6211. The motor worked fine.
 
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)
 
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.
 
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: 562
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: 613
  • motor controller1.jpg
    motor controller1.jpg
    17.7 KB · Views: 553

Similar threads

  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 27 ·
Replies
27
Views
1K
Replies
16
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
Replies
6
Views
4K
Replies
9
Views
3K
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 7 ·
Replies
7
Views
4K