• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

programming code for lcd and inverter

Status
Not open for further replies.

girgis adly

New Member
dear all
i write acod for my project which is multilevel inverter equipped with lcd screen but when i check the code on a simulation programe (proteus)it is not work as intended this is the code written in micro c language and i use
pic18f452 switches s1&s2 connected to port A gates of mosfets of the inverter connected to port B lcd connected to port c


void main()
{
int (x) ;
lcd_init(&portc);
lcd_cmd(LCD_CURSOR_OFF);
lcd_out(1,1,"project of :");
delay_ms(2000);
lcd_cmd(lcd_clear);
lcd_out(1,4,"Multilevel ");
lcd_out(2,1," Pwm inverter ");
delay_ms(2000);
lcd_cmd(lcd_clear);
Lcd_Out_Cp("supervised by:");
lcd_out(2,1," Dr. Gamal Hashm");
delay_ms(3000);
lcd_cmd(lcd_clear);
lcd_Out_Cp("press s1 for run");
lcd_out(2,1,"press s2 for EX");
delay_ms(2000);
menu:
lcd_cmd(lcd_clear);
lcd_cmd(LCD_CURSOR_OFF);
Lcd_Out_Cp("menu: ");
lcd_out(2,1,"s1:5l s2:EXIT");

TRISB=0;
trisA=00001111;
if(portA.f0==0)
{
lcd_cmd(lcd_clear);
lcd_Out_Cp("prog of 5l run");
//code of project
for(x=0;x,1000;x++)
{
PORTB=0;
Delay_us(337);
PORTB=0B00000101;
Delay_us(2717);
PORTB=0B00001001;
delay_us(3889);
PORTB=0B00000101;
delay_us(2667);
PORTB=0;
delay_us(777);
PORTB=0B00000110;
delay_us(2667);
PORTB=0B00001010;
delay_us(3889);
PORTB=0B00000110;
delay_us(2667);
PORTB=0;
delay_us(388);
}
lcd_cmd(lcd_clear);
Lcd_Out_Cp(" prog end");
lcd_out(2,1,"s1:menu s2:exit");
if(porta.f0==0)
{goto menu;}
if(porta.f1==0)
{goto exit; }}
if(porta.f1==0)
{goto exit;}
exit:
Lcd_Out_Cp(" Exit");
lcd_out(2,1,"s1:yes s2:No");
if(porta.f0==0)
{
lcd_cmd(lcd_clear);
Lcd_Out_Cp(" prog end");
lcd_out(2,4," good bye");
}
if(porta.f1==0)
{goto menu;}}

i want the prog to do that when i run the prog some message appear on the lcd then message appear
menu
s1:5l s2:EX
this message appear and still on the screeen till i press s1 or s2 then if i press s1 prog run and message appear prog of 5l run and still on the screen untill the prog end as we use for loop after the prog end message appear
prog end
s1:menu s2:exit
if press s2 the prog go to exit and message appear
Exit
s1:yes s2:No
if press s1 mesage appear
prog end
good bye

now the problems in my code is the programe run without i press any switch and still run regardless of for loop
please help me in correcting the code

thanks and regards
 

nike6

Banned
write a menu parser.

for each topic, there is a code/type of action:

-jump
-change variable

the parser reads from the table,
and then takes action based on the code.

if you have 30 options that is the only way to go.

so first you write the text

text:
db "menu topic",0

and then some data:

dw 0x0001,0x0024 (for instance).

after that you must also parse the string table for length,
and store this data in the RAM.

a few 100s of lines are required, maybe less in C.
 

girgis adly

New Member
thanks for reply but i can't understand what what is the wrong in my program i will be pleasure if you determine berifly what is the in my programe and what i must do to correct it
note the code is written in micro c
thanks
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top