External Battery Monitor with ADC

The OcPoC has an interval voltage monitor, but its internal ADC cannot support analog voltages greater then 1V. This tutorial presents the setup required to read an external battery monitor through I2C.

What you'll need:

Putting the hardware together

🚧

Beware!

The following process is lengthy, involves soldering, and a powerful LiPo battery. Practice proper soldering techniques. Practice safe battery handling.

  1. Remove the Mauch Hall Sensor from it's packaging. Solder your XT-60 connectors to the power module as shown in the picture below.
5184

XT-60 Connector Soldered with the Hall Sensor. If there is an arrow for current flow, solder the battery connection on the start of that arrow.

👍

Double Check

Make sure that the power goes in the square section of the XT-60 and ground goes into the triangle.

  1. Test your connection with your battery, sensor, and airframe. Everything should act like normal - otherwise check all your connections.

  2. The MAUCH Hall Sensor needs one of its 6-pin power connections to go to the OcPoC GPIO Pin 15 VCC pint (the middle pin). Connect at least one of it's ground connections to the ground rail on the GPIO pins (the ground rail is the top set of pins). Connect the 'current' pin to 'AD0' on the ADS1115 and 'voltage' to 'AD1'. See the picture below for explanation of wire colors from Mauch power module.

If properly wired, the Hall Sensor will light up blue when the battery is connected.

5184

Connection from the power module: Red - Power; Yellow - Current; White - Voltage; Black - Ground

  1. Wiring the ADS to the OcPoC

Connect the header pins that came with the ADC, or the leads coming off the JST-GH ended cable, to the ADS1115. Remember the right-most connection is power, and the left-most connection is ground. Additionally connect the ADDR pin on the ADS1115 to a ground pin on the PWM header. Connect the JST-GH plug to Port 1 on the OcPoC

🚧

Before soldering, confirm that you have the correct wiring for an I2C connection

Plug going into OcPoC
Pin 1 (Left most) - Ground
Pin 2 - SDA
Pin 3 - SCL
Pin 4 (right most and usually red) -Power

5184

4 Pin JST-GH to 4 single JST-RE connector - optional but highly recommended. The JST-GH plugs into the OcPoC and the JST-RE (Header) pins connect to the breakout of the ADS1115

Update Coefficients

If you ordered a MAUCH Hall sensor, it should come with a final calibrated set of coefficients for using it. You can either hardcode these coefficients in your source code or set them from the ground station parameters.

To hardcode the values into Ardupilot, open the file 'libraries/AP_BattMonitor/AP_BattMonitor_Analog.h' and change the coefficients in the following listing:

#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OCPOC_ZYNQ
 # define AP_BATT_VOLT_PIN                  -1
 # define AP_BATT_CURR_PIN                  -1
 # define AP_BATT_VOLTDIVIDER_DEFAULT       10.04975f   // V Divider << Change
 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT  33.05487f   // A/V  <<  Change

#else
 # define AP_BATT_VOLT_PIN                  -1
 # define AP_BATT_CURR_PIN                  -1
 # define AP_BATT_VOLTDIVIDER_DEFAULT       10.1f
 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT  17.0f
#endif

To set these parameters from the ground station, follow the steps for "Setup Through Mission Planner" provided in the ardupilot user guide.