ELFORUM - Forumul electronistilor

# Problema senzor de curent acs758

## Recommended Posts

Posted (edited)

Am facut un incarcator solar cu arduino, si am urmatoarea problema cu senzorul de curent, cand nu trece curent prin el ar trebui sa fie 0V, dar defapt e 0.590V, care e citit de un adc, si anume ads1115. Cum pot sa spun adc-ului sa inceapa numaratoarea doar de la 590mV?

```#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
float V1 = 0.0;
float V2 = 0.0;
float V3 = 0.0;
float V4 = 0.0;
float en1 = 0.0;
float en2 = 0.0;

void setup(void)
{
pinMode(9, OUTPUT);
lcd.init();
lcd.backlight();
Serial.begin(9600);
}
unsigned long startMillis;
unsigned long currentMillis;
unsigned long elapsedMillis;
byte pulseWidth = 0;

void loop(void)
{

currentMillis = millis();
elapsedMillis = (currentMillis - startMillis);
unsigned long SS = (elapsedMillis / 1000) % 60;
unsigned long MM = (elapsedMillis / (60000)) % 60;
unsigned long HH = (elapsedMillis / (3600000));

en1 = en1 += (V3 * V4) * 1 / 36000;
en2 = en2 += (V1 * V2) * 1 / 36000;

lcd.setCursor(0, 0);
lcd.print(V4, 2);
lcd.setCursor(5, 0);
lcd.print("V");
lcd.setCursor(7, 0);
lcd.print(V3, 3);
lcd.setCursor(12, 0);
lcd.print("A");
lcd.setCursor(14, 0);
lcd.print(V3 * V4, 1);
lcd.setCursor(19, 0);
lcd.print("W");

lcd.setCursor(0, 1);
lcd.print(V1, 3);
lcd.setCursor(5, 1);
lcd.print("V");
lcd.setCursor(7, 1);
lcd.print(V2, 3);
lcd.setCursor(12, 1);
lcd.print("A");
lcd.setCursor(14, 1);
lcd.print(V1 * V2, 1);
lcd.setCursor(19, 1);
lcd.print("W");

lcd.setCursor(0, 2);
lcd.print("IN");
lcd.setCursor(4, 2);
lcd.print(en1, 1);
lcd.setCursor(10, 2);
lcd.print("W/H");
lcd.setCursor(0, 3);
lcd.print("OUT");
lcd.setCursor(4, 3);
lcd.print(en2, 1);
lcd.setCursor(10, 3);
lcd.print("W/H");

lcd.setCursor(14, 3);
lcd.print(MM);
lcd.print(":");
lcd.print(SS);

if (V1 < 28 )
{
if (pulseWidth != 255) pulseWidth++;
}
if (V1 > 28 )
{
if (pulseWidth = 0);
}
analogWrite(9, pulseWidth);
}```

Edited by bogdan666
##### Share on other sites

Cum arata ACS 748 ?

##### Share on other sites

acs758, greseala mea, scuze...

##### Share on other sites

Dacă citeşti direct milivolţi, compensarea se face simplu. După linia de citire adc, mai introduci una:
V1 = V1 - 590;

##### Share on other sites

Foarte simplu...dupa mai multe teste, defapt functioneaza cu 588: V2 = (((ads.readADC_SingleEnded(1)) * 0.0001875) - 0.588) * 20;

mersi mult, o alta problema este faptul ca ecranul o ia razna cand chiar se foloseste energie, deci trebuie sa rotunjesc citirile...inapoi la studiat.

##### Share on other sites

Poate intereseaza pe cineva sau are aceeasi problema, am rezolvat problema cu "rotunjirile"

``` V1 = 0;
V2 = 0;
V3 = 0;
V4 = 0;
for (int i = 0; i < 10; i++)
{
delay(1);
}
V1 /= 10;
V2 /= 10;
V3 /= 10;
V4 /= 10;```

##### Share on other sites

Felicitari pentru rezolvarea problemei, numai ca metoda folosita nu-i rotunjire, e mediere - calculezi media unui numar de masuratori (in cazul tau 10).

Stiu, teoria chbritului...

##### Share on other sites

Da, media celor 10 masuratori, e adevarat.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×

• #### Activity

×
• Create New...