Thanks William! I did also think that the need to use a small microcontroller for DS18B20 read and transmit data through USART. But I have one controller available to carry bytes for other information indicating the same microcontroller and 7segm. display via USART. Or one microcontroller could receive data from another microcontroller and read DS18B20, and transmit data to third microcontroller via USART? Controller will be able both to read and to transmit via USART?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks William! I did also think that the need to use a small
microcontroller for DS18B20 read and transmit data through USART. But I
have one controller available to carry bytes for other information
indicating the same microcontroller and 7segm. display via USART. Or one
microcontroller could receive data from another microcontroller and read
DS18B20, and transmit data to third microcontroller via USART? Controller
will be able both to read and to transmit via USART?
I vote for timer interrupt to handle the ds18b20 and display updates, and have the 16f876a handle everything, it is more than capable. Have code (mostly) will travel.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
JANIS,
Here is multiplexing the 7 seg display with an interrupt.The interrupt executesoften enough to prevent flicker.
in this case : 4mhz/4/16/256/3
4 mhz is clockosc
4 is clock cycle is 1/4 clock osc
16 is the pre counter 0 divider
256 is ,it is an 8 bit counter
3 was the number of digits
so each digit is lit up for ~ 1/80 of a second
Each interrupt the next digit is displayed.
I don't have an 18S20 to test with so I tested on a protoboard and faked the DS with a "wait time" of 750 ms. It was working there. I am not sure if the interrupt will mess up the DS18S20.h sub readings?
This program is yours adapted with the interrupt parts. I have not tested this program but it should work.
Not running for office, and besides we know that Evan has improved the original library. I have found that tossing out the first reading before main can be a good idea when reading the ds18b20 type devices. So I agree with mmotte that the 250ms delay can be deleted.
As far as the interrupt ds18b20 driven code, say you have a counter counting to 10 for every 100ms timer interrupt, you can use code like this to toggle between starting a conversion, and reading the scratch pad value a second later.
LED_ON = 0
...
...
Main:
...
...
If TenthSec = 10 Then 'tenthsec multiplier or 1 sec intervals
LED_ON = NOT LED_ON 'toggle led flag
IF LED_ON = True Then
Set LED1 ON
'start DS18S20 temp conversion
MasterRST
OWout SkipRom
OWout ConvertT
Else
Set LED1 OFF
'read DS18S20 temp conversion
MasterRST
OWout SkipRom
OWout ReadScratch
Owin
LedTemp = HighLow/2
End If
End If
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks William! I did also think that the need to use a small microcontroller for DS18B20 read and transmit data through USART. But I have one controller available to carry bytes for other information indicating the same microcontroller and 7segm. display via USART. Or one microcontroller could receive data from another microcontroller and read DS18B20, and transmit data to third microcontroller via USART? Controller will be able both to read and to transmit via USART?
How far apart will they be?
If they are all on the same board you could put them on an I2C or SPI BUS.
On 14 June 2017 at 16:49, JANIS kalvitis@users.sf.net wrote:
I vote for SPI. Robust and no extra components.
I vote for timer interrupt to handle the ds18b20 and display updates, and have the 16f876a handle everything, it is more than capable. Have code (mostly) will travel.
I vote with Kent. He wrote the sensor library!!!!
JANIS,
Here is multiplexing the 7 seg display with an interrupt.The interrupt executesoften enough to prevent flicker.
in this case : 4mhz/4/16/256/3
4 mhz is clockosc
4 is clock cycle is 1/4 clock osc
16 is the pre counter 0 divider
256 is ,it is an 8 bit counter
3 was the number of digits
so each digit is lit up for ~ 1/80 of a second
Each interrupt the next digit is displayed.
I don't have an 18S20 to test with so I tested on a protoboard and faked the DS with a "wait time" of 750 ms. It was working there. I am not sure if the interrupt will mess up the DS18S20.h sub readings?
This program is yours adapted with the interrupt parts. I have not tested this program but it should work.
GL
M
Not running for office, and besides we know that Evan has improved the original library. I have found that tossing out the first reading before main can be a good idea when reading the ds18b20 type devices. So I agree with mmotte that the 250ms delay can be deleted.
As far as the interrupt ds18b20 driven code, say you have a counter counting to 10 for every 100ms timer interrupt, you can use code like this to toggle between starting a conversion, and reading the scratch pad value a second later.
Thank you for all. I am back, and I will test MMottes code :)
Hey! MMOTTE! Your code works! Thank you all!
I will continue the project and I will be probably a lot of confusions ...