Multitasking ?
- cicciocb
- Site Admin
- Posts: 2095
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 450 times
- Been thanked: 1385 times
- Contact:
- cicciocb
- Site Admin
- Posts: 2095
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 450 times
- Been thanked: 1385 times
- Contact:
Re: Multitasking ?
I'm doing some testing with the DS18B20
The goal is to improve the command without breaking the existing syntax.
Initially I planned to introduce a new command but I think I found a good compromise.
This should be the final syntax
The function continue to work as before (as documented in the help file)
Additionally, the parameter "resolution' can be provided (from 9 to 12 bits).
The resolution determine the minimal increment of temperature and also the conversion time (see table below)
if the resolution is ignored, it default to 12 as before.
The novelty is now the async mode :
Giving 0 as ID, starts the conversion on all the DS18B20 sensors connected without waiting for the answer
For example
The result will be the string "START"
Then, it will be possible to read the devices as below
In this case, if the value is not yet available (during the conversion time) the result will be "WAIT' that will be replaced by the good value at the end of the conversion.
To restart another conversion, the same command must be executed
What do think ?
Comments ?
The goal is to improve the command without breaking the existing syntax.
Initially I planned to introduce a new command but I think I found a good compromise.
This should be the final syntax
Code: [Local Link Removed for Guests]
ret$ = TEMPR$(pin, [id], [resolution])
Additionally, the parameter "resolution' can be provided (from 9 to 12 bits).
The resolution determine the minimal increment of temperature and also the conversion time (see table below)
if the resolution is ignored, it default to 12 as before.
The novelty is now the async mode :
Giving 0 as ID, starts the conversion on all the DS18B20 sensors connected without waiting for the answer
For example
Code: [Local Link Removed for Guests]
ret$ = TEMPR$(2, 0) ' starts an async read on the pin 2
Then, it will be possible to read the devices as below
Code: [Local Link Removed for Guests]
ret1$ = TEMPR$(2, 1) 'read the 1st sensor on the pin 2
ret2$ = TEMPR$(2, 2) 'read the 2nd sensor on the pin 2
To restart another conversion, the same command must be executed
Code: [Local Link Removed for Guests]
ret$ = TEMPR$(2, 0) ' starts an async read on the pin 2
Comments ?
You do not have the required permissions to view the files attached to this post.
-
- Posts: 36
- Joined: Sat Feb 20, 2021 9:36 am
- Location: Sindelfingen, Germany
- Has thanked: 143 times
- Been thanked: 10 times
Re: Multitasking ?
Really good proposal for time critical applications and easy to understand !
I think for many projects (also mine) the paramter "resolution" will be most beneficial.
Hopefully it will be available soon
Rainer
I think for many projects (also mine) the paramter "resolution" will be most beneficial.
Hopefully it will be available soon
Rainer
Re: Multitasking ?
Hi,
if i understand correctly in async mode and with the following code
no waiting time for conversion, no lost time.
(all sensors convert simultaneously, 750ms required, ESP is free)
It's very cool and suitable if many sensors are employed and hight resolution is needed
Se ho capito bene, in modalità asincrona e col seguente codice non c'e da attendere il tempo di conversione, quindi non c'e tempo perso.
(tutti i sensori convertono contemporaneamente nei 750ms e l'ESP è libero di effettuare altre operazioni)
Questo è il massimo se si impiegano molti sensori ed è richiesta la risoluzione a 12 bit.
if i understand correctly in async mode and with the following code
no waiting time for conversion, no lost time.
(all sensors convert simultaneously, 750ms required, ESP is free)
It's very cool and suitable if many sensors are employed and hight resolution is needed
Se ho capito bene, in modalità asincrona e col seguente codice non c'e da attendere il tempo di conversione, quindi non c'e tempo perso.
(tutti i sensori convertono contemporaneamente nei 750ms e l'ESP è libero di effettuare altre operazioni)
Questo è il massimo se si impiegano molti sensori ed è richiesta la risoluzione a 12 bit.
Code: [Local Link Removed for Guests]
code:
ret$ = TEMPR$(2, 0) ' starts of async conversion on the pin 2 for first read
gosub lbl_draw_page
onHtmlReload draw_page
'other code lines
timer0 1000, lbl_read_temp
wait
lbl_read_temp:
ret1$ = TEMPR$(2, 1) 'read the 1st sensor on the pin 2
ret2$ = TEMPR$(2, 2) 'read the 2nd sensor on the pin 2
ret1$ = TEMPR$(2, 3) 'read the 3st sensor on the pin 2
ret2$ = TEMPR$(2, 4) 'read the 4nd sensor on the pin 2
ret$ = TEMPR$(2, 0) ' starts an async conversion on the pin 2 for next read
return
- cicciocb
- Site Admin
- Posts: 2095
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 450 times
- Been thanked: 1385 times
- Contact:
Re: Multitasking ?
Yes, what you say is correct, I just need to test with several devices at the same time[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Mon Jan 23, 2023 9:25 pm Hi,
if i understand correctly in async mode and with the following code
no waiting time for conversion, no lost time.
(all sensors convert simultaneously, 750ms required, ESP is free)
It's very cool and suitable if many sensors are employed and hight resolution is needed
Se ho capito bene, in modalità asincrona e col seguente codice non c'e da attendere il tempo di conversione, quindi non c'e tempo perso.
(tutti i sensori convertono contemporaneamente nei 750ms e l'ESP è libero di effettuare altre operazioni)
Questo è il massimo se si impiegano molti sensori ed è richiesta la risoluzione a 12 bit.
Code: [Local Link Removed for Guests]
code: ret$ = TEMPR$(2, 0) ' starts of async conversion on the pin 2 for first read gosub lbl_draw_page onHtmlReload draw_page 'other code lines timer0 1000, lbl_read_temp wait lbl_read_temp: ret1$ = TEMPR$(2, 1) 'read the 1st sensor on the pin 2 ret2$ = TEMPR$(2, 2) 'read the 2nd sensor on the pin 2 ret1$ = TEMPR$(2, 3) 'read the 3st sensor on the pin 2 ret2$ = TEMPR$(2, 4) 'read the 4nd sensor on the pin 2 ret$ = TEMPR$(2, 0) ' starts an async conversion on the pin 2 for next read return
-
- Posts: 351
- Joined: Tue Jun 21, 2022 2:17 pm
- Location: South coast UK
- Has thanked: 187 times
- Been thanked: 113 times
Re: Multitasking ?
Looks like a good compromise between full one-wire functionality and ease of use.
Just to be clear, does TEMPR$(2,0) start the conversion on ALL DS18B20's connected to GPIO.2 and is it normal(3-wire) powered mode or parasitic(2-wire) mode?
Just to be clear, does TEMPR$(2,0) start the conversion on ALL DS18B20's connected to GPIO.2 and is it normal(3-wire) powered mode or parasitic(2-wire) mode?
- cicciocb
- Site Admin
- Posts: 2095
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 450 times
- Been thanked: 1385 times
- Contact:
Re: Multitasking ?
I need to continue the testing (I tested with only one DS12B20 so far) but the conversion should start on all the devices at the same time.[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue Jan 24, 2023 9:30 am Looks like a good compromise between full one-wire functionality and ease of use.
Just to be clear, does TEMPR$(2,0) start the conversion on ALL DS18B20's connected to GPIO.2 and is it normal(3-wire) powered mode or parasitic(2-wire) mode?
So far I tested only in normal mode but it should work also in parasitic mode
- cicciocb
- Site Admin
- Posts: 2095
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 450 times
- Been thanked: 1385 times
- Contact:
Re: Multitasking ?
I can confirm that it works as expected (I tested on an ESP32-S3).
Will be in the next release
Will be in the next release
-
- Posts: 351
- Joined: Tue Jun 21, 2022 2:17 pm
- Location: South coast UK
- Has thanked: 187 times
- Been thanked: 113 times
- cicciocb
- Site Admin
- Posts: 2095
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 450 times
- Been thanked: 1385 times
- Contact:
Re: Multitasking ?
I'll try to include the changes also in the ESP8266[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Fri Jan 27, 2023 5:30 pm Any chance we might see it for 8266 as well?