Categories
goatee-stroking musing, or something

today’s collage

Categories
photo

heigh ho the light goes in

heigh ho the light goes in

Instagram filter used: Lo-fi

View in Instagram ⇒

Categories
photo

@makersmakingchange Wobble Switch built! #imadedit

@makersmakingchange Wobble Switch built! #imadedit

Instagram filter used: Lo-fi

View in Instagram ⇒

Categories
computers suck goatee-stroking musing, or something

Canaduino STM32 boards with MicroPython

Volker Forster at Universal Solder was kind enough to send me a couple of these boards for free when I asked about availability. By way of thanks, I’m writing this article about what’s neat about these micro-controller boards.

always neat packaging from Universal Solder

Can I just say how nicely packaged Universal Solder’s own or customized products are? They want it to get to you, and they want it to work.

I’d previously played around with Blue Pill and Black Pill boards with limited success. Yes, they’re cheap and powerful, but getting the toolchain to work reliably was so much work. So when I read about the WeAct STM32F411CEU6 board on the MicroPython forum, I knew they’d be a much better bet.

Canaduino Black Pill Carrier Board with STM32F411 (and battery) installed

Volker sent me two different things:

Let’s start with the STM32 Screw Terminal Adapter:

Canaduino Black Pill Carrier Board (front)

It’s a neat, solid board built on a black 1.6 mm thick PCB. Apart from the obvious screw terminals — essential for long-term industrial installations — it adds three handy features:

  • a real-time clock battery. If you’re using a micro-controller for data logging, an RTC battery helps you keep timestamps accurate even if the device loses power.
  • mounting holes! This may seem a small thing, but if you can mount your micro-controller solidly, your project will look much more professional and last longer too.
  • A 6–30 V DC regulator. Connect this voltage between Vin and GND and the regulator will keep the board happy. From the helpful graph on the back of the board, it doesn’t look as if things start getting efficient until around 12 V, but it’s really nice to have a choice.
Canaduino Black Pill Carrier Board (back)

I made a little slip-case for this board so it wouldn’t short out on the workbench. The project is here: Canaduino STM32 Screw Terminal board tray and you can download a snapshot here:

The boards themselves are pretty neat:

two STM32F411 Black Pill boards from Canaduino

Gone are the lumpy pin headers of the earlier Blue and Black Pill boards, replaced by tactile switches. The iffy micro USB connectors are replaced by much more solid USB C connectors. According to STM32-base, the STM32F411 has:

  • 100 MHz ARM Cortex-M4 core. This brings fast (single-precision) floating point so you don’t have to fret over integer maths
  • 512 K Flash, 128 K RAM. MicroPython runs in this, but more flash is always helpful
  • Lots of digital and analogue I/O, including a 12-bit ADC
  • A user LED and user input switch.

About the only advanced features it’s missing are a true RNG, a DAC for analogue outputs, and WiFi. But on top of all this, Volker added:

the all-important 128 Mbit flash chip (and capacitor) fitted by Universal Solder

128 Mbit of Flash! This gives the board roughly 16 MB of storage that, when used with MicroPython, appears as a small USB drive for your programs and data. I found I was able to read the ADC more than 22,000 times/second under MicroPython, so who needs slow-to-deploy compiled code?

Building and Installing MicroPython

This is surprisingly easy. You’ll need to install the gcc-arm-none-eabi compiler set before you start, but following the instructions at mcauser/WEACT_F411CEU6: MicroPython board definition for the WeAct STM32F411CEU6 board will get you there.

I had to run make a couple of times before it would build, but it built and installed quickly. This board doesn’t take UF2 image files that other boards use, so the installation is a little more complicated than other. But it works!

Once flashed, you should have a USB device with two important MicroPython files on it: boot.py and main.py. boot.py is best left alone, but main.py can be used for your program. I’m going into more details in a later article, but how about replacing the main.py program with the fanciest version if Blink you ever saw:

# main.py -- fancy Blink (scruss, 2020-05)

from pyb import LED
from machine import Timer
tim = Timer(-1)
tim.init(period=1000, mode=Timer.PERIODIC,
         callback=lambda t: LED(1).toggle())

None of that blocking delay() nonsense: we’re using a periodic timer to toggle the user LED every second!

debugging the mystery huge potentiometer using two ADC channels

I’m really impressed with the Universal Solder-modified board as an experimentation/discovery platform. MicroPython makes development and testing really quick and easy.

[and about the mystery huge potentiometer: it’s a Computer Instruments Corporation Model 206-IG multi-turn, multi-track potentiometer I picked up from the free table at a nerd event. I think it’s a 1950s (so Servo-control/Cybernetics age) analogue equivalent of a shaft encoder, looking at the patent. Best I can tell is that each pot (there are two, stacked, with precision bearings) appears to have two 120° 10k ohm sweep tracks offset 90° to one another. The four wipers are labelled -COS, -SIN, +COS and +SIN. If anyone knows more about the thing, let me know!]

Categories
photo

Well done, neighbour. Well done.

Well done, neighbour. Well done.

Instagram filter used: Lo-fi

View in Instagram ⇒

Categories
photo

It never was, was it?

It never was, was it?

Instagram filter used: Lo-fi

View in Instagram ⇒

Categories
photo

dedbrik

dedbrik

Instagram filter used: Normal

View in Instagram ⇒

Categories
computers suck

MicroPython on the terrible old ESP8266-12 Development Board

… + 1 + 1 + 1 …

I just found my first ESP8266 dev board. This was from way back before Arduino support, and long before MicroPython

esp8266-dev-boards from ESP8266 Support WIKI

It’s not really in a useful form factor, but it’s got some sensors and outputs:

  • an LDR on the ADC channel
  • RGB LED for PWM on pins 15, 12 & 13
  • red LEDs pins 16, 14, 5, 4, 0, 2 with inverted logic: set them low to light them.

My board can’t quite be the earliest of the early, as it has 1 MB of flash. This is enough to install MicroPython, so I wrote a tiny test program for the outputs:

  • run a binary counter every second on the six red LEDs;
  • cycle through a colour wheel on the RGB LED while this is happening.

Here’s the code:

# esp8266 old explorer board
# see https://www.esp8266.com/wiki/lib/exe/detail.php?id=esp8266-dev-boards&media=esp8266-12_mod.png

from time import sleep
from machine import Pin, PWM
# LEDs are 16, 14, 5, 4, 0, 2 - L to R
# inverted logic: 1 = off
leds = [Pin(2, Pin.OUT, value=1), Pin(0, Pin.OUT, value=1), Pin(4, Pin.OUT, value=1), Pin(
    5, Pin.OUT, value=1), Pin(14, Pin.OUT, value=1), Pin(16, Pin.OUT, value=1)]

# RGB for PWM on [15, 12, 13]
rgb = (PWM(Pin(15)), PWM(Pin(12)), PWM(Pin(13)))
# LDR on ADC


def cos_wheel(pos):
    # Input a value 0 to 255 to get a colour value.
    # scruss (Stewart Russell) - 2019-03 - CC-BY-SA
    from math import cos, pi
    if pos < 0:
        return (0, 0, 0)
    pos %= 256
    pos /= 255.0
    return (int(255 * (1 + cos(pos * 2 * pi)) / 2),
            int(255 * (1 + cos((pos - 1 / 3.0) * 2 * pi)) / 2),
            int(255 * (1 + cos((pos - 2 / 3.0) * 2 * pi)) / 2))


i = 1
while True:
    i = i + 1
    i = i % 64
    w = cos_wheel(4 * i)
    for j in range(3):
        rgb[j].duty(4 * w[j])

    for k in range(6):
        if i &amp; (1 << k):
            leds[k].value(0)
        else:
            leds[k].value(1)
    sleep(1)

Categories
computers suck

super-special serial port standards

The PC I put together a few years ago (well, Scott Sullivan told me which bits to get, I bought them and assembled it) is still working really well. It was quite spiffy in its day — i7-4790K, 32 GB DDR3, Asus H97M-E — and is quite fast enough for me.

One thing, though, has never worked. The hardware serial port (the old kind, not the USB kind) refused to do anything. Only in the last day or so did I work out why and managed to fix it.

PC serial ports for roughly the last 25 years connected to the motherboard like this:

motherboard pin 1 → RS232 pin 1; motherboard pin 2 → RS232 pin 6; motherboard pin 3 → RS232 pin 2; motherboard pin 4 → RS232 pin 7; motherboard pin 5 → RS232 pin 3; 
motherboard pin 6 → RS232 pin 8; 
motherboard pin 7 → RS232 pin 4; motherboard pin 8 → RS232 pin 9; motherboard pin 9 → RS232 pin 5; motherboard pin 10 not connected
ZF SystemCard – Data Book (1998)

This rather strange mapping makes sense as soon as you see an IDC ribbon-cable DB-9 connector:

serial cable for the SBC6120-RBC, unhelpfully the wrong way up

Going along the cable from left to right (reversed in the photo above), we have:

    1 2 3 4 5 6 7 8 9

    1   2   3   4   5
      6   7   8   9

This was good enough for everyone except ASUS, who decided that they needed their own way of arranging cables. Because of course they would:

ASUS wiring: motherboard pin 1 → RS232 pin 1; motherboard pin 2 → RS232 pin 2; motherboard pin 3 → RS232 pin 3; etc.
Oh ASUS, how could you?

With a bit of resoldering, I’ve got a working serial port. You can never have too many.

Categories
photo

Finally got perfect C86 hairstyle – only 34 years too late

Finally got perfect C86 hairstyle – only 34 years too late

Instagram filter used: Lo-fi

View in Instagram ⇒

Categories
photo

necessary video call accessory

necessary video call accessory

3D model: Video call “on mute” etiquette sign

View in Instagram ⇒

Categories
photo

AWW YISS 67% OFF EASTER CHOCOLATE!!!1!

AWW YISS 67% OFF EASTER CHOCOLATE!!!1!

Instagram filter used: Lo-fi

View in Instagram ⇒

Categories
photo

some moody morning shit or other

some moody morning shit or other

Instagram filter used: Lo-fi

View in Instagram ⇒

Categories
photo

SimStapler© Simulator – in real life! Thanks to @leeborg_ for the inspiration!

SimStapler© Simulator – in real life! Thanks to @leeborg_ for the inspiration!

Instagram filter used: Normal

View in Instagram ⇒

Categories
goatee-stroking musing, or something

SimStapler© Simulator

ka-chunk … ka-chunk … ka-chunk … Splendid!

Long ago, the was a thing that called itself “SimStapler©”. It was a very early clicker game: every ten times you clicked on the virtual stapler, you got bonus audio. That was all it did.

It was a simpler time …

A couple of days ago, Lee posted a video with reminded me so much of that virtual stapler:

Since I have the hardware and for various reasons my social calendar isn’t what it was, I set out on the bold plan to make Sim-SimStapler© … or SimStapler© Simulator … or RealStaplerⒹ … or … look, I’ve spent more effort in trying to come up with a name for this than I did making the thing, so call it what you want.

You’ll need a Circuit Playground Express, a couple of alligator clip test leads, and a stapler. And maybe some tape and a paperclip, too

a Circuit Playground Express, a couple of alligator clip test leads, and a stapler
it doesn’t have to be in “I believe you have my stapler” red, but I feel it helps somehow

The important thing about a switch is that it has two electrically isolated parts that come together to close a circuit. And that’s exactly what the Swingline® 747® stapler doesn’t have: its entire metal body and mechanism is electrically conductive. So we have to rig something up …

stapler anvil with tape across it supporting a paperclip, taped down. A green alligator clip is attached to the free end of the alligator clip
Tape, paperclip and alligator clip make up one half of the switch
rear of stapler with white alligator clip protruding, clipped to staple dispenser
… while a handy ledge at the back of the staple dispenser provides a connection for alligator clip #2

Did I say take the staples out yet? No? Take the staples out of the stapler. Possibly even before doing anything else.

The code we’re going to run on the Circuit Playground Express is very simple:

  • Set up pin 1 (helpfully named A7 on the board) as an input. Turn off all the LEDs
  • If pin 1 is shorted to ground, increase a counter and light successive numbers of LEDs round the CPX’s face
  • If the counter reaches 10, play the sample, reset the counter and turn off all the LEDs
  • repeat from “If pin 1 is shorted to ground …” until too bored to continue.

Here’s the code:

# SIM-SimStapler / RealStapler - scruss, 2020-04
# circuitpython on CPX - stapler between D1 (A7) and GND

from adafruit_circuitplayground import cp
import board
from digitalio import DigitalInOut, Direction, Pull
import time

# set up stapler on pin D1 (port A7): goes LOW when pressed
stapler = DigitalInOut(board.D1)
stapler.direction = Direction.INPUT
stapler.pull = Pull.UP

# set up pixels - not too bright
cp.pixels.brightness = 0.1
# turn all pixels off
for i in range(10):
    cp.pixels[i] = (0, 0, 0)

count = 0
while True:
    # stapler pressed, so increase count
    if not stapler.value:
        count = count + 1
        # only count first press, not if held
        while not stapler.value:
            pass
        time.sleep(0.1)

    # light up pixels clockwise for each press
    for i in range(count):
        cp.pixels[9 - i] = (0, 255, 0)

    # get a bonus Penelope Keith every ten presses
    if count == 10:
        cp.play_file("splendid.wav")
        # turn all pixels off after bonus
        for i in range(count):
            cp.pixels[i] = (0, 0, 0)
        # and reset counter for next time
        count = 0

Here’s the code and sample ready to be copied to your CIRCUITPYTHON drive:

(The sample is a slightly tweaked version of Freeverse’s original Bonus.wav. I ran it through an equalizer to make it sound less awful through the CPX’s tinny little speaker. I was also today years old when I found out that the sample wasn’t Penelope Keith from To the Manor Born, but Jen Krasinski, a staffer at Freeverse.)

The connection (singular) is simple:

Alligator clips to A7 (in reality, D1) and GND

Have an appropriate amount of fun!

I suppose I could also have done this on the BrainPad, but I haven’t set it up with MicroPython yet, and I don’t have time to drag coding blocks around. Also, this is not any project to associate with the word “brain” …

If the video doesn’t work: local link.

Categories
photo

We have baby bunnies in the garden! #squee

We have baby bunnies in the garden! #squee

Instagram filter used: Lo-fi

View in Instagram ⇒

Categories
photo

rainbow moose detail

rainbow moose detail

Instagram filter used: Normal

View in Instagram ⇒

Categories
goatee-stroking musing, or something

Rainbow Moose

Rainbow Moose to enhance your day
Rainbow Moose detail (as seen on ig)

Model: Moose Head for Materio3D by Morena Protti (modified)
Clear PLA with manual colouring using ShinHan Touch markers

Categories
photo

delicate colours

delicate colours

Instagram filter used: Normal

View in Instagram ⇒

Categories
photo

morning walk pool

morning walk pool

Instagram filter used: Normal

View in Instagram ⇒