Hi Everyone, thank you in advance for your help and time.
I'm running into an issue when trying to automatically log data in excel using PLX_DAQ. I have an RGB colour sensor connected to my arduino and would like to plot the values with respect to time in excel.
When I open the serial monitor on the arduino it works and prints the values as expected, but when I close the serial monitor, open the PLX_DAQ file and hit connect, it generates the desired labels but never starts data logging.
Any help would be much appreciated.
Taken from here: PLX-DAQ version 2 - now with 64 bit support! (and further new features) - Interfacing w/ Software on the Computer - Arduino Forum
colorview.ino (2.13 KB)
dmharduino:
Taken from here: PLX-DAQ version 2 - now with 64 bit support! (and further new features) - Interfacing w/ Software on the Computer - Arduino Forum
This is probably just a minor procedural matter, and easily fixed, but you should raise it in the above thread.
It would help if you posted the code in the proper manner, using </> tags.
Sorry, didn't know how to do that, noob here. And okay, I'll mention that, thanks.
#include <Wire.h>
#include "Adafruit_TCS34725.h"
// Pick analog outputs, for the UNO these three work well
// use ~560 ohm resistor between Red & Blue, ~1K for green (its brighter)
#define redpin 3
#define greenpin 5
#define bluepin 6
// for a common anode LED, connect the common pin to +5V
// for common cathode, connect the common to ground
// set to false if using a common cathode LED
#define commonAnode true
// our RGB -> eye-recognized gamma color
byte gammatable[256];
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
void setup() {
Serial.begin(9600);
if (tcs.begin()) {
} else {
Serial.println("No TCS34725 found ... check your connections");
while (1);
}
Serial.println("CLEARDATA");
Serial.println("LABEL,C,R,G,B");
pinMode(redpin, OUTPUT);
pinMode(greenpin, OUTPUT);
pinMode(bluepin, OUTPUT);
// thanks PhilB for this gamma table!
// it helps convert RGB colors to what humans see
for (int i=0; i<256; i++) {
float x = i;
x /= 255;
x = pow(x, 2.5);
x *= 255;
if (commonAnode) {
gammatable[i] = 255 - x;
} else {
gammatable[i] = x;
}
//Serial.println(gammatable[i]);
}
}
void loop() {
uint16_t clear, red, green, blue;
tcs.setInterrupt(true); // turn off LED
delay(1000); // takes 1000ms to read
digitalWrite(7, HIGH);
tcs.getRawData(&red, &green, &blue, &clear);
Serial.print(clear);
Serial.print(",");
Serial.print(red);
Serial.print(",");
Serial.print(green);
Serial.print(",");
Serial.print(blue);
// Figure out some basic hex code for visualization
uint32_t sum = clear;
float r, g, b;
r = red; r /= sum;
g = green; g /= sum;
b = blue; b /= sum;
r *= 256; g *= 256; b *= 256;
//Serial.print("\t");
//Serial.print((int)r, HEX); Serial.print((int)g, HEX); Serial.print((int)b, HEX);
Serial.println();
//Serial.print((int)r ); Serial.print(" "); Serial.print((int)g);Serial.print(" "); Serial.println((int)b );
analogWrite(redpin, gammatable[(int)r]);
analogWrite(greenpin, gammatable[(int)g]);
analogWrite(bluepin, gammatable[(int)b]);
}
I haven't used PLX for quite a while, but your code looks pretty kosher. You might try changing that variable "clear" to "Fred". Just a guess.
Hey dmharduino
You are missing Serial.print("DATA,"); just above
Serial.print(clear);
Serial.print(",");
Serial.print(red);
Serial.print(",");
Serial.print(green);
Serial.print(",");
Serial.print(blue);
You should also remove this line Serial.println(); and instead changeyour last Serial.print(blue); in
Serial.println(blue);
The Serial.print("DATA,") is necessary for Excel to know what to do.