2017-02-19

LEGO Traffic Light

This project has been lingering on for long, maybe two years or so... and I'm still not done... So here goes...

My son had asked me to do a real traffic light for his LEGO Duplo train. I had tens of Atmel's ATTiny15L lingering around I thought it would be a good idea. I also had a 3D printer that can print in ABS... so I could combine both to produce the said traffic light.

I first found a Lego piece I wanted to "upgrade" and drew a mechanical drawing of it for reference. I used LibreCAD, seem a simple CAD program to design the basic location of the lights in the block.


I designed the 3D printed "LEGO" Traffic light, based on the LEGO designs. 
For this you need to go to Openscad library of LEGO designs (yes it exists, and yes you can). The code is here. My choice of OpenSCAD as design tool is based on my experience, I tend to visualize better with equations and program lines... and using the library is simple as including it and asking for a box 3:2... then "cut" holes in the case. Then you print... and test if it sticks...



I then started developing the circuit and the software, the circuit is very simple and biggest problem was extending the battery life from the CR2032 and lock it inside (to prevent it to come out during play). This time I used KiCAD to design the circuit and PCB.


The code is here. Initially I developed the code in a perforated board where I had soldered the circuit and connections. The yellow block was a test (in PLA) to see if the printer printed with the correct dimensions (more or less did). The black is the final one in ABS.


To finish the project I want to glue and acrylic rod on the LEDs as a light pipe and make the block solid.

2017-02-18

Dr. Vogel's Analog Computer

In 2014 I discovered the Analog Computer Museum and I was intrigued over a small analog computer in the collection. Dr.Vogel's small computer is an educational computer with very limited capabilities, but still it looked like a nice project to replicate.



The schematics for the computer are here, a short introduction to analog computing is here and the documentation of the computer is here.

Well the construction took several years, from the choosing the box, the type of plugs/sockets (2mm instead of the common 4mm), designing the front panel and sending it for fabrication (at this place as they do have linux support, for an idea of how incredibly long it took, the front panel was done in 2014).



At the circuit part, I made some "variations"... for the power supply I wanted a mains input and a linear regulator for each polarity. So I used a standard transformer, rectifier and LM337, LM317 regulator with +15V and -15V outputs.
In the circuit I changed all operational amplifiers for the LF411 and LF412. In the polarity indicator I used a dual colored LED (red/green), with this I could save one extra hole in the front panel. For the sinus generator I got a AD639 as I couldn't afford the space for the pots and diodes. Eventually I got the AD534 for the multiplier, but it appears that the ones remaining in ebay are made of unobtanium...
For the integrators I used pots as input resistors so that I could adjust the time constants.
After sourcing all the components, the construction took two weeks on several pcb pre-drilled boards (one of these, another of these and for the power supply another).

This is the final result:


With the box open you can see the power supply (transformer in white PCB), the measuring card (brown PCB inside the box, contains basically the second page of the schematics plus the multiplier and sinus generation) and on the right you can see the integrator capacitors and the adders.


The question now is what to do with one... well doing a "fall of object without drag" is quite interesting and easy, doing other ballistic experiments is also interesting... See the presentations at the Analog Computer Museum.


2017-01-05

Monster-B-Gone

Last year Make:Magazine had an article where they built a Monster-B-Gone detector. I did not had the same processor board (a trinket) and having a stash of Attiny15L, I thought I could use them instead.



There is one big problem with this MPU, speed. It only runs at 1.6MHz, meaning that the cycle time is 625ns. The Neopixel needs a feed of serial zeros and ones where minimum on-time is about half of that.
So I needed to get clever...
First I read a lot about Neopixels (here and here), then I decided to use the PWM generator to drive the Neopixels with the PLL, this would allow a faster impulse generation that the processor could do.
I had to compromise on the number of colors available (only 7) but in the end it worked. So that the 8 bits of a color byte always have the same value (there are 3 color bytes for each pixel). This not only is needed because of the speed, but also because the processor only has 32 byte registers.
The other components is a LiPo battery, a LiPo charger, a push button (resets the processor) and the neopixel (all from adafruit).


My Kids required one each... so ...


How it works required lot of cycle counting, but in the end I made it work! So first set up the PLL for a suitable upscaled frequency, then create the rolling blue light (walking one) and after some random rounds, show the green ring (room clean). There are lots of discussions if it should occasionally show the red light (MONSTER IN ROOM). I decided it should never show the red light, but changing the code to use the same random number generator to decide should be easy.

 The code is here.

2016-08-08

ATTinys

I finally have the time to post some old projects (some of witch I'm taking the opportunity to finish). These are all around the now dead Attiny15L from Atmel, but the techniques might be used in the newer tiny Atmel (Attiny25,45 and 85, Attiny10 Attiny104, etc). I write might because this first post probably will not be very useful for these newer devices, as the calibration of the internal oscillator has changed from the ATTiny15 times.
First I'll present my test board, many moons ago, the DIP Attiny15L was much more expensive than the wide SO8, so I built a board with the SO8 and the ISP connector with a 0.6 inch footprint. This way I could save space on the test board and use the cheap Attiny15 in SO8. I've recently uploaded the board to OSHPark so you can order it. You can also use the board for other SO8 Tinys (like the Attiny25,45,85 or tiny13). The board includes a Reset pull up resistor and a supply bypass capacitor (all optional if you know what you are doing).


This program just ouput a PWM sine wave (of 195Hz) on the OC1 output. The makefile takes care of programming flash, eeprom and the clock calibration on the last flash position.
I used an GNU octave script to generate a raw file of 64 bytes of a sampled sine wave.
The program just sets the calibration value, then sets up the Timer 1 for PWM at 12.5kHz and then goes on to read from the EEPROM the values in succession. The idea is to have a basis with the ATTiny to produce sound or voice.
On the bottom there is an Arduino board an a breadboard shield that I use to power the ATTiny and also to use as a serial to usb converter (the ATmega328 on the lower board has been removed).
There is a low pass RC filter on the output to get the 195Hz otherwise the PWM frequency appears. The blue box on the right is my AVRdragon.


One always thinks what will happen when pastebin is gone... and where all this code will end... no I don't... just kidding :-)