Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - decimal numbers

(you are viewing a thread; or go back to list of threads)

decimal numbers (by Alex)
Hello, is there any way to use decimal numbers for temperature or values for proximity sensor reading, etc , here is a video where he uses decimal numbers by doing some kind of trick, but i don´t understand:

https://www.youtube.com/watch?...gudatw03c010c.1548017347761422
Tue Jan 22 2019, 01:11:05
(no subject) (by José GILLES)
Hi Alex

There's no way to use decimal numbers in ldmicro, but I think sensors generally return int values to be converted by the user.

In your video, these values are converted in an integer part and a decimal part which are both integers, displayed with a dot '.' inbetween.

What is your sensor model and comnunication protocol ?

JG
Tue Jan 22 2019, 11:13:40
(no subject) (by MGP)
Attached a program you can find in Samples.zip on this forum.
Tue Jan 22 2019, 16:06:03, download attachment DecimalpointLCD.ld
(no subject) (by Alex)
Hello, thanks for your replies, i used DecimalpointLCD.ld with 2.4v it works ok:

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

is like an "ilussion" or trick to set a decimal dot, if there wasn´t decimal dot max value would e 1023 intead of 10.23 ,


i want to test lm35, if somehow with some math functions or some ladder tricks can we managed to visualize temperature with lm35 in decimal values?

here Jonathan Westhues explains a solution using lm35, i tested that before, it works, but only integer number can be shown in lcd
Tue Jan 22 2019, 20:44:36
(no subject) (by José GILLES)

Your LM35 can be connected directly to an ADC input (but should be translated with an offset if Temp <= 0 and may be amplified before because V_out = T/100 is low)

It isn't really designed to deal with decimal values, mainly integer temperatures because of its precision (+/- 0.5 °C) !

If you connect directly a 10 bits ADC (0->1023) with 5V reference you can compute temperature (T >= 0 °C only) simply in ldmicro with:

T ~= ((Adc_in + 1) * 25) / 51

Examples:

30°C => V_out= 300 mv= 0,3 V=> Adc_in= 61.38 -> 61
=> T= (62 * 25) / 51 = 30,3 => 30 °C

100°C => V_out= 1000 mv= 1 V=> Adc_in= 204
=> T= (205 * 25) / 51 = 100,4 => 100 °C


If you want to have some decimals (not reliable), do :

T'= ((Adc_in + 1) * 250) / 51 = 303

And then display (T'/10) '.' (T'%10) to get 30.3

But in this latter case beware that if Temp is too high, Adc_in will be higher than 130 and (Adc_in + 1) * 250 will overtake max signed value of 32767 !
So, for high Temps you must rather do (because 250 / 51 ~= 4.9):

T'= ((Adc_in + 1) * 5) - ((Adc_in + 1) / 10) = 304

JG
Wed Jan 23 2019, 03:45:51
(no subject) (by Ziggy)
What Jose said but with a small addition...

While LM35 accuracy may be 0.5C, Your display may show 0.1C resolution.

To correct for 0.5C accuracy You could calibrate the sensor.
Wed Jan 23 2019, 04:26:25
(no subject) (by Alex)
thanks for yout reply, i am testing :


btw in any ldmicro version i think we can´t use "°" symbol i want to display "°C" but instedad in prints "-C" in ldmicro versions
Wed Jan 23 2019, 14:17:01, download attachment lm35 °C.pdf
(no subject) (by José GILLES)
Some say that value 223 displays a '°' symbol on 16x2 LCDs ?
Wed Jan 23 2019, 15:56:05
(no subject) (by Tom J.)
Hi Alex, I didn't get to respond to you on YouTube until last night.
trip1.ld is what was in the video.

http://cq.cx/ladder-forum.pl?a...;parent=7691&tt=1541099457
Wed Jan 23 2019, 16:09:10
(no subject) (by José GILLES)
I confirm that writing value 223 (0xDF) to my 16x2 LCD display
shows a '°' like symbol.
It should be sufficient for your application ?

JG
Thu Jan 24 2019, 02:39:22
(no subject) (by Alex)
thanks for your help José GILLES, it works, now it prints '°' symbol :)
Thu Jan 24 2019, 16:46:41, download attachment lm35 °C_2.pdf
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):