Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 20th April 2008, 02:13 AM   (permalink)
Default ks0108b/ks0107 controller combo

I was googling for some tutorials on how to interface this particular glcd with a PIC18F452, and I came across a few threads in here. I started digging through the forum and came across that Unicorn example from Pommie, and I read through it and realized he was using a ks0108, not a ks0108b. Is the b version that different where if I were to port his code to an 18F452 that it wouldn't work? ..because I tried out of curiosity and wasn't getting _any_ output.

I'm using the same compiler he is.

Cheers!
desaila is offline   Reply With Quote
Old 20th April 2008, 02:50 AM   (permalink)
Default

Quote:
Originally Posted by desaila
I was googling for some tutorials on how to interface this particular glcd with a PIC18F452, and I came across a few threads in here. I started digging through the forum and came across that Unicorn example from Pommie, and I read through it and realized he was using a ks0108, not a ks0108b. Is the b version that different where if I were to port his code to an 18F452 that it wouldn't work? ..because I tried out of curiosity and wasn't getting _any_ output.

I'm using the same compiler he is.
I just did a quick buzz thru the ks0108b datasheet and it sure looks familiar. I just recently wired up and wrote software for a GLCD with KS0108B on it. It may possibly help you.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 20th April 2008 at 02:53 AM.
futz is offline   Reply With Quote
Old 20th April 2008, 02:52 AM   (permalink)
Default

I was actually reading your post, and the exchange you and Pommie had futz, thanks for the link I'll scope it out.
desaila is offline   Reply With Quote
Old 22nd April 2008, 10:34 PM   (permalink)
Default

Quote:
Originally Posted by futz
I just did a quick buzz thru the ks0108b datasheet and it sure looks familiar. I just recently wired up and wrote software for a GLCD with KS0108B on it. It may possibly help you.

Tried it out, and I have literally _nothing_ showing up on the display. I ported it to MCC18, but that just involved changing some tris statements to match the ones I am using (TRISB for data and TRISA for the modal pins like chip select, etc).

I hooked up an oscilloscope to a few of the data pins, and _tons_ of data is moving over them.

But ya, data is hooked up to PORTB, and the chip select and other modes are wired to PORTA. This is all on a pic18f452. Like i said, code is identical to yours... although I'm not sure what you're setting up in that #pragma at the start and that could be part of the reason.
desaila is offline   Reply With Quote
Old 22nd April 2008, 10:35 PM   (permalink)
Default

Tried it out, and I have literally _nothing_ showing up on the display. I ported it to MCC18, but that just involved changing some tris statements to match the ones I am using (TRISB for data and TRISA for the modal pins like chip select, etc).

I hooked up an oscilloscope to a few of the data pins, and _tons_ of data is moving over them.

But ya, data is hooked up to PORTB, and the chip select and other modes are wired to PORTA. This is all on a pic18f452. Like i said, code is identical to yours... although I'm not sure what you're setting up in that #pragma at the start and that could be part of the reason.
desaila is offline   Reply With Quote
Old 22nd April 2008, 10:42 PM   (permalink)
Default

Quote:
Originally Posted by desaila
Tried it out, and I have literally _nothing_ showing up on the display. I ported it to MCC18, but that just involved changing some tris statements to match the ones I am using (TRISB for data and TRISA for the modal pins like chip select, etc).

I hooked up an oscilloscope to a few of the data pins, and _tons_ of data is moving over them.

But ya, data is hooked up to PORTB, and the chip select and other modes are wired to PORTA. This is all on a pic18f452. Like i said, code is identical to yours... although I'm not sure what you're setting up in that #pragma at the start and that could be part of the reason.
Impossible for me to say without seeing your code and schematic.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline   Reply With Quote
Old 22nd April 2008, 11:22 PM   (permalink)
Default



ok, so in that picture PORTB-RB0 -> DB0; PORTB-RB7->DB7 (0 goes to 0, 1 goes to 1, etc) for the data.

for the other pins, D/I -> RA2, R/W -> RA1, E->RA0, CS1->RA3, CS2->RA4, RESET->RA5.

code is attached. I REALLY appreciate the help. I hope the schematic isn't too confusing, I just whipped it up in Visio as fast as I could seeing as you're "around."

Also, all the power sources, VDD, etc are 5 volts. The VEE is hooked up to a potentiometer and is getting ~1-2 V.

I think the problem might lie in the #pragma statement, because I didn't modify it at all, and am not positive what you're doing there. I was just hoping to get _something_ to display so I could study how you were doing it.

Again, thanks for any help you might be able to provide.
Attached Files
File Type: zip glcd.zip (2.0 KB, 13 views)

Last edited by desaila; 22nd April 2008 at 11:24 PM.
desaila is offline   Reply With Quote
Old 23rd April 2008, 12:04 AM   (permalink)
Default

I think you need to change your #defines to use the latch rather than the port.

Code:
#define	DI        LATAbits.LATA2
You will however have to keep portb in your Busy routine as this is a read.

Mike.
Pommie is online now   Reply With Quote
Old 23rd April 2008, 12:34 AM   (permalink)
Default

i have some experience with the pic18f452, but not a whole lot. i've never used the "lat" before and never saw them used until a glcd example in code of your's pommie. what's the motivation for lat's?
desaila is offline   Reply With Quote
Old 23rd April 2008, 12:54 AM   (permalink)
Default

Quote:
Originally Posted by desaila
i have some experience with the pic18f452, but not a whole lot. i've never used the "lat" before and never saw them used until a glcd example in code of your's pommie. what's the motivation for lat's?
My code was written for a 16F877, which has no LAT registers. They were added when the 18F's came along, I believe. Here's my simplified explanation from another thread:
Quote:
Normally you should use LATA/B/C/D/E for outputting to ports. It's a "shadow register" or "latch register". Using it avoids a problem that sometimes happens known as the Read/Modify/Write problem that happens if you write directly to one bit of a port like PORTA and immediately write to another different bit of the same port. Sometimes the first bit is still in the process of changing and when you write the second one so quickly the first one gets messed up. Using the latch register fixes that completely.
Anyway, I doubt if this code will have any problem writing directly to the ports when running on an 18F, but it would be better to use LATs just in case.

Desaila, I haven't even looked at either the schematic or the code yet. Was having a nap. Now I'll have food. Then I'll look.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline   Reply With Quote
Old 23rd April 2008, 01:01 AM   (permalink)
Default

Fair enough. This is for a big projec that's due in ~2 weeks. I have all the rest of the stuff done, RFID, MMC, but the glcd is really giving me a headache. I definitely appreciate this forum and everything I've seen on it.
desaila is offline   Reply With Quote
Old 23rd April 2008, 01:10 AM   (permalink)
Default

Desaila,

Futz is probably right and the Latch/Port probably won't matter but safer to change it just in case.

Have you turned off any analogue ports? (ADCON1=0x06 for the 18F452)

Mike.
Pommie is online now   Reply With Quote
Old 23rd April 2008, 01:11 AM   (permalink)
Default

No, I haven't turned any off. Why would that matter? (not disagreeing wtih you, but I'm curious)
desaila is offline   Reply With Quote
Old 23rd April 2008, 01:15 AM   (permalink)
Default

Analogue pins work fine as digital outputs but always read back zero when you access the Port register. This really messes up any bit read/write operations.

Mike.
Pommie is online now   Reply With Quote
Old 23rd April 2008, 02:31 AM   (permalink)
Default

Quote:
Originally Posted by desaila
Again, thanks for any help you might be able to provide.
Well, right off the bat I have to say this #pragma
Code:
#pragma DATA _CONFIG, _CP_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC & _LVP_OFF
is almost certainly wrong for an 18F. 18Fs have seven config words, whereas the 16Fs I wrote for only have one. Your compiler MUST have been at least warning you. It should have given you major errors.

Here's a set of typical BoostC pragmas for an 18F452
Code:
#pragma DATA    _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
#pragma DATA    _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_OFF_2L
#pragma DATA    _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
#pragma DATA    _CONFIG3H, _CCP2MX_ON_3H
#pragma DATA    _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
#pragma DATA    _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
#pragma DATA    _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
#pragma DATA    _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
#pragma DATA    _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
#pragma DATA    _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
#pragma DATA    _CONFIG7H, _EBTRB_OFF_7H
And here's a minimum one that I use mostly:
Code:
#pragma	CLOCK_FREQ	32000000
#pragma DATA    _CONFIG1H, _OSC_INTIO67_1H
#pragma DATA    _CONFIG2H, _WDT_OFF_2H
#pragma DATA    _CONFIG3H, _MCLRE_ON_3H
#pragma DATA    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
That CLOCK_FREQ line is so the delay lib calculates delays correctly.

All the above assumes BoostC. Your compiler may have different syntax.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 23rd April 2008 at 02:34 AM.
futz is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
COnnecting 2 telephone Sets via optical coupler waqar General Electronics Chat 4 20th April 2008 03:07 AM
Xbox 360 Tilt Controller adamthole Electronic Projects Design/Ideas/Reviews 0 20th January 2007 05:24 PM
closed loop controller that receives set point updates TXRX usacanbiteme Electronic Projects Design/Ideas/Reviews 5 28th September 2005 09:02 PM
Motor controller for a e-motor/generator Combo dreamtoys Electronic Projects Design/Ideas/Reviews 1 3rd October 2003 11:42 PM
Help With Temperature Controller bryan Electronic Projects Design/Ideas/Reviews 4 30th June 2003 12:18 PM



All times are GMT. The time now is 05:21 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.