View previous topic :: View next topic |
Author |
Message |
Khansokhua
Joined: 06 Nov 2021 Posts: 92
|
PIC16F877A with GLCD (HDM64GS12 with KS01108) |
Posted: Mon Dec 06, 2021 7:35 am |
|
|
Hi! Greetings. This is the project I have to do:
Required process: "Design a slide showing system using PIC16F877A with GLCD"
Step 1:"I want to select pictures and set the time process from stored logos in microcontroller memory. For this, the selection process will be initialized with a setting button/switch by microcontroller"
Step 2:"..
I understood that I will show on GLCD some pictures with a stated time. However, what does these means" select pictures and set the time process from stored logos" and "initialized with a setting button/switch". Can someone clearly explain what must I do exactly? Please guide me wisely, thanks and respects. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9240 Location: Greensville,Ontario
|
|
Posted: Mon Dec 06, 2021 7:42 am |
|
|
I think the following...
First ...consider that you have 10 pictures in memory
You're required to select some pictures (example #1,4,5,9).
Also required to select a time to display each picture.
Perhaps #4 needs to be seen for 4 seconds, #9 for 2 seconds
Once the required pictures and display times have been selected THEN 'press a key' to 'run the slideshow'. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Mon Dec 06, 2021 11:27 am |
|
|
Seriously, you are not going to be able to do this.
Microcontroller memory is _small_. Especially on an old chip like you
are referencing. On a big DsPIC, this might be possible, but not on a
PIC16. A single screen, is going to be 8KB. For 10 pictures this becomes
80KB. Then you have a second problem that the PIC you mention is
a 5v device. This is a 3.3v LCD.
The PIC here has enough ROM memory to hold just one screen. Nothing
else (no space for code then!...). You need a 3.3v PIC, with perhaps at
least a dozen times the ROM space to be able to do this.
You need to rethink your device choices.
Also where are the pictures actually going to code from?. If you are
loading them from something like serial, then they need to be stored
in RAM not ROM. This PIC has enough RAM for just two lines of the screen.
A much bigger device is needed however you intend to do this, and
preferably a 3.3 version. |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Mon Dec 06, 2021 11:47 am |
|
|
Quote: |
A single screen, is going to be 8KB
|
8kilobits/1kilobyte? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9240 Location: Greensville,Ontario
|
|
Posted: Mon Dec 06, 2021 12:25 pm |
|
|
Yes 8Kb. 128x64 bits for a FULL screen.
However...... it doesn't say that a 'picture' HAS to be a full screen, so you could get several small 'pictures' into the memory of that PIC. Numbers and letters are 'pictures', collections of pixels. Of course you'll need to properly interface the PIC to GLCD. |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Mon Dec 06, 2021 2:55 pm |
|
|
What I wanted to say is that one full screen takes 1kB of data. This PIC has 8kB of memory. Not much, but it might be possible to squeeze 3 or 4 full images into it and leave enough space for the actual code to create some kind of slide show. The basic drawing of one circle and one rectangle takes 12% of ROM with the code below. I have yet to research how to draw a bitmap to this kind of a display (since I never used one of those), just out of curiosity.
Code: |
#include <main.h>
#include <hdm64gs12.c>
#include <graphics.c>
void main(){
while(TRUE)
{
glcd_init(ON); // Must initialize the LCD
glcd_rect(1, 5, 126, 15, NO, ON); // Outline the bar
glcd_circle(30, 47, 10, NO, ON); // Draw the clock circle
delay_ms(1000); // Reduces flicker by allowing pixels to be on
}
}
|
If someone could give me a hint how to do that and how to organize the bitmap, I'd be grateful (there also seem to be some limitation about the size of it, it can't be 1024 bytes in one piece on this chip). I do know how to use search engine and I got many results, but it would be nice to know the easiest way :-) |
|
|
Khansokhua
Joined: 06 Nov 2021 Posts: 92
|
|
Posted: Mon Dec 06, 2021 6:46 pm |
|
|
I downloaded a converter program named Image2lcd. Here, I can obtain .c and .h file of pictures. As using this array, I can write functions and display the picture. What if I declare " #include <name.h>" ? Can I call this file into GLCD ? Is that something like that possible? Maybe it is ridiculous:)
After I solve this display's issues, I will come here soon. I hope I can do. Respects |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Tue Dec 07, 2021 1:50 am |
|
|
He still has the problem of a 3.3v device and a 5v PIC. Honestly the code to
talk to the screen and offer a menu etc., is going to use a lot of that PIC's
memory. Won't leave space for more than a couple of tiny pictures. |
|
|
Khansokhua
Joined: 06 Nov 2021 Posts: 92
|
|
Posted: Tue Dec 07, 2021 5:45 am |
|
|
I can choose just PIC16 and PIC18 series.What would you suggest me?I decided for PIC18F4550. Should I change the GLCD too? |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Tue Dec 07, 2021 6:02 am |
|
|
I used the code and bitmap found here:
http://www.ccsinfo.com/forum/viewtopic.php?t=37200
It takes 19% of ROM for one picture on 16f877A. 18f4550 has 4x the code memory, but doesn't work on 3,3V. You should either choose a PIC that supports 3,3V or GLCD that works on 5V. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9240 Location: Greensville,Ontario
|
|
Posted: Tue Dec 07, 2021 6:20 am |
|
|
I'd use the PIC18F46K22 instead of the PIC18F4550. Actually i've only used the 46k22 for my project/products for years now.
It has 4x the memory (64k vs 16k)
Runs faster, full VDD range( 64MHz at 3 volts or 5 volts
While the 4550 has builtin USB, the required 'driver' for that can use 1/4 to 1/3rd of the memory space. So... 8 pix=8KB, usbdvr = 4KB, would only leave 4KB for your program...you might run out of space !
The 46K22 wil directly connect to the GLCD (and any other 3V peripheral) when run at 3 volts. So, no 'logic level' conversion parts are required. That means an easier project to wire up and debug.
The 46K22 has a large amout of internal perhipherals, that while you don't need now, future projects may require them. It's nice to use one PIC for all.
It's been a reliable and stable PIC over the years and I've yet to run out of pins or memory yet. The 26k22 is the smaller version,but I still use the 40 pinner.
There are newer PICs,but I've built a library of known,good, WORKING code for several external peripherals like LCD,KBD,KPD,sensors, etc. This makes it fast to create new projects. |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Tue Dec 07, 2021 6:30 am |
|
|
Very true. The same code compiled for 18f46k22 takes 3% of ROM. |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Tue Dec 07, 2021 6:34 am |
|
|
Code: |
void glcd_imagen(){
char i,j;
signed char k;
for( i = 0 ; i < 64 ; i ++ )
{
for( j = 0 ; j < 16 ; j ++)
{
for(k=7;k>-1;k--)
{
if( bit_test(imagen[i][j] ,7-k ))
glcd_pixel( j*8+k,i, ON );
}
}
}
}
|
How can I transform this function to take the name of the bitmap as a parameter so that it can be reused for multiple bitmaps? This one displays only a specific "const int8 imagen[64][16]" ? |
|
|
Khansokhua
Joined: 06 Nov 2021 Posts: 92
|
|
Posted: Tue Dec 07, 2021 6:41 am |
|
|
I follow your advice Dear temtronic, I have made decisions that I had got to. So, next step what would you say:
Quote: | I downloaded a converter program named Image2lcd. Here, I can obtain .c and .h file of pictures. As using this array, I can write functions and display the picture. What if I declare " #include <name.h>" ? Can I call this file into GLCD ? Is that something like that possible? Maybe it is ridiculous:) |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Tue Dec 07, 2021 7:15 am |
|
|
The 46K22, is a much better choice. Key 'big thing' is that the PIC18 can
store two bytes per instruction word against the PIC16 only storing one.
Makes the memory even more effective.
On the array, you can have a two dimensional array and pass the
second index to the function, so you can select which index to display. |
|
|
|