element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Embedded Forum Current measuring with STM32 Nucleo
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 3 replies
  • Subscribers 463 subscribers
  • Views 2668 views
  • Users 0 members are here
  • arduino ide
  • stm32nucleo
  • current measurement
Related

Current measuring with STM32 Nucleo

sanyika95
sanyika95 over 6 years ago

I just got an STM32 Nucleo with the 24V Intelligent power switch expansion board. I heard it can measure current with it. I am using the Arduino IDE for the easier programming (my friend have given me a good library for it). I was able to read the voltage values on the multisense pin. How can I calculate the current from the voltage values?

 

The datasheet of the microcontroller:

https://www.st.com/content/ccc/resource/technical/document/user_manual/98/2e/fa/4b/e0/82/43/b7/DM00105823.pdf/files/DM00…

 

The datasheet of the shield:

https://www.st.com/content/ccc/resource/technical/document/user_manual/group0/6b/30/81/c3/f8/c1/46/31/DM00304689/files/D…

  • Sign in to reply
  • Cancel

Top Replies

  • dougw
    dougw over 6 years ago in reply to sanyika95 +2
    The value of K should be selected based on how much current is being sensed. use K1 (2960) for currents in the 1 A range use K2 (2930) for currents in the 3 A range use K3 (2900) for currents in the 12…
  • sanyika95
    sanyika95 over 6 years ago +1
    Okay, I have realized my own stupidity, but I still didn't get the current I am measuring with my multimeter. By using the formula from the datasheet, I should be able to calculate the load current. The…
  • sanyika95
    sanyika95 over 6 years ago in reply to dougw +1
    Thanks for your help. As I want to measure max 3-3,5A, I am using the 2930 value of K. To get rid of noise I averaged first 32 and then 64 of the measured voltages, but there were still 50-70mA error.…
  • sanyika95
    sanyika95 over 6 years ago

    Okay, I have realized my own stupidity, but I still didn't get the current I am measuring with my multimeter.

     

    By using the formula from the datasheet, I should be able to calculate the load current.

    image

    The Arduino's analogRead() function on the multisenseX pin gives me the needed to calculate the Usense. But first I calculated with 5V as reference voltage, later I read I should calculate with 3,3. This was my first mistake.

    So now I know:

    image

    And as there is a voltage divider,

    image

     

    Now the only thing I need is the value of K. In the datasheet there is a resistance, called RDSPower, but still don't how to get it. In the datasheet of the IC, there was values for the K: 2900, 2930, 2960. I tested with all of them, but the values still are not the same. The difference between them is around 100 mA. So if I can get somehow the good value of the K, I should be done.

    I have changed the resolution of ADC to 12 bit, that changed my second equation a bit. In the denominator there is 4095 in the case of 12 bit ADC instead of 1023.

     

    The other problem I realized is that, there is voltage on the multisense pin, even when there is no load on the output. How can I get rid of that noise, to correct the measurement?

    And the other problem is that, it doesn't measure the little currents in mA scale.

    (If I find it out before I get a reply, I will write about it, in the case if someone ever needs this, and find my post in the Google)

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • dougw
    dougw over 6 years ago in reply to sanyika95

    The value of K should be selected based on how much current is being sensed.

    use K1 (2960) for currents in the 1 A range

    use K2 (2930) for currents in the 3 A range

    use K3 (2900) for currents in the 12 A range

     

    The "noise" is probably either an offset or voltage noise.

    To get rid of the offset simply subtract the zero current reading from measurement readings.

    To get rid of voltage noise you can filter the signal or average a number of readings.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • sanyika95
    sanyika95 over 6 years ago in reply to dougw

    Thanks for your help.

    As I want to measure max 3-3,5A, I am using the 2930 value of K. To get rid of noise I averaged first 32 and then 64 of the measured voltages, but there were still 50-70mA  error. The failure rate is around 5%, so it could be its maximum accuracy.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube