Good day everyone,
I have been working for a while on a system that uses the AD5940 to perform both Impedance Measurement and Amperometric Measurement. The impedance happens between the CE0 pins and the AIN2 pin while the Amperometric happens between SE0 (shorted with RE0 via firmware) and CE0. I managed to make a firmware that on demand executes an Impedance measurement or an Amperometric measurement. Right now what my code is doing is that on a command it execute either the Impedance or the Amperometric example code from github (with a few changes of course)
I feel like the code can be improved by fusing the two examples into one code where all the necessary sequences are stored in the sequencer (Initialization Seq for Impedance, Measurement Seq for Impedance,Initialization Seq for Amperometric, Measurement Seq for Amperometric.) and then one demand call only the necessary sequences, reducing the amount of repeated code.
What do you think is the best way to fuse the Impedance example code and the Amperometric example code to get the best result?
Would storing all the necessary sequences and calling them on demand make sense for this solution?
If this is a good way of doing it, would the fact that the AFE settings need to be changed before using one type of measurement or the other (Impedance uses the High Speed Loop while Amperometric uses the Low Power Loop) everytime create problems on the device?
Any advice or help would be great, if there is already an example that does this type of thing it would be great if you could point it to me.
Thank you in advance