Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   NEED HELP WITH SERVOS!! (http://www.chiefdelphi.com/forums/showthread.php?t=81862)

EagleS!! 04-02-2010 08:35

NEED HELP WITH SERVOS!!
 
3 Attachment(s)
We have a problem about our servos. We are using them to control our camera system. The plan is to move the camera, using servos controled with joystick buttons. We tried some codes but they didn't work. We may need some advices.

Ziaholic 04-02-2010 09:02

Re: NEED HELP WITH SERVOS!!
 
You need to put some math in between your joystick button outputs, and the Servo Set Angle block.

That SetAngle SubVI is expecting a number between 0 and 180 degrees(typically), and not the simple true/false (boolean) that you're trying to connect in your 3rd image.

How do you want the button(s) to steer it? If you are controlling both the PAN and TILT motors, then you'd need at least 4 buttons to steer it left/right or up/down. Here's one idea, read the angles from the servos, then use some true/false statements from the buttons to either add or subtract some constant value (like 10 degrees) to the read angles, then set that new angle value into the motors. If none of the 4 buttons are pressed, simply pass the original value (Get Angle) to the new value (Set Angle).

There are many many options to do this ... this is just one ... tell us more about your intent ...

EagleS!! 04-02-2010 09:40

Re: NEED HELP WITH SERVOS!!
 
1 Attachment(s)
This is what we are trying to do. Here is a photo of our new code. But we can't figure out how to connect Button 8 to Servo GetAngle.

Ziaholic 04-02-2010 09:50

Re: NEED HELP WITH SERVOS!!
 
You need to add some case structures around that "+10" area ...

Make some room in that area and drop down a case structure. Wire up the output of the joystick button to the little green control-box on the case structure. In the TRUE window, put your "+10" in there, in the FALSE case, simply wire the GET, thru the case, into the SET.

To get all 4 buttons to steer it up/down/left/right, you'll need to put more cases within that case.

This image doesn't do what you want to do, but you can see how we are taking buttons 3, 4, and 5 and wiring them into the cases to do different things. And we also are using button 1 to override the joystick throttle to 100%.

EagleS!! 04-02-2010 11:02

Re: NEED HELP WITH SERVOS!!
 
1 Attachment(s)
we are trying some code but it isn't working. Could you tell me where is the mistake.

Alan Anderson 04-02-2010 11:42

Re: NEED HELP WITH SERVOS!!
 
Quote:

Originally Posted by EagleS!! (Post 913224)
we are trying some code but it isn't working. Could you tell me where is the mistake.

Saying "it isn't working" doesn't give a lot of information. What do you expect it to do, and what is it doing instead?

There's a red dot on the input of the Servo Set Angle vi. That means you're giving it a data type that it doesn't expect.

Your code will add ten every time Teleop is called -- which is fifty times a second. You probably don't want to do that.

Joe Ross 04-02-2010 12:27

Re: NEED HELP WITH SERVOS!!
 
Quote:

Originally Posted by Alan Anderson (Post 913247)
There's a red dot on the input of the Servo Set Angle vi. That means you're giving it a data type that it doesn't expect.

The coercion dot is because GetAngle outputs an unsigned 16 bit integer, while SetAngle accepts a signed 32 bit integer. Either one handles far more then the servo needs, and so the coercion dot shouldn't matter. Not sure why two different types are used by the library.

DavidGitz 04-02-2010 13:37

Re: NEED HELP WITH SERVOS!!
 
It might have just been the picture quality, but in your Begin it looks like it says "servc a" and not "servo a". Check that and watch the errors on the diagnostics tab of the Driver Station to see if you get any refnum errors, this will tell you if you have a typo somewhere.

As far as the datatype issue is, instead of using the blue constant (integer) use a orange constant (float), that should fix your datatype mismatch error (I think...No LV here to try it on.)

EagleS!! 04-02-2010 14:43

Re: NEED HELP WITH SERVOS!!
 
Quote:

Originally Posted by Alan Anderson (Post 913247)
Saying "it isn't working" doesn't give a lot of information. What do you expect it to do, and what is it doing instead?

There's a red dot on the input of the Servo Set Angle vi. That means you're giving it a data type that it doesn't expect.

Your code will add ten every time Teleop is called -- which is fifty times a second. You probably don't want to do that.

I just expect code to move camera by 10 degrees when button8 is pressed. But when pressed, nothing happens.

Do you think red dot on the input can cause problem?

I will try any code changes tomorrow as it is night here now.

Thanks in advance

Alan Anderson 04-02-2010 15:21

Re: NEED HELP WITH SERVOS!!
 
Quote:

Originally Posted by EagleS!! (Post 913356)
I just expect code to move camera by 10 degrees when button8 is pressed. But when pressed, nothing happens.

Can you probe the values while the code is running to see if the input to the Set Angle vi is changing?

Is the robot enabled using the Driver Station?

Is the Robot Status Light on the Digital Sidecar on and winking off for a moment every second and a half?

Is the 6v power jumper installed for the PWM channel that the servo is connected to?

Is the 6v light on the Digital Sidecar lit?

If you try to turn the servo by hand, does it go where you put it, or does it resist motion and try to stay in the same position?



Once you get the servo to respond, you're only partway there. You will need to add something that only changes the servo angle when the button value changes from false to true. That means remembering the previous value so you can test against it. I use something called a Feedback Node to do that.



The red dot won't break anything. Apparently it's there because the Servo vi data types aren't consistent, and there really isn't much you can do about it.


All times are GMT -5. The time now is 11:57.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi