So....
I was finally able to get the VBScript to work. But it didn't work very well. I had to insert a For Loop instead of the While Loop. By the time I received anything across the port and into a file, it came across as chicken-scratches. The ASCII characters weren't intact.
I then managed to get a bash scripting to work, but that wasn't for nice for the LeCroy and it meant headaches porting it to a Linux Box having to manage stty information on whichever port I happened to connect the Arduino up too.
In the end, I spent all of today learning Processing, which turns out to be perfect. By perfect, I mean I can write something in Processing on the Mac, send over the .pde file, and any other operating system that has Processing can just load up the .pde file and get to work... making it cross platform pleasing (my lab runs between Macs, PCs, and a Linux box... hence why I am crossing all these code types together.)
All in all, I packaged something together that I have called PreconSensorCodeBundle. It includes Arduino Code to operate an Arduino Nano (or any Arduino with at least 4 analog pins) with two Precon Sensors hooked up to it. The Processing script takes in Temperature and Humidity values and writes them to a file. I then have an optional bash script which uses regular expressions to reformat the text file's data stamps (since I use Date and Calendar within the Processing Script). For those who are familiar with ROOT, the bundle then includes a ROOT UnNamed Macro to analyze the file, create graphs/plots, and then write all graphs and canvases to a root file.
The root files is then portable to anyone else who has ROOT.
Thanks for the help both of you, but in the end I have found Processing to be a much more powerful and useable tool. For anyone else interesting in writing Serial Monitor to File, I include my Processing Code here. For those interested in the regular expression script and ROOT script, feel free to message me:
import processing.serial.*;
Serial port;
String PreconReadings;
Date StartingTimeStamp = new Date();
Date AnyTimeStamp = new Date();
Date EndingTimeStamp = new Date();
PrintWriter PreconReadingsFile;
Calendar Timing = Calendar.getInstance();
float numberofreadings = 0;
void setup() {
size(100,100);
println(Serial.list());
port = new Serial(this, Serial.list()[1], 9600);
PreconReadingsFile = createWriter("PreconReadingFile.txt");
PreconReadingsFile.flush();
StartingTimeStamp = Timing.getTime();
println("Now writing data to file! Starting time is: " + StartingTimeStamp);
}
void draw() {
}
void serialEvent(Serial port) {
PreconReadings = port.readString();
if(PreconReadings != null) {
PreconReadingsFile.print(PreconReadings);
PreconReadingsFile.flush();
}
if(PreconReadings.equals("*")) {
Timing = Calendar.getInstance();
AnyTimeStamp = Timing.getTime();
PreconReadingsFile.print(" " + AnyTimeStamp);
PreconReadingsFile.flush();
println("Number of readings: " + numberofreadings);
++numberofreadings;
}
}
Edit:
And for those who are wanting to see how to monitor four analog signals and print out results based on a pvss sort of system (i.e. don't print a reading within some small range of temperature fluctuation to ignore thermal noise:
/*
* Author: Tony Kelly
* Email: xxxxxxxxxxxxxxxxx
*
* The PreConSensor code is meant to be used with the Arduino Nano microcontroller, as well as, the HS-2000V Precon sensor.
* This sensor is able to measure both relative humidity from 0 to 100% and the Temperature from -30 to 100 Celsius. It
* arrives from the manufacturer already calibrated. This code attempts to take input into analog pins then record and
* graph that information over time.
*
* Special Note 1: The analogRead function takes a parameter that specifies the pin number to be read. For example,
* analogRead(0) reads out the signal on A0 pin of Nano board. Since it takes a 5V input, it will spread the 0 to
* 5 volt range over a read out value of 0 to 1023. This means that the number returned is a unit of .0049 volts.
* If the analogRead returns 200 (for example), then it must have read 200*.0049 = 0.98 Volts on the analog pin.
* This might need to be modified by whoever uses this code. For example, your own powersupply might actually give
* 4.95 volts which would actually give 4.95/1024 = .00483 volts.
*/
int MODTemp = 0;
int MODHumid = 1;
int FPGATemp = 2;
int FPGAHumid = 3;
int Holder = 0;
int ledPin = 13;
float previous[4] = {0,0,0,0};
float present[4] = {0,0,0,0};
int readswitch = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(MODTemp, INPUT);
pinMode(MODHumid, INPUT);
pinMode(FPGATemp, INPUT);
pinMode(FPGAHumid, INPUT);
Serial.begin(9600);
Holder = analogRead(MODTemp);
present[0] = 0.12695313*Holder-30;
Holder = analogRead(MODHumid);
present[1] = 0.09765625*Holder;
Holder = analogRead(FPGATemp);
present[2] = 0.12695313*Holder-30;
Holder = analogRead(FPGAHumid);
present[3] = 0.09765625*Holder;
Serial.print(present[0]);
Serial.print(" ");
Serial.print(present[1]);
Serial.print(" ");
Serial.print(present[2]);
Serial.print(" ");
Serial.print(present[3]);
Serial.println(" *");
}
void loop()
{
readswitch = 0;
analogReference(EXTERNAL);
Holder = analogRead(MODTemp);
Holder = analogRead(MODTemp);
present[0] = 0.12695313*Holder-30;
Holder = analogRead(MODHumid);
present[1] = 0.09765625*Holder;
Holder = analogRead(FPGATemp);
present[2] = 0.12695313*Holder-30;
Holder = analogRead(FPGAHumid);
present[3] = 0.09765625*Holder;
if (present[0]-previous[0] > 0.30 || previous[0]-present[0] > 0.30) {
Serial.print(present[0]);
Serial.print(" ");
Serial.print(present[1]);
Serial.print(" ");
Serial.print(present[2]);
Serial.print(" ");
Serial.print(present[3]);
Serial.println(" *");
readswitch=1;
for (int i=0; i<4 ; ++i){
previous[i] = present[i];
}
}
if(readswitch != 1) {
if (present[1]-previous[1] > 0.30 || previous[1]-present[1] > 0.30) {
Serial.print(present[0]);
Serial.print(" ");
Serial.print(present[1]);
Serial.print(" ");
Serial.print(present[2]);
Serial.print(" ");
Serial.print(present[3]);
Serial.println(" *");
for (int i=0; i<4 ; ++i){
previous[i] = present[i];
}
}
}
delay(100);
}