hi...
i´m starting an egg incubator using a ds18b20 and a ks0108 based 128*64 dysplay.
Controling them is a PIC16F876A@20Mhz, which will do the temp reading,
dysplay refresh and control the heater dimmer throught a moc3020, using a PID loop.
Till now i´ve made and tested the zero crossing detection circuit. It uses a 6N139. Fully working in my dual trace analog scope.
Now, to start controling and viewing things happening i need the display working.
So far i´ve seen some sample code from Peter Onion here.
Also some code snippets in this forum. i've been around for some time,
but i've always found my questions already answered by someone in someone else´s thead.
So no need to bother anyone, till today.
I was able to take from that code the InitLCD and the ClearLCD routines.
I´ve run the code one routine at a time using some LED´s beeing the outputs.
It works, mainly because i use 1 second delays between instructions for my eyes to see it happen.
After debug i´ve taken the delays away.
I have yet to built and debug routines like ReadLCD, Write LCD, ReadData and WriteData.
Then i´ll take away the LED´s. The remaining code will be built on top of this.
Meanwhile, i have a doubt. The display's data sheet refers to 450ns (nanoseconds) enable time.
The code i´ve seen from Peter Onion has some time delays i find too big. Like this:
In there i see him setting the enable bit for 9 clock cicles, which is correct. overkill, but correct.
since two cycles will be 400ns, for a 20MHzclock, two single instructions like the following would be enough:
What am i missing?My code provides for 600ns. Peter´provides for 1800ns.
And what is that delay right before that is 12 time even bigger?
Is he wasting time just because he didn´t use the method of polling the LCD and waiting for the not Busy state?
i haven't put the LCD up to speed yet but i´m afraid of missing something and losing a lot of time debugging.
Warm Regards,
Hugo Ferreira,
Portugal
i´m starting an egg incubator using a ds18b20 and a ks0108 based 128*64 dysplay.
Controling them is a PIC16F876A@20Mhz, which will do the temp reading,
dysplay refresh and control the heater dimmer throught a moc3020, using a PID loop.
Till now i´ve made and tested the zero crossing detection circuit. It uses a 6N139. Fully working in my dual trace analog scope.
Now, to start controling and viewing things happening i need the display working.
So far i´ve seen some sample code from Peter Onion here.
Also some code snippets in this forum. i've been around for some time,
but i've always found my questions already answered by someone in someone else´s thead.
So no need to bother anyone, till today.
I was able to take from that code the InitLCD and the ClearLCD routines.
I´ve run the code one routine at a time using some LED´s beeing the outputs.
It works, mainly because i use 1 second delays between instructions for my eyes to see it happen.
After debug i´ve taken the delays away.
I have yet to built and debug routines like ReadLCD, Write LCD, ReadData and WriteData.
Then i´ll take away the LED´s. The remaining code will be built on top of this.
Meanwhile, i have a doubt. The display's data sheet refers to 450ns (nanoseconds) enable time.
The code i´ve seen from Peter Onion has some time delays i find too big. Like this:
Code:
#define CNTLPORT PORTB
#define CNTLTRIS TRISB
#define DATAPORT PORTA
#define DATATRIS TRISA
;; For 20Mhz use 12. Can be reduced at lower clock speeds
;; For 12.288Mhz use 5 Select on test !
#define DELAY 12
;; Definitions for bits in CNTLPORT
#define CSABIT 0
#define CSBBIT 1
#define DIBIT 2
#define RWBIT 3
#define EBIT 4
#define RESETBIT 5
WSTROBE MACRO
movlw 12
movwf scratch3
decfsz scratch3,F
goto $-1
bsf CNTLPORT,EBIT ; Rising edge
IF 0
movlw 1
movwf scratch3
decfsz scratch3,F
goto $-1
ENDIF
bcf CNTLPORT,EBIT ; Falling edge
; strobes data
ENDM
In there i see him setting the enable bit for 9 clock cicles, which is correct. overkill, but correct.
since two cycles will be 400ns, for a 20MHzclock, two single instructions like the following would be enough:
Code:
movlw 12
movwf scratch3
decfsz scratch3,F
goto $-1
bsf CNTLPORT,EBIT ; Rising edge
goto $+1 ;2 cycles - 400ns
nop ;2 cycles - 200ns
bcf CNTLPORT,EBIT ; Falling edge
What am i missing?My code provides for 600ns. Peter´provides for 1800ns.
And what is that delay right before that is 12 time even bigger?
Is he wasting time just because he didn´t use the method of polling the LCD and waiting for the not Busy state?
i haven't put the LCD up to speed yet but i´m afraid of missing something and losing a lot of time debugging.
Warm Regards,
Hugo Ferreira,
Portugal