Go to Post FIRST kids never cease to amaze me. - Wayne C. [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-03-2009, 17:36
m3rc1l3ss m3rc1l3ss is offline
Registered User
FRC #1178 (DURT)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Missouri
Posts: 14
m3rc1l3ss is an unknown quantity at this point
Camera servo control off of the Joystick axes

I have been trying to figure this out for some time, but so far I have failed in being able to use the joystick axes to move the camera mount instead of the normal method of using the buttons. I am interested in using the analogue on the joystick as to have the ability to dynamically change the rate of servo movement.

What would I need to do to get a set up like this to work seeing as servos work by moving to a designated position? I would assume that I would want to set it somehow to move towards either 0 or 170 when the joystick is moved, but have the rate at which the servo changes position be varied by the value sent by the joystick.

Any assistance that you might be able to give would be much appreciated.
Reply With Quote
  #2   Spotlight this post!  
Unread 04-03-2009, 18:40
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,622
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Camera servo control off of the Joystick axes

I'm going to be slightly pedantic here, but I'm hoping you'll benefit from seeing the thought process exposed. I'm also hoping someone doesn't swoop in in the next 5 minutes with the answer all gift wrapped for you. Here's my sort of thought process on something like this:

What exactly are we trying to do? We have a servo and a joystick. We want to move the servo with the joystick. Specifically, we want to control the speed of the servo by the position of the joystick. Alas, the joystick outputs position, and the servo inputs position, not speed.

Mathematically speaking, what's the difference between the position input the servo has, and the speed input we want it to have? The mathematical definition of speed is change-in-position per unit of time. So, we need to change a command of change-in-position per unit of time into an actual command of position. We know that speed times time is the change in position over that chunk of time. So if we started at 0", and we moved at 1"/sec for 1 sec, then we'd be at 1". If we moved for another sec, we'd be at 1"+1", or 2". If we sped up to 3"/s for the next second, we'd be at 2"+3", or 5". And we could keep on adding the speed times time to our last position to find out where we are now.

The big question, of course, is what on earth this has to do with controlling the servo. The answer is pretty simple. With my ridiculous example just above, we could determine our position based on our last position, our speed, and how long we moved. You can do the same thing to tell your servo where you want it to be.

Your program has a nice sort-of timed loop in it where it waits for data from the driver's station. This gives us our chunks of time to work with. Your joystick is telling us how fast we're moving. The only other thing we need is to know where we were the last time through the loop. So here's what you do:

1. Save the position of the servo from one loop to the next. It's important that this is a floating point number, not an integer.
2. Add your joystick position (times some scaling factor) to the old servo position from the last time through the loop.
3. Check that this new position command fits inside the bounds of a good servo command. In your case, check if it's between 0 to 170. If it's not, make it fit. That is, if the new position is 172, make it equal 170.
4. Send this new position command to the servo, and save the command to use is as the OLD position in your next run of the loop.
5. Repeat for 2 minutes.

Actual implementation depends on if you're using Labview or WindRiver. But it's important that you only use a floating point number. Your loops are going to be running fairly quickly, so you'll probably be wanting to add small amounts to the position in each loop. If you're using an integer and try to add 0.25 to your old position in every loop, it will be rounded down and your servo won't move. You'd be stuck adding 1, 2, 3, etc. every loop, and that's pretty likely to be too fast to really be useful.

So, for a more detailed explanation, I'd need to know what programming language you're using. But the basic idea is to just add your joystick's value to the position of your servo every time you make a loop.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #3   Spotlight this post!  
Unread 09-03-2009, 16:04
m3rc1l3ss m3rc1l3ss is offline
Registered User
FRC #1178 (DURT)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Missouri
Posts: 14
m3rc1l3ss is an unknown quantity at this point
Re: Camera servo control off of the Joystick axes

I am running labview for the code. I think I know how to do the majority of the codework, but how would I save the floating point number?
Reply With Quote
  #4   Spotlight this post!  
Unread 12-03-2009, 21:45
m3rc1l3ss m3rc1l3ss is offline
Registered User
FRC #1178 (DURT)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Missouri
Posts: 14
m3rc1l3ss is an unknown quantity at this point
Re: Camera servo control off of the Joystick axes

If anyone can help, I know exactly how to do this now. I just need to know how to make it so the joystick axes have a value of 0-179 instead of a value of -1 to 1. I would be most greatful if anyone were to help me with this.


Also, reading the servo position into the current value of a pid and having the modified joystick on the input would allow me to run the servos as such, correct? (I cant explain this too well so I can give a screenshot if anyone wants it.)
Reply With Quote
  #5   Spotlight this post!  
Unread 12-03-2009, 23:36
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Camera servo control off of the Joystick axes

Quote:
Originally Posted by m3rc1l3ss View Post
I just need to know how to make it so the joystick axes have a value of 0-179 instead of a value of -1 to 1. I would be most greatful if anyone were to help me with this.
It's a simple linear equation. Multiply by 89.5 then add 89.5, and you've got what you need. Alternatively, add 1 then multiply by 89.5 and you get the same thing.

Quote:
Also, reading the servo position into the current value of a pid and having the modified joystick on the input would allow me to run the servos as such, correct? (I cant explain this too well so I can give a screenshot if anyone wants it.)
I suppose you could do this, but why would you want to? The servo itself does its own closed-loop feedback control of position.
Reply With Quote
  #6   Spotlight this post!  
Unread 13-03-2009, 20:00
m3rc1l3ss m3rc1l3ss is offline
Registered User
FRC #1178 (DURT)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Missouri
Posts: 14
m3rc1l3ss is an unknown quantity at this point
Re: Camera servo control off of the Joystick axes

Thank you, I will try this out tomorrow. Also the pid is mainly so I can modify the rate of change.

Last edited by m3rc1l3ss : 13-03-2009 at 20:08.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I program a relay to turn on and off by pressing a button on the joystick? eweathers NI LabVIEW 4 28-01-2009 22:34
Servo Control? mattg101 Technical Discussion 2 20-01-2007 13:12
problems mounting the camera to the 'bot with the default servo/mount set up Redneck Programming 0 16-02-2005 20:53
Help with Joystick Axes and Sensitivity bglass Programming 6 06-02-2005 14:01
Camera Servo Obi Programming 2 30-01-2005 17:09


All times are GMT -5. The time now is 09:39.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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