Posted 20 February 2017
As part of the project to implement autonomous charging capability for Wall-E2, I needed a way to monitor main battery voltage in normal ‘run’ mode, in order to tell when to start searching for a charging station. The main battery is a 2-cell LiPo stack, and so has a nominal stack voltage of around 7.5-8V when fully charged. Since this is well above the Arduino Mega’s internal +5V operating voltage, I can’t measure this directly via the analog input ports. So, I installed a 1/3-2/3 resistive voltage divider between the main battery voltage input, analog input A0, and ground, as shown in the following schematic detail.
The nominal reading at A0 is 1/3VBatt. Using the Arduino’s internal +5V regulator as the reference, the nominal battery voltage is 5*[A0/1023]*3.
To test this arrangement, I modified the operating software to print out the raw and calculated battery voltage values, and got the following printout.
BattMonVol: Raw 568 pin 2.78V TTL Batt 8.33V
BattMonVol: Raw 569 pin 2.78V TTL Batt 8.34V
BattMonVol: Raw 539 pin 2.63V TTL Batt 7.90V
BattMonVol: Raw 559 pin 2.73V TTL Batt 8.20V
BattMonVol: Raw 567 pin 2.77V TTL Batt 8.31V
BattMonVol: Raw 570 pin 2.79V TTL Batt 8.36V
BattMonVol: Raw 568 pin 2.78V TTL Batt 8.33V
BattMonVol: Raw 554 pin 2.71V TTL Batt 8.12V
BattMonVol: Raw 553 pin 2.70V TTL Batt 8.11V
BattMonVol: Raw 566 pin 2.77V TTL Batt 8.30V
In addition, I measured the battery voltage directly using my trusty multimeter, and got 8.03V, so a pretty reasonable monitor setup.
Next up; I had previously added the 4-detector IR module to the robot, and now I needed to integrate the IR detector measurements into the telemetry stream. The battery monitor is on A0, and the 4 detectors are on A1-A5. After adding the telemetry code, I got the following printout.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Time Batt DET1 DET2 DET3 DET4 0.20 8.15 937 935 651 950 0.40 8.01 943 934 739 952 0.60 7.61 934 935 792 953 0.80 7.90 932 937 824 955 1.00 8.14 940 940 847 957 1.20 8.04 927 937 862 956 1.40 7.70 930 939 876 957 1.60 7.70 932 942 889 959 1.80 8.11 935 940 898 957 2.00 8.06 929 941 899 959 2.20 7.89 944 943 904 960 |
Now I will add back in the left/right/forward distances, the forward variance, and the left/right wheel speeds. After adding everything back, I get the following telemetry stream:
1 2 3 4 5 6 7 8 9 10 11 12 |
Time Batt DET1 DET2 DET3 DET4 Left Right Front Track Var LSpd RSpd 0.20 8.12 933 944 748 956 200 200 400 IR 407 127 127 2.00 7.65 936 941 818 955 200 200 48 IR 446 127 127 3.81 8.08 924 934 821 951 200 200 64 IR 516 127 127 5.61 8.08 942 933 830 951 200 200 85 IR 641 127 127 7.42 8.15 938 943 829 956 200 200 65 IR 705 127 127 9.22 7.92 939 945 832 958 200 200 71 IR 781 127 127 11.02 8.01 944 939 827 954 200 200 73 IR 858 127 127 12.83 8.11 941 932 826 950 200 200 69 IR 921 127 127 |