Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling multiple servos

Hello,

 

I have recently been working through the myRIO demonstration VI's, specifically the servo demo, and I have noticed some strange behavior when trying to control more than 1 servo simultaneously.

 

I duplicated the code on the block diagram of the demo and made the appropriate changes to output the PWM on another PWM channel (Connector B, PWM channels 0 and 1). I am also using an external power supply set to 5V DC and allow up to 5 amps current to power both servos. The servos being used are the ones that were included in the mechatronics kit for the myRIO.

 

Even with the servos being externally powered and not using the myRIO to power them, I see erratic servo behavior when trying to control them. Sometimes they work mostly ok, other times they randomly jump around while sweeping through their ranges, and other times they just go crazy moving to random positions very rapidly. If I unplug one of the servos, the remaining servo operates as expected. As soon as I add in the second servo, the weird behavior resumes.

 

Since these are being powered externally, and more than enough current is being allowed to pass through if needed, I do not understand why I am seeing this odd behavior. Anyone have any ideas?

0 Kudos
Message 1 of 4
(3,097 Views)

Make sure the servos are being powered correctly by the power supply. Additionally, something I ran across that might make your development process easier is the Digilent motor adapter. Have you looked into it? 

0 Kudos
Message 2 of 4
(3,050 Views)

Thanks for the reply DahlmanR.

 

The problem seems to happen when I have the servo powered through the myRIO. This occurs even when using the Digilent motor adapter board that comes with the myRIO mechatronics kit. 

 

Using the S03N STD servo that came with the kit, on the motor adapter that came with the kit, I still see erratic servo behavior if getting its power from the myRIO. As soon as I switch to external power for the servo it behaves just fine. 

 

My program is set to sweep the servo through a predefined range (160 to -160 for example) incrementally in a loop running at about 20ms. When working correctly, the servo takes several seconds to sweep the full range and back and makes the full motion of the sweep. When the issue occurs, the servo moves very quickly, sometimes making the full sweep of the range and sometimes not, and sometimes the speed will change.

 

It is like there is noise in the signal or perhaps some sort of feedback, but I can't figure out what would be the issue. I am certainly not an electrical engineer, and I believe the issue lies with the circuit somehow, but not sure how to fix it.

0 Kudos
Message 3 of 4
(3,048 Views)

I'm a bit confused. The initial post suggested you have unexpected behavior when both servos are connected to the external power, but you mentioned now that it seems to work when the servos are connected to external power. 

You will definitely need to ensure that we're using external power, not the myRIO to power two servos. 


Are you running two different code snippets when controlling one motor versus two, or are you simply running the same two motor code and disconnecting the servo? 

0 Kudos
Message 4 of 4
(3,032 Views)