Getting started with programming pics in Basic

Post here to discuss programming with swordfish basic

Moderators: Chuckt, Garth, bitfogav

FreeThinker
decided to stick around...
decided to stick around...
Posts: 25
Joined: Mon Aug 02, 2010 1:13 am
Location: UK
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by FreeThinker » Wed Aug 18, 2010 8:11 am

bitfogav wrote:
FreeThinker wrote:
bitfogav wrote:HaHa! I was just interested in this because I have used LCDs alot in assembly and I have now switched to swordfish so this would be very usefull :)

and oh yeah i dont think you can upload PDF files on this forum hehe.
Has the attachment worked?I cannot see it' but is there in preview?
No sorry buddy it hasn't worked, do you have a link to the PDF file ?
Here's a link the the site of my lcd
http://www.dataimagelcd.com/product/cm/cm.htm
just pick one of the 16 x 2 line models they are all much the same.
Machines were mice and men were Lions once upon a time........But now that it's the opposite its twice upon a time. MooNDoG

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Post by bitfogav » Wed Aug 18, 2010 8:20 am

When power is applied to the lcd display it runs its internal init routine and defaults to an 8 bit data bus with its display cleared and pointing to its first memory location.Any data received is now used to index into an internal character map and the bit pattern copied to the current cursor location and then incremented.Certain data is interperated as a command code and thedisplay switches to command mode.the next data byte is then decoded as the required action.When completed the display returns to its previous mode.You can clearly see how the function command(data) now works all you need to know now is the command code list.90% of displays are based on the industry standard hd44780 by hitachi, cloned by many others.You need to find the data sheet for your display and check.I've attached the data sheet for the lcd controller for my display which is the same as most others, page 13 has a nice table of codes.Happy reading.
PS How will these (LCD Specific) commands help with a Led Matrix, are they controlled with a hd44780?


Thanks for that FreeTinker, :)

FreeThinker
decided to stick around...
decided to stick around...
Posts: 25
Joined: Mon Aug 02, 2010 1:13 am
Location: UK
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by FreeThinker » Wed Aug 18, 2010 11:45 pm

Hi BitFogav
Being doing a little reading of the hd44780 data sheet when I was struck by a thought.Character codes 0 to 7 are user defineable in 5x7 blocks.My idea was to write the user graphic off screen, scroll it in to view and reload the graphics ram with fresh data in a loop. :twisted: You now have dot addressable display on an alphanumeric screen (sort of :lol: ).Once you write data to the screen (say char0) you can then change char0 and the original data remains the same.so you could in effect have a large bit map in an array that you blit to the screen 280 dots at a time.Limitations would be band width of display which I think is 250khz and the dot spacing of the display but it's a fasinating thought...... :twisted: :twisted: :twisted: Vertical dot size scroll could also achieved by pointer manipulation into the array.It would be like those large screen displays on the tv made up of lots of smaller screens!!!!!....or should you just buy a graphic lcd and be done with it?.Damm I hate it when these thoughts pop in my head Lol
Machines were mice and men were Lions once upon a time........But now that it's the opposite its twice upon a time. MooNDoG

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by brad » Fri Aug 20, 2010 12:06 am

Some really neat info there :)

I had a look on ebay recently and found you can get graphic LCD displays for around $5 with free postage. I think they were something like 128 x 64 pixels maybe?

FreeThinker
decided to stick around...
decided to stick around...
Posts: 25
Joined: Mon Aug 02, 2010 1:13 am
Location: UK
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by FreeThinker » Fri Aug 20, 2010 1:33 am

brad wrote:Some really neat info there :)

I had a look on ebay recently and found you can get graphic LCD displays for around $5 with free postage. I think they were something like 128 x 64 pixels maybe?
Arrrh! Pains in the chest.... Think it's constriction of the wallet :shock: :lol: :lol: :lol:
Seriously I was only thinking out loud, but it appeals to my hardware hacking ethos to get a piece of kit to perform outside it's normal limits (even if it is not very practical or cost effective).The possiblility of Graphics on an alphanumeric display appeals.If this is possible or not I don't know, the therory seems sound but I know very little about user defined graphics at the moment.I remember many years ago (about 1980/81) a program for the sinclair zx80 was made by a 14 year old kid that put a HiRes image on the screen by remapping the charachter generator Rom into ram and mapping the image into it, everyone seid it was impossible to do but he did it, took hours to run was very limited in use but it worked.I like things like that.
Machines were mice and men were Lions once upon a time........But now that it's the opposite its twice upon a time. MooNDoG

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by brad » Fri Aug 20, 2010 10:38 pm

He he, very good. I guess it's half the fun making hardware do things that it wasn't actually intended to do!

Be sure to keep us updated with it because you have now sparked my interest :)

FreeThinker
decided to stick around...
decided to stick around...
Posts: 25
Joined: Mon Aug 02, 2010 1:13 am
Location: UK
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by FreeThinker » Tue Aug 24, 2010 5:48 am

Ok not had much time to play but here is an update of what I havedone so far.Using sword fish I created four sets of 8*8 user graphics.Then using four for next loops I printed the graphics 8 at a time to the lcd ending up with 32 user graphics on the screen at the same time.I now know that the theory works and the user graphics can be switched in 'realtime'.Next step is to create a large array and index into it for the graphic data, struggling a bit at the moment understanding the way swordfish handles things, more reading and playing required.Attached code example of my first attempt.NOTE it does NOT simulate well in Isis (But we will not go there will we :lol: :lol: ), I've simulated it in PIC18 Simulator from Oshon and it works as expected :wink:

http://www.bradsprojects.com/phpBB2/download.php?id=165
Attachments
udgtest.zip
(875 Bytes) Downloaded 754 times
udgtest.zip
(875 Bytes) Downloaded 759 times
Last edited by FreeThinker on Tue Aug 24, 2010 5:59 am, edited 1 time in total.
Machines were mice and men were Lions once upon a time........But now that it's the opposite its twice upon a time. MooNDoG

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Post by bitfogav » Tue Aug 24, 2010 5:56 am

Just update your last comment FreeThinker so we could see the file that you attached :)

So it is possiblse to make more than 8 user graphics on a LCD? :)

Here is FreeTinkers swordfish code:

Code: Select all

// if device and clock are omitted, then the compiler defaults to 
// 18F452 @ 20MHz - they are just used here for clarity...
Device = 18F452
Clock = 20

// some LCD options...
#define isis_used
#option LCD_DATA = PORTD.4
#option LCD_RS = PORTE.0
#option LCD_EN = PORTE.1

// import LCD library...
Include "LCD.bas" 
Include "utils.bas"


                                 
Const Bottom_Left(64) As Byte = ($00,$1F,$11,$15,$11,$1D,$1D,$1F,   // LCD.Write(0)
                                 $00,$1F,$1B,$15,$15,$11,$15,$1F,   // LCD.Write(1)
                                 $00,$1F,$11,$15,$13,$15,$11,$1F,   // LCD.Write(2)
                                 $00,$1F,$11,$15,$17,$15,$11,$1F,   // LCD.Write(3)
                                 $00,$1F,$13,$15,$15,$15,$13,$1F,   // LCD.Write(4)
                                 $00,$1F,$11,$17,$13,$17,$11,$1F,   // LCD.Write(5)
                                 $00,$1F,$11,$17,$13,$17,$17,$1F,   // LCD.Write(6)
                                 $01,$1F,$0D,$13,$13,$0D,$1F,$1F)   // LCD.Write(7)
Const Top_Left(64) As Byte = ($1F,$00,$0E,$0A,$0E,$02,$02,$00,   // LCD.Write(0)
                               $1F,$00,$04,$0A,$0A,$0E,$0A,$00,   // LCD.Write(1)
                               $1F,$00,$0E,$0A,$0C,$0A,$0E,$00,   // LCD.Write(2)
                               $1F,$00,$0E,$0A,$08,$0A,$0E,$00,   // LCD.Write(3)
                               $1F,$00,$0C,$0A,$0A,$0A,$0C,$00,   // LCD.Write(4)
                               $1F,$00,$0E,$08,$0C,$08,$0E,$00,   // LCD.Write(5)
                               $1F,$00,$0E,$08,$0C,$08,$08,$00,   // LCD.Write(6)
                               $1F,$01,$13,$0D,$0D,$13,$01,$01)   // LCD.Write(7)
Const Top_Right(64) As Byte = ($1F,$10,$14,$14,$14,$14,$14,$10,   // LCD.Write(0)
                                $1F,$00,$0E,$02,$04,$08,$0E,$00,   // LCD.Write(1)
                                $1F,$00,$0E,$02,$0E,$02,$0E,$00,   // LCD.Write(2)
                                $1F,$00,$08,$0A,$0E,$04,$00,$00,   // LCD.Write(3)
                                $1F,$00,$0E,$08,$0E,$02,$04,$00,   // LCD.Write(4)
                                $1F,$00,$0E,$08,$0E,$0A,$0E,$00,   // LCD.Write(5)
                                $1F,$00,$0E,$02,$04,$08,$08,$00,   // LCD.Write(6)
                                $1F,$00,$0E,$0A,$04,$0A,$0E,$00)   // LCD.Write(7)
Const Bottom_Right(64) As Byte = ($10,$1F,$1B,$1B,$1B,$1B,$1B,$1F,   // LCD.Write(0)
                                  $00,$1F,$11,$1D,$1B,$17,$11,$1F,   // LCD.Write(1)
                                  $00,$1F,$11,$1D,$11,$1D,$11,$1F,   // LCD.Write(2)
                                  $00,$1F,$17,$15,$11,$1B,$1F,$1F,   // LCD.Write(3)
                                  $00,$1F,$11,$17,$11,$1D,$1B,$1F,   // LCD.Write(4)
                                  $00,$1F,$11,$17,$11,$15,$11,$1F,   // LCD.Write(5)
                                  $00,$1F,$11,$1D,$1B,$17,$17,$1F,   // LCD.Write(6)
                                  $00,$1F,$11,$15,$1B,$15,$11,$1F)   // LCD.Write(7)

                                  
Dim index As Byte
Dim char_ As Byte                                  

// clear screen...
ADCON1 = $07 // PORTE as digital (LCD)
Write(Top_Right)
char_ = 0
For index = 1 To 8
WriteAt(1,index,(char_))
char_ = char_ + 1
Next 
char_ = 0
Write(Top_Left)
For index = 9 To 16 
WriteAt(1,index,(char_))
char_ = char_ + 1
Next

Write(Bottom_Right)
char_= 0 
For index = 1 To 8
WriteAt(2,index,(char_))
char_ = char_ + 1
Next 
Write(Bottom_Left)
char_ = 0
For index = 9 To 16 
WriteAt(2,index,(char_))
char_ = char_ + 1
Next

FreeThinker
decided to stick around...
decided to stick around...
Posts: 25
Joined: Mon Aug 02, 2010 1:13 am
Location: UK
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by FreeThinker » Tue Aug 24, 2010 6:07 am

Yes and No.What i am doing is writing 8 graphics to the screen updating the graphic data writing that to the screen etc.Once a User Defineable Graghic (UDG) is written to the screen it can be changed without altering what is on the screen so you can have any number of UDG's displayed but only 8 in use at anyone time.
PS sorry about the attachment forgot to press submit after I added it, will get used to it soon!
Machines were mice and men were Lions once upon a time........But now that it's the opposite its twice upon a time. MooNDoG

FreeThinker
decided to stick around...
decided to stick around...
Posts: 25
Joined: Mon Aug 02, 2010 1:13 am
Location: UK
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by FreeThinker » Tue Aug 24, 2010 6:15 am

Thanks for that Bitforgav.The code may look a little strange but was witten that way to ease debugging, I simply comment out sections when testing (Especially in Isis).Hope to create an interupt driven 'Blitter' to write the screen with the array manipulation handled in the main loop, Don't expect speed to be great screen updating is quite slow and the display is only 250khz.
Machines were mice and men were Lions once upon a time........But now that it's the opposite its twice upon a time. MooNDoG

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by brad » Tue Aug 24, 2010 10:06 pm

That is really impressive!

I know exactly what you mean about the screen refresh rate though. I seem to get quite a bit of 'ghosting' from the transition of one screen of text to another.

Having said that, it displays static text just fine. I.E. without any flicker.

FreeThinker
decided to stick around...
decided to stick around...
Posts: 25
Joined: Mon Aug 02, 2010 1:13 am
Location: UK
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by FreeThinker » Wed Aug 25, 2010 7:47 am

brad wrote:That is really impressive!

I know exactly what you mean about the screen refresh rate though. I seem to get quite a bit of 'ghosting' from the transition of one screen of text to another.

Having said that, it displays static text just fine. I.E. without any flicker.
The hardware varies so much between manufacturers its difficult to predict results.This will be yet another area that needs careful research,they may all have the same functionality but how they achieve this is up to the maker.As I may of seid previously I can only simulate the code as I do not have an 18F platform to work on at the moment only 16F.The flicker you are seeing could be due to the cursor being overprinted by the UDG's I have not turned it off yet, thanks for that! The Lcd Screen does not refresh as such ie once data is written to the screen it is latched as long as the power is on unlike a monitor where the data needs to be rewritten at say 60hz so that your eyes 'see' a static image.I have a 4 line display on order Which should be double the fun.Will need to get a 18f dev board up and running as well so I've got some work to do over the next week or so.
Machines were mice and men were Lions once upon a time........But now that it's the opposite its twice upon a time. MooNDoG

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by brad » Thu Aug 26, 2010 10:42 pm

I have to say, you certainly know what you're talking about with these displays!

You're certainly bring some great knowledge to the forum and look forward to what you achieve when you get the 18f dev board. :)

FreeThinker
decided to stick around...
decided to stick around...
Posts: 25
Joined: Mon Aug 02, 2010 1:13 am
Location: UK
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by FreeThinker » Thu Aug 26, 2010 11:43 pm

Hi,
Have a read of these pdf's on LCD's.Now thats what I call cool! :twisted:
http://www.epemag.wimborne.co.uk/resources.htm
Machines were mice and men were Lions once upon a time........But now that it's the opposite its twice upon a time. MooNDoG

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Post by brad » Sun Aug 29, 2010 10:00 pm

thanks buddy, I downloaded the pdf and am surprised that these LCD's have been around for that long.

Having said that, I guess people have been programming pic microcontrollers for many years now :)

A good read, thanks again for the link!

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 7 guests