CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC16F877A with GLCD (HDM64GS12 with KS01108)
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Khansokhua



Joined: 06 Nov 2021
Posts: 92

View user's profile Send private message

PIC16F877A with GLCD (HDM64GS12 with KS01108)
PostPosted: Mon Dec 06, 2021 7:35 am     Reply with quote

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: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Dec 06, 2021 7:42 am     Reply with quote

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: 19496

View user's profile Send private message

PostPosted: Mon Dec 06, 2021 11:27 am     Reply with quote

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: 478
Location: Montenegro

View user's profile Send private message

PostPosted: Mon Dec 06, 2021 11:47 am     Reply with quote

Quote:

A single screen, is going to be 8KB


8kilobits/1kilobyte?
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Dec 06, 2021 12:25 pm     Reply with quote

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: 478
Location: Montenegro

View user's profile Send private message

PostPosted: Mon Dec 06, 2021 2:55 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 06, 2021 6:46 pm     Reply with 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:)

After I solve this display's issues, I will come here soon. I hope I can do. Respects
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Dec 07, 2021 1:50 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 07, 2021 5:45 am     Reply with quote

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: 478
Location: Montenegro

View user's profile Send private message

PostPosted: Tue Dec 07, 2021 6:02 am     Reply with quote

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: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Dec 07, 2021 6:20 am     Reply with quote

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: 478
Location: Montenegro

View user's profile Send private message

PostPosted: Tue Dec 07, 2021 6:30 am     Reply with quote

Very true. The same code compiled for 18f46k22 takes 3% of ROM.
PrinceNai



Joined: 31 Oct 2016
Posts: 478
Location: Montenegro

View user's profile Send private message

PostPosted: Tue Dec 07, 2021 6:34 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 07, 2021 6:41 am     Reply with quote

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: 19496

View user's profile Send private message

PostPosted: Tue Dec 07, 2021 7:15 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group