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 CCS Technical Support

SHT15,MPX4115A and external pulse counter with PIC16F72
Goto page 1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

SHT15,MPX4115A and external pulse counter with PIC16F72
PostPosted: Sat Dec 11, 2010 7:44 am     Reply with quote

Hi,

I'm Stijn Keersebilck from Belgium and I'm sitting in the sixth year.
And when we're in the sixth year you're need to make a thesis. So I decided to make a small weatherstaion with the sht15, mpx4135 and speedometer for the wind and I will put it on a lcd.

But my question is that maybe someone can tell me how to let work a lcd because it doesn't work with codes I find here (and I don't know why).

Maybe someone can zip a sample with that only shows a word to the lcd.
Now I use a PIC16F877.

Thanks in advance


Last edited by stijn023 on Tue Jan 04, 2011 5:56 am; edited 3 times in total
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 8:09 am     Reply with quote

Let Google be your friend.
Search with C Code,your LCD module part number and the PIC type you're using(PIC16F877) and you'll find many examples.

Most LCD modules can be used in 8 bit mode ,or 4 bit mode so the code is different. Also it depends on the display size( 2*16,4*16,4*20).

Can't give you a specific answer unless we know the exact LCD you're using,and the hardware wiring.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 9:44 am     Reply with quote

I'm using a lcd of 2*16 and I want to use it in 8 bit mode.

Thanks to reply
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 11, 2010 3:52 pm     Reply with quote

Quote:

But my question is that maybe someone can tell me how to let work a lcd
because it doesn't work with codes I find here (and I don't know why).
I'm using a lcd of 2*16 and I want to use it in 8 bit mode.

Start with the Flex lcd driver. It runs in 4-bit mode. Don't worry about
8-bit mode for now. Most LCD drivers are written for 4-bit mode.
As a newbie, you should not try to use 8-bit mode. Use 4-bit mode now.
Example of problems, and suggested solutions:
http://www.ccsinfo.com/forum/viewtopic.php?t=43914

If you can't make your LCD work, then post the list of connections
between the PIC and the LCD.

Post the manufacturer and part number of the LCD.

Post your CCS compiler version.

Post if you are testing this in real hardware or in Proteus.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Sun Dec 12, 2010 10:13 am     Reply with quote

Thanks for the help.
But the first test will probably only within one and a half weeks of the exams.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 3:31 am     Reply with quote

Hi,

can this code works with the PICmicro® MCU Multiprogrammer
EB006-00-6 programmer?

thanks in advance
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 4:06 am     Reply with quote

Hi,

I changed the code in this one, my LCD connections:

#define LCD_DB4 PIN_B0
#define LCD_DB5 PIN_B1
#define LCD_DB6 PIN_B2
#define LCD_DB7 PIN_B3

#define LCD_E PIN_B4
#define LCD_RS PIN_B5
#define LCD_RW PIN_B6

// If you only want a 6-pin interface to your LCD, then
// connect the R/W pin on the LCD to ground, and comment
// out the following line.

//#define USE_LCD_RW 1

I don't use the LCD_RW but when I compile I receive an error,
this one:

A #DEVICE required before this line

and this is the line I'm talikng about:
int8 const LCD_INIT_STRING[4] =

Could someone help me please?
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 5:00 am     Reply with quote

I have found my mistake.
I called the wrong line for the enable that was my mistake.
I want to thank everyone to help me.
In the vacation I will search how to work the temperature and humidity sensor.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

question
PostPosted: Sat Dec 25, 2010 12:38 pm     Reply with quote

Hi,

do someone know what is the difference between:
Code:

printf(lcd_putc, "Temp : %3.1f %cC   ", restemp, 223);
printf(lcd_putc, "\nRH   : %3.1f %%   ", truehumid);

and:
Code:

lcd_putc( "Temp : %3.1f %cC   ")
lcd_putc( "\nRH   : %3.1f %%   ")

I don't know what is the difference, can someone explain it to me?

Thanks in advance

PS.
This is out of the sht75 driver file:
http://www.ccsinfo.com/forum/viewtopic.php?t=28564&highlight=sensirion
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 25, 2010 2:59 pm     Reply with quote

Regarding the first two lines:
Read any Help file or online tutorial on the printf function. Google for it.
This will explain Format Specifiers. Also, CCS has a special feature for
the printf function, which allows the output to be re-directed to any
function you specify, such as lcd_putc(). The code you posted is doing
this.

Regarding the 2nd two lines:
The lcd_putc() function has no ability to interpret Format Specifiers.
Only printf() can do this.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

It works
PostPosted: Mon Dec 27, 2010 9:09 am     Reply with quote

It works!
This afternoon I tested first the LCD of my thesis and then I tested the sht15 and the sensor does what he needs to do. Measure the temperature and humidity.

So the final two (actually three) things I have to do is the mpx4115 and make a counter for the windspeed. I think I would make first the windspeed because it is easier, I think. And then I will do the mpx4115.
Have somebody worked already with this sensor?

Thanks in advance
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Dec 27, 2010 9:21 am     Reply with quote

Search the forum for MPX4115 and you will find some helpful info...
_________________
Google and Forum Search are some of your best tools!!!!
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Mon Dec 27, 2010 9:57 am     Reply with quote

I will do.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Mon Jan 03, 2011 9:05 am     Reply with quote

Hi,

I found a code for the MPX4115A sensor but when I tested it I think there's something wrong.
This can be also a mistake from me but I don't know.

The code:
Code:
#include <16f72.h>         // device selection 
#device adc=10    *=16
#fuses XT,NOWDT,NOPROTECT,PUT,NOBROWNOUT
#use delay(clock=20000000)    // 20 MHz

#include<flex_lcd.c>

int16 p_an;
int16 adc_sample;
float p_hPa_float;                 
char p_corr;

void mpx4115a_read()
{

p_an=0;                                 // reset value

setup_adc(ADC_CLOCK_DIV_32);                 
setup_adc_ports(AN0_AN1_VSS_VREF);            // A0 A1 Ref=A2
delay_ms(1);                           // module warm-up time
set_adc_channel(0);                        // set & read adc ch 0 (RA0)
delay_ms(1);                           // to prevent erroneous result at boot
adc_sample = read_adc();
setup_adc( ADC_OFF );


// adc_sample>>=6;   // shift 6 bits to the right, correction for 10 bit AD conversion

// 10 bits ADC is 1024 steps --> -Vref is Vss and +Vref is Vcc 
// so ADC range goes from 0 V (0 hPa) to 5 V (1200 hPa)
// --> each step is 1,17 hPa

if (adc_sample>1023)return;            // error detection
p_an=adc_sample;                   //

p_hPa_float=((float)p_an*1.17)+600.1+(p_corr*1.17);   // 0.5 hPa multiply for one bit
                                       // 600.1 increment for -Vref compensation
                                       //
                                       // p_corr= manual adjust via user menu

}

void main()
{
   lcd_init();
   while(1)
   {
   mpx4115a_read();
   lcd_gotoxy(1,1);
   printf(lcd_putc,"%4.1f",p_hPa_float);
   }
}


Thank for replying
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jan 03, 2011 10:04 am     Reply with quote

You have to give us more to go on than that...

What happens when you try the code?
Does it compile?
If the code runs, how do you know?
What indications are you seeing?
Does any text appear on the display?
_________________
Google and Forum Search are some of your best tools!!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3, 4, 5  Next
Page 1 of 5

 
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