Sensor DS18B20

Any bugs you encounter with Flowcode should be discussed here.
Carmelo
Posts: 123
http://meble-kuchenne.info.pl
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 50 times
Been thanked: 4 times

Sensor DS18B20

Post by Carmelo »

I want to use the DS18B20 sensor for a thermometer. I have reviewed the example from the wiki and created an environment to test.
I have created a Float type variable to see the temperature but in the simulation the variable is always at 0.
Can you tell me what I'm doing wrong?
Attachments
Test_DS18B20.fcfx
(10.86 KiB) Downloaded 21 times

Arix
Posts: 8
Joined: Wed Dec 02, 2020 9:53 pm
Has thanked: 3 times
Been thanked: 7 times

Re: Sensor DS18B20

Post by Arix »

Hi Carmelo,

First you need to Link the DS18B20 component to the One Wire component as below:
Link.jpg
Link.jpg (38.56 KiB) Viewed 2643 times
properties.jpg
properties.jpg (38.79 KiB) Viewed 2643 times

Next add your variable 'Temperatura' to the Return Value :(Float) under DS18B20 Component properties:
Value.jpg
Value.jpg (31.04 KiB) Viewed 2643 times
It is also good practice to Initialise the One Wire component.

KR

Martin

Arix
Posts: 8
Joined: Wed Dec 02, 2020 9:53 pm
Has thanked: 3 times
Been thanked: 7 times

Re: Sensor DS18B20

Post by Arix »

Hi Carmelo,

Attached is a copy of your flow chart amended with the changes listed in my previous post.

Good luck with your project.

Martin
Attachments
Test_DS18B20_fixed.fcfx
(11.12 KiB) Downloaded 23 times

chipfryer27
Valued Contributor
Posts: 1575
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 357 times
Been thanked: 561 times

Re: Sensor DS18B20

Post by chipfryer27 »

Hi

Just to add that as you are using an internal oscillator so you will need to add in a C-code block as your first iscon for this to run in hardware. Add the IntOsc component and it will help you.

Regards

Carmelo
Posts: 123
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 50 times
Been thanked: 4 times

Re: Sensor DS18B20

Post by Carmelo »

Arix wrote:
Sat Mar 22, 2025 7:40 am
Hi Carmelo,

First you need to Link the DS18B20 component to the One Wire component as below:

Link.jpg

properties.jpg


Next add your variable 'Temperatura' to the Return Value :(Float) under DS18B20 Component properties:

Value.jpg

It is also good practice to Initialise the One Wire component.

KR

Martin
Fhanks for the response.
I knew about the float variable but I forgot and I didn't know about linking the bus to the sensor, hence the question.

C.

Carmelo
Posts: 123
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 50 times
Been thanked: 4 times

Re: Sensor DS18B20

Post by Carmelo »

chipfryer27 wrote:
Sat Mar 22, 2025 8:14 am
Hi

Just to add that as you are using an internal oscillator so you will need to add in a C-code block as your first iscon for this to run in hardware. Add the IntOsc component and it will help you.

Regards
thanks for the response.
I also know about the internal oscillator block, but since it is a test to see how it works I didn't take it into account.
C.

chipfryer27
Valued Contributor
Posts: 1575
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 357 times
Been thanked: 561 times

Re: Sensor DS18B20

Post by chipfryer27 »

Hi

"since it is a test to see how it works I didn't take it into account"

I frequently do the same as I am more interested in something specific rather than "the project", and I find FC simulation a great feature. I sometimes move on to Ghost when testing in hardware which again can be very helpful.

Regards

Carmelo
Posts: 123
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 50 times
Been thanked: 4 times

Re: Sensor DS18B20

Post by Carmelo »

I already finished the program, except for one issue that I will try to resolve later.
But what has been done so far should work because I have been physically testing it in parts and the result is good.
When adding the temperature reading part, when compiling I get problems that appear in the attached file that cannot be interpreted.
Can you tell me what the problem is so I can solve it?

C.
Attachments
Termostato_10_90.msg.txt
(6.02 KiB) Downloaded 18 times
Termostato_10_90.fcfx
(142.3 KiB) Downloaded 24 times

chipfryer27
Valued Contributor
Posts: 1575
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 357 times
Been thanked: 561 times

Re: Sensor DS18B20

Post by chipfryer27 »

Hi

I think you have ran out of memory.

I see you are using multiple 7-Segment displays and you have multiple macros that are used to display each individual number. That's ten sections of code that could perhaps be reduced by using one of the 7-Segment Display components.

Regards

Carmelo
Posts: 123
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 50 times
Been thanked: 4 times

Re: Sensor DS18B20

Post by Carmelo »

chipfryer27 wrote:
Sat Mar 22, 2025 1:57 pm
Hi

I think you have ran out of memory.

I see you are using multiple 7-Segment displays and you have multiple macros that are used to display each individual number. That's ten sections of code that could perhaps be reduced by using one of the 7-Segment Display components.

Regards
Thanks for clarifying the error Martin,
I will change the pic model to 16F886.
Regarding the use of the 10 macros to represent the numbers, I have not used the component macro because after many tests with its use (I already made queries in another topic "Problems with a 7-segment display"), I have not been able to make it work for me.

What I need to add to the program is an improvement and no matter how many times I go around I can't find the solution:
I would like that within the "adjust tHi and tLo" macro, the digit on which the adjustment is being made is flashing and the other 2 digits remain fixed.
Any suggestions on how to implement that functionality?

Thanks in advance for your time.

Post Reply