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.

LCD displaying numbers from 0 to 999

Status
Not open for further replies.

marduk18

Newbie level 3
Joined
Feb 11, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,313
PIC 16F877A and using mikrobasic

hi all

Im writing a program to display values from 0 to 999. actually the word 'FLOW RATE=' is displayed first.

Then, when portc.0=1, a value of 0 to 9 is displayed on the 11th column of row 1

When portc.1=1, the cursor shifts to the right, that is, to the 12th column of row 1

when portc.0=1 again, a value of 0 to 9 is displayed at the current cursor position, that is on the 12th column of row 1

sadly, the program is not working as planned on the PIC simulator IDE

please help friends
here's the program


program LCD_trial12

dim k0 as byte
dim text as string [20]

main:
TRISC = 1
TRISB = 0
Lcd_Init (portB)
Lcd_Cmd(LCD_CLEAR)

text = "FLOW RATE="
Lcd_Out(1,1,text)
Lcd_Cmd(Lcd_Underline_On)

k0=0

path0:
for k0=0 to 9
if
portc.0=1
then
gosub augmenter
end if

if
portc.1=1
then
Lcd_cmd(Lcd_Move_Cursor_Right)
end if
delay_us(1000)
goto path0


augmenter:

select case k0

case 0
Lcd_out_cp("0")


case 1
Lcd_out_cp("1")


case 2
Lcd_out_cp("2")


case 3
Lcd_out_cp("3")


case 4
Lcd_out_cp("4")


case 5
Lcd_out_cp("5")


case 6
Lcd_out_cp("6")


case 7
Lcd_out_cp("7")


case 8
Lcd_out_cp("8")


case 9
Lcd_out_cp("9")

end select
delay_us(1000)
next k0

return

end.
 

path0:
for k0=0 to 9
if
portc.0=1
then
gosub augmenter
end if
next k0 << added here



remove it from to subroutine gosub

looking microc basic will localise a for and next to a single routine
and not at gosub level
:. the for never gets stepped on even if the if again qualifies
as the for has not already been stepped on by the local routine the for is inside

a kind of code oxymoron
path0:
for k0=0 to 9
if
portc.0=1
then
gosub augmenter <<next was here inside an if
end if
next k0 << added here outside the if

otherwise its boot strapping the for
and there is no tie in case for a for
 
Last edited:

still its not working..when portc.1=1 the cursor is not moving to the right in fact
 

path0:
for k0=0 to 9
if
portc.0=1
then
gosub augmenter
end if

if
portc.1=1
then
Lcd_cmd(Lcd_Move_Cursor_Right)
end if
next k0 <<< move here
delay_us(1000)
goto path0


i didnt see the bottom few lines
were in the same sub eek

try above it will work
 

it is still not working like it should be on the simulator. have you tried it? does it work properly?

when portc.1=1, the cursor moves to the left and then erase the word 'FLOW RATE=' and it writes it again. strange:S
 

init:
TRISC = 1
TRISB = 0
Lcd_Init (portB)
Lcd_Cmd(LCD_CLEAR)
text = "FLOW RATE="
Lcd_Out(1,1,text)
Lcd_Cmd(Lcd_Underline_On)
k0=0
goto main


main:
for k0=0 to 9
if
portc.0=1
then
gosub augmenter
end if

if
portc.1=1
then
Lcd_cmd(Lcd_Move_Cursor_Right)
end if
next k0
delay_us(1000)
goto main

augmenter:

select case k0

case 0
Lcd_out_cp("0")


case 1
Lcd_out_cp("1")


case 2
Lcd_out_cp("2")


case 3
Lcd_out_cp("3")


case 4
Lcd_out_cp("4")


case 5
Lcd_out_cp("5")


case 6
Lcd_out_cp("6")


case 7
Lcd_out_cp("7")


case 8
Lcd_out_cp("8")


case 9
Lcd_out_cp("9")

end select
delay_us(1000)

return

end. << not sure this is needed and may be the issue or something

---------- Post added at 09:16 ---------- Previous post was at 09:12 ----------

you will need to do this

write the words then move the cursor to the right place in the line to avoid over writing it and strange results

lcd doesnt need refreshed every print
the data will stay in ram

so this is why it over writes i think
main is main and isnt init is main routine
always a sub running can confuse simulators
where you find that the hardware actualy works

better using proteus vsm its a better sim
 

it is still not working. program can actually work perfectly on the hardware but when simulated in the simulator it can get confused? i was thinking about that also. may be i should try it on an LCD itself..thanks lot mate
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top