Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

Running Servo Motor

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. There are two sensors with a divider between them. So as the light strucks both the photo resistors teh 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 !

Download All
0 Kudos
Message 1 of 15
(7,751 Views)

HI jacksons,

 

Thanks for your post. What hardware are you using and how are you connecting your Light Dependant Resistors and servo motor? I would suggest you run the servo motor in a while loop within a case structure, therefore you can read in your raw sensor values and check that against a threshold and switch cases when the light threshold is reached.

 

Regards,

Ben B.

Applications Engineer
National Instruments UK & Ireland

"I've looked into the reset button, the science is impossible!"
0 Kudos
Message 2 of 15
(7,732 Views)

Yes I am connecting them and using DAQ USB interface. Could you show how I do that by modifying the Lab view file I have attached please. Since I am new to it I find it hard to understand exactly. Thanks!

0 Kudos
Message 3 of 15
(7,729 Views)

Hi jacksons,

 

The screenshot of a vi i have attached takes a voltage in, compares whether or not the input is above 3 volts, then depending on this output the Select function will output either true or false to change the case structure. So for example if the input was 2 volts the select function would output a False causing the program to run the code in the False part of the case structure. Within the case structure you can then place your PWM code to stop or turn the servo. You will need to create the PWM task outside the while loop as you have done in your Motor test vi.

 

Regards,

Ben B.

Applications Engineer
National Instruments UK & Ireland

"I've looked into the reset button, the science is impossible!"
0 Kudos
Message 4 of 15
(7,724 Views)

Hi

 

Thanks for your help. I really appreciate it. Could you tell me a bit more about the programming code and how we can do it? I basically connected a wire when its false. 

Also should I copy the entire block from the motor.vi file and place it outside the loop? After doing that how and where do I connect as the input.

 

Sorry for so many questions. Thanks! 

0 Kudos
Message 5 of 15
(7,709 Views)

Hi jacksons,

 

The way you set up DAQ tasks is the same way you have done in your Motor test vi. You create the channel, then setup the clock and start the task before the while loop, then write the signal inside the while loop. Then clear the task outside the while loop after the vi has been stopped. The best way for me to help you would be for you to try to create this program around the code i suggested. You can then post the code so i can see exactly what you are doing then i can offer guidance from there.

 

Regards,

Ben B.

Applications Engineer
National Instruments UK & Ireland

"I've looked into the reset button, the science is impossible!"
0 Kudos
Message 6 of 15
(7,688 Views)

The code that goes into the case structure is teh conversion factor where the voltages received from the light sensor is converted into pulse width modulation...I guess. And that is (angle in degrees*1/180)+Offset time(in ms). So could you show how to place this code in case structure and then how I connect it to motor program please. Thanks

0 Kudos
Message 7 of 15
(7,649 Views)

Or Can you help me in making a simple program where I can get my objective. Doesnt has to be a continuation of what I did

0 Kudos
Message 8 of 15
(7,631 Views)

Hi jacksons,

 

Is it possible to post the code you have so far? That way it makes it easier for me to see exactly what your train of thought is.

 

Regards,

 

 

Ben B.

Applications Engineer
National Instruments UK & Ireland

"I've looked into the reset button, the science is impossible!"
0 Kudos
Message 9 of 15
(7,609 Views)

Hi

 

I don't have much clue what I have done. I have just made the program which is the conversion factor inside the case structure. Please let me know what to do next. Thanks

0 Kudos
Message 10 of 15
(7,603 Views)