M mastero Member Mar 23, 2021 #1 Hello I am making a simple pressure sensor all works fine. i get the output reading as XX.XXX on a 16x2 LCD i want only the XX before the decimal to be displayed. Help please. Code: Dim Pressure as Single displaypressure: Adcin 0, analogread pressure = analogread * 5.0 / 1024 pressure = (pressure - 0.54) / 0.059 Lcdcmdout LcdLine1Clear Lcdcmdout LcdLine1Home Lcdout "PRESSURE", ":", " ", " ", #pressure Return cheers Mastero
Hello I am making a simple pressure sensor all works fine. i get the output reading as XX.XXX on a 16x2 LCD i want only the XX before the decimal to be displayed. Help please. Code: Dim Pressure as Single displaypressure: Adcin 0, analogread pressure = analogread * 5.0 / 1024 pressure = (pressure - 0.54) / 0.059 Lcdcmdout LcdLine1Clear Lcdcmdout LcdLine1Home Lcdout "PRESSURE", ":", " ", " ", #pressure Return cheers Mastero
J jjw Active Member Mar 23, 2021 #2 mastero said: Hello I am making a simple pressure sensor all works fine. i get the output reading as XX.XXX on a 16x2 LCD i want only the XX before the decimal to be displayed. Help please. Code: Dim Pressure as Single displaypressure: Adcin 0, analogread pressure = analogread * 5.0 / 1024 pressure = (pressure - 0.54) / 0.059 Lcdcmdout LcdLine1Clear Lcdcmdout LcdLine1Home Lcdout "PRESSURE", ":", " ", " ", #pressure Return cheers Mastero Click to expand... ...deleted... Last edited: Mar 23, 2021
mastero said: Hello I am making a simple pressure sensor all works fine. i get the output reading as XX.XXX on a 16x2 LCD i want only the XX before the decimal to be displayed. Help please. Code: Dim Pressure as Single displaypressure: Adcin 0, analogread pressure = analogread * 5.0 / 1024 pressure = (pressure - 0.54) / 0.059 Lcdcmdout LcdLine1Clear Lcdcmdout LcdLine1Home Lcdout "PRESSURE", ":", " ", " ", #pressure Return cheers Mastero Click to expand... ...deleted...
Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Mar 23, 2021 #3 I would try to cast... example.. Code: Dim Pressure as Single Dim DispPressure as word displaypressure: Adcin 0, analogread pressure = analogread * 5.0 / 1024 pressure = (Pressure - 0.54) / 0.059 DispPressure = Pressure Lcdcmdout LcdLine1Clear Lcdcmdout LcdLine1Home Lcdout "PRESSURE", ":", " ", " ", #DispPressure Return That should get rid of the floating points..Untested ..Try it.
I would try to cast... example.. Code: Dim Pressure as Single Dim DispPressure as word displaypressure: Adcin 0, analogread pressure = analogread * 5.0 / 1024 pressure = (Pressure - 0.54) / 0.059 DispPressure = Pressure Lcdcmdout LcdLine1Clear Lcdcmdout LcdLine1Home Lcdout "PRESSURE", ":", " ", " ", #DispPressure Return That should get rid of the floating points..Untested ..Try it.
J jjw Active Member Mar 23, 2021 #4 jjw said: ...deleted... Click to expand... Deleted too soon This should work. Define SINGLE_DECIMAL_PLACES=0
jjw said: ...deleted... Click to expand... Deleted too soon This should work. Define SINGLE_DECIMAL_PLACES=0
phoenixcomm New Member Mar 23, 2021 #5 the pressure you are getting is an analog thing you want to convert it to a digital thing try this: int r(float f) { int result = f; return result; // You could just write "return f;" instead. } ~~Cris
the pressure you are getting is an analog thing you want to convert it to a digital thing try this: int r(float f) { int result = f; return result; // You could just write "return f;" instead. } ~~Cris
Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Mar 23, 2021 #6 phoenixcomm said: the pressure you are getting is an analog thing you want to convert it to a digital thing try this: int r(float f) { int result = f; return result; // You could just write "return f;" instead. } ~~Cris Click to expand... That is C This is Oshonsoft Basic forum.. Singes are new to the platform..
phoenixcomm said: the pressure you are getting is an analog thing you want to convert it to a digital thing try this: int r(float f) { int result = f; return result; // You could just write "return f;" instead. } ~~Cris Click to expand... That is C This is Oshonsoft Basic forum.. Singes are new to the platform..
J jjw Active Member Mar 23, 2021 #7 jjw said: Deleted too soon This should work. Define SINGLE_DECIMAL_PLACES=0 Click to expand... No, it does'nt work This define accepts values 1-6
jjw said: Deleted too soon This should work. Define SINGLE_DECIMAL_PLACES=0 Click to expand... No, it does'nt work This define accepts values 1-6
M mastero Member Mar 23, 2021 #8 Ian Rogers said: I would try to cast... example.. Code: Dim Pressure as Single Dim DispPressure as word displaypressure: Adcin 0, analogread pressure = analogread * 5.0 / 1024 pressure = (Pressure - 0.54) / 0.059 DispPressure = Pressure Lcdcmdout LcdLine1Clear Lcdcmdout LcdLine1Home Lcdout "PRESSURE", ":", " ", " ", #DispPressure Return That should get rid of the floating points..Untested ..Try it. Click to expand... PERFECT Thanks
Ian Rogers said: I would try to cast... example.. Code: Dim Pressure as Single Dim DispPressure as word displaypressure: Adcin 0, analogread pressure = analogread * 5.0 / 1024 pressure = (Pressure - 0.54) / 0.059 DispPressure = Pressure Lcdcmdout LcdLine1Clear Lcdcmdout LcdLine1Home Lcdout "PRESSURE", ":", " ", " ", #DispPressure Return That should get rid of the floating points..Untested ..Try it. Click to expand... PERFECT Thanks