KCC's Quizzes AQQ305 about a mutual exponentiation equation
1. Quote of the month: "A train station is where a train stops. A bus station is where a bus stops. I have a work station on my desk, so..." - unknown
2. Quiz AQQ305 about finding a mutual exponential equation
Good luck, and try to be among the
View All
October Monthly Blog Quiz! Read the blog, take the quiz, and you could win a gift card
Finding Your Circuit Chi — EMC Quiz!
Think you know EMC? Test your knowledge with our 5-question quiz!
Read the blog first, then take the challenge: Finding Your Circuit Chi
Every current flowing creates electromagnetic fields.
Strong EMC design
View All
AD5940
Recommended for New Designs
The AD5940 and AD5941 are high precision, low power analog front ends (AFEs) designed for portable applications that require high precision, electrochemical...
Datasheet
AD5940 on Analog.com
After writing c code for AD5940 SPI drivers that can read & write to the ad5940 registers, I am now trying to clone the necessary files to implement the full AD5940_BATImpedance system.
However while I can write my own "hardware porting file" code to provide the all the necessary low level SPI functions such as reading and writing to registers there appears a significant issue with integrating the core ad5940.c and ad5940.h files as there is confusion in regards to the functions defined in these files.
For example the ad5940.h file suggests that only these functions need to be implemented for specific hardware controllers ?
Further to my investigation I find that the ad5940.c and ad5940.h files are bloated up with unnecessary complexities/functions with RAW SPI functions that are not required and will not work because they do not follow the ADI SPI protocol requirements. They don’t send SPICMD_SETADDR, SPICMD_READREG, or SPICMD_WRITEREG — which are mandatory protocol requirements for AD5940 register access, so what real function or purpose do they actually perform? Are they required or used by the higher level applications ( AppBATImpedance, etc.) I cannot see how as these APP's should work even with these unnecessary functions, especially working outside the ADuCM355 ecosystem which relies on manually generated SPI CS logic unlike standard SPI control where the CS line is automatically controlled in the SPI transactions.uint32_t ad5940_read_reg32(uint16_t addr) .... read 32 bit data from 16bit address
The AD5940 SDK files (ad5940.c/.h) appear riddled with many abstractions that don’t match the actual ADI SPI protocol requirements? Its difficult to know which functions are actually needed.
Also functions are defined for 32bit writes to registers but the datasheet lists no 32 bit registers at all. They way I see it the only required RAW hardware functions that are needed to be provided are
1) void ad5940_write_reg16(uint16_t addr, uint16_t value) ... write 16bit data to 16bit address since the chip only uses 16bits
2)
3) ad5940_read_fifo() ?
I do not see the need for other functions .. can someone shed a light of these aspects?
Thanks for your help.
Collin
Whatever functions you call in your main.c (example : main.c) are to be defined in your "hardware porting file".
All the AD5940 functions defined in ad5940.c need to be defined in your "hardware porting file".
Thanks Akila,
I already understood these matters, my hardware porting functions all work perfectly fine, that was never really an issue. I have now successfully completed this project and it is now working 100% perfectly fine now with improved response accuracy and repeatability of better than <1%. That said the AD5940 is not suitable for frequencies below 10Hz or much above 50kHz.
The main cause of the problems/issues I had was Linux timing issues (-50%) because the AD5940 sequencer/FIFO approach relies so much on precise timing with interrupts etc. The ADI Example Code and Quality ( -25%) where Filter/DFT setting transitions are not documented, FIFO overflow conditions not handled and "magic numbers" for settling times are empirical, and not explained.
The AD5940 Chip Design (- 25%), apart from the poor documentation the chip itself is well-designed, but, the sequencer is powerful but complex, the FIFO is way too small (4KB) and easy to overflow especially at low frequencies. The DFT at low frequencies with high OSR takes 20+ seconds - the examples don't emphasize this and the chip expects a "real-time" host.
To overcome these problems I have completely re-written the Battery impedance ADI code to work completely in "manual mode, and it works in all functionality without any sequencer or FIFO" and also I have strengthened the very poor RCAL coding. My control method takes about the same execution time without using the faulty ADI sequencer and FIFO coding, so there is no lost time, the timing is more defined by the measurement parameters than anything else as you may well understand.
The built-in AD5940 sequencer/FIFO isn't broken - it does work on dedicated microcontrollers. It's just the wrong approach for Linux or other O/S, but there are ways to overcome this as I have proved.
That said I have now moved on from the AD5940 chip, I don't believe it has any particular use case in my projects, it doesn't have the performance, so I am in the process of designing a far superior EIS system based on discrete hardware.
Thanks again for your response, hope you had a great break.
Regards,
Collin