Page 1 of 2

Sensor DS18B20

Posted: Fri Mar 21, 2025 7:35 pm
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?

Re: Sensor DS18B20

Posted: Sat Mar 22, 2025 7:40 am
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 3030 times
properties.jpg
properties.jpg (38.79 KiB) Viewed 3030 times

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

KR

Martin

Re: Sensor DS18B20

Posted: Sat Mar 22, 2025 7:43 am
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

Re: Sensor DS18B20

Posted: Sat Mar 22, 2025 8:14 am
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

Re: Sensor DS18B20

Posted: Sat Mar 22, 2025 11:01 am
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.

Re: Sensor DS18B20

Posted: Sat Mar 22, 2025 11:02 am
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.

Re: Sensor DS18B20

Posted: Sat Mar 22, 2025 11:47 am
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

Re: Sensor DS18B20

Posted: Sat Mar 22, 2025 12:54 pm
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.

Re: Sensor DS18B20

Posted: Sat Mar 22, 2025 1:57 pm
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

Re: Sensor DS18B20

Posted: Sat Mar 22, 2025 4:49 pm
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.