ciao a tutti,
ho già scritto un post (sezione hardware) su un primo lavoro di tesi che sto facendo: rilevare la caratteristica corrente tensione di un alimentatore.http://arduino.cc/forum/index.php/topic,126840.0.html
dopo aver implementato questo circuito su breadboard
con il codice corrispondente per rilevare tensioni e corrente
#define RELAY_PIN 3 //digital pin to control the relay
#define c_pin A1 //capacitor analog pin
#define ps_pin A0 //power supply analog pin
void setup()
{
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(9600); // open serial
Serial.println("Press the spacebar to toggle relay on/off");
}
void loop()
{
static int relayVal = 0;
int cmd;
float c_voltage, ps_voltage, current;
static float res = 5.2;
while (Serial.available() > 0)
{
cmd = Serial.read();
switch (cmd)
{
case ' ':
{
relayVal ^= 1; // xor current value with 1 (causes value to toggle)
if (relayVal)
Serial.println("Relay on");
break;
}
default:
{
Serial.println("Press the spacebar to toggle relay on/off");
}
}
if (relayVal)
{
digitalWrite(RELAY_PIN, HIGH);
delay(20); // relay transition time
do
{
c_voltage = analogRead(c_pin);
ps_voltage = (analogRead(ps_pin));
c_voltage = c_voltage *5 /1023;
ps_voltage = ps_voltage * 5 / 1023;
current = (ps_voltage - c_voltage)/res;
Serial.print(ps_voltage);
Serial.print(" ");
Serial.print(c_voltage);
Serial.print(" ");
Serial.print(current);
Serial.print("\n");
}
while(current >0.000001);
Serial.println("Please wait for the capacitor to discharge");
digitalWrite(RELAY_PIN, LOW);
do
{
c_voltage = analogRead(A1);
c_voltage = c_voltage * 5 / 1023;
Serial.println(c_voltage);
delay(50); // just a delay to not print all the values
}
while(c_voltage > 0.001);
relayVal = 0; // reinitialze the relayVal
Serial.println("\nThe relay is off, press the spacebar");
Serial.println("again if you want to repeat the measure\n");
}
}
}
vorrei riuscire a plottare in real time i dati che ricevo su corrente e tensione tramite processing.
ho letto tutti i vari post qui sul forum che riguardano processing e visto anche qualche tutorial, ma non ho trovato come fare a prendere le due serie di dati e plottarli in un semplice grafico tipo questo ottenuto con excel
grazie per l'aiuto