Showing posts with label Battery charging. Show all posts
Showing posts with label Battery charging. Show all posts

Tuesday, March 21, 2023

Solar Shed Update 2


 This is a really quick update.  The weather has been very cloudy the past few days.  So I disconnected the solar panel from the circuit.  The battery was at 14.40 VDC.  Three days later when I checked the battery, it was at 13.45VDC.  So it is obviously going to last one night and may last many days with little sun.

I have made the changes I discussed in the last Update Post.  They are installed, but there are issues.  This means I really need to take the laptop out to the shed and work on it there.  Most importantly the LED lighting turns on now. But it won't turn off.  The OLED does display the counts as an alternate screen, but it is updating too fast.  

Finally based on the voltge drop over 3 days, not sure what the super cap is going to add.  What it will do is stretch the battery out.  So if there is no solar power for many days and the LED lighting is used, it will stretch the battery in those circumstances.  Under normal operation, it is just providing a surge for the circuit.


Thursday, March 16, 2023

Solar Shed Update


 

A quick update on the Solar Shed progress.  The snow has melted and there is some sun.  I have not been formerly taking down readings, but in general the battery has charged to slight over 14VDC on it at the day and about 13.8VDC in the morning.  Which is comparable to what I saw on the bench.

Moving to the real world is always going to bring on new issues.  What problems did I have, well πŸ˜›

  • For the switch that turns on the LED Lighting, for some reason the weak pullups on that input was off.  The overhead LED  lights would go on and off randomly.  I was never a fan of those weak pullups, not sure why I did not just put a 10K or 100K pullup there.  Space and cost were not a driving factor.
  • Next this switch does not wake up the PIC.  When is the PIC sleeping, at night .  When do I need the light, at night.  It is a simple fix, but I am waiting to gather more changes before fixing this.
  • I had added a relay for selecting power source for PIC and etc, from either the battery or the solar panel.  I implemented the logic to use the Solar Panel as the power source whenever it is above about 8VDC.  But forgot to change the TRIS register for the drivers to an output.  No wonder I could not drive the relay to change the source.  Now as long as there is sufficient solar panel voltage, that powers the PIC and etc.
  • All of the conversion constants moved a little, again.  1% resistors are nice, but they are still only 1% accurate.  Another change is to add an OLED screen that shows the ADC count instead of a calculated voltage.  Maybe that will help refine the conversion chart I showed earlier.
  • The 7.5F supper cap took over 2 mins to charge the first time.  I thought there was a short somewhere since the voltage would not rise.  Then I remembered that an uncharged cap is a short. 

I have been thinking of a good test for the super cap.  What I am thinking now is around 8PM disconnect the battery.  The sun will be down, so no solar power.  Then before the sun lights up the solar panel, check if the PIC is still in sleep mode.  One way is to press one of the buttons that will illuminate on the LEDs.  It is a left over debug routine, that is actually quite useful.  The other is to measure the voltage at the Suoer Cap and see if it is providing sufficient voltage.  Then this test needs to be repeated without the OLED installed.  

The process continues.

 

Friday, March 10, 2023

Solar Shed - Assembled

It is mostly assembled now.  First step is test the ADC inputs and make sure they are working correctly.  I built this spreadsheet.  

  • Column A is Vcc=3.29VDC and ADC size is 1024 counts
  • Column B is Battery input voltage
  • Column C is Battery voltage at the ADC input
  • Column D is the ADC counts for that voltage
  • Column E is LT1085 voltage at the ADC input (input voltage is from column B)
  • Column F is the ADC counts for that voltage
  • Column H is Solar Panel input voltage
  • Column I is Solar Panel voltage at the ADC input
  • Column J is the ADC counts for that voltage

Finally the three numbers in row 2 (0.2015, 0.2035 and 0.1286) are actual measured voltage ratios of the voltage input and what is present at the ADC input for each input. Even though I used 1% resistors, there is still +/-1% over the marked resistor values.  And to be fully transparent, even though there are unity gain low bandwidth (10KHz) OP-AMPs driving the PIC ADC, the layout probably could have been better.  It is as tight as SMT0805 resistors/capacitors would allow and is surrounded by ground plane.  But not being an Analog Guru, it is probably just OK.  Below the table You can see the layout for the three ADC inputs. (It;s late and my hand is not quite steady, s the picture is a little fuzzy)

 

Then I compared these numbers against what the ADC was reading.  Finally I tweaked the Vcc number a few millivolts to get  a more consistent match of the table values to the actual ADC readings.  During this process I noticed that I had left the weak pullups on the three ADC input pins on.  After turning them off, the readings were much more consistent.

The next issue was going in and out of sleep.  Just needed to make sure that everything I turned on/off before sleep, was turned off/on after coming out of sleep.  So at least on the desk it seems to work as before.  There are a few enhancements and more testing that are needed

  • When the solar voltage is high enough, run the PIC from the solar panel.
  • Install the super cap and test it.
  • Maybe the PIC runs from the solar panel all the time and the battery only powers the LED lighting in the shed.

Ran the system in sleep all night.  Starting battery voltage at 10PM was 13.68VDC.  At 8AM the next morning the voltage was 13.51VDC.  Now in LiFePO battery system this doesnt mean much.  Unless you have a calibrated battery gas gauge IC connected, there is no way to know how much battery life was consumed.   We must remember that a LiFePO battery discharge curve is quite flat until the inflection point.  What is important is the current numbers from the previous post, the system with OLED and in SLEEP, consumed 2.25mA from the battery.  That should be equivalent to 18mA-Hr.  Fully charged (and new) the battery is rated at 9.6A-Hr.  So over night we used about 0.2% of the battery.  

I will be interested to see what the super cap does.  That will be the next test.  Still waiting for the sun to appear and the snow to melt.


 


Monday, March 6, 2023

Solar Shed-Close

 

I am closer to having a working system, but some further "compromises" may still be in order. πŸ˜•

The new PIC processor came in.  It did not take long to swap out the PIC18F4525 for the PIC18F46K40.  Went through some configuration issues, but finally got it working.  Since this was a minimal part design, there is no oscillator.  The PIC18F46K40 has an internal Oscillator that runs up to 64MHz.  Nothing I am doing needs that kind of speed.  Thus 8MHz was the compromise speed.  What I did do was up the SPI clock rate to 2MHz.  The MIKROE OLED C will run much faster, but that is good enough.  

Then I started working on the SLEEP routine.  I have not done any very low power work since working on the T-DUST module.  Spent a few minutes reading the data sheet on SLEEP and Watchdog Timers, as well as reviewing what I did in T-DUST.  

On the PIC18F46K40 the way it is implemented on the Solar Shed PCB, nothing runs when it goes to sleep, except the Watchdog Timer (WDT).  And in this configuration, it can only run from one of the low frequency oscillators, whose frequency is about 31KHz.  The WDT has pre-scaler that will give a maximum time of about 256 seconds or a signal about every 4 minutes.

In the main loop, the code will look at the Solar Panel voltage each time through the main loop.  If the voltage is above about 8VDC (subject to change when the system is tested), the code will continue in the main loop.  If it is below this threshold, the PIC will go start the WDT and then go to SLEEP.  When the WDT expires (about 256 seconds), the PIC will wake up.  At this point it will look at the Solar Panel voltage, and if it is above 8VDC, the code will wake up and continue with the main loop, until which time the solar panel voltage falls below 8VDC.  If the solar panel voltage is below 8VDC, the PIC will restart the WDT and go back to sleep.  At this point the SLEEP process starts all over.

I do check to make sure the WDT is the wake up source, if not, then a reset of the entire system is executed.

This led to taking current measurements.  Without making some changes, I can only measure the input to the DC-DC converter that makes the 5VDC, that then is transformed to 3.3VDC by an LDO.  So assuming 100% efficiency in the DC-DC converter, these numbers are the best one would expect.  Reality is they are somewhat worse at 5VDC.

  • Run w/o OLED on  4.5mA @12VDC = 10.8mA @5VDC
  • Run w/ OLED on 12.0mA @12VDC = 28.8mA @5VDC
  • Sleep (OLED is powered but display not on) 2.25mA @12VDC = 5.4mA @5VDC
  • Sleep (OLED module removed) 275uA @5VDC = 600uA @5VDC

There is a 7.5F super cap that is suppose to power the system through the night if the battery is too low.  At 600uA this might happen, but a 5.4mA I have my doubts.  This leaves me with three choices:

  1. Remove the OLED.  It is nice to have to see voltages, but for the 80%+ of the time no one is inside the shed, it serves no purpose.
  2. Do some cutting of traces and install a high side switch on the OLED.  Thus it is only on when voltage display is requested.  Cutting the ground traces will problematic since there is ground plane on both sides of the PCB.  Also not sure there won't be leakage through the SPI and other control pins.  This option is not appealing.😞
  3. Do nothing.  Maybe at 10.8mA, the battery will last long enough to get to the charging opportunity.

So this is a testing processing to see what happens.  Right now it is snowing, so nothing will happen until the sun comes out again.

An interesting note is what happened to the PCB when I removed the PIC18F4525 with the hot air gun and then cleaned the pads with solder wick.  The combination of the two seems to have rubbed off some of the solder mask.  Nothing is critical, but these pictures show the issue.  Not going to complain, paid $5 for five PCBs.  It is a one off.





 

Wednesday, March 1, 2023

Solar Shed - Epic Fail

 

This is very embarrassing.  The new PCB for the Solar Shed has multiple problems and they are just dumb mistakes.  I can't believe I did not catch these.  So here is the revelation of what happened.

Digital vs Analog Inputs

The PIC18F4525 is an older PIC.  During the design process, there was a nagging issue in the back of my mind on how the ADC actually connected to the I/O pins.  Early on in my designing with PIC processors (PIC16F876 and PIC16F877), I was burned by an issue with the ADC.  I did a cursory look at the PIC18F4525 data sheet but could not find anything that was out of the ordinary.  When I was changing the firmware to accommodate the PIC18F4525, I finally found it, but this was after the PCB arrived in hand.

This is an excerpt from the PIC18F4525 data sheet.  This is one of the registers that controls the ADC.  In particular look at Port Configuration Control Bits.  These four bits determine which I/O ports are digital inputs and which are analog inputs.  But you don't have complete freedom.  This is a cascading implementation.  As an example if you need AN5 to be analog, then AN0-AN4 also have to be analog.

As time went along in the development of the PIC18F processors, the Port Configurations Control Bits were expanded inside the ADC registers to have a bit for each input.  Then when more analog features were added and the ADC inputs were expanded to almost every I/O pin, the Analog Select (ANSELx) registers appeared, one for each PORT (A-E) on 44 pin parts.

Well if you have not surmised already, the three inputs that I used are AN5-AN7.  That means the I/O pins AN0-AN4 are also analog inputs.  This translates to RA0=RA3 and RA5.  I did not use RA5 and RA0-RA3 are used for i/O control of the OLED display.  What I should have done was finish the firmware changes for the PIC18F4525.  That way I would have run into this before I submitted the PCB design.

SPI Connections

Next issue is even more embarrassing.  I did not correctly connect the SPI to the OLED.  The PIC18F4525 is before PPS (Peripheral Pin Select) which let you have some flexibility on moving PIC functions to different I/O pins.   As you can see from the schematic snippet below, I built the symbol correctly as RC3-RC5 are labeled with the SPI pins.  I just did not connect the wires.  This is mostly a cut and paste failure.  I copied this circuit from a previous design that used a PIC18F47J50 that had PPS.  Somehow in the process of checking this, it went right by me.

Solutions:

  1. Software fix:  Since I use the ADC every few seconds and the OLED display is strictly user initiated through one of the push buttons, I could change these four bits in ADCON1 to reflect current usage at the time. However there is this warning (shown below) in several places in the data sheet about having analog inputs on a digital input.  And even if I pursue the software fix, the SPI issue will have to be a "cut and jump" approach.

  2. New PCB:  So I only paid $5 for five PCBs and $27 to ship it and 3 other PCB designs.  Total cost was about $12 for the five PCBs.  So I am not into it for a lot of money.  This is just a time factor.  Redo the design, submit and wait for delivery.
  3. New Processor: I was trying to use existing parts I had.  I have other 44 pin TQFPs on hand.  All of them are USB devices and thus have a slightly different pin usage.  Mostly the USB pins and internal regulator that needs a capacitor on the pin.  Not a good choice.  So I started looking at what other PIC18F processors come in a 44 pin TQFP.  The parameter tool on the Microchip website was not as good as it used to be.  It is pushing newer parts that are not what I am looking for.  What I need is a basic 44pin TQFP with PPS.  So I went to Digi-Key and used their search tool.  What popped up was a PIC18F46K40, which is the next FLASH size down from the PIC18F47K40, the part in the HPC Curiosity board this all started from.  The difference is 64K vs 128K FLASH program space.  And it was $2.50 in quantity 1.
     

Where am I, well I am thinking of the PIC18F46K40.  This time I am going to do all the software changes first and make sure the current PCB layout will work.  If that works out, then I will buy two PIC18F46K40s and go from there.  If not, then it may be hacking up the board to make it work.  I only need one.


 

Wednesday, February 22, 2023

Solar Shed Battery Charging

 

 

While I was waiting on the new PCB to come in, I started testing the charging of the battery under real conditions.  What I did was take just the daughter board from the old design (as shown above) and force the path from the solar panel through the LT1085 to the battery.  Then about once a day I recorded the battery voltage to see what was happening.  The data so far is shown here.

 
 
There were some very sunny days and a few slightly clouded days.  In retrospect, I probably should have recorded the sky conditions for the previous period also.  The data shows how the voltage has varied.  As a reminder, the solar panel is only 7.5W and has a max current of about 500mA, under ideal sun conditions.  Given the time of year and the fact that sun does not clear the house next door until after 11AM this time of year, I am not surprised that it is not charging very fast.  Once the house next door is not blocking the sun at anytime, which won't happen until sometime in March, I suspect it will be hard to charge much faster.

I am surprised that there appears to be some discharge during the night.  It is not much and for now I am assuming it is more self discharge due to very cold nights (20-25F).  There might be some sneak current path back into the LT1085 when it is not powered.  I did put in a diode in the new desig to help prevent this.

 






Monday, February 20, 2023

Solar Shed Update

 

As I explained in the previous post on the Solar Shed, I redesigned the PCB, since the HPC Curiosity Board was consuming too much power.  My plan is to build this in phases (which was a good idea as explained later).  These phases will be and probably in this order:

  • DC-DC converter
  • 3.3 VDC LDO
  • PIC processor, buttons and LEDs
  • LT1085 LDO
  • Relays and FET drivers
  • ADC Input
  • Misc

Once the first three are done, I will work on getting the PIC firmware running.  May have to fake the ADC inputs, but that is OK.  Really all I will be trying to do is ensure the PIC runs and the buttons?LEDs work.  Once that is done, then the rest should go very quickly.

No Power

Following the list above I built the DC-DC converter section.  I literally took the design from the train LED controller, which works, and placed that design on this PCB.  Well there was no 5VDC.   My first thought was that the resistor divider network was in backwards, ie somehow the reference designators had not been placed correctly during PCB layout.  I measured the resistance in circuit, which is always iffy, since there is no way to see what the equivalent circuit really is.  The 20K measured 16K and the 120K, measured 55K.  So I pulled the 120K and replaced it with a 110K, that was in the original design.  Still no 5VDC.

Nothing was getting hot, the converter just wasn't starting.  I poked around with a DVOM looking at the voltages everywhere, other than no output voltage nothing seemed wrong.  Touched up most of the small solder joints, just to make sure they were connected, even though the DVOM showed connections.  Then did continuity checks where I could, still nothing.

 

Then I carefully looked at the inductor.  These can be hard to get the solder to flow onto the connections.  The picture shows what should be sufficient solder, but these are Lead Free, thus that is silver solder and will need more heat to flow properly.  Plus I didn't help the issue by using the very small tip on the Metcal Soldering Station.  I changed to the bigger tip (see picture below) and reflowed both connections on the inductor.  And that solved the problem😊.  Note to self, don't take short cuts, especially with the inductors and any parts that have silver solder on them already.


 

Installed the 3.3VDC LDO and the 3.3VDC came right up.  So I am ready to move on and install the PIC processor and related items.

This is why I try to build these in phases.  I have lots of experience building these types of boards by hand, but things happen.



Monday, February 13, 2023

Solar Shed - New Design

 

In my last update, I stated the need to redesign this.  I went through the extra parts I have and started working on a new design that eliminated the Curiosity HPC development board.  Here are the changes that have been made.

  1. Had quite a few PIC18F4525 PIC processors.  Since they had 48K of FLASH memory, that made them a good choice.  The FONT files for the OLED take up to 64K, but they can be trimmed downed to fit in 32K, so this will work just fine.
  2. Changed the LED configuration a little and with a custom PCB I can label them and make them different colors so I can easily tell what is happening.
  3. I added a DC-DC converter circuit that will take either the Solar Panel output or the Battery as input and make 5VDC.  This is the same DC-DC that I used in the Train Light Controller.  I had to buy 20 of them from the Asian after market, so these are essentially free.  
  4. I changed the way the relays work.  While this is hard to read, it is good enough to explain the basics.  The top relay works as before connecting/disconnecting the battery from charging.  The middle relay connects/disconnects the LED lights in the shed.  The bottom relay is new and allows for either the battery or the solar panel to provide power to the DC-DC converter that then powers the PIC circuit.  Also the relays are now powered either by the battery or the solar panel through the LT1085 in a wired OR configuration. 

  5. Finally the PIC is still at 3.3VDC since that is the power of the OLED display.  To provide a quasi battery backup, a large super capacitor (7.5F) is installed between the DC-DC output and the 3,3VDC LDO input.  When the solar panel goes under voltage and the battery is also under voltage, the super cap should power the PIC.  It will be sleeping 90% of the time, waking up every few minutes to check the voltage on the solar panel and the battery, if neither is sufficient it will go back to sleep.

  6. Added two push buttons that will allow me to manually change the relay that charges the battery and the relay selects the power source for the DC-DC converter.  This way if I can make sure the battery is connected/disconnected and the appropriate power source is selected. 
  7. I added four #6-32 holes to make mounting easier.

Need to some final checks, then I can generate the PCB files.  I am working on a few other designs so that I can take advantage of combined shipping.

 

 



Friday, January 27, 2023

Solar Shed - Update

 

We had 12" of snow and this completely covered the solar panel.  This caused the battery to completely drain.  That is the battery voltage was less than 10VDC.  Which leads me to this

  1. Probably need a cutoff relay to disconnect the battery when there is no charging voltage and the battery voltage falls below a certain value.
  2. If the battery is disconnected, then the controller needs power from somewhere else, probably a combination of the solar panel and a very large cap.
  3. Which leads to the Curiosity HPC board is not going to work.  Need a custom board that I can put to sleep to save power.  75-90mA is just too much current.

Oh well more fun designing.

 

Wednesday, January 25, 2023

Solar Shed - Intstall

 

I kept all of the big currents (charging and SHED LEDs) on the add on PCB.  To make the A/D readings as stable as possible. I added a unity gain OP-AMP on all inputs, a 16 sample rolling average, some thought on the ground connections and ground pour on both sides of the add on PCB.  But the OP-AMPS have to powered by the development board, so minute current is flowing between the Curiosity HPC board and the daughter board.  Also during development the whole system is powered by USB, since the development board has the debugger built into the board (PIC24 16 bit).  When installed in the shed, the battery runs everything with a 5VDC LDO replacing VUSB.  That was enough of a change in the ground currents to cause the A/D readings to move a little.  Fortunately I coded all of the trip point values (Battery over voltage, Solar Input over/under voltage, etc..) as constants derived from a spread sheet.  This program takes almost 64K of FLASH because of the embedded fonts for the OLED.  So adding table look ups for converting A/D readings to voltage did not add much in comparison.

A major concern now is that the whole setup draws about 75mA when just idling.  The OLED only displays when a button is pushed.  And one LED is cycling at 50% to indicate that the main loop is running.  So I am guessing that the PIC24 implementation of the debugger is the main current draw.  I looked at the schematic and there is no clean way to cut the power.  Right now I get about 4-6 hours of some charge.  The sun is too low and the house next door is 5 feet higher and blocks the morning sun and the remainder of the day the angle is very low.  In about 6 weeks, the sun should be high enough to give more charge time and by spring it will be over 10 hours a day and very direct.  For now I will just watch the battery voltage to see what the trend is.

Monday, January 23, 2023

Solar Shed - Final Testing

The Solar Shed thing is almost done.  Instead of trying to debug the final issues in the shed on the wood pile and me all twisted in a pretzel, I built up  an environment in my office.  Instead of the Solar panel I used a 24VDC power supply I had.  This allowed for testing most of the different voltage points that control the relays  and the battery charging.  Here is a summary of the voltage decision points

  • If the Solar panel voltage falls below 14 VDC, charging is disabled.  No sense in charging at this point, the panel is providing very little current.
  • If the battery voltage rises above 14.6 VDC, charging is disabled.  Don't want to over charge the battery.  Also a five minute backoff timer goes into effect.  That way the charger won't be connecting/disconnecting at the main loop revisit rate. 
  • If the LED light switch is turned on, charging is disabled.  I want only the battery to supply the LED lights.

Got the coding done.  Now over a few days of monitoring the setup in the shed, I have needed to only change some constants.  Much easier to just take the laptop out to the shed and program the board, than try to step thru code.  Between the development board base and the PCB add on I built, there are some crazy ground currents that are effecting the A/D readings.  Thus the constants needed some updating.

  

Tuesday, January 17, 2023

Solar Shed - Realized

My original plan was to build a perf board proto with the LT1085 and the relays.  Then after some thought I decided  I needed to add multiple ADC inputs.  The PIC ADC does not like high impedance inputs.  I had lots of low bandwidth (<15KHz) OP_AMPS that would provide the buffer and a low impedance input to the ADC.  These MCP6031 are set up as unity gain buffers.  The input is scaled down depending on the input voltage range.  

Well using these SOT-23-5 parts made perf board very hard.  One of the PCB fab houses I use was running a special of $5 (plus shipping) for 4" by 4", qty 5.  Thus it made since to make a PCB.  Easier to build and more reliable.

Here is the board.

 
This the board next to the Curiosity HPC Development board.  The daughter board will plug into the connectors on either side of the processor.
 
 

Here is the unpopulated daughter board attached to the Curiosity HPC.


Here is the daughter board assembled. 

These are the major parts of the daughter board.

  • LT0185 with 100uf 50VDC capacitors on the input and output. I have lots of these capacitors, so I decide to use them.  They are excessive in size and capacity, but they are free.  The LT085 takes in the solar panel output and generates the 14.4VDC charging voltage.
  • Two 12 dual latching relays that control connection to the battery and the LED lighting in the shed.
  • Some N-FET buffers for the PIC outputs that control the Relays,
  • The MCP6031 OP-AMP buffers.
  • A LDO that converts battery voltage to 5VDC for the Curiosity HPC.  In turn the Curiosity HPC converts this 5VDC to 3.3VDC.
  • The necessary connections to the Solar panel, battery, light switch and LED light power.





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.


 



Tuesday, January 10, 2023

Solar Shed - An Idea

I have an IDEA😁

I have this nice shed in the back that I use for lumber storage and gardening.  Keeping the door open has been problematic, so I installed a 12 VDC LED light strip I had left over.  I obtained this battery at the electronics flea market, probably should have bought more, they were only a few dollars each.  LiFePo4 batteries are probably the safest Lithium cells in existence (relative statement).  I have used them in a project where the group was motorizing Kayaks.  They were very easy to deal with and very tolerant of the environment and the charging.  

I bought his solar panel at home depot, regular $49.99 on clearance for $13.03.  This is a 7.5W output and 24 volts open circuit.  Max current appears to be 500mA.  

The battery wants about 14.4VDC to charge.  So I went through my parts to see what regulators I might have.  I found an LT1085, one of the first high current 3 terminal regulators.  At 3 AMPS  it should handle what I need.  I built the little perf board you see in the first two pictures with other parts I had.  (220uF caps at 100VDC on the in and out).  

As you draw current out of the solar panel, the voltage drops like a rock.  As the voltage drops below 14.4VDC, the LT1085 just follows the input at about 1.5VDC drop.  Thus when the current draw is the greatest, the voltage drop across the regulator is the lowest.  As the current goes down the input rises, but the power drop across the regulator is also decreasing.  At the end there should be about a 10V drop across the regulator, but only about 50mA trickle charge.  

I prefer not to leave this connected during extended road trips.  But at least I got it going.  I will be interested to see how will the solar panel holds up in the sun, all year.  If the plastic casing does not have UV inhibitors in the plastic, this may be a 12 month solution only.   We shall see.  There is a reason it was $13.03.