Saturday, July 31, 2021

0000 0000 0110 1100

7W LED Cobs (for the workshop)

“In the valley of the blind, the one-eyed man is king.”

August Wilson

My eyes are fading and the components I'm soldering seem to be getting smaller! In anticipation of future SMD projects I decided to upgrade the lighting in the workshop.

I could have (read: should have) just fronted up to the hardware store with a fistful of dollars but in the tradition of spending way too much time (and money) making something at home, I looked into the buckets and pulled out some bits and pieces which put together may resemble lighting.

Along the way I happened upon some discarded light fittings at the local recycling centre and before you know it I had a skeleton of an idea.

A 3D printed case for the circuitry to hide in, and some appropriately oversized heat sinks strapped to the the cobs, saw the project conclude with a well lit work area - nice one!

The only downside was that the extra light in the previously dark corners of the workshop revealed a LOT of cleaning up needed (and a few forgotten components found!)



Saturday, July 24, 2021

0000 0000 0110 1011

Indicator LEDs and final tests

The PSU project is so close to finishing now I can almost smell it! (solder fumes or magic smoke?) I have learned so much along the way and as usual one of my favourite quotes bubbles up to the surface of my mind:

“There is no such thing as a problem without a gift for you in its hands. You seek problems because you need their gifts.”
Richard Bach (Illusions)

One of the remaining challenges I set myself is to provide an indicator LED for when one of the regulator circuits is live. So for instance if the 5V circuit is live, I'd like a visual indicator.

After a few trials, I used a simulator to narrow down the components required, centering on the BS170 mosfet. The reason I chose a mosfet and not my old favourite the SS8050 BJT is that a mosfet gate is triggered by voltage whereas a BJT base responds to current. 

So theoretically, as soon as the transistor gate senses voltage in the circuit above it's threshold voltage, it should let current flow to the LED.

The gate threshold voltage for the BS170 is typically around 2 volts and as I'm not asking for any voltage below 3.3V then it should be fine to trigger the LED in the circuit as shown.

After wiring up the components as shown in the diagram above, I was able to turn on the regulator and see the indicator LED, even under load.

Choices for the LED resistors are centred around Ohms Law and, using 10mA as a benchmark, should be as per the following spreadsheet snapshot:

After all the testing the concept seems quite sound, so now the final stretch of this <long> project is to box the whole shebang in a 3D printed housing, throw the switch and stand back!


Saturday, July 17, 2021

0000 0000 0110 1010

EEprom programmer

A few attempts were made recently to solder up a "Data Flash Board".  While I eventually produced some working modules, there were moments when I doubted the authenticity of some of the components including the voltage regulator and the WinBond W25Q32FV 4Mb flash memory chips.

I de-soldered a couple of the data chips and replaced them, which resulted in working modules, but I did keep the "faulty" chips and started to look about for a means to test them. Sure enough the hardware is pretty ubiquitous.

More problematic is software that will work on a range of platforms (e.g. I use Linux Mint). After looking at commercial solutions I settled on AsProgrammer and the CH341a Programmer.

I had to swap out to Windows, but I'm still hopeful of finding a software option that might work on a saner OS. The linux program "flashrom" works fine, but it does not appear to have a current GUI.

I think problems programming these little fellows nearly always comes down to a driver issue, and chasing OS upgrades is not fun as usually recompiling the drivers from source code is required.

In my case after a bit of fiddling around I was able to read a chip, blank a chip, write to a chip and recover data from a chip. Oh, and the two chips that I thought I had fried? Still working!

I count that as a success (notwithstanding the stupendous amounts of time invested faffing about with these EEProms, the software, the drivers, the emulators, etc.,).



Saturday, July 10, 2021

0000 0000 0110 1001

Fan fried goodness

Everyone seems to be buying an air fryer at the moment. I'll wait until they're out of fashion to pick up one. That's how I got my awesome bread maker!

Meanwhile, in my little corner of the garage where I solder up unsuspecting components, I try not to breathe in any of the nastiness that comes up from the boards being tortured.

One of the first things I "made" in the workshop was a solder fume extractor fan which comprised a re-purposed computer cooling fan and funnel as shown.



In a recent experiment I unwittingly fried this extractor fan by running a few more amps through it than recommended (>160mA). The hunt was then on for a replacement fan. I do have some new 12V fans bought for cooling projects, but they are way smaller than this application requires.

But for awhile during this replacement process I did feel like I was in a three little bears skit, surrounded by fans pulled from 2nd hand computer cases that were either two small or two big - none that were "just right".

Finally in a dark corner of the garage, inside a power supply inside a old computer, I found what I was looking for and cobbled the whole extractor back together. I'm gonna miss the smell of solder in the mornings...



Saturday, July 3, 2021

0000 0000 0110 1000

16-bit arithmetic on an 8 bit device in assembly (Part One)

The PFS154 has three 11-bit (2048 increments) hardware PWM channels, which is great - but it is an 8-bit microcontroller. So it might be time to explore 16-bit arithmetic to cover the possibility I might use the full PWM capabilities on this device.

Crazily I have also decided to explore this from an AVR assembly perspective (???). The problem with this is that the PFS154 is not part of the AVR family, I have no familiarity with the instruction set for Padauk assembly, and as well no experience with the toolchain to program the PFS154 in assembly. So...

I'm going to start with subtraction. From my AVR by example booklet, the sub command simply subtracts one register from another. When zero is reached the flag is raised and a branch can be initiated. It's pretty simple code - check out the video below for the code running on Gerd's excellent AVR-SIM

.nolist
.include "tn13adef.inc" ; Define device ATtiny13A
.list

.dseg
.org SRAM_START

.cseg
.org 000000

Main:

ldi r16, low(RAMEND)
out SPL, r16           ; Init LSB stack pointer
.equ mycount = 146     ; initialise countdown (0x92)

Loop:
ldi r16, mycount       ; load counter
ldi r19, 1

rcall Countdown
subi r22, -1           ; how many loops?
rjmp Loop

Countdown:
sub r16, r19
cpi r16, 0
brbc 1, Countdown
ret

; End of source code

A quick screen grab shows the beast humming along happily subtracting (and keeping an 8-bit count of the loops in R22). Note that AVR has no "add immediate"(addi) command on the premise that you can subtract immediate (subi) using -1 instead. It's a little weird but 5 - ( -1) = 6 and that's OK with the AVR (and me).

Two byte (16-bit) subtraction uses both sub and subc for the low and high bytes respectively. The subc command is subtract with carry which will use the registers defined to effectively result in a 16-bit operation, as per the code below.

.nolist
.include "tn13adef.inc" ; Define device ATtiny13A
.list

.dseg
.org SRAM_START

.cseg
.org 000000

Main:

ldi r16, low(RAMEND)
out SPL, r16           ; Init LSB stack pointer
.equ mycount = 900     ; initialise countdown (0x0384)

Loop:
ldi r16, high(mycount) ; load high byte 0x03
ldi r17, low(mycount)  ; load low byte 0x84
ldi r19, 1
ldi r20, 0
rcall Countdown
subi r22, -1
rjmp Loop

Countdown:
sub r17, r19
sbc r16, r20
cpi r17, 0
brbc 1, Countdown
cpi r16, 0
brbc 1, Countdown
ret

; End of source code

See below for a quick screen grab of this code in action.


Note that this code only subtracts one at a time, but the same process applies to larger 16 bit integers as per the code below.

.nolist
.include "tn13adef.inc" ; Define device ATtiny13A
.list

.dseg
.org SRAM_START

.cseg
.org 000000

Main:

ldi r16, low(RAMEND)
out SPL, r16           	; Init LSB stack pointer
.equ higher = 425 	; 0x01A9
.equ lower = 342 	; 0x0156

Loop:
ldi r16, high(higher) 	; load high byte 0x01
ldi r17, low(higher) 	; load low byte 0xA9
ldi r18, high(lower) 	; load high byte 0x01
ldi r19, low(lower) 	; load low byte 0x56
sub r17, r19 		; subtract low byte
sbc r16, r18 		; subtract high byte with carry

; result in r16:r17 = 0x0053

rjmp Loop

; End of source code