CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

pic18f4550 and mpx4250, getting pressure

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
blackdragon



Joined: 24 May 2010
Posts: 10

View user's profile Send private message

pic18f4550 and mpx4250, getting pressure
PostPosted: Thu May 27, 2010 2:29 pm     Reply with quote

Hi folks,

Now, I'm trying pressure sensor read in the ISIS, so I found some information about pressure logic such as digital/analog converter etc.

So, I've just used read_adc() functions and a few settings as below;

:::: settings ::::
Code:

setup_adc_ports(AN0);   
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);           
set_adc_channel(0);

::::: read sensor value :::
Code:

pressure = read_adc();

However sensor value and pressure value haven't match. Also, I read sensor's datasheet and I found transfer function as below:

Nominal Transfer Value: Vout = VS x (0.00369 x P + 0.04)
± (Pressure Error x Temp. Factor x 0.00369 x VS)
VS = 5.1 ± 0.25 Vdc

After all, may I making something wrong/missing, how can I read exactly seeing in sensor value ?

thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 27, 2010 3:01 pm     Reply with quote

Post your test program. (Complete).
blackdragon



Joined: 24 May 2010
Posts: 10

View user's profile Send private message

PostPosted: Fri May 28, 2010 12:17 pm     Reply with quote

PCM programmer wrote:
Post your test program. (Complete).


my source as below;

Code:

#include <18F4550.h>

#FUSES  NOPROTECT, NOPUT, NOWDT, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NOMCLR

#use   delay(clock=4000000)
#define use_portb_lcd True

#include <lcd.c>

void main(void)
{
   float temperature;
   int16 value;
   
   setup_adc_ports(AN0);   
   setup_adc(ADC_CLOCK_INTERNAL);     
   set_adc_channel(0);
   
   lcd_init();
     
   while(TRUE)
   {
 
      value = read_adc();
     
      printf(lcd_putc,"\fPressure:%lu", value);
 
   }

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 28, 2010 12:44 pm     Reply with quote

I was expecting to see some math equations in the code.

But here are some comments:

1. The compiler is using 8-bit mode for the A/D converter. The numbers
returned by read_adc() will be from 0 to 255 in 8-bit mode. If you want
to use 10-bit mode, with the result from 0 to 1023, then you need to
add the line shown in bold below:
Quote:

#include <18F4550.h>
#device adc=10
#fuses ...


2. You don't have an oscillator setting in the #fuses statement, but
maybe Proteus doesn't care. But if it did care, you could use INTRC_IO.

3. The oscillator clock of ADC_CLOCK_INTERNAL is not the best.
For a 4 MHz oscillator, the correct value is ADC_CLOCK_DIV_4, but
maybe Proteus doesn't care.
blackdragon



Joined: 24 May 2010
Posts: 10

View user's profile Send private message

PostPosted: Fri May 28, 2010 2:03 pm     Reply with quote

PCM programmer wrote:
I was expecting to see some math equations in the code.


Actually I'm not sure about math equations but I'll investigate for more clarification.

Thanks for another comments..

cheers
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group