Go Down

Topic: Blink without delay reading cell from Excel with PLX-DAQ (Read 911 times) previous topic - next topic

Xendelaar

Hi there,

I've found many great examples on how to create a blink without delay in an Arduino loop, but I couldn't find anything about reading the content of a particular excel cell without any wait function.

Is this even possible? Or do you have to wait until you receive the data before continuing the loop?

In my case I want to send data from a sensor, and send the sum of the recorded data to excel using a blink without delay function.
This works perfectly.

At the same time, I want to read a specific cell in Excel and check whether it is 1 or 0. I need to check this say once every second. it's more out less a digital button.  In order to read this value, it seems it takes a significant amount of time and the arduino has to wait until the data has been received. Blink without delay doesn't seem to be an option here. Are there alternatives or am I not seeing things clearly...

Level of Arduino knowlegde = scruffy n00b

PaulS

Quote
Or do you have to wait until you receive the data before continuing the loop?
Can you read my reply without waiting for me to type it?
The art of getting good answers lies in asking good questions.

Xendelaar

 nope. but i could check every loop if you did.
I guess it doesn't work this way.
thanks for giving me an answer though.  :)

i guess my only option is to make a physical switch / button then.. I can use a blink without delay for that.  that way i won't lose precious sensor data while I'm waiting.


Robin2

i guess my only option is to make a physical switch / button then.. I can use a blink without delay for that.  that way i won't lose precious sensor data while I'm waiting.
The purpose of the BWOD concept is that you can do other things while waiting.

Suppose you need to make a request to Excel but the response will not be available for (say) 500 millisecs. Then save the value of millis() when you make the request and come back to check for the answer when the 500 millisecs has expired - something like this pseudo code
Code: [Select]
if (millis() - timeWhenRequestMade >= 500) {
   read response
}


The demo Several Things at a Time is an extended example of BWoD and illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

Have a look at Using millis() for timing. A beginners guide if you need more explanation.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Xendelaar

So you're saying I CAN use BWOD while I'm waiting for a reply from the serial port? Interesting! I'll have to experiment with that.

Thanks for the elaborate explanation. I've seen many threads explaining the principle of BWOD, but only on stuff that's happening "inside" the arduino. My code also uses BWOD while it's gathering  data before it is sent to the PC. Waiting for a reply from a com port felt completely different to me… but I guess it isn't. :)

I will perform some experiments tonight! Thanks you!

Robin2

Using millis() is much the same as using your kitchen wall clock to time the cooking of a chicken. Using delay() is the equivalent of sitting watching the oven for 90 minutes - which you would not dream of doing. Instead you note the time when the chicken goes in the oven and periodically check the clock to see if the 90 minutes has elapsed.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

PaulS

Quote
Instead you note the time when the chicken goes in the oven and periodically check the clock to see if the 90 minutes has elapsed.
Nice analogy, but I hope that you don't really cook a chicken that way. The 90 minutes is a guideline to define when to start paying more attention to the internal temperature of the meat. IMHO, anyway.
The art of getting good answers lies in asking good questions.

Robin2

Nice analogy, but I hope that you don't really cook a chicken that way. The 90 minutes is a guideline to define when to start paying more attention to the internal temperature of the meat. IMHO, anyway.
I just follow the instructions on the roast-in-the-bag packet  :)

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up