Hello again,
How does one program the power expander using PROS?
Thanks,
brep
Hello again,
How does one program the power expander using PROS?
Thanks,
brep
What do you mean? There’s no programming involved. Or are you talking about the status port?
For instance, if there are motors attached to the power expander how does one write a speed to them in the program?
As far as you need to be concerned (as a programmer), the power expander does not exist. Using 3-wire extension cables, you plug up to four cables into your motor ports into the power expander’s “IN” ports. Your motors are plugged into a corresponding “OUT” port. See the Installation Instructions for a slightly (read: significantly) better explanation and visual. You would set motor values using the usual
motorSet(unsigned char port, int speed);
command.
The power expander has to be plugged into the cortex as well. The programming is the same while the wiring just uses a few more extension cables and the power for the motor comes from the power expander while the processing comes from the cortex.
Ninjad
But what values do I pass that correspond to the motor ports on the power expander?
Wait nevermind, I understand now. Thanks everyone!
Click the link.
Okay, this is not essential, but how would I program the status port using PROS? Would it be programmed as a sensor and set to an INPUT pinmode?
Thanks,
brep
I used the following line of code:
lcdPrint(uart1, 2, "M:%1.2fV|E:%1.2fV", (double)powerLevelMain() / 1000, (double)analogRead(aPOWER_EXPANDER_STATUS) / 280);
This prints
M:0.00V|E:0.00V
with the “0.00” replaced with the reported values. You connect the status port into an analog port on the Cortex. analogRead(int port) is the function that will return the value of the voltage, which needs to be adjusted to read in the correct units. The divisor (280) changes based off of what power expander you’re using, the Installation Instructions linked above tells you what value to use. I tweaked with my value a little bit using a voltmeter to read the correct values. powerLevelMain() returns the voltage of the main battery in millivolts, so dividing by 1000 will return volts. You also need to make sure you cast both of the functions to double, so that you can get a decimal answer and not rounded gibberish.
Note that in my line of code, aPOWER_EXPANDER_STATUS is a preprocessor define for 6 (#define aPOWER_EXPANDER_STATUS). You’ll need to replace aPOWER_EXPANDER_STATUS with whatever port you plug the status into.
Awesome! So the value returned by the status port will always be the voltage of the power expander’s battery in millivolts?
Thanks for the code. It helps a lot.
Edit: checked the wiki. My question is answered. Thanks everyone.
the power expander you must be talking about is probably a backup battery
Not sure were you are getting this idea. The current conversation is about the vex part called a power expander.
This has been referred to and linked multiple times in the thread.