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

why isn't working
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

why isn't working
PostPosted: Wed Apr 16, 2014 12:44 pm     Reply with quote

ı can work this project with both "//#include <HDM64GS12.c>
//#include <graphics.c>" but when ı define lcd.c, there is no life on screen

Code:

#include <18F4550.h>
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES PLL1                     //No PLL PreScaler
#FUSES CPUDIV4                  //System Clock by 4
#FUSES INTHS                    //Internal Oscillator, HS used by USB
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(int=8000000)

//#include <HDM64GS12.c>
//#include <graphics.c>

#define LCD_ENABLE_PIN  PIN_B4                                 
#define LCD_RS_PIN      PIN_B2                                   
#define LCD_RW_PIN      PIN_B3                                 
#define LCD_DATA4       PIN_D4                                   
#define LCD_DATA5       PIN_D5                               
#define LCD_DATA6       PIN_D6                                   
#define LCD_DATA7       PIN_D7

#use fast_io(a)
#include <lcd.c>

unsigned long int bilgi;
float voltaj, sicaklik;



void main()
{
   setup_psp(PSP_DISABLED);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
   setup_CCP1(CCP_OFF);
   setup_CCP2(CCP_OFF);
   
set_tris_a(0x01);
setup_adc(adc_clock_div_32);
setup_adc_ports(AN0);
//glcd_init(ON);

lcd_init();
set_adc_channel(0);
delay_us(20);

   while(TRUE)
   {
   lcd_init();
   bilgi=read_adc();
   delay_ms(100);
   voltaj=(0.0048828125*bilgi)*1000;
   sicaklik=(voltaj/10)+2;
   printf(lcd_putc,"\fHİ BABY");
    delay_ms(100);
    lcd_gotoxy(10,1);
printf(lcd_putc,"%5.1f",sicaklik);
delay_ms(100);

   }

}
temtronic



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

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 1:21 pm     Reply with quote

try this....

add

delay_ms(500);
THEN
lcd_init();

LCD module take some time to get 'organized' before you ( the PIC) can properly access them.

also

delete the
use fast_io(a);

unless YOU specifically control the tris registers, the PIC won't operate the I/O port the way you think it will. Probably 99.99% of all PIC code cut doesn't really benefit from fast_io(),at least none of the 'simple' programs.

hth
jay
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 1:42 pm     Reply with quote

I tried, there is some life on the screen but no character like just death pixels for a moment
Code:

#include <18F4550.h>
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES PLL1                     //No PLL PreScaler
#FUSES CPUDIV4                  //System Clock by 4
#FUSES INTHS                    //Internal Oscillator, HS used by USB
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(int=8000000)

//#include <HDM64GS12.c>
//#include <graphics.c>


//#use fast_io(a)
#include <lcd.c>

unsigned long int bilgi;
float voltaj, sicaklik;



void main()
{
   setup_psp(PSP_DISABLED);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
   setup_CCP1(CCP_OFF);
   setup_CCP2(CCP_OFF);
   
set_tris_a(0x01);
setup_adc(adc_clock_div_32);
setup_adc_ports(AN0);
//glcd_init(ON);

lcd_init();
delay_ms(500);
set_adc_channel(0);
delay_us(20);

   while(TRUE)
   {
   lcd_init();
   bilgi=read_adc();
   delay_ms(100);
   voltaj=(0.0048828125*bilgi)*1000;
   sicaklik=(voltaj/10)+2;
   printf(lcd_putc,"\fHİ BABY");
    delay_ms(100);
    lcd_gotoxy(10,1);
printf(lcd_putc,"%5.1f",sicaklik);
delay_ms(100);

   }

}


I move the pinout lcd.c also there are no warning or error.
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 1:51 pm     Reply with quote

i tired this there is anything on screen,

Code:

#include <18F4550.h>
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES PLL1                     //No PLL PreScaler
#FUSES CPUDIV4                  //System Clock by 4
#FUSES INTHS                    //Internal Oscillator, HS used by USB
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(int=8000000)

//#include <HDM64GS12.c>
//#include <graphics.c>


//#use fast_io(a)
#include <lcd.c>

unsigned long int bilgi;
float voltaj, sicaklik;



void main()
{
   setup_psp(PSP_DISABLED);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
   setup_CCP1(CCP_OFF);
   setup_CCP2(CCP_OFF);
   
//set_tris_a(0x01);
//setup_adc(adc_clock_div_32);
//setup_adc_ports(AN0);
//glcd_init(ON);

lcd_init();
delay_ms(500);
//set_adc_channel(0);
//delay_us(20);

   while(TRUE)
   {
   //bilgi=read_adc();
   //delay_ms(100);
   //voltaj=(0.0048828125*bilgi)*1000;
   //sicaklik=(voltaj/10)+2;
   lcd_gotoxy(10,1);
   printf(lcd_putc,"\fHİ BABY");
    delay_ms(100);
    //lcd_gotoxy(10,1);
//printf(lcd_putc,"%5.1f",sicaklik);
//delay_ms(100);

   }

}
temtronic



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

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 1:56 pm     Reply with quote

lcd_init();
delay_ms(500);


needs to be other way...

delay_ms(500);
lcd_init();


also have you got the LCD wired correctly according to the lcd.c driver pin configuration ?
also do you have a contrast pot on pin 3 of the LCD. should have about 0.5V on it.



hth
jay
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 2:05 pm     Reply with quote

ı tried before lcd_init but not working

ı connect pins ı checked again what ı define;

#define LCD_ENABLE_PIN PIN_B4
#define LCD_RS_PIN PIN_B2
#define LCD_RW_PIN PIN_B3
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7

last thing ı'm using 20k pot pin3, pin 18 and 5v, this process working graphics.c but not working lcd.c there is a little tiny point but ı didn't figure out
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 2:05 pm     Reply with quote

Hi,

Dude! You seem to be throwing mud at the wall and hoping for something to stick.... Shocked

LCD.C is for a CHARACTER LCD display, while HDM64GS12.c is for a GRAPHICAL LCD. Do you know the difference??

Post a link to the LCD that you are using. Right now you seem hopelessly lost.......

John

PS Proteus or real circuit???
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 2:13 pm     Reply with quote

may ı cry aaaaaaaaaaaaaaaaaaaaaaaa
any way last question

++++++++++++++++++++++++++++++++++ in this point how ı show the sicaklik value on screen ı tried glcd_text57 but ı couldn't thanks

Code:

#include <18F4550.h>
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES PLL1                     //No PLL PreScaler
#FUSES CPUDIV4                  //System Clock by 4
#FUSES INTHS                    //Internal Oscillator, HS used by USB
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(int=8000000)

#include <HDM64GS12.c>
#include <graphics.c>


#use fast_io(a)

unsigned long int bilgi;
float voltaj, sicaklik;



void main()
{
   setup_psp(PSP_DISABLED);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
   setup_CCP1(CCP_OFF);
   setup_CCP2(CCP_OFF);
   
set_tris_a(0x01);
setup_adc(adc_clock_div_32);
setup_adc_ports(AN0);


glcd_init(ON);
delay_ms(500);
set_adc_channel(0);
delay_us(20);

   while(1)
   {
   bilgi=read_adc();
   delay_ms(100);
   voltaj=(0.0048828125*bilgi)*1000;
   sicaklik=(voltaj/10)+2;
  //+++++++++++++++++++++++++++++++++++++++++++++
    delay_ms(100);
   

   }

}
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 2:42 pm     Reply with quote

Hi idris,

I really don't think you have any idea at all what you are doing, you are just 'tweaking' everything in order to get *something* to work..... Moreover, this is almost certainly a Proteus exercise......

Anyway, if you hope to learn anything at all, looking graphics.c and try to determine what the glcd_text57 needs to work properly. Then look at the CCS manual and take a look at sprintf function.

John
temtronic



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

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 3:02 pm     Reply with quote

get back to basics !!
get rid of all code EXCEPT

LCD specifics like driver and init functions

ADD delay_ms(500);
BEFORE lcd_init();

do a simple print to lcd like 'hello world'. There are examples here and in the examples folder that CCS supplies

so

recode/recompile/retest/report back...

show program and results....

we'll go from there.

hth
jay
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 4:26 pm     Reply with quote

Jay,

I don't think the OP has any real hardware, because the code that has been posted seems to randomly switch between character display code and graphics display code. More importantly, I don't think the OP has any real idea of what they are trying to do. I think we are just chasing a homework exercise here by a student that hasn't really bothered to figure out what they are trying to accomplish. It's the old 'ask first, think second'.... Right now, all we have is a bowl of Jello......

John
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 10:38 pm     Reply with quote

I search ccs manual and prepare again code:
Code:

 while(1)
   {
   bilgi=read_adc();
   delay_ms(100);
   voltaj=(0.0048828125*bilgi)*1000;
   sicaklik=(voltaj/10)+2;
   delay_ms(500);
   sprintf(text,"%5.2f", sicaklik); <<<<<<<<<<<<<<<< holy code
   glcd_text57(1, 1, text, 1, ON);
   delay_ms(1000);
}

but ADC not working, lcd screen (128x64) show me "2.00"
Source code:
http://s3.dosya.tc/server21/LkPCrx/Desktop.rar.html
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Apr 17, 2014 12:35 am     Reply with quote

This is a very small program and you have to learn to debug it yourself. If we give you the solution now you will never be able to find a bug in a more difficult program.

To help you we have to know if you are using a simulation program or real hardware. This has been asked before but you never answered it. We suspect you are using Proteus simulation software.

For debugging you will have to go through the program step - by - step. For this you can use a hardware device called 'In Circuit Debugger' like the Microchip ICD2 or PicKit. Or you can use the free Microchip software simulator in MPLAB.
Only when you go step-by-step you can see the values of all variables and figure out which line is going wrong. This is how professionals work. If you want to become a professional then learn to use these tools.
Don't just 'think' about how the program works but use the tools to measure the values, then you will 'know' where things go wrong.
idris



Joined: 07 Apr 2014
Posts: 16

View user's profile Send private message

PostPosted: Thu Apr 17, 2014 12:56 am     Reply with quote

Real hardware I'm using and you right I have to survive but what I suppose to do? Thanks.
temtronic



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

View user's profile Send private message

PostPosted: Thu Apr 17, 2014 7:19 am     Reply with quote

You should 'play computer' !
Manually, with pencil and paper do the operations...

your code...

voltaj=(0.0048828125*bilgi)*1000;
sicaklik=(voltaj/10)+2;

first you multiply by 1000
then divide by 10

The +2 is 'odd'..same number as displayed....

You should printout 'voltaj' to see what it is.


hth
jay
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  Next
Page 1 of 2

 
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