07-22-2012 11:33 AM
Hello,
I-m new here.
My project use arduino to monitor mini aerogenerator.
All in ok in arduino side, i send to serial port somme electrical parameters: U, I, P, RPM (values calculated and stored in variables).
Now, i need to send these values in LabView and monitor these using ghaphic charts.
How i can identify these values? i mean for RPM, to send it to serial port, i use this: Serial.println(rpm); how i can identify this value in serial port and collect for ghaphic chart?
I have these 4 values and i need 4 graphics, one for each value with evolution in time.
I somme one can help me!
LEO
07-22-2012 04:37 PM
07-22-2012 04:54 PM
Hello and big thanks for your reponse. THis is my arduino code:
#include <SoftwareSerial.h>
#include <SparkFunSerLCD.h>
SparkFunSerLCD led(7,2,16); // desired pin, rows, cols);
int ledPin = 13; // IR LED connected to digital pin 13
volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;
// declaratii pentru partea de masurare tensiune
float vout = 0.0;
float vin = 0.0;
float vout2 = 0.0;
float vin2 = 0.0;
float vout3 = 0.0;
float vin3 = 0.0;
float curent = 0.0;
float putere = 0.0;
int analogInput = 1;
int analogInputa = 2;
int analogInputb = 3;
float R1 = 48500.0; // !! rezistenta R1 !!
float R2 = 4600.0; // !! rezistenta R2 !!
int value = 0;
int valoare = 0;
int valoareb = 0;
void rpm_fun()
{
//Each rotation, this interrupt function is run twice, so take that into consideration for
//calculating RPM
//Update count
rpmcount++;
}
void setup()
{
pinMode(analogInput, INPUT); //aici preiau prima tensiune
Serial.begin(9600);
led.setup();
delay(1000);
led.at(1,1,"RPM: ");
led.at(2,1,"U1: ");
//Interrupt 0 is digital pin 2, so that is where the IR detector is connected
//Triggers on FALLING (change from HIGH to LOW)
attachInterrupt(0, rpm_fun, FALLING);
//Turn on IR LED
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
rpmcount = 0;
rpm = 0;
timeold = 0;
}
void loop()
{
turatie();
delay(1000);
tensiuni();
}
void turatie()
{
//Update RPM every second
//delay(1000);
//Don't process interrupts during calculations
detachInterrupt(2);
//Note that this would be 60*1000/(millis() - timeold)*rpmcount if the interrupt
//happened once per revolution instead of twice. Other multiples could be used
//for multi-bladed propellers or fans
rpm = 8.57*1000/(millis() - timeold)*rpmcount;
timeold = millis();
rpmcount = 0;
//Print out result to lcd and serial
Serial.print ("RPM:");
Serial.print(rpm);
Serial.print (" | ");
led.at(1,6," ");
led.at(1,6,rpm);
//Restart the interrupt processing
attachInterrupt(2, rpm_fun, FALLING);
}
void tensiuni(){
// read the value on analog input
value = analogRead(analogInput);
valoare = analogRead(analogInputa);
valoareb = analogRead(analogInputb);
//Serial.print("value=");
//Serial.println(value);
if (value >= 1023) {
Serial.println("TENSIUNE MAXIMA!!");
return;
}
else if (value <= 0) {
Serial.println("TENSIUNE MINIMA!!");
return;
}
// print result over the serial port
vout = (value * 5.0) / 1024.0;
vout2 = (valoare * 5.0) / 1024.0;
vout3 = (valoareb * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
vin2 = vout2 / (R2/(R1+R2));
vin3 = vout3 / (R2/(R1+R2));
curent = (vin - vin2)/1.2;
putere = vin3*curent;
//Serial.print("vout=");
//Serial.println(vout);
Serial.print("Ugen=");
Serial.print(vin3);
Serial.print("V | ");
Serial.print("U1=");
Serial.print(vin);
Serial.print("V | ");
Serial.print("U2=");
Serial.print(vin2);
Serial.print("V | ");
Serial.print("I=");
Serial.print(curent);
Serial.print("A | ");
Serial.print("P=");
Serial.print(putere);
Serial.println("W ");
led.at(2,5," ");
led.at(2,5,"Aici tensiune");
}
This program, send data to serial port and to my serial LCD. I really need to send "curent", "putere", "tensiune" to labview for three charts.
Any sugestion for me?
07-23-2012 10:15 AM
What have you tried so far? There are a couple of simple examples for serial communication? You will probably have to parse part of the receive string to get the prefix and wire that to a case statement with the separate indicators in each.
If you run one of the examples or any other code, go to Edit>Make Current Values Default and save the VO so someone can see the data in an indicator that you would have on the VISA Read.
07-23-2012 10:24 AM
We tried several variants. Not a problem sending data to LabVIEW itself, the problem occurs when data must be filtered. That is, data for "current" to be sent to the graphics generator for current, as power ... etc..
Any other ideas?
07-23-2012 10:26 AM
Yes, do what I asked and provide some sample data.
07-23-2012 10:32 AM
Above is the Arduino program that I use. The data that I want to send them to LabView, separately are: "wine", "vin2", "vin3", "Current", "power".
Got an idea on how to do this? A minimal example would be a great joy for me
07-23-2012 10:43 AM - edited 07-23-2012 10:44 AM
@Leonte2012 wrote:
Above is the Arduino program that I use. The data that I want to send them to LabView, separately are: "wine", "vin2", "vin3", "Current", "power".
Got an idea on how to do this? A minimal example would be a great joy for me
send them to LabVIEW??
Huh?
Have you looked at the LabVIEW examples????
07-23-2012 10:51 AM
A mistake of expression. Labview need to take these values from Arduino.
07-23-2012 11:23 AM
You've said that several times. I don't understand why you keep repeating that. I've already said that there are serial examples and you have said you tried different variants. The examples have a string indicator. Do what I asked so someone can see exactly what you are receiving.