Saturday, August 28, 2021

0000 0000 0111 0000

Resurrection of broken UNOs

In one unnamed school in a galaxy far far away (but you know who you are), a non-science person decided to design a science lab or two. There were glaring errors and gaping holes (figuratively not literally), not least of which were stainless steel laboratory benches (modelled on an abattoir?)

There were also some unexpected discussions about the legitimacy and cost of fume cupboards in science laboratories (you know, because it is entirely fiscally reasonable that student and staff safety can be measured on some linked monetary scale).

And so when an "Actual Science  Teacher" came to use the lab, it transpired that some students inadvertently rested powered UNOs (used to monitor physical experiments) on these famously conductive surfaces, and then  they predictably blew up! What an unexpected plot twist.


Rescuing the UNOs from the bin was the easy part - figuring out what to do with them took a few years (not actually true - it was sloth). Just recently when I was cleaning up the workshop, I found a small brown paper bag with two such fried UNOs and had to make the decision to either turf them out (Nooooooo!), or try a few things to resurrect them.

The classic first step in such a resurrection attempt was to de-solder the ATMega328pa-au chip and throw in, for instance, an ATMega168 or ATMega88 analog for lolz.

I was a little disappointed that the computer didn't recognise the USB port in one of the reclaimed devices, and with the other UNO the port was recognised, but it wouldn't connect enough to allow programming or boot loader burning. This may indicate that more than the main chip had been fried in the great stainless steel science lab bench debacle of the 21st Century.

With a USBASP to the rescue, I was able to burn a bootloader and also program the ATMega88 chips in situ (using at first the internal 8MHz timer, and then later the 16MHz external crystal on the UNO). So that counts as a win I think.

I already have a project in mind for at least one of the reconditioned units - watch this space.



Saturday, August 21, 2021

0000 0000 0110 1111

PSU V - final

“There is no real ending. It’s just the place where you stop the story.”
Frank Herbert

All good things must come to an end, and in my case the long running PSU project is now complete:

1. PSU I (LM2596 switching regulator IC)
2. PSU II (LM7805 linear regulator IC)
3. PSU III (LM338 linear regulator IC)
4. PSU IV (BS170 mosfet)

In this instalment, all that is left to do is to wire up each voltage module (3.3V, 5V, 12V and the variable output), print out a nice box to house the project, and do some testing to make sure it all works fine.




I've already experienced regrets over some of the design choices I have made for this PSU and so I hope that the next version will benefit from this hindsight.

I'll leave it a year or so to make sure that this prototype has been properly tested and evaluated on site before whipping up the next version.

It's been a fun project, one of those that results in a very useful and much needed device. You'll probably see it on the bench in future videos and blogs for some time to come!




Saturday, August 14, 2021

0000 0000 0110 1110

16-bit assembly multiplication

When 8-bit microcontrollers have 11-bit PWM output, some 16-bit arithmetic may be required. The ATTiny13 and the PFS-154 do not have hardware multiplication (MUL or MULS) and so these operations need to be done in software.

Although there are a few different algorithms (both manual and automated) to multiply two numbers together, I have chosen to do the typical "shift and add" method that we are all taught in primary school.

In assembly, and for 16 bit multiplication, this means a code section on shifting the data to the right (multiplication by 10 for decimal, and 2 for binary):

  rol r21            ; multiply by 2
  rol r20            ; for next iteration

There is also a code section for adding two sixteen bit numbers:

  add r23, r21       ; no so add lower
  adc r22, r20       ; and upper bytes

The complete code is below, which runs great on Gerd's excellent AVR-SIM

.nolist
.include "tn13adef.inc"
.list

.dseg
.org SRAM_START

.cseg
.org 000000

rjmp Main    ; Reset vector

Main:
  ; initialise stack
  ldi r16,Low(RAMEND)
	out SPL,r16  ; Init LSB stack pointer
  .equ mult1 = 27   ; 0x1B
  .equ mult2 = 58   ; 0x3A

Loop:
  ; clear working registers
  clr r16
  clr r17
  clr r18
  clr r20
  clr r21
  clr r22
  clr r23

  ; load numbers and counter
  ldi r17, mult1
  ldi r21, mult2
  ldi r18, 8

testbits:            ; test each bit
  ror r17
  brcc zero_partial  ; is it a zero?
  add r23, r21       ; no so add lower
  adc r22, r20       ; and upper bytes

zero_partial:
  rol r21            ; multiply by 2
  rol r20            ; for next iteration

  subi r18, 1        ; decrement counter
  brne testbits      ; any more left?
  rjmp loop          ; start again

Next time in this series I'll do a program that makes 16-bit random numbers, and then maybe we'll start looking to program the PFS-154 in assembly - gulp!




Saturday, August 7, 2021

0000 0000 0110 1101

Mailbag (#6) and Postbag (#2)

I wouldn't have thought there was too much more needed from China for a humble Tasmanian hobbyist such as myself, but some insomniac buffoon (possibly tired and emotionalkeeps ordering cheap stuff online (and sometimes some not so cheap stuff).


Here are some of the results of the over-indulgence: