Good day to everyone, may i remind you that I am pretty new to using serial commands in my experience of arduino and I may have a learning curve through out this thread.
First things first lets list down all the equipment i will be using in this project:
Arduino Mega
Power Analyzer MKII (See PDF attached.)
Obviously I will be using the Power Analyzer to send a continuous stream of data (VRMS,IRMS,PF, etc) in ASCII to my Arduino Mega. I will then display all of this data later on using processing and arduino/firmata.
I started my code like so:
(I'm using software serial at the moment , I know mega has 3 serials this is just what I started with)
Buffer is 64bits
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
mySerial.write(0x02); // Start transmission
mySerial.print("M3"); // to send a setting of M3 = [b]Comma Seperated Value[/b]
mySerial.write(0x03); // End transmission
// we initiated a csv setting
}
void loop() {
// put your main code here, to run repeatedly:
delay(50);
char value = mySerial.read();
Serial.print(value); // using Serial.Print to check data read from mySerial
delay(50);
Serial.flush();
delay(50);
}
THE PROBLEM:
I can read the data from the Power Analyzer just fine in CSV format it starts as follows:
STAT,VERSION,VRMS,IRMS,PREAL,VA,QAVERAGE,QINSTANT,PF,TEMPERA TURE,PHARMONIC,PFUNDAMENTAL,PQFUNDAMENTAL,WATTHR,INT
It is quite accurate but in the Serial Monitor, this data is only presented once and doesn't repeat again. My theory is that the buffer size of 64 bits is not enough and is filled up with the first reading and the rest of the data receive is trashed.
I need the community's help to make me understand the concept of buffer sizes.
- How can gather my continuous data if there is a buffer limit ?
- Can I delete the buffer each time I am done displaying the data so it can measure the values again?
- How can i refresh the buffer ?
- Do you have any suggestions for my project on how can i approach my Data?
Note: The Power analyzer used has a "on demand" feature that lets me just get the data i needed and not in a steam of CSV.
I thank you in advance for reading this long post and hopefully helping me out in my project.
Power Analyzer Manual rev 1r0.pdf (3.63 MB)