Archives July 2011

Wednesday 27th July 2011 - 07:52:47


I now have Hi-Tech C running under piklab. I'm glad that I tried it now.

After messing around for an evening or two with a stupid problem where bitwise OR assignments "|=" on PORTA and reading the value on PORTA fails, I decided that maybe SDCC was bugged. The OR would appear to work, but on closer inspection they actally zeroed the byte I was working on and only set the single bit that I was specifying. I installed MPLAB 8.73 with the Hi-Tech C compiler for 10/12/14/16 MCUs. There was trouble initially with wine as the picc.exe executable lived under "Program Files", So I moved the folder down to the home directory. This brought me a step closer as piklab verified the files exist - when it came to compile time piklab still tried to execute the linux executable rather than the .exe. I symlinked sdcc.exe to sdcc and libr.exe to libr and it now works fine.

Straight away I tried a compile (which failed) and then started the port from sdcc to picc. Once I had finished, the project built ok and I burned the hex to the pic (an 'f88). Lo and behold the same error occurred!

The code I used was originally an experiment with the adc which I wrote previously to try out SDCC. After combing the net I found a FAQ on the Hi-Tech website which described exactly my fault! I had a read of the FAQ and then checked out my code. Doh! I had remmed out the ANSEL declaration rather than implicitly setting it to 0. Facepalm.

Saturday 23rd July 2011 - 20:15:43


Last night I decided to try SDCC again. It works much nicer than the last time I tried it. It also managed to make it work correctly with Piklab.

I have the USART and basic stuff running on a breadboarded TG watchdog.

Thursday 7th July 2011 - 20:38:20


I am learning LTSpice and have finally worked out how to sweep a resistor value over time in an LTSpice simulation. I tried all sorts of stuff to make it work, but didn't think of this novel way of doing it. Drive the resistance by multiplying the total resistance by a 0-1v sweep (and add say 0.001 so LTSpice doesn't cry). Unfortunately I can't take credit for this idea myself - it came after lots of googling and forum trolling. I've incorporated this sweep into my new constant current load simulation. This sweep starts after a delay of 2s.

The first part of the simulation (first 2s) concentrates on the low battery indicator. The vbattery voltage sweeps from 12v up to 24v over 2s so that we can see the battery voltage cross the low battery set threshold and the vlowled indicator fall.

In the top plot area you can see the traces for the battery after the resistor divider (vlowsens), the low battery threshold voltage set with a zener diode (vlowset), the output from the opamp to drive the low battery LED (vlowled) and the +15v output from the LT1121.

In the middle plot we can see the amount of current being sourced and by multiplying the voltage on the high side of R1 by the current on R1, we can see the power in watts.

The bottom plot area shows the linear response of the pot simulating the rotation of the dial for its full range over 10 seconds. It crosses over in the middle where the wiper is at exactly 50%.

There are also a few more notes and photos in the gallery.

Friday 17th June 2011 - 13:08:01


Off sick today.

Watching some Red Dwarf on DVD. Best quote ever: at 7:25

KRYTEN: Computing time to impact... calculations coming through - here they come.

LISTER: How long have we got?

KRYTEN: About the time it takes to read a stop sign, sir.

Daily archives