Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / Re: get the status of plx daq control on: March 30, 2012, 10:47:35 am
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 ?
2  Using Arduino / Interfacing w/ Software on the Computer / Re: get the status of plx daq control on: March 29, 2012, 11:56:53 am
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.
3  Using Arduino / Interfacing w/ Software on the Computer / Re: get the status of plx daq control on: March 29, 2012, 10:35:49 am
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
    }

4  Using Arduino / Interfacing w/ Software on the Computer / Re: get the status of plx daq control on: March 29, 2012, 09:46:20 am
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 ?
5  Using Arduino / Interfacing w/ Software on the Computer / get the status of plx daq control on: March 29, 2012, 08:47:54 am
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);     //

}
Pages: [1]