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.

video
 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 :-)

2016-06-12

An ARM experience

Well... we're back at writing.
Two years ago NXP lauched a 8pin dip ARM with 4K FLASH and 1K RAM, lots of people started doing things with it, as most other ARM processors (even Cortex M0) are multi-leaded-smd-monsters. This one, on the other side, looks like an ATTiny85 in its PDIP8.
This weekend decided to try it out. I just followed the herd, although not the common route. I followed this tutorial and bought this "starter kit".
I used one LED and the two switches that come in the bundle to wire one LED output as the example and one switch for the RESET and the other to force the bootloader.

I used two machines for the LPCXpresso installation (you do have to register to get a free non limiting license, but if you can't be bothered for this processor you don't need to). You will need to install some extra packages, follow the procedure in this link. I managed to have LPCXpresso running both in OpenSuse 13.2 and Leap 42. In Leap you need to install the 32bit packages instead of the x64. Download the LPC810 Codebase example from here, import the project and build all. No joke, it is that simple.
Since I'm running linux, the alternative loader is this one. Like most linux command line programs, it is crude and simple. Just download, extract and type make.
Just copy the example command line with the your hex program (it is in the Release directory in the workspace project folder).
and yes... it blinks!
The processor has lots of embedded resources but only 4k of code might be the limiting factor. Still it is very interesting, in particular if you can save more power than an ATTiny and when needed produce way more MIPS.
For a first post after such a long hiatus it was not bad... more to come :-)


2015-09-06

Building the "new" MSPGCC from TI and RedHat

Ok, after a system update (opensuse 12.3 to opensuse 13.1) I was without my MSP430 compiler and launchpad connection. Also since the last time a new compiler version appeared (from 4.6.3 to 4.8.0) so I thought I could build (install) a new one.
TI also got together with RedHat to build a new opensource msp-gcc compiler. It took them quite some time but we've got them.
For those that like to try linux installers (beware: sometimes things go up in flames and you don't know why.) you can download the installer from here and run it as
su.

If that doesn't work for you... you can always build from source, these instructions (in spanish) appear to unlock the code .

On the other hand I also tried the install from source! After a couple of attempts I manged to do it, here's how:
- download the sources from here and untar it. (in the following commands remove the "" in the comand line;
- create a new directory like "mkdir build";
- "cd build";
- "../sources/tools/configure -target=msp430-elf -prefix=/opt/cross/msp430"
- "make"
- go and take a looooooooooong coffee (might as well go to work and come back later).
- "sudo make install".

A few caveats I found out the hard way:
- the target must be specified as msp430-elf otherwise gdb won't compile;
- the prefix can be other, it is the directory where all the files will be placed.

I haven't checked actually using the cross compiler for anything but I'll try soon. Also there are some heather files that must be placed in some directory (according to TI) but they don't tell you how and where... I will also have to check that...
Furthermore it appears that mspdebug is not built... also need to check that...
But the compiler runs and gdb also.