|
Re: using mplab with vex
Well i don't think i can answer all your questions and i have never seen this type of info written anywhere but i will try to help out a little.
I would start by getting the Sensor Test code from Vexlabs because you will need it down the road and build off of that version.
Once you get that look at Your RC and Radio controller while you have ifi_aliases.h open and study all of the inputs and outputs and the names they are assigned to in the code.
On the RC you have motors 1-8 which are assigned to pwm01, pwm02, ect.
You have Digital/Analog I/O 1-16 which correspond to rc_dig_in01, rc_dig_out01, rc_ana_in01, ect.
On the Controller if you look under and beside the joysticks and on the buttons on the back you will see they say channel 1 - channel 6. theses correspond to PWM_in1 - PWM_in6 in the code.
The inputs From the Controller and the pwm outputs range from 0 - 254 and rest at 127 (0 being full reverse, 254 being full froward). these numbers are what you use to control different actions.
The main file you need to be worried about editing is user_routines.c . This is were all of the drive code is stored and where you call your different routines when you get that far. All drive code is in Default_Routine at the bottom of this file.
now if you wanted to drive your three wheeled robot you could just delete the pre defined code below (from user_routines.c ) so there is nothing being overwritten:
pwm01 = PWM_in1;
pwm02 = PWM_in2;
pwm03 = 255 - PWM_in3; // reverse direction of left side (CCW)
pwm04 = PWM_in4;
Then paste in something like this and plug the two motors into pwm1 and 2 and the servo into pwm3:
pwm01 = PWM_in3;
pwm02 = 255- PWM_in03;
pwm03 = PWM_in1; // Drive servo
good luck, hope i could help.
Last edited by Jetweb : 07-04-2008 at 17:29.
|