Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

CURRENT MEASUREMENTS C.D. ARDUINO_ACS712

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO
View previous topic :: View next topic  
Author Message
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Mon Aug 03, 2020 1:19 am    Post subject: CURRENT MEASUREMENTS C.D. ARDUINO_ACS712 Reply with quote

In this topic it is about measuring the consumption of direct current without load (No load) but my current should be zeroed ampere.
The program of this very simple code stops showing c.d current. and actually connect ACS712 as shown in the photos and the graphical chart of the earring-
My current sensor is 5 Amps maximum and the sensitivity is 0.185 millivolt per ampere.
It should measure 0 Amp but is something wrong with my code? Confused Confused

Code:
Config Adc = Single , Prescaler = Auto , Reference = Avcc   'El punto de referencia es el voltaje de la CPU (5000mV)

     ' 5000mV/1024 ->4,88 mV por un punto ADC


Dim Vadc As Word
Dim X As Single
Dim Y As Single
Const Vout = 2.5
Const Sensibilidad = 0.185
Dim I As Single



Do
  Vadc = Getadc(0)
  Print Vadc
  X = Vadc / 2
  Print X
  Y = X - Vout
  Print Y
  I = Y / Sensibilidad
  Print "Corriente= " ; I
  Waitms 100
Loop
End
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Mon Aug 03, 2020 2:25 am    Post subject: Reply with quote

C.D current sensor test with single code for ACS712.
Until there you are correct and the value is 513 +/- 520

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32

$baud = 9600


Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc

Dim V_sensor As Integer



Do

  V_sensor = Getadc(0)
  Print V_sensor

Loop
End
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Mon Aug 03, 2020 2:55 am    Post subject: Reply with quote

I have done a lot of testing with these sensors.
I could not get good readings with 10 bit ADCs
They were not stable and two digits were the best I could get.
You need a 10uF Tantalum capacitor on the sensor at the power supply.
I increased the filter capacitor to 100nF but fast measurements are lost with this.
I now use a 12 bit ADC and get stable 5 digit readings.
I do 16 samples and average them storing each average in a variable .

here is the readings from 11 sensors on my battery banks

1.860<>1.992<>0.096<>2.568<>2.736<>1.860<>0.768<>2.052<>1.656<>0.348<>1.932<>

Total Amps = 17.868

It can be seen that bank 3 is no good 7 and 10 not much better but now nearly 9 years old so expected.

Regards Paul
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Mon Aug 03, 2020 4:42 am    Post subject: Reply with quote

Aquí están las lecturas de 11 sensores en mis bancos de baterías

1.860 <> 1.992 <> 0.096 <> 2.568 <> 2.736 <> 1.860 <> 0.768 <> 2.052 <> 1.656 <> 0.348 <> 1.932 <>

Amperios totales = 17.868

Se puede ver que el banco 3 no es bueno 7 y 10 no mucho mejor, pero ahora tiene casi 9 años, así que se esperaba.

So ACS712 is very bad and INA219 is good? I have never tested them for current sensors.

Good and the code corrected them but I have doubts what variables to put?



Code:

Dim Voltaje_sensor As Single
Dim X As Integer
Dim Y As Integer
Dim I As Single
Const Sensibilidad = 0.185
 


My simple code is already working well and I corrected it. Very Happy Very Happy

Code:
$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32
$baud = 9600

Config Adc = Single , Prescaler = Auto , Reference = Avcc   'El punto de referencia es el voltaje de la CPU (5000mV)
Start Adc
'*****************************************
' V= mI + 2.5
' V= 2.5 +/- I=0
'V=(Sensibilidad)(I)+2.5
'Por lo tanto:
'I=V-2.5/Sensibilidad
'****************************************


Dim Voltaje_sensor As Single
Dim X As Integer
Dim Y As Integer
Dim I As Single
Const Sensibilidad = 0.185



Do
'VOLTAJE DE SENSOR
X = Getadc(0) * 5
Voltaje_sensor = X / 1023
Print "Voltaje_sensor= " ; Voltaje_sensor

'ECUACION PARA OBTENER LA CORRIENTE
Y = Voltaje_sensor - 2.5
I = Y / Sensibilidad
Print "Corriente= " ; I

Loop
End
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Mon Aug 03, 2020 5:07 am    Post subject: Reply with quote

I do not see much difference we already see tomorrow because it is already very nights.
Nothing loads and the values come out.
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Mon Aug 03, 2020 3:06 pm    Post subject: Reply with quote

Very Happy Hello!!
Already solved since there is current noise can be the capacitors or setting a code for more precise.
Does anyone know how to add all values to a single value with a for_next? Very Happy
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Mon Aug 03, 2020 3:14 pm    Post subject: Reply with quote

As we have already seen the monitor tables, the values are varied.

_0.039__0.066__0.092__0.066__0:092.................... Shocked

difference of 27 +/- Sad
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Tue Aug 04, 2020 1:15 am    Post subject: Reply with quote

Printpix52 wrote:
As we have already seen the monitor tables, the values are varied.

_0.039__0.066__0.092__0.066__0:092.................... Shocked

difference of 27 +/- Sad


A 100nF filter capacitor on pins 6 and 5 greatly stabilizes this.

Also the devices are sensitive to nearby magnetic fields.
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Tue Aug 04, 2020 11:38 pm    Post subject: Reply with quote

I am going to buy and order 100 nF tantalum capacitors tomorrow and I inform you, thank you !! Very Happy Very Happy
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Thu Aug 06, 2020 5:56 am    Post subject: Reply with quote

Hello!! I already change a little noise and we continue tomorrow to change other values of 1uF, 10nF and 100nF tantalum capacitors. Very Happy Very Happy Very Happy Very Happy
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Fri Aug 07, 2020 1:00 am    Post subject: Reply with quote

Paulvk wrote:
I have done a lot of testing with these sensors.
I could not get good readings with 10 bit ADCs
They were not stable and two digits were the best I could get.
You need a 10uF Tantalum capacitor on the sensor at the power supply.
I increased the filter capacitor to 100nF but fast measurements are lost with this.
I now use a 12 bit ADC and get stable 5 digit readings.
I do 16 samples and average them storing each average in a variable .

here is the readings from 11 sensors on my battery banks

1.860<>1.992<>0.096<>2.568<>2.736<>1.860<>0.768<>2.052<>1.656<>0.348<>1.932<>

Total Amps = 17.868

It can be seen that bank 3 is no good 7 and 10 not much better but now nearly 9 years old so expected.

Regards Paul



Hello!!
You are absolutely right I have changed capacitors and nothing changes, the only thing that changes is the sensitivity to 170 and I see a little noise but we already let it.
in the future I will try 12Bit ADC... Very Happy Very Happy Very Happy
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Fri Aug 07, 2020 5:28 am    Post subject: Reply with quote

The noise has disappeared but without load and I am going to test an ammeter test and with a lamp load to compare with ACS712 Very Happy Very Happy Very Happy
Back to top
View user's profile
SZTRAD

Bascom Member



Joined: 30 Dec 2019
Posts: 165

blank.gif
PostPosted: Wed Feb 17, 2021 8:58 am    Post subject: Reply with quote

Hi
I assume you don't want to use another chip(I would choose something with differential inputs) Do you need to measure negative current or will you only measure positive current? You're using the power voltage as a reference. Is it well blocked? The ACS712 walks quite a bit with the power supply so block again. The combination of 10,100,1000nF in quality ceramics is ideal. Next, I suggest you use measurement averaging, I don't know how fast you need to measure. With appropriate connection and correction of the output signal, you are able to measure quite steadily. I use in serial production ACS712 in 20A version and the distinctiveness is around 10mA. Deployed in BMS for large battery blocks for balancer control and calculation of individual cell parameter. I don't have problems with them except for one production series that hasn't held parameters since production. You can calm the output with a plugged capacitor, but the error will be greater the greater the current. The tips of the sample will be completely lost. Consideration should be given to how long and how you.
Of course, you can calm the output with a connected capacitor, but there'll be more error in the current take-offs the bigger the current. The tips of the sample will be completely lost. Consideration should be given to how long and how the capacitor will discharge. You haven't written down what you need an evaluation for, so it's hard to answer. Software doesn't solve everything.
RS
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum