DS18B20 7 segment temperature Display

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

Moderator: Benj

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

DS18B20 7 segment temperature Display

Postby George_B » Mon Feb 22, 2016 7:43 pm

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 214 times


Thank you in advance
George

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

Re: DS18B20 7 segment temperature Display

Postby George_B » Wed Feb 24, 2016 8:45 pm

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

https://www.youtube.com/watch?v=boocN0SAWqo
These users thanked the author George_B for the post:
Benj (Thu Feb 25, 2016 5:16 pm)
Rating: 5.26%
 

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

Re: DS18B20 7 segment temperature Display

Postby Benj » Thu Feb 25, 2016 5:29 pm

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.
These users thanked the author Benj for the post:
George_B (Fri Feb 26, 2016 11:56 pm)
Rating: 5.26%
 

George_B
Posts: 88
Joined: Wed Jul 04, 2012 11:21 pm
Has thanked: 37 times
Been thanked: 12 times
Contact:

Re: DS18B20 7 segment temperature Display

Postby George_B » Fri Feb 26, 2016 11:55 pm

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: 14361
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4443 times
Been thanked: 4143 times
Contact:

Re: DS18B20 7 segment temperature Display

Postby Benj » Mon Feb 29, 2016 1:45 pm

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.
These users thanked the author Benj for the post:
George_B (Wed Mar 02, 2016 9:33 pm)
Rating: 5.26%