Power

Power Registers:

Several functions are available to monitor various status of the rover.

.

PIC_ReadPower(); PIC_ReadPower(); //gets voltage and power values from PIC processor powerVoltage //global variable, now holds battery voltage (in millivolts) powerCurrent //global variable, now holds total current consumption (in milliamps)

This function reads the key power values - battery voltage, and current consumption. This reading is accurate to within 20 milliseconds (the value returned is the last reading taken during the last 20ms cycle). The function automatically populates two global variables powerVoltage and powerCurrent. These variables can be used anywhere in your code. Each time this function is called, the variables are updated.

.

PIC_ReadPower_Instant(); PIC_ReadPower_Instant(); //gets instant voltage and power values from PIC processor powerVoltage //global variable, now holds battery voltage (in millivolts) powerCurrent //global variable, now holds total current consumption (in milliamps)

This function works the same as the normal PIC_ReadPower, except the resulting values are instant, and do not include the 20 millisecond delay. When this function is run, the PIC processor will pause for a brief time to perform an instant reading of the power values and replies back with the values. It is suggested to generally use the normal PIC_ReadPower function, though you can use this function if a more instant reading is required.

.

PIC_ReadPowerAverages(); PIC_ReadPowerAverages(); //gets average voltage and power values from PIC processor powerVoltageAverage //global variable, now holds average battery voltage (in millivolts) powerCurrentAverage //global variable, now holds average total current consumption (in milliamps)

This function returns the average readings of battery voltage and current consumption. This is a running average from the previous 8 times the PIC processor performed its 20 millisecond interval measurement. You will find this value is more stable over time than the other readings above as the average tends to filter out spikes.

Last updated