Pages: [1]   Go Down
Author Topic: get the status of plx daq control  (Read 1753 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've got an arduino uno and i am trying to read the status of one of the four checkboxes on the PLX-DAQ interface. The PLX Help says :

DEBUG "USER1,GET",CR                         ' Request checkbox value
DEBUGIN DEC check1                            ' Accept value into variable

so I thought it should look like Serial.println("GET,USER1");
and maybe  value = Serial.read(); to see if user1 is checked or not. But it's not working, any ideas ?

code:
void setup (){
  Serial.println("GET,USER1"); 
  value = Serial.read();
}

void loop (){
 if (value == '1')           
       {Load = (analogRead(0)*0.45359;}
       
    else
     {  Load = analogRead(0); }   
   
   
    Serial.println(Load*0.005);     //

}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The PLX Help says :

DEBUG "USER1,GET",CR                         ' Request checkbox value
OK.

Quote
so I thought it should look like Serial.println("GET,USER1");
The Serial.println() function makes sense, as it sends the data and appends the carriage return. Switching the order of the tokens does not. Why did you?

Why do you expect a response in the few nanoseconds between sending the (apparently invalid) request and reading the response?

Why do you try to read a response without checking that one has arrived (or waiting for one to arrive)?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I switched the GET and USER1 because the Arduino should probably begin with the control directive I want the macros in PLX-DAQ to run (DATA, LABEL, CLEARDATA, RESETTIMER, SET, GET, etc.). Changed it also back, made no difference. There seems to be no serial available.
Also I checked the response for several seconds.
And I tried to check the arrival of the response with serial.available(). Nothing.
So I guess the statement Serial.println("USER1,GET");/Serial.println("GET,USER1");  isn't working or something with the serial connection at all.
But how to get the status then ?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to provide a lot more details. What is running on the PC? Is there something running that is connected to the serial port? Are you able to use other commands to talk to that something?
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is no Serial.begin() in your sketch.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I downloaded the PLX-DAQ SW for Excel. I can make graphs, so sending data from an analog input to Excel is fine. I can send this data via the serial port to Excel but not get anything back. Basically, I'd like to read if one of the boxes is checked so I can evaluate this in my program to switch between weight units. But the whole if statement can not be done.
Code:

    int sample = 100;
    int row=0; //int USER1=0;
    float Load = 0;
    int metric = 0; //  0/1 eng/met units
   
 // choose "PLX-DAQ Simple Test";
    void setup() {     
     
    // initialize the serial communication:
    Serial.begin(9600);           // baud rate/speed
    Serial.println("CLEARDATA");   // clear data in excel on reset
    Serial.println("LABEL,Time,,,LOAD/Newton"); // columnnames, Time, not TIME -> is instruction
    Serial.println("MSG,Set Metric for Newton - otherwise in Pound");
    Serial.println("USER1,LABEL,Metric");  // user1 new label
   
   //Serial.println("USER1,GET");    in all variants didn't work
   //USER1=Serial.read(); //
 
    }
   
    void loop() {
   
    // allows serial port to send data to Excel, first field always TIME, then fields of interest (val)   
    Serial.print("DATA,TIME,,,");
   
    Serial.println("USER1,GET");
    if (Serial.available() > 0){
    //Serial.println("USER1,GET");
    metric=Serial.read();
    if (metric == '1')
    {Serial.println("y");}
    if (metric == '0')
    {Serial.println("n");}
    else {Serial.println("no serial");}
    }
   
    Serial.println(Load*0.005);     // read the analog input on pin 0, field of interest, and
    row++;  // next line
   
    // wait a bit for the analog-to-digital converter
    // to stabilize after the last reading:
    delay(sample);  // in milliseconds
    }

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
Serial.println("USER1,GET");
    if (Serial.available() > 0){
    //Serial.println("USER1,GET");
    metric=Serial.read();
    if (metric == '1')
    {Serial.println("y");}
    if (metric == '0')
    {Serial.println("n");}
    else {Serial.println("no serial");}
    }
I want to know the value of the USER1 field, and I demand to know it NOW!!!!

I'm pretty sure that it takes more than a few nanoseconds for the request to get to the PC, get evaluated by the Excel plugin, and to get the answer back to the Arduino.

I'm also certain that you don't want to send the request on every pass through loop.

Finally, I'm pretty sure that Excel can do the conversion faster than the Arduino can. Just send data in one system of units, and let Excel, through the use of formulas, display the data however the viewer wants to see it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

USER1 is one of the boxes in the control, 0 for unchecked, 1 for checked (or what do u mean?). If I try the if-statement in the setup() there is also no status coming back.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If I try the if-statement in the setup() there is also no status coming back.
Because you didn't wait for a reply. You expected the reply to be available a few nanoseconds later when the read method was called.

Try this:
Code:
void setup()
{
    Serial.begin(9600);           // baud rate/speed
    Serial.println("CLEARDATA");   // clear data in excel on reset
    Serial.println("LABEL,Time,,,LOAD/Newton"); // columnnames, Time, not TIME -> is instruction
    Serial.println("MSG,Set Metric for Newton - otherwise in Pound");
    Serial.println("USER1,LABEL,Metric");  // user1 new label
   
    Serial.println("USER1,GET");
    unsigned long sentTime = millis();
    while(millis() - sentTime < 60000UL) // Wait up to 60 seconds for a reply
    {
       if(Serial.available() > 0)
       {
          USER1 = Serial.read();
          digitalWrite(13, HIGH);
          break;
       }
    }
}

If, at the end of setup(), the LED is on, then you got some kind of response. Without an LCD or some means to show what that response was, I don't know how you can debug the issue.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, tried the prior example, led is working fine so serial communication and if-statement seems not to be the matter. Back to the status request which is not working. Anyone an idea how to talk to the directive and write DEBUG "USER1,GET",CR  in Arduino language ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi..
you guys are discussing about getting the state of one of the checkbox at PLX Daq interface..
my question is can we get cell data from Excel if yes please post some example here..

thanks
Logged

Pages: [1]   Go Up
Jump to: