Continue to Site

# I have a problem with a sensor of pressure anb PBP 2.42

Status
Not open for further replies.

#### debutpic

##### Member level 4
pbp negative numbers

Hi all

I have a sensor of pressure MPX 2010 DP and a PIC 16F87X, which measures a pressure and a depression.
In the atmospheric pressure ~1013 mb the ADC = 126
with a depression of 2200 mb the ADC=149
I defined one équationressure = (-131) X (value ADC) + 17519
Everything is good in pressure value increases, but in depression under 0
my LCD show 65500 mb,65450 mb etc...

Define LCD_DBIT 4
Define LCD_RSREG PORTB
Define LCD_RSBIT 3
Define LCD_EREG PORTB
Define LCD_EBIT 2

TRISA = %11111111

Pause 500
Lcdout $fe, 1 Lcdout "Value: ", DEC adval_final Pause 100 Goto loop End help me please #### Tornado ##### Full Member level 3 pbp negative number Hi Debutpic how are you? the equation is giving negative number. Is the output of the pressure sensor linear? example 1013mbar = 1.000 volts, 2026mbar = 2.000 volts If not, you have to get data for various pressure points and built a table lookup. Regards Tornado #### Sobakava ##### Full Member level 6 lcdout I finished a project with pressure sensor (custom made) and PIC18F452 project with CCS. Works fine. I seems you have problem with size of variables. In CCS compiler you can use 32bit integers and also floating point variables. BASIC is not a language for microcontrollers. (It is just my opinion) :wink: #### Fragrance ##### Advanced Member level 4 mpx2010 pic18f hI, JUST TRY WITH LOOKUP TABLE REGARDS FRAGRANCE #### Kripton2035 ##### Advanced Member level 4 basÄ±nÃ§ sensÃ¶rÃ¼ pbp Sobakava said: I finished a project with pressure sensor (custom made) and PIC18F452 project with CCS. Works fine. I seems you have problem with size of variables. In CCS compiler you can use 32bit integers and also floating point variables. BASIC is not a language for microcontrollers. (It is just my opinion) :wink: it's not mine ! basic is a good language for microcontrolers. c is good for computers. c is good also if you have floating point needs... althought some basics now have floating points. basic is easier to learn then c they are both usefull, each one in their own domain. basic is also often cheaper than c... I also made a project with on the same card with lcd display a pressure sensor, humidity sensor, light sensor and temperature sensor, all made with picbasic and it works fine too ! #### para_racer ##### Newbie level 4 picbasic pro lcdout dec 32bits If you still haven't figured it out you can give this a try. There are lots of ways around this problem and here is one example. adcin 0, temp 'Reads ambient temperature IF temp >= 428 THEN 'Checks if temp is greater than 'or equal to 0 deg C temp1 = (temp-428)/9 'Calculates temp in degrees C lcdout$FE,1 'Clear LCD
lcdout $FE,$80, "Initializing...."
lcdout $FE,$C0, "Temp = ",DEC temp1, " Deg C"
ENDIF
IF temp < 427 THEN 'Checks if temp is less than 0 deg C
temp1 = (temp-427)/(-15) 'Calculates temp in degrees C
lcdout $FE,1 lcdout$FE,$80, "Initializing...." lcdout$FE,\$C0, "Temp = ","-",DEC temp1, " Deg C"
ENDIF

You can calculate the A/D value that causes the equation to go negative and use IF statements to split the positive and negative parts. The example above splits at the 0 crossing and uses a new equation for the negative value. The new equation devides the negative sign out and then you just display a "-" charactor before the negative number.

Hope this helps.