I am attempting to make my Arduino Uno or any other model read multiple SPC outputs at once and then transfer that data to excel using PLX-DAQ. I have figured out how to read and transfer the data from a single gauge, but I cannot figure out how to tweek the code in order to transfer the data from 4 different gauges. I am not even sure if it is actually possible. The code I am using is posted below.
int req = 5; //mic REQ line goes to pin 5 through q1 (arduino high pulls request line low)
int dat = 2; //mic Data line goes to pin 2
int clk = 3; //mic Clock line goes to pin 3
int i = 0; int j = 0; int k = 0; int q = 0;
byte mydata[14];
float num;
void setup() {
Serial.begin(9600);
Serial.println("CLEARDATA");
Serial.println("LABEL,Time,Timer,Data");
Serial.println("RESETTIMER");
pinMode(req, OUTPUT);
pinMode(clk, INPUT_PULLUP);
pinMode(dat, INPUT_PULLUP);
digitalWrite(req, LOW); // set request at LOW
}
void loop() { // get data from mic
digitalWrite(req, HIGH); // generate set request
for (i = 0; i < 13; i++ ) {
k = 0;
for (j = 0; j < 4; j++) {
while ( digitalRead(clk) == LOW) { // hold until clock is high
}
while ( digitalRead(clk) == HIGH) { // hold until clock is low
}
bitWrite(k, j, (digitalRead(dat) & 0x1)); // read data bits, and reverse order )
}
// extract data
mydata = k;
-
}*
-
// sign = mydata[4];*
-
// decimal = mydata[11];*
-
// units = mydata[12];*
-
// assemble measurement from bytes*
-
char buf[7];*
-
for (q = 0; q < 6; q++) {*
-
buf[q] = mydata[q + 5] + '0';*
-
buf[6] = 0;*
-
num = atol(buf); //assembled measurement, no decimal place added*
-
Serial.print("DATA,TIME,TIMER,");*
-
Serial.print(num / 1000, 3); //add decimal*
-
Serial.println('\n');*
-
delay(500);*
-
}*
-
//delay(500);*
}