Continue to Site

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.

  • 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.

Some help with starting my first real PIC project ?

Status
Not open for further replies.

HommerSimpson

New Member
I have A pic16f1937,pic16f684,pic18f4580 some max232. And several hd74ls273p 244p 374p 245p. couple of 74hct245n And few other chips laying around.. I also have a pickit 3. And a bread board .. a 20 pin lcd **broken link removed** ...some cell phone lcds Some a/v cameras as in web and security cameras.
And I have a 3 dig 7 segment led that has 22 pins.. 1 + the other 21 are each a ground to light each segment.
Im having problems getting started.. I cant make up my mind what I want to " TRY" to build first.
Anyone willing to draw up a schematic using the parts listed for ANYTHING .. even just say hello world..make the 7 segment display count down. Anything.. Im not haveing luck finding a schematic putting anything I have together. I do have a key pad I made too. Of course I have lots of other things capacitors and resistors usb serial parallel ends ..
Thanks
Greg
 
So this is how far I have gotten. Does it even look right ?

Does this look right so far? I dont want to draw to much. yet and not even be close. I basically want to type things on the LCD from the computer. or have it show things about the computer. Does not matter.
 

Attachments

  • logicanalyzer009.jpg
    logicanalyzer009.jpg
    159.5 KB · Views: 177
Last edited:
That looks correct (except for LCD reset floating) however, you have chosen a graphic LCD. Graphic LCDs are notoriously hard to get working especially as a first project. I would advise switching to a text LCD (HD44780 based) such as this 4*20 display.

Edit, if you fill in your location other posters may be able to advise where to obtain things locally.

Mike.
 
Last edited:
Well I have the LCD now.. and well. its what I have to work with.. I have Color LCDs out of cell phones. but none I think I can get to work at moment. When I check the Design rules im getting alot of errors. Im useing tinycad.. Anyway to Auto fix this ?
 
I would really, really second that emotion that you not try to program a graphic LCD your first time out of the gate. Text LCDs aren't very expensive, so it ain't worth the headaches, even if you have a pile of free ones available.

Cut your teeth on a text output device first. Then try programming graphics. Otherwise, you'll just drive yourself nuts.
 
Have a read of the later pages of this thread for an idea of the problems people have with graphic displays. There is working code that I posted about half way through the thread but it only works with certain makes. All the manufacturers seem to make them slightly different which is why it's so difficult to get them working.

Mike.
 
time vr money

Well, I dont have the luxury of spending $ 25-30 bucks on a lcd..I do have the model number and found information on the GLCD that I have. I was hoping that's all I needed when it came time to work on the source code.
IM not looking to learn everything there is to PIC microchips. IM trying to just get as good an understanding of how all this works. My Plans are to make things that interest me not repair electronics just make a few gizmos...I have some health issues IM dealing with.. and Learning About IC chips sitting here at desk is something I can do and not be standing up..I have a lot more time on my hands then money.... And reading greek for hrs and hrs tends to get me confused sometimes.. Now if someone is willing to help me at least get this drawing done and answer some questions about tinycad that would be great.. If nobody is willing then fine...
 
SNIP.. Now if someone is willing to help me at least get this drawing done and answer some questions about tinycad that would be great.. If nobody is willing then fine...

People are willing to help you............by offering the best route to getting you started, without using obscure devices which have almost no information available.
You had the suggestion to get a HD44780 compatible LCD module, offered by myself, in your other thread https://www.electro-tech-online.com/threads/m6117b-a1-mini-board-help.119570/ and use the tried and tested PIC tutorials made by Nigel Goodwin.

The same advice is being offered within this thread, by other members with much more years of experience. You should appreciate why...

If you give us your location, we may be able to find a source for one of these inexpensive HD44780 compatible LCD modules for you. There may even be a member close by willing to lend you a hand, or point you to a store where they could be had for minimal cost.

As already stated, trying to use the GLCD you have, as a beginner and due to the extremely limited information available for it, is more likely to lead to headaches and frustration, rather than progress.
 
no idea if this will help

;*** Driver program for MG1206E4-SGL 128x64 graphics display
;*** Target: AT90S2313 at 4Mhz speed
;*** Author: Serasidis Vasilis
;*** Date : 29-07-2001
;*** Email : info@serasidis.gr
;*** web site: https://www.serasidis.gr
;
;
;
;

;*** Connections
;*** LCD CONTROLS
;*** PortB D0----> Lcd D0
;*** PortB D1----> Lcd D1
;*** PortB D2----> Lcd D2
;*** PortB D3----> Lcd D3
;*** PortB D4----> Lcd D4
;*** PortB D5----> Lcd D5
;*** PortB D6----> Lcd D6
;*** PortB D7----> Lcd D7

;*** PortD D2----> Lcd CS1
;*** PortD D3----> Lcd CS2
;*** PortD D4----> Lcd D/I
;*** PortD D5----> Lcd WR
;*** PortD D6----> Lcd E

;*** Delay40us - Delay 40 us
;*** Delay100us - Delay 100 us
;*** Delay4ms - Delay 4ms
;*** NOTE : ALL DELAYS ARE CALCULATED FOR A 4MhZ CRYSTAL

.nolist

.include "2313def.inc" ;Set 2313's data for the compiler

.list



;***** Global register variables
.def Temp=r17
.def wreg =R16 ;General use working register
.def wreg2=R18
.def CommandReg=R23
.def DataReg=R24
.def Count=R19

;EEPROM related variables

.equ lcddi =PD4 ;LCD D/I pin connected to PD4
.equ lcdrw =PD5 ;LCD r/w pin connected to PD5
.equ lcde =PD6 ;LCD e pin connected to PD6








reset:

; Setup buffers and pointers
ldi temp,RAMEND
out SPL,temp;Init Stack Pointer
;*************************************************
ldi wreg,0x00 ;PortB Low

out PORTB,wreg
ldi wreg,0xFF ;Make port B pin all outputs

out DDRB,wreg

ldi wreg,0x00 ;PortD Low

out PORTD,wreg
ldi wreg,0xFF ;Make port D pin all outputs

out DDRD,wreg
rcall Lcd_Init ;Init the LCD
ldi temp,$7
;*************************************************************
;*************************************************************



rcall Delay4ms
clr count


ldi ZH,high(msg*2)
ldi ZL,low(msg*2) ;Init Z-pointer

clr wreg
rcall command
rcall cs1
rcall next
rcall cs2
rcall next

ldi wreg,$01
rcall command
rcall cs1
rcall next
rcall cs2
rcall next


ldi wreg,$02
rcall command
rcall cs1
rcall next
rcall cs2
rcall next

ldi wreg,$03
rcall command
rcall cs1
rcall next
rcall cs2
rcall next

ldi wreg,$04
rcall command
rcall cs1
rcall next
rcall cs2
rcall next

ldi wreg,$05
rcall command
rcall cs1
rcall next
rcall cs2
rcall next

ldi wreg,$06
rcall command
rcall cs1
rcall next
rcall cs2
rcall next

ldi wreg,$07
rcall command
rcall cs1
rcall next
rcall cs2
rcall next
telos:
rjmp telos


next:
lpm ;Get next character from ROM
mov temp,R0
cpi count,$40;See if at end of message
breq cont ;If so, do next message
rcall lcdwait ;Send it
rcall write_lcd
adiw ZL,1 ;Increment Z-pointer
inc count
rjmp next ;Loop for more


cont:
clr count
ret

;********************************************************************
cs1:
Sbi PortD,2 ;Enable the CS1 of the display
Cbi PortD,3 ;Disable the CS2 of the display
ret

cs2: Cbi PortD,2 ;Enable the CS2 of the display
Sbi PortD,3 ;Disable the CS1 of the display
ret
;*********************************************************************
;*********************************************************************





;***************************************************************


; Wait for LCD to go unbusy
lcdwait:

ldi wreg,0x00;Make portB all inputs
out DDRB,wreg
sbi PORTD,lcdrw;Set r/w pin to read
cbi PORTD,lcddi;Set register select to command
waitloop:

rcall E_strobe
in wreg2,PIND;Read busy flag
sbrc wreg2,7 ;Loop until done
rjmp waitloop
ldi wreg,0xff;Make portB all outputs
out DDRB,wreg


ret


;*********************************************************************


Lcd_Init:
Sbi PortD,2 ;Enable the CS1 of the display
Sbi PortD,3 ;Enable the CS2 of the display
cbi PortD,lcddi ;Clear D/I \_
cbi PortD,lcdrw ;Clear RW / Command mode

rcall Delay4ms
ldi Wreg,$c0 ;Display start line = 0 (0-63)
Out PortB,Wreg
Rcall E_strobe


rcall Delay4ms
ldi Wreg,$40 ;Set address = 0 (0-63)
out PortB,Wreg
rcall E_strobe

rcall Delay4ms
ldi Wreg,$b8 ;Set page = 0 (0-7)
Out PortB,Wreg
Rcall E_strobe

rcall Delay4ms
ldi Wreg,$3f ;Display ON
out PortB,Wreg
rcall E_strobe
Cbi PortD,2 ;Disable the CS1 of the display
Cbi PortD,3 ;Disable the CS2 of the display
ret

;***************************************************************
;*********************************************************************
E_strobe:
sbi PortD,lcde ;E high
cbi PortD,lcde ;E low

Ret


;***************************************************************************

Write_lcd:


Sbi PortD,lcddi
Cbi PortD,lcdrw
Out PortB,temp
rcall E_strobe

ret

;*********************************************************************

command:

Sbi PortD,2 ;Enable the CS1 of the display
Sbi PortD,3 ;Enable the CS2 of the display
cbi PortD,lcddi ;Clear D/I Command mode
ldi Wreg2,$b8 ;Set page (0-7)
add wreg,wreg2
Out PortB,Wreg
Rcall E_strobe
sbi PortD,lcddi ;Set D/I Data mode

Ret

;*********************************************************************
Delay40us:
ldi r21,$40
Loop3: dec r21
brne loop3
ret
;*********************************************************************
;****
;****
;*********************************************************************
Delay100us:
ldi r21,$88
Loop: dec r21
brne loop
ret
;*********************************************************************
;****
;****
;*********************************************************************
Delay4ms:
ldi r22,$1c
Loop1: ldi r21,$00
Loop2: dec r21
brne loop2
dec r22
brne loop1
ret
;*********************************************************************
;****
;****
;*********************************************************************
LongDelay:
ldi wreg,255 ; Delay for about 1 sec for the LCD to start
Longdelay_Loop:
rcall delay4ms
dec wreg
brne LongDelay_Loop
Ret




msg: .DB 0,0,0,160,88,5,86,145,74,49,142,81,173,86,171,191
.DB 238,95,255,191,253,255,187,255,255,255,223,255,190,255,127,255
.DB 254,255,247,255,223,255,254,191,253,255,251,255,223,255,255,251
.DB 223,255,255,247,255,127,239,255,254,127,247,255,127,239,255,254
.DB 111,255,254,255,183,255,255,253,223,255,123,255,254,239,253,255
.DB 251,223,254,191,251,255,255,219,255,255,219,255,247,126,239,253
.DB 247,255,221,247,254,223,245,255,223,251,222,247,127,219,254,239
.DB 187,255,90,255,93,247,127,219,126,111,251,94,127,245,95,123
.DB 0,224,220,98,189,74,245,26,237,178,93,166,219,108,215,58
.DB 214,107,189,102,187,221,43,246,31,235,23,237,31,167,91,39
.DB 142,51,79,19,77,163,23,75,165,19,75,149,35,75,21,75
.DB 165,19,75,37,83,143,35,215,43,199,59,71,191,7,91,175
.DB 23,175,93,175,31,182,95,191,93,63,223,127,125,191,119,254
.DB 255,123,255,239,255,254,187,255,255,239,254,191,255,127,251,255
.DB 254,251,221,255,254,246,254,222,252,245,252,172,249,236,120,212
.DB 248,164,241,76,162,88,132,104,21,160,86,8,228,18,76,0
.DB 52,223,106,255,168,215,125,214,171,124,215,253,42,223,50,223
.DB 33,222,35,156,67,44,145,6,81,4,146,0,74,32,5,208
.DB 2,73,160,21,194,40,69,48,74,32,213,104,82,60,141,36
.DB 153,4,82,129,42,133,36,146,73,36,130,17,74,0,145,4
.DB 64,18,0,74,32,138,96,202,112,149,232,82,221,240,154,245
.DB 104,23,232,87,41,151,73,23,107,183,203,47,87,47,95,77
.DB 63,143,127,31,254,47,127,191,253,127,255,247,255,239,255,255
.DB 254,247,255,253,191,247,254,190,233,252,98,217,196,18,0,160
.DB 16,75,167,253,175,250,255,170,253,87,255,160,127,137,246,25
.DB 230,25,228,18,169,84,34,136,101,16,74,160,82,9,164,74
.DB 176,15,240,205,178,120,137,118,10,149,66,181,104,181,216,164
.DB 126,194,62,131,45,6,169,4,1,148,2,40,5,64,20,34
.DB 8,81,4,81,4,91,5,82,137,110,145,111,151,106,151,105
.DB 86,105,52,82,185,26,140,46,3,137,34,8,130,41,0,85
.DB 0,21,64,21,64,21,130,41,4,83,138,37,95,171,255,190
.DB 239,253,127,255,239,255,255,125,255,239,255,125,251,238,188,251
.DB 255,255,251,191,255,247,127,255,247,255,255,254,247,253,238,251
.DB 220,247,216,230,185,196,89,166,81,140,99,24,198,57,68,176
.DB 74,181,69,179,84,146,85,128,85,40,66,9,34,137,37,0
.DB 75,0,37,2,149,0,86,129,106,128,106,165,82,168,131,104
.DB 181,196,50,76,176,77,176,74,176,72,160,74,16,37,0,170
.DB 1,16,69,0,16,4,64,8,0,34,128,8,0,34,0,9
.DB 32,2,64,8,129,16,66,32,201,212,96,250,237,122,255,239
.DB 125,255,223,247,125,255,215,127,255,219,255,119,255,191,253,7
.DB 127,247,223,239,191,239,255,127,255,238,255,127,253,255,239,255
.DB 191,255,253,191,251,255,255,111,254,239,238,155,252,119,221,250
.DB 221,123,234,253,86,249,214,248,166,249,68,249,196,178,200,165
.DB 80,170,196,17,234,140,119,154,253,87,188,235,95,109,183,151
.DB 107,148,37,146,201,100,171,116,27,79,165,5,144,69,16,72
.DB 2,104,1,80,132,17,64,132,17,64,4,144,65,4,144,65
.DB 168,192,101,208,242,212,243,185,238,243,223,245,119,223,235,255
.DB 175,251,239,191,237,255,175,251,191,237,191,235,255,39,137,0
.DB 255,219,254,247,255,90,255,247,127,237,255,223,255,245,255,191
.DB 235,255,127,239,251,127,239,255,127,247,255,239,255,255,223,254
.DB 255,127,255,253,255,255,251,254,255,247,255,239,254,255,255,246
.DB 255,239,254,255,190,255,250,255,254,187,254,253,251,255,245,254
.DB 251,237,255,245,252,119,248,247,248,247,232,254,176,255,240,237
.DB 250,217,250,253,184,253,244,190,250,253,118,254,254,119,255,253
.DB 239,255,223,251,127,238,255,219,255,190,251,255,255,237,255,126
.DB 223,251,126,223,125,247,95,246,95,235,190,235,117,15,0,128
.DB 255,186,239,190,251,175,253,183,221,191,212,127,181,218,191,213
.DB 110,187,159,235,157,183,173,157,247,155,182,219,175,182,219,183
.DB 95,239,183,222,191,239,189,223,187,255,175,255,191,237,191,251
.DB 191,239,191,255,183,255,127,247,191,255,191,255,253,191,251,255
.DB 255,247,255,255,239,255,255,254,255,247,255,239,255,255,255,189
.DB 255,123,255,191,255,191,187,255,111,255,191,247,63,255,123,175
.DB 254,191,235,63,239,191,237,63,247,95,246,191,213,127,171,191
.DB 247,29,247,189,215,189,215,189,151,253,150,251,0,0,0,32
 
People are willing to help you............by offering the best route to getting you started, without using obscure devices which have almost no information available.
You had the suggestion to get a HD44780 compatible LCD module, offered by myself, in your other thread https://www.electro-tech-online.com/threads/m6117b-a1-mini-board-help.119570/ and use the tried and tested PIC tutorials made by Nigel Goodwin.

The same advice is being offered within this thread, by other members with much more years of experience. You should appreciate why...

If you give us your location, we may be able to find a source for one of these inexpensive HD44780 compatible LCD modules for you. There may even be a member close by willing to lend you a hand, or point you to a store where they could be had for minimal cost.

As already stated, trying to use the GLCD you have, as a beginner and due to the extremely limited information available for it, is more likely to lead to headaches and frustration, rather than progress.
I do understand you trying to give me the best advice you know you can.
I would rather fail 999 times out of 1000 then to succeed the first time out.
Now as far as hands on help. That would be great. I live in New Smyrna Beach Florida. That's south of DAYTONA Beach about 10 miles. I guess I should update profile.
I have a lot of patients... I do not give up easy
Thanks for offering Your best advice you know how. But no thanks.
I will figure this out.
I look at it this way. It will take me weeks to scrounge up money to buy a LCD. Then order.. Then if its anything like my last experience it will take months to get... I ordered chips from mouser... post office lost them... Mouser was nice and sent out replacements.. told me i should use fedx... ofcourse one of the big chips pic16f1937 had pins laid all the way over.
My luck is not good.. never has been...And when it comes to doing with what you have on hand... I make McGyver look bad at times.. Yes hes one of my heros :} lol
 
As you're stuck with the GLCD then let's try and get something working. Things I would change/add to your diagram,

Add a pullup to the GLCD reset line. Also think about connecting it to a pic pin so it can be reset in software.
Add the required capacitors to the crystal. If these aren't available (yet) then you can use the internal oscillator.
Add decoupling capacitors to both chips.
Depending on power supply availability, you may want to add a regulator and associated capacitors.
On a spare pin (or 2/3) add resistors and LEDs that can be lit/flashed for debugging purposes.
Think about adding an ICSP socket for programming purposes. This would require freeing up port B, so switch to port D and put ALL control lines on one port (A maybe).
That's all I can think of for now.

Edit, forgot to add, data sheet doesn't mention chip set but I think (hope) it's the KS0107/8. The code above doesn't help much as it doesn't read the display so not sure if a dummy read is needed or not.

Mike.
 
Last edited:
Yep its a KS0107B according to midas web site (half way down)..

There are plenty of examples on the web for this... I have C drivers for this, but non in assembly (probably wouldn't take to long to convert )
 
I'm not sure what language the OP is planning to use. I have C code and Assembly but the asm is for a 16F886.

Mike.
 
Thanks for the help Guys... I was planning on using C as that seams to be very common. Of course I dont know how to Program.. What IM hoping is to just get the screen to say... Hello World From HommerSimpson.
Then I can backtrack.. Look at what I built. Look at the code that was used.. and with any luck it will help me grasp what is going on.
I did do the mplab courses and well I do grasp some of it.
I have some issues reading and staying focused on what IM reading. Kinda like Reading a history book. And then when done, asked Questions on what I just read. Cant Answer.. But I can tell you what motor I just rebuilt in my Head while I was Reading LOL... ( my mind wanders. touch of ADHD I guess).
Can I upload the tinycad file and have someone fix what I have wrong then Maybe a simple explanation as to what I was doing wrong or right...?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top