DS18B20 7 segment temperature Display

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

DS18B20 7 segment temperature Display

Post by George_B »

Hello all,

i was trying to make a digital clock using six 7 segments displays.

I would like to display the temperature with no decimal places.

The program runs on the hardware but very often i see random numbers instead of the real temperature.

Could someone please check this and let me know because i think the problem is not on the hardware.

Is there any example of how can i display the temperature from DS18B20 to a 7 seg display?

I tried both 4 and 6 version of flowcode to test this but no luck, the same result on both versions.
DS18B20_MM_Clock_7Seg.fcfx
(43 KiB) Downloaded 438 times
Thank you in advance
George

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: DS18B20 7 segment temperature Display

Post by George_B »

I will try to upload a video showing the problem that is described above.

https://www.youtube.com/watch?v=boocN0SAWqo

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: DS18B20 7 segment temperature Display

Post by Benj »

Hello George,

Thanks for posting the video it helps for us to see exactly what's going wrong.

As your reading a 1-wire sensor which is very timing critical I would also advise you to disable the timer interrupt at the start of the DS18B20_Temperature macro and re-enable the interrupt at the end of the macro. This ensures that the interrupt only fires when you are inside the 100ms delay and that your temperature readings will not be corrupted by the interrupt kicking in halfway through a 1-wire read.

You could also simplify some of this code to get rid of the string processing and ensure your calculations are as fast as possible.

Code: Select all

Temp1_Int = (Get_Temp / 10) MOD 10
Temp2_Int = Get_Temp MOD 10
Temp1 = Temp1_Int
Temp2 = Temp2_Int
Temp1_Int and Temp2_Int can be made into byte variables for even more speed.

Hopefully this will help things.

George_B
Posts: 128
Joined: Wed Jul 04, 2012 11:21 pm
Location: Greece
Has thanked: 51 times
Been thanked: 19 times
Contact:

Re: DS18B20 7 segment temperature Display

Post by George_B »

Hello Benj,

thank you for your reply and your help.

In the next video is shown the improvement of the previous code according your advice.

The temperature is now displayed fine indeed.

The only issue that i can not get over is that when i disable the interrupt in order to read the DS18B20 and re-enable it again, there is a gap time with the display off for a couple of milliseconds as it can be seen in the video.
https://www.youtube.com/watch?v=0uRfpr-k_Q0

By the way, i liked very much the way you used MOD. Could it be possible to show me how i could use it in case that the temperature goes below zero and therefore it will produce a negative number?

Thank you
George

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: DS18B20 7 segment temperature Display

Post by Benj »

Hi George,

Yes that's looking much better now.

The Mod stuff should still work correctly if the number is negative. You may need a decision icon to see if the number is negative to allow you to display the minus symbol.

Code: Select all

Get_Temp < 0
Should go down the yes branch if the number is less than 0.

Regarding the delay when reading the 1-wire sensor. I'll ponder on it and see if I can come up with a better solution.

Post Reply