plx-daq

Hello,

We're busy to modify the plx-daq (Parallax) macro for optimal use by our pupil.

Two questions about it:

  • We want a button to take only one sample. The Connect-button takes a lot of samples, depending of (include) delaytime. I can't trace the code to make a new button which take only one sample. Connect - take sample - Disconnect. Any recommandations?
  • In the plx-daq Help-file is an example to update the delay-time directly from the Excel-form. But I can't understand the Basic Stamp code to do this...

Must there anything be changed in the Arduino sketch, or only in the VBA-code?

I hope some help is coming...

Gr.
Johan

Hi Johan,

Define a state machine that switches between two states DISCONNECTED and CONNECTED depending on the signal from the button. Check the code below and you will see that it will only read once.

(partial code)

#define DISCONNECTED  0
#define CONNECTED  1

int state = DISCONNECTED;
bool makeMeasurement = false;

void setup()
{
  ...
}

void loop()
{

  // HANDLE STATEMACHINE
  int B = analogRead(buttonPin);  // assume LOW if pressed 
  if (state == DISCONNECTED && B == LOW)
  {
    state = CONNECTED;
    makeMeasurement = true;
  } 
  else 
  if (state == CONNECTED && B == HIGH)
  {
    state = DISCONNECTED;
  }

  // HANDLE MEASUREMENT
  if (makeMeasurement)
  {
    makeMeasurement = false; 
     int z = analogRead(A0);
     Serial.println(z);
  }
}

as said not tested but you should get it,

succes

Hi Rob,

Thanks, but plx-daq is working with own commands in the C-sketch. Such as: ' DATA', 'LABEL', 'TIME', etc.

Here is my code for arduino:

int tijdstap; //this is the delaytime

void setup() {
  Serial.begin(9600);
  Serial.println("CLEARDATA");
}

void loop() {
  
//DIT GETAL WIJZIG JE ALS JE DE MEETFREQUENTIE WILT VERANDEREN

  tijdstap = 500;
  
  
  int sensorValue = analogRead(A0);
  Serial.print("DATA, ,");
  Serial.print (tijdstap);
  Serial.print (",");
  Serial.println (sensorValue);
    delay(tijdstap);   

}

So the serial code DATA gives in the VBA macro a special command to get a endless list of data.
I rather think things must be changed in VBA, but i don't have enough know-how...

Gr.
Johan

The problem is solved.

I have simply to change a little bit of code in the arduino-sketch so that the analogValues only one time be sentout serial.
Thats all...

Thanks for thinking with me.

Gr.
Johan