Programs

Julian on October 14th, 2013

// Wiring: //A0 - Pot //A1 - Volts (solar) //A2 - Volts (battery) //A4 - Amps (solar) //A5 - Amps (battery) //D3 - PWM out to DCOI //D8 -LCD_RST (1) //D9 - LCD_CE (2) //D10 - LCD_DC (3) //D11 - LCD_DIN (4) //D12 - LCD_CLK (5) //—–LCD_VCC (6) //—LCD_LIGHT (7) //—–LCD_GND (8) #define LCD_C     LOW #define LCD_D     HIGH #define PIN_RESET 8 #define PIN_SCE   9 #define PIN_DC    10 #define PIN_SDIN  11 #define PIN_SCLK  12 //#include <stdlib.h>; #include ”header.h”; #include <PWM.h> int32_t frequency = 15000; //frequency (in Hz) int sensorValue = 0; float panelVolts = 0; float batteryVolts = 0; float lastPanelVolts = 0; float lastBatteryVolts = 0; float panelAmps = 0; float lastPanelAmps = [...]

Continue reading about Code Listing for Arduino MPPT Solar Charge Controller

Julian on April 14th, 2010

Too great a compromise. That’s the upshot of trying to use two 5.6 volt zener diodes in series instead of a single 9.1 volt diode. The 9.1 volt has a completely stable reverse voltage over a wide range of current. The 5.1 and 5.6 volt zeners are completely different and have a non-linear current/voltage relationship. [...]

Continue reading about Zener Zeitgeist (continued)

Julian on March 16th, 2010

This program uses Timer0 and the PICs interrupt system to flash an LED connected to GP2 on the PIC 12F683. The program uses a special kind of subroutine called an interrupt service routine (ISR), but there’s no ‘call’ instruction anywhere in the code. Instead, the subroutine is called by the PIC hardware by enabling interrupts. [...]

Continue reading about 12F683 Flashing LED using Timer0 and interrupts

Julian on February 24th, 2010

The purpose of the charge controller is to fill the battery with charge as quickly as possible without causing any damage. Letting the battery voltage rise to 13.5 volts, then holding it there using PWM is fine, but the battery saturates (fills with charge) slowly. Allowing the voltage to rise initially to 14.4 volts, then [...]

Continue reading about Saturation Charge and External Influences

Julian on January 21st, 2010

While I was looking for a solution to the EMC issue, I thought about turning the regular 122Hz PWM frequency into something more like white noise. The idea was to spread the spectrum of the emmited radiation so that at any one frequency, the signal would be weaker. It didn’t work. The intended effect was [...]

Continue reading about Fibonacci

Julian on December 13th, 2009

This program is a bit of a novelty, it uses the PIC’s watchdog timer to flash an LED. It’s probably the least sensible way to make an LED flash, but it illustrates some interesting features of the 12F683 microcontroller. A few things to note. We intentionally don’t use the CLRWDT instruction, we want the WDT to timeout and [...]

Continue reading about 12F683 Flashing LED using watchdog timer

Julian on December 7th, 2009

The PIC 12F683 has 3 timers, Timer0, Timer1 and Timer2. Timer0 is an 8 bit timer with an 8 bit prescaler and is currently being used to drive the LED pattern generator. Each time Timer0 overflows, a register called ‘pattern’ is incremented and analysed to determine whether the LED should turn on or off. These [...]

Continue reading about 12F683 Timers

Julian on November 3rd, 2009

So far, not much has been said about the process of writing software for the PWM solar charge controller, so let’s rectify that. Prototype code has already been written; a friend and I developed the current software during three 1-day programming sessions. The basic feedback control mechanism, which holds the battery voltage at a selected [...]

Continue reading about Software

Julian on August 31st, 2009

Gotta watch these PICs, they’re out to get you! Think I’ll flash an LED on GP0. Let’s see… bsf GPIO,0 call delay bcf GPIO,0 call delay Hmm, doesn’t work. That’s because GP0 hasn’t been defined as an output. OK… bcf TRISIO,0 bsf GPIO,0 call delay bcf GPIO,0 call delay Hmm, still doesn’t work. That’s because TRISIO [...]

Continue reading about PIC Gotchas

Julian on February 19th, 2009

This program flashes LED D6 on the PICkit1 programmer board using the PWM hardware. The microcontroller’s clock is set to 125kHz to make the pulse frequency low enough to see the LED turning on and off.  ;12F683 Flashing LED using PWM list p=12F683 #include “p12f683.inc” __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF org 0×00 init clrf GPIO ;initialise [...]

Continue reading about 12F683 Flashing LED using PWM

Google+