Quote:
|
Originally Posted by sear_yoda
Also being the electronics dude, I checked all of our wiring. Everything is straight to FIRST specification, and I've got the current sensors all built and ready to be read by the RC (that's another issue: figuring out what the ~500 value I get from the sensor really is, and what's the correct formula to convert it to amps). Neither motor draws more than the assigned voltage, as tested by a multimeter, but I don't think that really means much.
|
Hopefully I can help you out with the current sensors, at least. Some other sucker on our team is responsible for the drive train
I also read about 500 counts from the Get_Analog_Value(rc_ana_inXX) function call in the software, when the motors aren't moving. When you think about this for a minute it makes sense. Get_Analog_Value() returns an unsigned int (16 bits), but only the 10 least significant bits represent the voltage on the analog input. The biggest number you can make with 10 bits is 1023. We're reading about half of that, around 500. The analog input on the robot controller can read voltages between 0 and 5 volts. 2.5 volts output from the current sensors corresponds to 0 amps (no current, motor stopped). Maybe we're onto something!
Since we're digitizing the input voltage using 10 bits, we have to scale the number that comes out of Get_Analog_Value() appropriately:
input_voltage = Get_Analog_Value(rc_ana_inXX) * 5 / 1023;
The current sensors put out a voltage between 0 volts and 5 volts. 4 volts corresponds to 75 amps (fast forward), and 1 volt corresponds to -75 amps (fast backwards). It's pretty linear in between. Do a y = mx + b on this and rearrange to solve for current in terms of voltage. Try it yourself, and you will find that drive_current = 50 * input_voltage - 125. This will only give you an integer value for the current but at least it gets you started. There are some tricks you can play with averaging and bit-shifting in order to get more resolution, but I'd concentrate on making the sucker drive first.
Hopefully this helps with the current sensing. Let me know if you have any questions at all.
{edit} There's a far easier way to do all of this. In your message you mentioned converting the voltage reading to current, and I tried to answer along those lines. But you don't have to convert to current in order to do simple current limiting. All you have to do is figure out what voltage from the sensor corresponds to your threshold current where you want to limit the motor, and then figure out the corresponding number you'd get from Get_Analog_Value() for that voltage. That's your threshold. Note that there are actually two threshold voltages if you drive the motor backwards, because the current is negative if you drive backwards. {edit}