Pages: [1]   Go Down
Author Topic: plx-daq  (Read 2056 times)
0 Members and 1 Guest are viewing this topic.
Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
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

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
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
Logged

Netherlands
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: