Skip to content

speed up input output current monitoring tuning

Zhicai Zhang requested to merge zz_speedupCurrTune into activeTB

This MR improves the speed of the input and output current monitoring tuning.

The main reason of the previous version being slow is that every time you call the AMACv2::readAM function, it does two things: 1) write the AMAC MUX field to set the MUX of the AMAC ADC; 2) read the AMAC ADC. And in the write part (wrField) there is a 10 ms sleep after each write. And in the input/output current monitoring part (which uses function like AMACv2::getCUR10V), we call about 10^4 times of readAM function to get an average number of the ADC reading. So we see here the problem is that actually we only need to write the AMAC MUX once and read the AMAC ADC about 10^4 times to avoid the sleep time in the wrField part. The proposed solution is: instead of calling readAM N times and then take the average, now we call readAM one time and pass the N to readAM and do the average inside readAM.

Before the change:

AMACv2::getCUR10V(100) takes about 1.7 seconds.

After the change:

AMACv2::getCUR10V(100) takes about 0.35 seconds.

After this fix, the basic test of one powerboard now takes around 3 minutes (was around 10 minutes before the fix).

Edited by Zhicai Zhang

Merge request reports

Loading