turning inputs into outputs

Hi I am programming for Vex and using mplab so my source code is similar to FIRST. I am programming a vex robot and i was wondering is there a way to use the analog/digital inputs to control the motors like they are controlled by the designated outputs on the microcontroller?

Thanks for you time

Sincerly

Chris Lowson

A Huron Heights Robtic Programmer

In FRC, a very simple version (that you could put in your main user routines) would look like:

This is for the 2006 FRC controller, things may have changed since then.


unsigned int analog_value,output_value;

// this is a 10-bit value, which means it is between 0 and 1024
analog_value = Get_Analog_Value(rc_ana_in01); 

// chops off the 2 least significant bits to make it an 8-bit value
output_value = analog_value>>2;

// the pwm outputs are all 8-bit
pwm01 = output_value;


Things that may be different for the vex controller, and I’m not sure of:
-The analog inputs may be a different # of bits than the FRC controller is, so you’d have to remove more or less of the least significant bits
-The Get_Analog_Value function may be different. In any case, there should be some function defined in all the ifi_blah.h files that allows you to retrieve the analog input values

Edit: Is that Huron Heights in the Kitchener/Waterloo region?
Edit2: I’m guessing it is the Huron Heights in Newmarket. Did you guys get started from 1281?

I believe that you did not understand us correctly. Our problem is that we only have 8 pwm outputs on the microcontroller. we would like to add 2 more motors to our system and controll them separately using other pins, like the digital/analog inputs - but we cant seem to get the motor working on these correctly. After we turn pin14 on digital inputs into an output pin, the motor randomly jerks, we guess it doesnt recieve enough voltage, but we havent tested that yet, anyways - still looking for a reply.

P.S - yes, we are Huron heights from Newmarket. We guess we are speaking to Alex Mac - hey guys, nice to meet ya here.

Oh, whoops. As you can guess, I read it as “we want to read from the analog inputs, then drive a motor with that value”.

After reading innovationfirst’s docs, it looks like it could be possible. In the spec sheet, they say that the analog interrupt ports CAN be used as outputs and can drive “open circuits”.

I don’t know enough about VEX or the PIC hardware to help beyond that. Good luck!

If I was doing the programming, I’d look at the various IFI functions that access the ADC and see if you can find some that might let you set values. The OpenADC function called from ifi_utilities.c looks hopeful.

Are you outputting a PWM signal? Or did you just set the tristate to 1?

also you might want to have a look at this post of mine… it might help a little.

if you arent outputting PWM, you’ll need to set up a timer or CCP to use as a PWM timebase and another CCP for each individual motor channel… also you’ll need to see what pins on the microcontroller are connected to which pins on the I/O pins…

is this what you need? either way let me know.

-q