Thursday, January 12, 2023

Solar Shed - A Beginning

The Controller

As a distraction from my long term projects, I decided to start working on a usable version of the Solar Charger for the Shed. Right now it is just an LT1085 3 terminal regulator set to 14.4VDC. The Solar Panel puts out up to 24 VDC Open circuit, but will fall dramatically when current is drawn. So the LT1085 output just follows the input with a 1.5 volt drop when the input voltage drops below ~16VDC. When the battery is fully charged, it seems to trickle charge just fine at 14.4VDC.

My idea for this is to add some relays and a PIC to monitor voltage. When the battery voltage gets to 14.4VDC, the solar panel/ LT1085 is disconnected. When the battery drops below 14VDC, the panel is reconnected. Or some numbers similar to that. The idea is to protect the battery from excessive voltage. This is basically what a battery charging circuit would do. Just an extra safety check so I dont have to worry about this.

Time to move on to a design I can install.  This is definitely a one off.  Thus I am looking for an inexpensive solution.  I have multiple Microchip Development boards that I no longer use, so that seems like the place to start.  Additionally I have several OLED displays.  

The Development board I chose was the CURIOSITY HIGH PIN COUNT (HPC) DEVELOPMENT BOARD, DM164136.  This has a PIC18F47K40 ( which cannot be bought right now, maybe later in 2023).  This has two MIKROE CLICK board sockets on it, which goes well with the several OLED Click boards I have.  So I started out to get the OLED to work, then I would need to build a small perf board addon for the LT1085, relays and connections.  This seemed easy and quick. 

Well......................the first step took over 3 days on and off.  I could not get the OLED to display any text.  The FONT file is placed in program FLASH memory, because it is much bigger than the available RAM on this PIC.  I finally drilled down into the C compiler generated assembly code to watch the TBLRD opcode always show a read of 0x00.  I double checked the FLASH to verify the FONT file was there.  Something kept nagging at me that I needed something else to make this work.

Off to search the Internet.  After tooooo many hours, I stumbled on a comment that you need to read the errata.  In this always useful document, was a known defect on one version (my version of course) that the TBLRD opcode did not work unless a certain two bits in a certain register were set correctly, not the reset value as the data sheet says.  And then it came back to me that I had the same problem before with this PIC and the Dev board the first time I did this. For some reason the fix was not in the code I thought worked when I started this a few days ago.

In the end I am now going to package up the OLED code and place it in the repository so I have this for future OLED Projects

And just to make it more fun, I spent one morning trying to understand the color pattern.  It has a 5-6-5 (RGB but maybe BGR, SW controlled) pattern to keep it to 16 bits and 65K.  But it is also inverted this pattern in the OLED controller, so you have to put the inverted value in.  Too many variables, but i found the right order and the bit pattern to finally get something out of it.  Plus there were some hard coded sections in the driver that needed fixing from the last time I worked on this.  But I am declaring victory.  I got 4 lines, with no reading glasses required, and about 8 characters, which should be enough.  R-G-B is OK, but the intermediate colors are off.  Last line is supposed to be yellow and white looks awful pink.  The OLED also has a burned in pattern at times from previous use, which might be why the intermediate colors are off.  But again, good enough for this.

And here is the chosen OLED, (OLED-C MIKROE 1585) working.


 



No comments:

Post a Comment