Arduino Forum

Using Arduino => Interfacing w/ Software on the Computer => Topic started by: kniappp on Apr 04, 2019, 11:08 am

Title: Using PLX DAQ to write to different Excel cells from an Arduino Uno
Post by: kniappp on Apr 04, 2019, 11:08 am
I'm trying to write to varying cells in Excel using PLXDAQ from an Arduino Uno but can't find how to do it - or if it's possible.

Serial.print((String)"CELL,SET,",A6,50);

writes the value 50 into cell A6 with no problem but as soon as I try to use a string in place of A6 it bombs out.
Might be that I'm not getting the string syntax correct (I'm a bit of a beginner programming the Uno) or might be that it's not possible using PLX DAQ.
Can anyone help?
Title: Re: Using PLX DAQ to write to different Excel cells from an Arduino Uno
Post by: sumguy on Apr 04, 2019, 04:54 pm
There are several ways to accomplish what you want but going with the example you posted you might try something along these lines

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

int row=2;
int data=1;

void loop() {

Serial.print("CELL,SET,A");
Serial.print(row);  //row variable
Serial.print(",");
Serial.println(data);  //data variable

delay(1000);

  row++;
  data++;
 
}


This allows you to change the row and data variable, you might be able to see that the addition of another Serial.print instruction would allow you to also use a variable for the column.

As it is the four Serial instructions output one continuous string :- "CELL,SET,A value contained in row , value contained in data" . It is important to note that the last Serial instruction is println , all PLX-DAQ commands must be terminated with a newline character. The syntax of all the commands is detailed in the "Beginners Guide" which comes packaged with PLX-DAQ v2.
Title: Re: Using PLX DAQ to write to different Excel cells from an Arduino Uno
Post by: sumguy on Apr 05, 2019, 02:02 am
If you wanted to improve the above example and reduce the Serial instructions to one there are a couple of options.

Using the library function sprintf
Code: [Select]
void setup() {
Serial.begin(9600);
}

int row=2;
int data=1;
char buffer[20];

void loop() {

sprintf(buffer, "CELL,SET,A%i,%i",row,data);
Serial.println(buffer);

delay(1000);

  row++;
  data++;
 
}


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

int row=2;
int data=1;

void loop() {

Serial.println(String("") + "CELL,SET,A" + row + "," + data);
delay(1000);

  row++;
  data++;
 
}


I would probably lean toward sprintf
Title: Re: Using PLX DAQ to write to different Excel cells from an Arduino Uno
Post by: kniappp on Apr 08, 2019, 03:40 pm
Many thanks SmugGuy - this is really useful stuff. I will get to spend some time on it this week and should get it working. The PLX DAQ info is good as far as it goes but the reference document I found is fairly limited so your information is extremely helpful.
Thanks again.