Skip to main content
MÇETİ.1
Associate III
March 30, 2021
Solved

Measuring DC current with ACS271(20A)

  • March 30, 2021
  • 1 reply
  • 1246 views

Hi everyone,

I am too new at STM, so I couldn't understand how to measure DC current. Can anyone help me to do my setting and code, please. I found out code for AC current and I decided to change some parts of this code, but I couldn't understand how should I do settings of pinout and configuration.

    This topic has been closed for replies.
    Best answer by Vangelis Fortounas

    Hello

    do you mean ACS712?

    This sensor converts current flowing to voltage on output pin. Current measuring pins are electricaly isolated from the rest pins.

    All you need, is to measure the ouput voltage of ACS with one pin of MCU configured as "ADC input" but there are some pitfalls.

    ACS712's VCC is 5v and max output is about 4.5~4.6v for 20 A. STM32 ADC inputs voltage range is 0 - ~3.3V(about max MCU's VREF or VDDA)

    The sensitivity is 0.1V/A that means the usable range is from -20A to +8A for MCU's VDDA=3.3V (when output is connected directly to an ADC input pin ). Note that zero amperage, gives 2.5V output signal.

    To use safely the full range of ACS, consider use a proper T resistor voltage divider connected from ACS output to an ADC input of MCU with factor 4.6/VREF

    The rest is more simple. Just configure the ADC input pin.

    CUBEMX can do the configuration and produce the code . (like the example below)

    Strongly suggest to use a voltage divider, not to stress or damage the MCU.

    0693W000008yLk7QAE.jpg 

    1 reply

    Vangelis Fortounas
    Associate II
    March 31, 2021

    Hello

    do you mean ACS712?

    This sensor converts current flowing to voltage on output pin. Current measuring pins are electricaly isolated from the rest pins.

    All you need, is to measure the ouput voltage of ACS with one pin of MCU configured as "ADC input" but there are some pitfalls.

    ACS712's VCC is 5v and max output is about 4.5~4.6v for 20 A. STM32 ADC inputs voltage range is 0 - ~3.3V(about max MCU's VREF or VDDA)

    The sensitivity is 0.1V/A that means the usable range is from -20A to +8A for MCU's VDDA=3.3V (when output is connected directly to an ADC input pin ). Note that zero amperage, gives 2.5V output signal.

    To use safely the full range of ACS, consider use a proper T resistor voltage divider connected from ACS output to an ADC input of MCU with factor 4.6/VREF

    The rest is more simple. Just configure the ADC input pin.

    CUBEMX can do the configuration and produce the code . (like the example below)

    Strongly suggest to use a voltage divider, not to stress or damage the MCU.

    0693W000008yLk7QAE.jpg 

    MÇETİ.1
    MÇETİ.1Author
    Associate III
    March 31, 2021

    Thank you so much. Yeah, I ment ACS712. I didn't know that ACS712 converts the current to voltage. I'll try it as soon as possible. Thank you so much again.