|
|
View previous topic :: View next topic |
Author |
Message |
solracAnallero
Joined: 26 Mar 2015 Posts: 4 Location: El Salvador
|
Nokia 5110 lcd Problem |
Posted: Thu Mar 26, 2015 1:51 pm |
|
|
I'm trying to use the Sparkfun Graphic LCD 84x48 - Nokia 5110 sku: LCD-10168 library to show data from a magnetometer approximately every second. It starts fine, but after some measurements the lcd stops showing data, sometimes it shows some random characters before stopping and some other times it just stops. I'm using pic18f4550 and the A ports to control the lcd. I took a look at the lcd code and it apparently works with whichever pin you choose. This is the code i use:
Code: |
#include <18F4550.h>
#include "math.h"
#include "HMC5883L.c"
#include "n5110.c"
#fuses INTRC_IO, PROTECT, PUT, BROWNOUT ,CPD, NOWDT, NOFCMEN, NOMCLR, NOIESO
#use delay(internal = 4MHz)
int X,Y,Z;
void setup();
void main()
{
float h = 0.0,cont=0.0;
int16 head=0;
set_tris_b(0xF3);
set_tris_a(0x00);
delay_ms(50);
setup();
nokia_init();
delay_ms(10);
nokia_gotoxy(0,0);
nokia_init();
delay_ms(10);
printf(nokia_printchar,"INICIO...");
while(TRUE)
{
h = HMC5883L_heading();
head=(int16)h;
X=(int)X_axis;
Y=(int)Y_axis;
Z=(int)Z_axis;
cont+=1;
if(cont>=(2)){
output_toggle(PIN_B2);
cont=0;
nokia_erase_x(1);
nokia_erase_x(0);
nokia_gotoxy(0,0);
printf(nokia_printchar,"Heading = %f ",h);
}
delay_ms(100);
}
}
void setup()
{
setup_WDT(WDT_off);
setup_oscillator(osc_4MHz);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_off);
setup_adc_ports(no_analogs);
setup_timer_0(T0_internal | T0_8_BIT);
setup_timer_1(T1_disabled);
setup_timer_2(T2_disabled, 255, 1);
port_B_pullups(FALSE);
set_RTCC(0);
set_timer1(0);
set_timer1(0);
set_timer2(0);
setup_CCP1(CCP_off);
HMC5883L_init();
}
|
the lcd library description is this:
Code: |
/*
-- Sparkfun Graphic LCD 84x48 - Nokia 5110 sku: LCD-10168
-- Adaptation of the original Nokia 3310 LCD header
-- CCS compiler
Special thanks to Michel Bavin 2004 (Original Author)--- [email protected] --- http://users.skynet.be/bk317494/ ---
august 29, 2004
*/
// x displays from 0 to 78 before displaying on a new line
// ex: nokia_gotoxy(78,1);nokia_print_leftarrow();
//
// ...
// nokia_init();
// ...
// nokia_gotoxy(0,0);
// printf(nokia_printchar,"test???");
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Thu Mar 26, 2015 2:56 pm |
|
|
hmmm...let me guess...
You've connected FIVE volt PIC to a 3 VOLT LCD unit directly without ANY logic level translation ??
If that's correct, then THAT is the problem.
Jay |
|
|
solracAnallero
Joined: 26 Mar 2015 Posts: 4 Location: El Salvador
|
|
Posted: Thu Mar 26, 2015 4:22 pm |
|
|
Well i'm actually using an lm301 to reduce the supply voltage to 3.6v. I get exactly 3.44v, but the source i use is the one that's given by the Pickit 3. Would you think that is a hardware problem? Maybe some connection or that the lcd is not working properly rather than a software problem? I mean am i using the code as it is supposed to be used? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
solracAnallero
Joined: 26 Mar 2015 Posts: 4 Location: El Salvador
|
|
Posted: Thu Mar 26, 2015 7:06 pm |
|
|
ammm.... sorry i thought it would do, i used that cause I didn't have a proper voltage regulator, so i just used it to reduce the source voltage for both the lcd and the compass. I think while the load doesn't consume too much current it would not be a problem, but maybe you are right, so i think the code its fine, and the problem is more likely a hardware problem. Thanks, and well i tried and now it works, i'll try with a regulator. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Fri Mar 27, 2015 2:23 am |
|
|
Just reducing the voltage for the external chips, doesn't make the circuit work.
It's like trying to use a crosspoint screwdriver to drive a flat screw. It is possible, but only by having a proper adapter bit.
The PIC will be putting out 5v logic signals which _will_ be overdriving the inputs to the display:
"VIH HIGH level input voltage 0.7VDD - VDD V"
Then you talk about '3.44v''. What does the data sheet say is the _maximum_ supply voltage?. :
"Logic supply voltage range VDD to VSS: 2.7 to 3.3 V"
So you are overvoltage before you start..... |
|
|
solracAnallero
Joined: 26 Mar 2015 Posts: 4 Location: El Salvador
|
|
Posted: Fri Mar 27, 2015 3:40 am |
|
|
You are absolutelly right, thanks Ttelmah that was all the problem, all the pins use 5v too, i skipped that litle fact i changed the voltage supply for al the circuit, now it is working fine, poor lcd, im lucky its still working. |
|
|
|
|
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
|