servo

if i want to program a servo to move say 5 degrees up when i push a button on the joystick, how do i do that, specificly in teleop (a diagram would be nice)

the way i have it wired now is from the name to joystick vi’s, to unbundled y axis, to case structure (true). here is where i have trouble, i can’t connect the wiring to any of the servo vi’s, set position, get position, you name it. that is my problem. How do i wire this so when i push the axis or button, it moves how ever many degrees or speed. ive been looking in all the tutorials for awhile, that includes other websites.::rtm::

Have a feedback node keep the current value of the servo, which is always writing to it. Have a case structure so that when you press the button, it adds five to the value.

With that setup, it will add 5 degrees every single time the loop runes (which is quite fast). If you want to wait for the button to release and then repress before it adds another five, you will have to add another feedback node. This one would keep the value of another case structure, around the first one. You wire the output of the feedback node into the input of the case structure. This would have several names as the cases: Try calling them “Button Pressed” and “Button Released”

The button released state would look for the button to be pressed, and when that happens would send the +5 degree command and the “Button Pressed” constant to the feedback node. In the Button Pressed state, it would give either a value of “Button Pressed” to the feedback node if the button was pressed or a value of “Button Released” if the button was released. At that point, it would go back to button released and start over.

I guess I’ll attach some code… One of them is how I said to do it in this post, and the “simplified” version is one that uses no case structures and very few functions.

Joystick Servo.vi (10.6 KB)
Joystick Servo Simplified.vi (9.63 KB)


Joystick Servo.vi (10.6 KB)
Joystick Servo Simplified.vi (9.63 KB)

what program do i open the files with?

…Labview?..

maybe

I apologize, my reply was a bit obnoxious. The answer is definitely Labview.

no problem, i wasn’t sure if it was word or picture or something like that.

I hooked up your simplified version to the buttons. I’ve attached the vi below. It still does nothing. No servo moves at all when I press a button. I replaced a couple (+) vis with (-). I want to control up with 3, down with 2, left with 4, and right with 5. What’s wrong with the program?

Teleop.vi (26.5 KB)


Teleop.vi (26.5 KB)

Perhaps nothing is wrong with the program.

Did you remember to install the 6v servo power jumper next to the PWM output pins on the Digital Sidecar? Without that jumper in place, the servo won’t be powered and won’t be able to move at all.

I can see your problem, but I’m not sure how to describe it. My code either told the servo to go to the position it’s already at or go to the position it’s at +5 degrees. You have two commands, one saying to go to the one it’s at and one telling it to go up 5 degrees. This means that several microseconds after it sends the signal to go to one position, it’s already telling it to go to another.

I could give you a few ways to make it either go +0, +5, or -5, but it looks like you really want to be able to hold down the button and have the camera move down. In that case, you can just have a selector or case structure with the input wired to the joystick button; the true case wired to “add five” and the false case have another identical case structure but with a “subtract five” in the true case and a “say the same” in the false case. Remember to use a feedback node to have the servo remember its current position.

Sorry I can’t give you another example, but I really have to do my homework and get to bed.

I think this thread is getting more complicated then it needs to. The way I understand your question is that when a button is not pressed you want a servo to be at angle X, and when it is you want it to be at angle X+5. Is this right?

The way I would do this is by having a true/false case statement with the numeric constant X in the false case and X+5 in the true case. I would then feed this value in to the WPI servo .vi called “Set Angle”. This code would make the servo go to one angle (in this case X) while the button is not pressed and another (in this case X+5) when it is.

If you still don’t see any movement try changing the values from X and X+5 to 0 and 170, it could just be to small a change to see. If there is still no servo movement after that, respectfully suggest to electrical it’s their fault, calmly double check your code, then yell at electrical.

What is this jumper everyone refers to? Is it a special piece that fits around the two prongs? Is it like the PWM cable only two wired, and if so where does the other end go to? I have looked all over the web and have only seen it refered to as jumper.

Four of them were in the Kit of Parts, in the small parts bag in the black tote. Look at the KoP checklist for a picture.

This is what i have, what next? don’t forget i want the arm to go up however fast however far when i push the y axis, i just want it to move. i also need to do the same thing with another part of the arm. i have also been told they will be used with denso motors, do i change the vi’s at all for that? and i am confused on how to input what port/pwm the motor or servo is wired into for each specific servo or motor vi. if anyone can send me a copy of my attachment an example on how to do all of what i just stated, i should be good from there.

Teleop.vi (13.4 KB)


Teleop.vi (13.4 KB)

I am also having trouble connecting the unbundled buttons going through the case structure and into the motor set output vi. :confused:

A Joystick button returns a boolean. The motor set output requires a number. If you want to feed the numeric value of a boolean (0 or 1) into the set output VI (this would run a motor in one direction whenever the button is held and stop it when released there is a small VI block that will do the conversion.

I don’t have Labview in front of me here at work, but I would guess that it is in the Boolean palette and if I recall correctly has “0:1” on the icon.

When you get the chance, can you modify the attachment i added before and show me that.:smiley:

I head straight from work over to the school to work with 3573 where I don’t have Internet access. I will take a look at the attached code when I get home this evening (6 or 7 ET).

that is great, thanks.