View previous topic :: View next topic |
Author |
Message |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
SHT15,MPX4115A and external pulse counter with PIC16F72 |
Posted: Sat Dec 11, 2010 7:44 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9173 Location: Greensville,Ontario
|
|
Posted: Sat Dec 11, 2010 8:09 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
|
Posted: Sat Dec 11, 2010 9:44 am |
|
|
I'm using a lcd of 2*16 and I want to use it in 8 bit mode.
Thanks to reply |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Dec 11, 2010 3:52 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
|
Posted: Sun Dec 12, 2010 10:13 am |
|
|
Thanks for the help.
But the first test will probably only within one and a half weeks of the exams. |
|
![](templates/subSilver/images/spacer.gif) |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
|
Posted: Thu Dec 23, 2010 3:31 am |
|
|
Hi,
can this code works with the PICmicro® MCU Multiprogrammer
EB006-00-6 programmer?
thanks in advance |
|
![](templates/subSilver/images/spacer.gif) |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
|
Posted: Thu Dec 23, 2010 4:06 am |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
|
Posted: Thu Dec 23, 2010 5:00 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
question |
Posted: Sat Dec 25, 2010 12:38 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Dec 25, 2010 2:59 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
It works |
Posted: Mon Dec 27, 2010 9:09 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Mon Dec 27, 2010 9:21 am |
|
|
Search the forum for MPX4115 and you will find some helpful info... _________________ Google and Forum Search are some of your best tools!!!! |
|
![](templates/subSilver/images/spacer.gif) |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
|
Posted: Mon Dec 27, 2010 9:57 am |
|
|
I will do. |
|
![](templates/subSilver/images/spacer.gif) |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
|
Posted: Mon Jan 03, 2011 9:05 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Mon Jan 03, 2011 10:04 am |
|
|
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!!!! |
|
![](templates/subSilver/images/spacer.gif) |
|