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
Experimenting with Current Sense Amplifiers
  • Challenges & Projects
  • Design Challenges
  • Experimenting with Current Sense Amplifiers
  • More
  • Cancel
Experimenting with Current Sense Amplifiers
Challenge Blog Blog #13: MAX40080 Samples corruption when FIFO Roll-over mode enabled
  • Blog
  • Forum
  • Documents
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: misaz
  • Date Created: 7 Jun 2022 4:25 PM Date Created
  • Views 616 views
  • Likes 4 likes
  • Comments 1 comment
  • Current 6 Click
  • csa
  • current sense amplifier
  • fifo
  • MAX40080
  • Experimenting with Current Sense Amplifiers
Related
Recommended

Blog #13: MAX40080 Samples corruption when FIFO Roll-over mode enabled

misaz
misaz
7 Jun 2022

Hello everyone.

This is my last blog post (I am considering one more, but most probably I will not be able to write them before deadline) as part Experimenting with Current Sense Amplifiers Design Challenge. In next blog post I will post complete summary, but before this I want to describe one issue which I found when I was experimenting with MAX40080 sensor and which I think is bug in digital logic implementation of chip. I originally found this issue when I was developing and especially testing my CLI utility for using MAX40080 without programming needed on Raspberry Pi.

Problem

My utility worked well but I noticed that when I for experimental purposes enabled Roll-over feature of FIFO, then first samples are correct but at some moment sensors start reporting samples with valid bit set, but current value is invalid, and voltage is zero (also invalid). By default sensor throws away new samples when FIFO overflow and FIFO Roll-over mode allows to change this behaviour and instead, sensor will overwrite oldest sample by newest.

I run my utility and pass its output over nl command which add number lines to output and have seen following behaviour:

image

As you can see first 64 samples are correct, but then something strange happened. If I run command multiple time boundaries when sensor started providing invalid samples marked as valid is always at 64th sample (note that 64 is capacity of FIFO). Interestingly when I disabled roll-over feature everything worked well again. Roll-over is good feature which suits use case of most CLI utility use cases, but this issue prevented me to enable it in utility. It is commend now.

CLI Utility Internals

For further explanation it is good to know how does CLI utility works. CLI utility after start parse command line arguments and prepare configuration structure which is than used for writing into Configuration and FIFO_Configuration registers. After configuring sensor, CLI utility flushes all previous data from FIFO and then cleanup all interrupt flags. CLI utility generally do not use interrupt flags, but clearing is important for detection of FIFO overflow at the end of collection of samples. After it clears interrupt flags, it immediately starts reading from Measurement register (Current_Measurement, Voltage_Measurement or Current_Voltage_Measurement depending on configuration). After it receives value from sensor it checks if Data Valid bit is set. When it is set, then CLI utility prints sample. When it is not set, then it means that utility attempted to read sample when there were no sample in the FIFO yet. After required number of samples (-n parameter) is collected, then utility stops collecting samples and reads interrupt flags to check if FIFO overflow occurred anytime when collecting samples. Finally, utility reconfigure sensor to standby mode.

Further investigation

I tried to investigate issue furthermore. Note that at development time I was not sure if this is issue is caused by some bug in my code or sensor really provided this wrong data. I patched internals of my C library and added debug printing of all data received from sensor including data without valid bit set. These printing are marked with x at beginning on following screenshot. Samples with valid bit set are samples beginning with 8. Samples starting with 0 are samples received when there were no sample in the FIFO (without valid bit set). As you can see on the following screenshot after receiving 64th sample something very interesting happened and when preparing 65th sample MAX40080 shifted voltage value 0x022D to the right and marked this sample as valid.

image

This resolved mystery where did invalid current values come from – It is voltage about 5V improperly interpreted as a current.

I tried some other experiment and found that this happens only when sampling both current and voltage. If I configured sensor to sample only current or only voltage, roll-over mode worked well.

I searched over the datasheet, and I did not find any restriction on using roll-over mode when sensor is configured for storing both current and voltage, so I decided to contact Maxim support and ask them about it. In fact, this was my 7th support request regarding MAX40080 on Maxim support. Maxim support works well and can help you. This is significantly different from support of my internet service provider which generally looks like “Did you tried turn it off and on?”. In previous tickets I reported some mistakes in datasheet (all were accepted. Maxim is working on new revision of datasheet but they did not publish them within contest period) and I asked about Flush Fifo bit behaviour which I described in my 4th blog. 7th case regarding this issue is not closed yet as of end of this contest, but Maxim Application Engineer navigated me to test some other test with inserting delay between readings. CLI utility attest to read data from sensor as fast as possible (and ignore possible readings when no data are prepared yet). For experiment I converted setup to MCU for being able to more precisely control timings of transactions and I tried to interleave sample readings with delay. When I set delay to similar time like period of sample rate divided by configured digital filter, then I was seeing another interesting behaviour (I added 3 columns with values to the printing. They are values of configurations and status register after reading sample, but they are not important now):

image

If I increased delay to time slightly more than is sampling period, then I received all samples correct. If I decreased it below, I was received only 64 samples valid, then all were incorrect and finally If I set delay to value similar to sampling period, then some of them was wrong and some of them was correct (higher delay results to fewer wrong samples)

Workaround

To summarize issue happens when both following points apply (when some of them is not satisfied, then sensor works well).

  • Collecting both current and voltage
  • FIFO roll over feature enabled in FIFO_Configuration register

Then you need to prevent reading samples from FIFO when there are no data. There are at least two ways how to ensure this:

  • Read Status register and wait until number of available samples became non-zero (and check for overflow flag, because number of available samples is zero also when FIFO is full)
  • Use FIFO overflow warning set to 1 sample and then sensor assert interrupt when new sample become available in FIFO

Maxim support is still investigating the issue, maybe they find some better workaround with knowhow of internal details. To me it looks like wrongly implemented digital logic which is responsible for interleaving voltage and current. This is description from datasheet:

image

I think that when roll-over mode is enabled, then logic described above marks sample as valid sooner than it is really valid. But without knowhow of chip internals, it is hard to estimate what really happened inside chip.

Last words

Thank you for your attention and reading this blog post. In this blog post I described issue which I was facing when experimenting with MAX40080 CSA sensor. Contest is ending soon, and I will very soon post my summary of all my experiments, projects and what I have learnt and some other closing words. Stay tuned. Similarly, to all my previous blog post I welcome any feedback. Feel free to comment below.

Next blog: Blog #14: Experimenting with Overvoltage Detection

  • Sign in to reply
  • misaz
    misaz over 2 years ago

    UPDATE 2023-02-21:

    Toaday I found that Maxim documented this bug: https://support.analog.com/en-us/knowledgebase/article/KA-16844

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • 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