Home of the Solarpunk Forever_Engine

~~~ Just me, building a thing in public ~~~

Sketch of the Solarpunk Forever Engine

The Solarpunk Forever_Engine (or SP4EE) will be a tiny scratch-built solar engine. It will spin when the sun shines and it will keep count of its turns forever. It’s a silly idea with no practical use, which is why I like it. There’s more about the concept here.

Building SP4EE is my first attempt to learn in public. I barely know a thing about electronics, microcontrollers or motors. So this will be a lot of fun! Check back to see what I’m currently failing at. Or sign up for the newsletter and get the updates right in your Inbox.

Sign me up for the newsletter
With this you accept Substack's .

My first ATTiny! And I just bricked it.

October 28, 2020

After I got the brushless motor prototype working I needed a short break from 3D stuff like laser-cutting and gluing and winding coils, so I chose to give the ATTiny microcontroller a spin. Here it is sitting on its “Hello, world!” breadboard, accompanied by its big brother, the Arduino Nano that is used as an ad-hoc programmer.

ATTiny45 and Arduino Nano

I fell in love with the ATTiny because of its simplicity. Yes, the “classic” microcontrollers like the various Arduinos or the ESP32 are also impressively small and accessible. But they still come with a breakout board with two dozen or more pins, a USB socket, in the ESP’s case even WiFi and Bluetooth… It’s a lot. In contrast, with the ATTiny45 or ATTiny85:

Programming an ATTiny

There are really lots of tutorials and examples out there, so I won’t bore your with details. You write and compile your code in PlatformIO, but to upload, you need an extra device (the programmer) that has a USB connection. You can buy dedicated gadgets for this, but it makes a lot more sense to use an Arduino. So that setup means your PC talks to the Arduino, which is easy because you can plug the Arduino directly into a USB port. The Arduino, in turn, talks to the ATTiny chip over 4 wires, plus supplies it with power over 2 additional wires. This is documented in tons of tutorials, like this Instructable or this German article.

There are only a few things worth noting:

Messing up the clock

Once I figured out the capacitor trick with the Arduino, writing and uploading the first little program for the ATTiny was easy. There’s one very funny detail that the German article correctly points out at the end: the Arduino code library makes an assumption about the microcontroller’s CPU frequency. But by default the ATTiny runs at 1 MHz instead of the library’s assumption of 8 MHz, so the delay in the code below takes 8 times as long.

#include <Arduino.h>

const int led = 1;
const int sleep = 1000;

// the setup routine runs once when you press reset:
void setup()
{
    // initialize the digital pin as an output.
    pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever
void loop()
{
    digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(sleep);            // wait for a second
    digitalWrite(led, LOW);  // turn the LED off by making the voltage LOW
    delay(sleep);            // wait for a second
}

To fix this, you need to add the board_build.f_cpu key to the platformio.ini file:

[env:attiny45]
platform = atmelavr
board = attiny45
framework = arduino
board_build.f_cpu = 1000000L

upload_protocol = stk500v1
upload_flags =
  -P$UPLOAD_PORT
  -b$UPLOAD_SPEED
upload_speed = 19200
upload_port = COM5

So far so good! But now I tasted blood and realized that it’s possible to programmatically change the ATTiny’s CPU clock – and why wouldn’t you do that if you can? It’s been documented here and all it takes is a few lines of code like so:

// Change to 2 MHz by changing clock prescaler to 4
cli();                // Disable interrupts
CLKPR = (1<<CLKPCE);  // Prescaler enable
CLKPR = 2;            // Clock division factor 4 divisor code
                      // Division factor is 2^N, with maximum N=8 for 256
sei();                // Enable interrupts

There are two details that none of the pages I visited seemed to mention.

This latter part is what got me. I successfully reduced my first ATTiny45’s clock speed to 128 kHz, and could never upload another program again. I was apparently not the first one to run into this. It is probably possible to reset this chip physically, but the number of hours I would need to get there is way more than what the chip is worth. So now I have this sad guy lying around – a dead bug, for all intents and purposes.

Sad bricked ATTiny45

Got a working motor! (But not solar.)

October 24, 2020

I got to build a prototype motor! And it works.

There are so many open questions about the motor. How many magnets should the wheel have? Should it be an odd or an even number? What type of wire is best for the coil, and how many turns? I decided to first replicate something very close to the video I included in the previous post. That uses a reed relay, which is the simplest way to achieve motor control with zero electronics. Can I get a running motor from a battery? Will it run from a solar cell?

If you’re only interested in seeing the working proof-of-concept, here it is. For the part that really matters, read on ;-)

Embedded video: Brushless motor with reed relay: test from battery
Brushless motor with reed relay: test from battery Click to activate embedded video. With this you agree to YouTube's privacy policy.
Play video

Motion and smarts

October 17, 2020

Learning about pummers awakened my building instinct, but it turns out the desire goes a bit deeper this time. A blinking light is, well, a blinking light, but it’s somehow very – abstract? immaterial? The non-sitters in the BEAM menagerie get their twitchy motion from tiny motors soldered in weird ways, and that, in turn, is somehow a little – scrappy?

I want motion, but also elegance, and at least some interesting engineering. And hey, my whole obsession with making started with microcontrollers, so there has to be some form of programmed goodness in there too. And so, starting off on the general idea of motors, I rabbitholed into the YouTube sub-genre of scratch-built solar and brushless motors, like this one:

Embedded video: Solar Brushless Motor out of Fidget SPINNER
Solar Brushless Motor out of Fidget SPINNER Click to activate embedded video. With this you agree to YouTube's privacy policy.
Play video

Wait, what... A pummer?

October 10, 2020

May Kevin Lynagh be damned! I have just found me an entire new herd of yak to shave, and his newsletter is largely to blame. If he hadn’t included that link to Mohit Bhoite’s freeform circuit sculptures at the bottom in the October 4 issue, I would still be blissfully ignorant of pummers and BEAM circuits. I would not have ordered yet another small bag of parts, and I would definitely not have found myself tweeting out this image on a Friday evening:

Pummer schematic and parts