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
will this be excessively taxing on the RC program
is this the best way to make full use of the 0 to 5 volt analog input
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.
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
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/2004-programming-reference-guide-12-apr-2004.pdf
*-----------------------------------------------------------------------------------------------------
*---------- 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
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
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:
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.
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.