Can someone help me. We are using a power expander and trying to display the voltage of the power expander on the lcd. We created the code but the lcd is given us a battery reading of 27volts. any idea why???
here is the code (using RobotC)
{//Open LCD battery loop
bLCDBacklight = true; // Turn on LCD Backlight
string mainBattery, backupBattery;
{
clearLCDLine(0); // Clear line 1 (0) of the LCD
clearLCDLine(1); // Clear line 2 (1) of the LCD
//Display the Primary Robot battery voltage
displayLCDString(0, 0, "Primary: ");
sprintf(mainBattery, "%1.2f%c", nImmediateBatteryLevel/1000.0,'V'); //Build the value to be displayed
displayNextLCDString(mainBattery);
//Display the Power Expander battery voltage
displayLCDString(1,0, "Secondary:" ) ;
sprintf(backupBattery, "%1.2f%c", (((float)SensorValue[in1] * 5.48 / 184.7)), 'V');
displayNextLCDString(backupBattery);
//Short delay for the LCD refresh rate
wait1Msec(100);
}
}//Close LCD battery loop
Actually, it was sort of a rhetorical question, it was probably one of my posts.
To convert raw sensor value to volts you divide by either 280 (new power expander) or 182 (old power expander).
To convert raw sensor data to mV (mV = 1/1000 volt) you multiply by 1000/280 = 3.57 (new power expander) or by 1000/182 = 5.49 (old power expander).
So it all depends if you want to convert to volts or mV and whether you have one of the new (revision A2 or newer, it’s printed on the power expander somewhere) or the old power expanders.
So i have tried a few different numbers from the wiki (280, 182, 70.8, 45.6, 155, 70) all of this values have not worked for me. We are getting a analog reading of 538, with a battery with 8.4v. Any suggestions on way its not working??? I am puzzled by this…
I am using version 3.65 (most up to date). When nothing is plugged in we get a reading of 0. In addition we tried other analog ports with similar readings to 538 with the 8.4v battery.
Hmm, another question based on those remarks. Any chance you are using a PIC? We all assumed you have a cortex but if you have a PIC then I understand what’s happening.