Skip to main content

RC Current Sensor

Most of the RC current sensor designs are using a hall effect-based current sensor, like the ACS758. In this project I would like to try something different (more difficult?) and use a conventional high-side current sensor to achieve the following goals:
  • Maximum 60A continuous current sensing capability
  • Maximum 5S (18.5V) LiPo battery input
  • Send telemetry data (current, voltage, power and capacity) to my Jeti DS-24 transmitter
  • Lightweight, small (and cheap) design

Hardware design

In the project I used an STM32G431KBU which is a powerful 32bit processor in a small package (LQFP32). It is too much for this job, but I bought them in bulk because I would like to use them in other projects too.

The design based on a high-side current sense amplifier: MAX4081. The current from the battery to the speed controller flows through a precision high power current-sense resistor (CSS2H-3920R-L200FE) which is sensed by the MAX4081. The current-sense resistor dissipates its own I2 × R loss, so for 60A it would be 0,72W which can easily be handled by that resistor. The gain of the current sensor amplifier is 60V/V this sets the maximum load current at the full-scale sense voltage to ±125A (yes, it's bidirectional!). Theoretically the current-sense resistor could also handle that load, but the XT60 connectors used in the design limits the current to 60A anyway. The voltage output of the MAX4081 corresponds to the sensed current (VOUT = VREF ± RSENSE × ILOAD(MAX) × AV) and is feed to the CPU's ADC. The reference voltage for the MAX4081 is generated by the DAC of the CPU.

The analog section of the CPU is powered from an MCP1501 reference voltage (3V) to achieve adequate precision for the DAC and ADC.

Using a resistor voltage divider the ADC can also measure the battery voltage. At the moment the divided is set that the maximum voltage can reach 50V. From the current and voltage the power is calculated and with a help of a timer the used capacity can also be calculated reasonably well.

The complete hardware design is on github.
Note: the schematic displayed is rev.3 already which fixes two small issues, but those changes are not incorporated to the PCB design yet:
  • The SWDIO and SWCLK is mixed
  • The layout for the servo connector pins a bit inconvenient (the signal and positive power pins are swapped)
Anyway, they are small issues so if you want to rebuild the device you can order the PCB from OSH Park. The fully assembled rev.2 PCB as shown here:


Note that the ground connection wire is not soldered yet between the two terminals of the XT60. You really need a beefy wire there, because the PCB is not designed to handle 60A or so.

Software architecture

The software is very simple: after the initialisation of ADC, DAC and serial port of the CPU the ADC automatically reads battery voltage and current. A timer interrupt routine stores those readings in a local variable in every 10 millisecond. In the main loop the serial port scans for Jeti EX bus telemetry request and sends those measured values (current, voltage) along with the calculated ones (power and capacity) in the necessary format.

At the moment the sensor only supports Jeti EX bus protocol, but any other protocol can easily be implemented.

The firmware can be found here: github

Conclusion

The voltage measurement pretty accurate and does not need any calibration. For the current measurement the reference voltage generated by the DAC needs some calibration: set the DAC output to a value that the measured current is 0 with no load (it's 2031 in my case). I have no electronic load capable to test more then 12A, but in that range the circuit measured the current also very well. Once the weather allows me I'll test the circuit in my plane.

In terms of weight the device is 14 grams, but half of that weight is from the XT60 connectors. All the components and PCB set you back around 15 per device which is way less than any commercially available product with similar specification. And top on that you can hack it in the way you would like to.

Comments

  1. Hello, Bodri,
    I replicated your current sensor. I can't get a handle on the software.
    I used to build and flash Arduino-based sensors.
    The STM 32 is uncharted territory for me.
    I have the tool STM 32 ST Link for flashing.
    This needs compiled hex files, I can't handle the Software
    from ST to generate an executable hex code.
    Would it be possible to provide a compiled hex file for download?

    Juergen

    ReplyDelete
  2. Hi Juergen, this is a STM32CubeIDE project. You can download the IDE from https://www.st.com/en/development-tools/stm32cubeide.html. Of course I could provide a hex file, but the firmware is not fully polished, so I recommend you to use the IDE, therefore you can also change the firmware if needed. Let me know if this works for you.

    Bodri

    ReplyDelete
  3. I added the .hex file into the github repo.

    ReplyDelete
    Replies
    1. Hello Varadi,
      thanks for the hex file.
      I tried flashing with the STM32 ST-Link Utility software.
      The tool ST-Link V2 recognizes the controller, also shows that the controller was flashed.
      When I read out afterwards, all memory cells are empty and the sensor works also not on the remote control.
      Probably I still have problems with the configuration
      of the option bytes in the STM 32 ST- Link Utility
      Can you give me another hint?

      Delete
    2. Hi Juergen, I did not change anything on configuration bits, it should work with default values. I can think of two potential issues now:
      1.) Make sure that the current sensor connected to an EX BUS protocol port.
      2.) The EX BUS protocol uses two different communication speed but in the firmware I hard-coded 125 kbaud (low speed).

      Do you see the green LED on? If so that means the initialization of the firmware was complete. Maybe that's a good starting point.

      I really would like to help you to make it work. Can you please send me a direct e-mail message, so we can speed up the communication? You can find my e-mail on my profile page.

      Delete

Post a Comment