Go Down

Topic: Arduino -> Sensor Result plotting with PLX-DAQ (Read 4 times) previous topic - next topic

juuka

Hi
i use a SRF02 Sensor on my Arduino. The result is coming to the serial monitor. That works fine.
That is my Code

Code: [Select]

#include <Wire.h>

#define srfAddress1 (0x70)                            // Address of the SRF02

void setup()
{
   Serial.begin(9600);
   Wire.begin();                               
}

int reading = 0;

void loop()
{
 
//Sensor 1
  Wire.beginTransmission(srfAddress1);            // Start communticating with SRF02
  Wire.write(0x00);                                                    // Send Command Byte
  Wire.write(0x51);                                                   // Send 0x51 to start a ranging takes place
  Wire.endTransmission(); 


delay(70);                                                                  // Wait for ranging to be complete


//instruct sensor to return a particular echo reading, Sensor1
  Wire.beginTransmission(srfAddress1);        // Start communticating with SRF02
  Wire.write(0x02);                                                // Call register for start of ranging data
  Wire.endTransmission();                                  // stop transmitting


//request reading from sensor, Sensor1
  Wire.requestFrom(srfAddress1, 2);              // request 2 bytes from slave device Sensor1


//receive reading from sensor
  if (2 <= Wire.available())                                  // if two bytes were received
  {
   reading = Wire.read();                           // receive high byte (overwrites previous reading)
   reading = reading << 8;                         // shift high byte to be high 8 bits
   reading = Wire.read();                          // receive low byte as lower 8 bits
   Serial.print("Entfernung1:");
   Serial.println(reading);                        // print the reading
  }

  delay(500);                                      // wait a bit to read the output

}


Now i want to plot the result with PLX-DAQ software in a graph.
The PLX-DAQ software shows me that it is connected to the Arduino (green C) and it shows me that it received some data (red R).
But there is no data transmission (green T).

How can i receive data from my Arduino?? Do i have to correct my Arduino-code??

NickPyner

#1
Nov 13, 2012, 04:47 am Last Edit: Nov 13, 2012, 11:20 pm by NickPyner Reason: 1

Do i have to correct my Arduino-code??


I think you do, but not fundamentally.

I had a bad time with PLX and went on to Live-Graph, which was a lot easier. I have now just got back to PLX to have another shot at it. The main reason why I gave this away is because It looked like I would have to learn all about strings. This is probably desirable but not necessarily essential.

If you can see numbers you expect to see on the monitor then it is just a matter of presenting them properly to PLX. I don't think you are doing that.

I assume "Entfernung1" means "sensor1" in German.  You can be sure Excel doesn't speak German, and probably can't understand "sensor1" either. You will see in the help that PLX makes a lot of "Control and data directives"  and the structure of these commands is the secret of making it work.

The problem is that the example is for Basic Stamp and needs to be translated to Arduino

I guess "DEBUG" means Serial.print and CR means Serial.println()
The vital bit, as i see it, is that you have to declare data following as "DATA". If you said that instead of "Entfurnung1", it might work!

Here is a useful link

http://robottini.altervista.org/arduino-and-real-time-charts-in-excel

The code is simpler than  I thought

Here is an adaptation of some code I have been working on.  It is for two temperatures and the difference between them.

Code: [Select]
//  This Arduino sketch reads DS18B20 "1-Wire" digital
//  temperature sensors.
//  Copyright (c) 2010 Mark McComb, hacktronics LLC
//  License: http://www.opensource.org/licenses/mit-license.php (Go crazy)
//  Tutorial:
//  http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
//  modernised, compacted, and metricated by Nick Pyner
//  code uses Arduino LCD stuff, for shield on Freetronics EtherTen.
//  Research your own pins!

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(8,9,14,5,6,7); // patchwire is to A0 (pin14) on this proto
int flag;
// Data wire is on pin 3
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress InThermo = {  
 0x28, 0x69, 0xC2, 0xB0, 0x03, 0x00, 0x00, 0X9F };
DeviceAddress OutThermo = {
 0x28, 0x7A, 0x8B, 0xC0, 0x03, 0x00, 0x00, 0x2F };

//temperature variables
float InTemp, OutTemp, diff, drain, flow, power, tempC;

void setup(void)
{
 // start serial port
 Serial.begin(9600);
 // set up the LCD,s number of columns and rows:
 lcd.begin(16, 2);
  Serial.println("LABEL,Time,TempIn,TempOut");
 // Print a message to the LCD.
 lcd.print("temp in     out");    

 // Start up the library
 sensors.begin();

 sensors.setResolution(InThermo, 12);
 sensors.setResolution(OutThermo, 12);
}

void loop(void)
{
   Serial.print("DATA,TIME,");
 delay(1000);
 flag = 0;
 //Get the sensor readings. There are two of them
 sensors.requestTemperatures();

 GetandPrint(InThermo);
 InTemp=tempC;
 flag = 1;

 GetandPrint(OutThermo);
 diff = tempC - InTemp;
 Serial.print (diff);
 Serial.println(" ,  ");

}

void GetandPrint(DeviceAddress deviceAddress)
{
tempC = sensors.getTempC(deviceAddress);
 if (tempC == -127.00) {
   Serial.print("Error getting temperature");
 }
 else {

   Serial.print(tempC);
     Serial.print(" ,  ");
 }
 lcd.setCursor (1,1);
 if (flag==1)
   (
   lcd.setCursor (11,1)
     );
 lcd.print (tempC);
}


This works insofar that it (apparently) puts the right data into the right places in Excel.  
That is as far as I can go. The worksheet has three tabs. The first has the data, and the other two the graphs. There is an instruction on them - "Move this sheet to 1st tab position to accept data"

I don't know how to do that.

edit:

Yes I do. I thought it was the contents that had to be moved. It isn't. You just slide the tab at the bottom of the page to the left. The graph then activates.

chrisa_

Does anyone know from where I can download PLX-DAQ? this link http://classic.parallax.com/tabid/393/Default.aspx does not work. Thank you!

Nick_Pyner

I have the link down as https........ rather than http........ but that doesn't work either. It seems like a balls-up at their end. I downloaded from there only a week or so ago and now I am getting identity theft threats and god knows what all else.

You can get the zip here, along with some background notes. The notes are mostly about getting the graph together for inexperienced Excel users. Getting a CSV file is easy.

http://homepages.ihug.com.au/~npyner/Arduino/PLX.zip
http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2PLX.pdf

Go Up