Jump to content
ELFORUM - Forumul electronistilor
Vlad Mihai

Arduino mega2560 12 intrari analogice

Recommended Posts

Salut, intentionez sa  citesc  8 tensiuni si 4 curenti utilizant un arduino mega2560, dar  ma lovesc  de faptul ca deja  de la al doilea canal nu mai masora ok, masuratoarea variaza mult, desi tensiunea de pe  pinul de intrare analogica e stabila..Cred ca e ceva software care imi scapa....Are cineva idee  ce  trebuie facut?

void setup() {Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps}void loop() { //read  voltages//1v high current int sensorValue1 = analogRead(A8);int sensorValue7 = analogRead(A7);sensorValue1=0;sensorValue7=0;for (int i=0; i<  10; i++){delay(10);sensorValue1 += analogRead(A8);delay(10);}for (int i=0; i<  30; i++){delay(5);sensorValue7 += analogRead(A7);delay(5);}float voltage_1 = (sensorValue1 / 10) * (5.0  / 1023.0);  //read   voltage float current_1 = (sensorValue7 /30) * (5.0 / 1023.0) *5.0;  //read   voltage//send  data to serial  Serial.print("Z");   //sync data  Serial.println(voltage_1);  Serial.print("n");  Serial.println(current_1);  Serial.print("n"); delay(100);}
Edited by Vlad Mihai
Link to comment
Share on other sites

Scoate din bucla:

sensorValue1=0;sensorValue7=0;

In setup initializeaza o citire falsa a ADC si apoi adu la zero cele doua variabile sensorValue1 si 7.

Informatii interesante gasesti aici: http://meettechniek.info/embedded/arduino-analog.html

 

P.S. Divizarea se face la 1024 si nu la 1023. In setup introdu :

analogReference(INTERNAL);// sau DEFAULT, functie de referinta folosita
Link to comment
Share on other sites

Salut, multumesc de raspunsuri, dar si cu  modificarile de mai sus la fel aveam   fluctuatii... pana cand am pus osciloscopul  pe tensiunea respectiva si am vazut ca aveam un riplu cat casa poporului cauzat de un consumul a 4A la 1V (in gol masura  bine toate canalele dar cand alimentam  device-ul, un FPGA, o lua razna), dupa Paste remediez problema si revin. Multumesc!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines