Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help to convert a program with micro Pascal to mikro C

Status
Not open for further replies.

we!rd

Newbie level 4
Joined
Feb 4, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,353
Sans titre.jpg
the project name is the control of public lighting and temperature measurement and i use an LCD and pic 16F877 i found the program with pascal language i need this program with mikro c plz
i use pic 16F877 , LCD , keyboard , temperature sensor LM35 , and LDR
the pic compares brightness threshold (LDR) and the rate of brightness (seuil) and send to the LCD the temperature (LM35) and in the lcd we can see also:
kp is in relation with the keyboard
if we chose 1 in the keyboard we can see in the LCD the mesure of the temperature
if we chose 2 in the keyboard we can see in the LCD the value of the rate of brightness
if we chose 3 in the keyboard we can see in the LCD "lamp on" or "lamp off" in relation with the comparaison of the pic
if we chose 4 in the keyboard we can see in the LCD the value of brightness threshold
THE PROGRAME

var //declaration de variable
kp : byte;
x,j,u: LONGINT;
label temp,seuil,lum ,lampe,start;
Procedure lam();
begin
J:=adc_read(1);
u:=adc_read(2);
if j>u then
begin
DELAY_ms(250);
portd.0:=1;
end
else
begin
portd.0:=0;
kp := Keypad_Released();
end ;
end;
Procedure ADC(x:integer);
var ch: byte;//declaration de variable
tlong,t: longint;
begin
lcd_cmd(lcd_cursor_off);//etiendre le clavier
tlong := (x*5000);
t := longint(tlong shr 10);
ch:= t div 100000;
lcd_chr(2,3,48+ch);
ch:= integer(t div 10000)mod 10;
lcd_chr(2,4,48+ch);
ch:= integer(t div 1000)mod 10;
lcd_chr(2,5,48+ch);
lcd_chr(2,6,'.');
ch:= integer(t div 100)mod 10;
lcd_chr(2,7,48+ch);
ch:= integer(t div 100) mod 10;
lcd_chr(2,8,48+ch);
ch:= integer(t div 10) mod 10;
end;
begin
lcd_init(portb);//initialisation de l'afficheur LCDsur le portB
trisa:=$EF;//toute les broches de portA en sortie sauf RA4
trisc:=$7F;// toute les broches de portC en sortie sauf RA7
ADCON1:=$80; //déclaration pour le CAN ,extrait de datasheet du Pic
Trisd:=$00;//initialisation de portd
lcd_cmd(lcd_cursor_off);//etiendre le curseur de l'afficheur LCD
Keypad_Init(PORTC);//initialiser le clavier sur le port C
Lcd_Cmd(LCD_CLEAR);// effacer le contenu de l'afficheur
lcd_out(1,1,'projet fin d"etude');//afficher sur la 1 er ligne et la 1 er colnne de LCD "projet fin d"etude"
portd.0:=0; // initialiser le pin RD0
repeat
start:
portc :=$00;//initialisation de portc
begin
kp := 0;//initialisation de kp
while kp = 0 do
kp := Keypad_Released();//lecture de clavier

// structure du clavier;
if (kp = 1) then kp := '1';
if (kp = 2) then kp := '4';
if (kp = 3) then kp := '7';
if (kp = 4) then kp := '*';
if (kp = 5) then kp := '2';
if (kp = 6) then kp := '5';
if (kp = 7) then kp := '8';
if (kp = then kp := '0';
if (kp = 9) then kp := '3';
if (kp = 10) then kp := '6';
if (kp = 11) then kp := '9';
if (kp = 12) then kp := '=';
LCD_chr(2,5,kp);
Lcd_Cmd(LCD_CLEAR); //effacer le contenu de l'afficheur
if kp ='1' then goto temp ;
if kp ='2' then goto seuil ;
if kp ='3' then goto lampe ;
if kp ='4' then goto lum ;
lcd_out(1,1,'1-temp 2-seuil');//afficher sur la 1 er ligne et la 1 er colnne de LCD "1-temp 2-seuil"
lcd_out(2,1,'3-lampe 4-lum');//afficher sur la 2 eme ligne et la 2 eme colnne de LCD "3-lampe 4-lum"
lam();
goto start ;
temp:
begin
DELAY_ms(50);//
kp := Keypad_Released();//lecture de clavier

while kp=0 do
begin
x:=adc_read(0);
lcd_out(1,1,'1-Temperature:');//afficher sur la 1 er ligne et la 1 er colnne de LCD "1-Temperature:"
lcd_out(2,10,' (Degre)');//afficher sur la 2 eme ligne et la 10 eme colnne de LCD " (Degre)"
lam();
adc(x);//
kp := Keypad_Released();//lecture de clavier

end ;
goto start ;//
end ;
seuil:
begin
DELAY_ms(50);//
kp := Keypad_Released();//lecture de clavier

while kp=0 do
begin
J:=adc_read(1);//
lcd_out(1,1,'1-Reglage Seuil:');//afficher sur la 1 er ligne et la 1 er colnne de LCD "1-Reglage Seuil:"
lam();//
adc(J);//
kp := Keypad_Released();//lecture de clavier

end ;
goto start ;//
end ;
lampe:
begin
DELAY_ms(50);//
kp := Keypad_Released();//
while kp=0 do//
begin
J:=adc_read(1);//
u:=adc_read(2);//
if j>u then //
begin
DELAY_ms(250);//
portd.0:=1;//
lcd_out(1,3,'lampe allume');//afficher sur la 1 er ligne et la 3 eme colnne de LCD "lampe allume"
end
else
begin
portd.0:=0;//
lcd_out(1,3,'lampe eteint');//afficher sur la 1 er ligne et la 3 eme colnne de LCD "lampe eteint"
end ;
kp := Keypad_Released();////lecture de clavier

end;
goto start ;
end ;
lum:
begin
DELAY_ms(50);
kp := Keypad_Released();
while kp=0 do
begin
u:=adc_read(2);
lcd_out(1,1,'4-Lumiere:');//afficher sur la 1 er ligne et la 1er colnne de LCD "4-Lumiere:"
lcd_out(2,10,' Lum'); //afficher sur la 1 er ligne et la 10 eme colonne de LCD "Lum"
adc(u);//
lam(); //
kp := Keypad_Released(); //lecture de clavier

end;
goto start ;
end ;
end ;
until FALSE ;
end.
 

hi

just get the idea from the project and write a fresh program
that will reduce time for errors and will be easy for debugging

regards

ml
 

I dont know how to program with mikro c can you convert for me this program or show me how ? plz
 

i just need help i know how to learn C but i dont have time for this , if you want to give me your assistance thx but give me a pdf document not this link ..
 

Bru - you will get the same result in ANY language and excuse the pun but the code is messy and the schematic too wiring "goto top sorry bottom sorry keyboard" all over isis to lcd & keyboard and since you don't have time for this why do you want us to help you fix your mess in our time if you want help sure anytime. You start C like this void Main() {'Snotty code goes here'}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top