Servo motor?

So my team and I were trying to figure out how to program a servo motor in teleop where when we push button 1 the servo spins its full range then once the button is released the servo returns to 0° automatically. No clue how to program this and any help given would be great

This depends on the rate at which you want this to happen at. As fast as possible is pretty easy since the servo just needs you to give it an angle and it does the rest unlike other motors that need a speed input. So before I can give you a definite answer, do you have a rate at which you would like the servo to move?

Assuming you don’t care about slowing down the servo’s motion, what you want to do is pretty easy. Use a joystick button to select between 0 (when false) and 180 (when true), and feed the selected value to a Gyro Set Angle.

I think the default maximum is actually only 170 degrees. You can change it to match the servo you’re using when you Open it.

We don’t care about speed, and we’re just trying to get the servo to go from button not pushed: 0°; button pushed 180°, 170 if this is max.

Below is the code we have so far, it’s from an example I believe.













The code looks good to me. Another thing to remember is that the servo needs power applied to it, too. There has to be a jumper across the two pins directly next to the PWM port the servo is plugged into.

There’s a jumper, and it’s wired in PWM 4. We’re currently having problems with our Digital Sidecar. There’s a thread posted here http://www.chiefdelphi.com/forums/showthread.php?t=112925

Well… That opens up a whole 'nother bag of worms. Based on what you have said from your last thread, have you tried swapping the cable from the cRIO to the digital sidecar with a known working one? Remember that last year’s ribbon cables shipped assembled backwards, which would screw up a bunch of things.

We’ve differentiated between the round and flat cables, however I do believe the issue MAY be with DS (digital sidecar) as it wasn’t receiving full power. Tomorrow I will make adjustments and take photo pictures then upload them here. Here’s to hope!

I saw the other thread, and I can’t believe I made the fundamental mistake of not suggesting power to the Digital Sidecar. Hopefully applying power will fix everything easily.