Arduino Forum

Using Arduino => Interfacing w/ Software on the Computer => Topic started by: Xendelaar on Apr 30, 2018, 10:48 pm

Title: Blink without delay reading cell from Excel with PLX-DAQ
Post by: Xendelaar on Apr 30, 2018, 10:48 pm
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
Title: Re: Blink without delay reading cell from Excel with PLX-DAQ
Post by: PaulS on May 01, 2018, 12:44 am
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?
Title: Re: Blink without delay reading cell from Excel with PLX-DAQ
Post by: Xendelaar on May 01, 2018, 06:12 am
 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.

Title: Re: Blink without delay reading cell from Excel with PLX-DAQ
Post by: Robin2 on May 01, 2018, 09:13 am
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 (http://forum.arduino.cc/index.php?topic=223286.0) 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 (http://forum.arduino.cc/index.php?topic=503368.0) if you need more explanation.

...R
Title: Re: Blink without delay reading cell from Excel with PLX-DAQ
Post by: Xendelaar on May 01, 2018, 09:53 am
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!
Title: Re: Blink without delay reading cell from Excel with PLX-DAQ
Post by: Robin2 on May 01, 2018, 11:46 am
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
Title: Re: Blink without delay reading cell from Excel with PLX-DAQ
Post by: PaulS on May 01, 2018, 01:41 pm
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.
Title: Re: Blink without delay reading cell from Excel with PLX-DAQ
Post by: Robin2 on May 01, 2018, 03:13 pm
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