Go Down

Topic: serial data logging (Read 2744 times) previous topic - next topic

trvslamm

I have several values being printed to the arduino IDE serial monitor using the println function. I would like to use some other program or application to display this data in a more organized fashion. What are some options other than labview or arduino manager?

mcasale

Hi. I am doing a similar project. I started with the Serial Monitor, but have moved to the "Processing" application. It is discussed in the Arduino web pages. It's open source and FREE! Try doing the simple examples with the two applications talking to each other.

I used to use VB6 for things like this. Processing looks NOTHING like Microsoft.

I must caution you that I am having a problem when I turn off the PC side - it looks like the Arduino is resetting itself. I'm looking on this forum for some ideas.

Good luck.

spatula

Yes, Processing is a good suggestion. And since the Arduino IDE is based on Processing it also makes easy to switch from one programming environment to the other. There is a whole section in this forum for "Interfacing w/ Software on the Computer". You may look at it for further ideas.

@mcasale, I think that your problem is due to the fact that the Arduino resets when it receives a DTR signal on the serial line (it typically happens when a program opens the serial port). I guess that Windows resets all serial communications before shutting down (or perhaps it's just the result of a voltage change due to the computer switching off). Perhaps you just need to disconnect the Arduino before shutting down. Otherwise there are hardware tricks involving the use of a capacitor (sometimes a resistor), also frequently discussed in this forum.

trvslamm

I downloaded processing but i'm such a rookie at this it's not even in my relm of feasability to make an application. anywhere i could find one already made?

mcasale

Yo @trvslamm. Here's the Processing application I'm working on. It loops forever sending out a command to the Arduino, Z, which asks for a bunch of data. This then formats the returning data onto the window. My laptop uses COM8, which is actually a USB port. You will have to comment out a lot of this, and just try to send 1 piece of data. You should put this file wherever you have your Processing app, and put it in a folder called "TrySerial".

Let me know if this helps.
Mike

mcasale

FYI I was able to find a fix for the Arduino RESET problem. It is here

http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection

On my PCB, I was planning on using a "real" reset/brownout chip. That also might mitigate this problem.

Funny, it's always the basic things that screw me up.

trvslamm

what should i add into my arduino code to send the data to TrySerial?

mcasale

I am using the PString library to generate the strings that I send to the PC. Here's what I do:

//PString library
#include <PString.h>
char serbuff[20];
PString Serialbuff(serbuff, sizeof(serbuff));

//Then somewhere in your code, generate the string that contains the data.
// GOT INQUIRY FOR EVERYTHING, Z
        Serialbuff.begin();
        Serialbuff.print(intTemp);  //data
        Serialbuff.print(',');
        Serialbuff.print(intVolts);  //data
        Serialbuff.print(',');
        Serialbuff.print(intCurrent);  //data
        Serialbuff.print(',');
        Serialbuff.print(intAmpHrs);  //data
       
        //SEND OUT SERIAL PORT
        Serial.println(Serialbuff);

I hope this helps. Note I am using commas (,) to separate the data integers. You can use almost anything you like.


mixania

The best way is using Processing.

This example may help you grasp the basics. It graphs an Analog reading for a pin.

Code for Arduino:

Code: [Select]
void setup() {
 Serial.begin(9600);
}

void loop() {
 Serial.println(analogRead(A0));
 delay(2);
}


Code for Processing:
Code: [Select]
import processing.serial.*;

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph

void setup () {
// set the window size:
size(400, 300);        

// List all the available serial ports
println(Serial.list());
// I know that the first port in the serial list on my mac
// is always my  Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set inital background:
background(0);
}
void draw () {
// everything happens in the serialEvent()
}

void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');

if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);

// draw the line:
stroke(127,34,255);
line(xPos, height, xPos, height - inByte);

// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0);
}
else {
// increment the horizontal position:
xPos++;
}
}
}

Go Up