1
\$\begingroup\$

Below is my circuit diagram for ACS712 5A current sensor using peak detector circuit.

enter image description here

Currently I facing 2 problems.

i)zero cross dc voltage keep changing

ii)The current scale is non linear and not accurate

For problem (i), I verified by measuring the voltage from VIOUT every time power on tend to be different even the input voltage stay almost the same(5.01V to 4.95V), I be getting output lets say in the range (2.57V to 2.43V). I replaced a new current sensor and got almost the same result. Each time after taking load current measurement, I turned off supply to the load and recheck the VIout, it tend to be different from the voltage during power on which mean the zero cross voltage changed. I'm using a 4 channel relay module and aware relay module can be power consuming so I using dual supply, one for relay module and another one for microcontroller, reference voltage and Opamp. As a result, the input voltage feeding to microcontroller, voltage reference and Opamp voltage is more stable as compare to using single supply to power all unit but that does not solve my zero cross dc voltage shifting issue. Below picture shown the relay module I currently using.

enter image description here

For problem(ii) my peak detector voltage does not have much changes but the measured current can be quite different? It does not scale linearly according to the 0.185mV/A formula.In term of accuracy, it is bad but reading stability is good.

Below are the pseudocode I use to calculate the current.

   pseudocode
{  void init()
  __delay_ms(8000); \\ delay 8 sec on each power on for the capacitor to reach stable value
  InitialCurrent=ADRead(1); \\store this startup reading for calculation since VIOUT can be different on each power on

  void Current()
{
   PeakCurrent=0;
   AveragePeakCurrent=0;
   for(int u=0;u<300;u++)
 {  
    PeakCurrent=ADRead(1);
    AveragePeakCurrent=AveragePeakCurrent+PeakCurrent;
 }
  AveragePeakCurrent=(AveragePeakCurrent/300);
   PeakCurrent=((AveragePeakCurrent-InitialCurrent)*0.009775)*4.2;  

 \\initialcurrent=(ADC reading)*5/1023*2(due to voltage divider),AveragePeakCurrent=(ADC reading)*5/1023*2
\\lastly, the differeces is times by (1/0.185)*0.7071=3.822 but i put 4.2 to offset it    to match a load measured at around 1A current but it scale non linear when measure load with different current,example 0.3A,0.8A.
PeakCurrent=fabs(PeakCurrent);
 }
\$\endgroup\$
3
  • \$\begingroup\$ You might like to compare with my ACS712 calibration results: raspberrypi.stackexchange.com/questions/94403/…. \$\endgroup\$
    – tlfong01
    Commented Jun 23, 2022 at 14:29
  • 1
    \$\begingroup\$ To be honest I haven't read yet, I looked at the schematic first and first thing I saw was an SSR in series with a LED + 10.0k resistor supplied from 5V (return pulled low) and without looking at the SSR part number I doubt that's sufficient current. \$\endgroup\$ Commented Jun 23, 2022 at 14:35
  • 1
    \$\begingroup\$ Note that magnetic shields must be used ... \$\endgroup\$
    – Antonio51
    Commented Jun 24, 2022 at 16:58

1 Answer 1

4
\$\begingroup\$

User of several similar hall current sensors here: The problem is that hall sensors measure magnetic fields. Every current flow in the close proximity to the sensor will influence its measurements.

My sensors are in a small device (approx 30x30x30mm), and they deliver considerably different values if a cable runs near the box.

\$\endgroup\$
3
  • \$\begingroup\$ Indeed I have use alot of jumper on my breadboard and near to current sensor, I'll try to isolate it from the jumpers and recheck the result . \$\endgroup\$
    – chuackt
    Commented Jun 23, 2022 at 15:28
  • \$\begingroup\$ Is a cheap solution like simple emf detector app on Google play that utilize phone hall effect sensor sensitive enough to detect the possible magnetic field around acs712 that can affect the reading? \$\endgroup\$
    – chuackt
    Commented Jun 23, 2022 at 15:46
  • \$\begingroup\$ I didn't knew that phones had hall effect sensors. I learn something new every day.... A quick google tells me that they are used to detect if a magnetic hull is open or closed. Don't think that they are sensitive and longrange enough. Besides, do you know where the sensor is located? A smartphone is big.... \$\endgroup\$
    – jwsc
    Commented Jun 24, 2022 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.