Go to Post Expect a lot of noise, unexpected things going wrong, and most of all, tons and tons of fun. - nitneylion452 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-02-2006, 20:47
Superstitions's Avatar
Superstitions Superstitions is offline
Gadget Wizard
FRC #0039
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Gilbert AZ
Posts: 13
Superstitions is an unknown quantity at this point
change pwm range preserve input sensitivity

I am using analog input (pot) from the user console to control a motor speed through a victor speed control. The analog gets converted to PWM_1= 0 to 254. I want my PWM (PWM_2) output to the victor to be 100 to 254. We are controlling ball distance by changing speed of ball shot with victor to a motor. I want input to this to be from the pot and want to presrve the ability to be able to go in reverse a little if the shooter gets jammed. I have come up with a formula for the conversion:
(PWM_1*154/254) + 100 =PWM_2.
My questions are
1) will this be excessively taxing on the RC program
2) is this the best way to make full use of the 0 to 5 volt analog input
3) do I need to use the terms PMW_1 and PMW_2 or can I use a term (PMW_1 temp)
Thanks in advance, please take it easy on me I am just starting out.

Last edited by Superstitions : 07-02-2006 at 21:49.
  #2   Spotlight this post!  
Unread 07-02-2006, 21:12
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: change pwm range preserve input sensitivity

Well lets start with the basics:
127 is nuetral

127-254 is one direction

0-127 is in another direction

so you want the to have a range control between either 0-127 or 127 - 254 (depending on the direction you want to spin)

second analog input form the OI (operator interface gets converted into) to one of the these values defined in 'ifi_aliases.h' not PWMs

2) This controller can do floating point trig calculations so I dought this will be taxing in anyway. If fact this is the type of code is quite basic.

3)All the physical variables you can use are defined in ifi_aliases.h. p1_y and so on are the values form the OI ports(joysticks for example). pwms are the this being outputed at the pins. Look at the default_code in the user_routines.c. You can add tons more software variables like the ones you stated. Read:http://ifirobotics.com/docs/legacy/2...2-apr-2004.pdf

Quote:
*
*-----------------------------------------------------------------------------------------------------
*---------- Aliases for each OI analog input ---------------------------------------------------------
*-----------------------------------------------------------------------------------------------------
* Below are aliases for the analog inputs located on the Operator Interface.
*/
#define p1_y rxdata.oi_analog01
#define p2_y rxdata.oi_analog02
#define p3_y rxdata.oi_analog03
#define p4_y rxdata.oi_analog04
#define p1_x rxdata.oi_analog05
#define p2_x rxdata.oi_analog06
#define p3_x rxdata.oi_analog07
#define p4_x rxdata.oi_analog08
#define p1_wheel rxdata.oi_analog09
#define p2_wheel rxdata.oi_analog10
#define p3_wheel rxdata.oi_analog11
#define p4_wheel rxdata.oi_analog12
#define p1_aux rxdata.oi_analog13
#define p2_aux rxdata.oi_analog14
#define p3_aux rxdata.oi_analog15
#define p4_aux rxdata.oi_analog16
you need to select the one of these, they are based on the input pins on each port. p1,p2... are the ports on the OI

px_y
px_x
px_wheel
are available on the joysticks

Read this completely before you start soddering. http://ifirobotics.com/docs/oi-ref-guide-11-21-05.pdf

Last edited by 6600gt : 07-02-2006 at 21:15.
  #3   Spotlight this post!  
Unread 07-02-2006, 21:31
Superstitions's Avatar
Superstitions Superstitions is offline
Gadget Wizard
FRC #0039
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Gilbert AZ
Posts: 13
Superstitions is an unknown quantity at this point
Re: change pwm range preserve input sensitivity

Hi, to clarify the output I want, the shooter direction I want is my forward from 127 to 254, I also want to preserve part of the reverse from the 126 down to 100. Hope this helps clarify. I have chosen to use #define p3_aux rxdata.oi_analog15 as the input via the pot on the console. The pot is a stand-alone device on the console not related to the two joysticks
Thanks Jeff

Last edited by Superstitions : 07-02-2006 at 21:33.
  #4   Spotlight this post!  
Unread 07-02-2006, 21:40
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,729
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: change pwm range preserve input sensitivity

To be more specific, you should range the PWM from about 136 to 232. The Victor has a deadband from 117 to 137, and it reaches 100% output at 232. All detailed at the IFI FAQ:
http://www.ifirobotics.com/forum/viewtopic.php?t=317

EDIT: Strike that, didn't see you still wanted reverse on there. You can range from 100 to 232. Note that you'll get a max of about 20% power in the reverse direction.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter

Last edited by Kevin Sevcik : 07-02-2006 at 21:42.
  #5   Spotlight this post!  
Unread 07-02-2006, 21:56
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,113
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: change pwm range preserve input sensitivity

You have exactly the right idea -- multiply by the desired output range, divide by the available input range, and add an offset to get it to start where you want.

I will give you two warnings. First, the OI doesn't really want to see a potentiometer giving it a voltage. It wants to see a variable resistance. You won't necessarily get the full 0-254 range of values in either case, so you might need to tweak your formula slightly to compensate.

Second, the compiler is notorious for overflowing intermediate results when you do things like multiplying values that each fit in eight bits. A bit of (int)-casting will force the code to do 16-bit arithmetic, and you should be fine.
Code:
  pwm02 = (int)p3_aux * 154 / 254 + 100;
  #6   Spotlight this post!  
Unread 07-02-2006, 22:33
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: change pwm range preserve input sensitivity

Quote:
Originally Posted by Superstitions
I am using analog input (pot) from the user console to control a motor speed through a victor speed control. The analog gets converted to PWM_1= 0 to 255. I want my PWM (PWM_2) output to the victor to be 100 to 255. We are controlling ball distance by changing speed of ball shot with victor to a motor. I want input to this to be from the pot and want to presrve the ability to be able to go in reverse a little if the shooter gets jammed. I have come up with a formula for the conversion:
(PWM_1*155/255) + 100 =PWM_2.
My questions are
1) will this be excessively taxing on the RC program
2) is this the best way to make full use of the 0 to 5 volt analog input
3) do I need to use the terms PMW_1 and PMW_2 or can I use a term (PMW_1 temp)
Thanks in advance, please take it easy on me I am just starting outhttp://www.chiefdelphi.com/forums/newthread.php?do=newthread&f=51#
Confused
How about something like:

unsigned char PWM_1; // 0-255 input from joystick
unsigned char PWM_2; // 100-255 output to victor
unsigned int temp; // temporary storage

temp = 39 * (unsigned int)PWM_1;
temp >>= 6; // right shift six bits, which is the same as dividing by 64
PWM_2 = (unsigned char)temp + 100;

Notice that 39/64 is an approximation of 155/255.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org

Last edited by Kevin Watson : 07-02-2006 at 22:36. Reason: icky math
  #7   Spotlight this post!  
Unread 11-02-2006, 20:59
Superstitions's Avatar
Superstitions Superstitions is offline
Gadget Wizard
FRC #0039
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Gilbert AZ
Posts: 13
Superstitions is an unknown quantity at this point
Re: change pwm range preserve input sensitivity

This helped greatly, thanks to all involved, we are off to the test arena.
Thanks, Jeff
Closed Thread


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
Accelerometer code ImmortalAres Programming 28 04-06-2005 01:02
Change joystick to pwm mapping Joe Lewis Programming 3 30-03-2005 19:27
Compiling Failed Teh Mike Programming 7 09-02-2005 13:27
heres the code. y this not working omega Programming 16 31-03-2004 15:18
Some EDURobotics Problems squide Robotics Education and Curriculum 9 20-01-2004 10:27


All times are GMT -5. The time now is 13:47.

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