Toy Synthesizer

Making a rugged synthesizer toy for a teenager with developmental issues.

Similar projects worth following
This project is one that a former colleague brought to me. He has a teenage daughter that was unfortunately born with severe brain deficiencies who dearly likes a particular toy piano.
Trouble is, the toy piano is made for the rough and tumble of a toddler, not a ham-fisted teenager.

The plan is to develop a small synthesizer toy that can play tones and flash lights based on what buttons are being pressed. The device will be expandable to suit the needs of the situation in which it is being used.

The device at the moment is built around the ATTiny861 microcontroller which is closely related to the rather common ATTiny85. There exists ports of this firmware to the ATTiny85 and also a port that runs on a PC using libao. (By extension, should work on Linux-based single-board computers too.)

A third candidate in the AVR world would be the ATMega32U4 which is available as a through-hole module in the form of the Arduino Leonardo. This code should also work on ARM, TI MSP430 and Microchip PIC32 microcontrollers and anything else that gcc works on.

The plan is to have 8 peripheral ports (probably using DIN-8 connectors) which expose:

  • Power rails: +12V and 0V
  • A general purpose I/O line … 12V tolerant (so smoke won't be released if +12V and GPIO get crossed)
  • N-MOSFET drain output for driving lights up to ~1A
  • Microcontroller control signals for I²C networking/peripherals and ICSP programming (MOSI/MISO/SCK/nRESET)

This allows some flexibility: through the use of pull-resistors, it is possible for the microcontroller to sense what is connected on a given port by looking at the analogue voltage seen at power-up, and thus auto-detection of buttons, lights and light+button combos is possible.

Future expansion ideas:

  • Networking multiple units using an I²C "network"
  • Control from an I²C master such as a WIFI module (e.g. ESP8266) or single-board computer (Beagle Bone, Raspberry Pi, etc)
  • Reading from I²C slaves such as EEPROMs, GPIO expanders.

The idea here is a toy that can grow with the person using it. It can be used by a child (disabled or otherwise) as a toy for them to play with… then reprogrammed to create new games as they develop. The device can also be used in other projects to provide sound and light control.

To provide +12V tolerance, each channel will use a module like the following:

The design here is based on this article by Digikey on input protection. The aim here is to tolerate +12V, over-current and ESD. 8 of these, plus some tweaked ones for the I²C, MOSI and nRESET lines comprise the front line that connects the external sockets to the internal controller.

My controller has this schematic:

The microcontroller pin assignments are as follows:

  • Pin 2 (PB1, MISO/DO): Common GPIO / ICSP MISO
  • Pin 3 (PB2, SCL/SCK): I²C SCL / ICSP SCK
  • Pin 4 (PB3, OC1B): Audio PWM output
  • Pin 7 (PB4): Audio enable
  • Pin 8 (PB5, OC1D): Light PWM output (inverted)
  • Pin 9 (PB6): GPIO Enable
  • Pin 10 (PB7, nRESET): ICSP nRESET
  • Pins 11…20 (PA0…PA7): Channel GPIOs/MOSFET control

The Port A pins connect to the inputs on two 74HC4066s and a 74HC574 edge-triggered D-latch. The light PWM connects to the output enable on the 74HC574. The GPIO Enable line controls the 74HC4066s and the 74HC574.

  • When GPIO_EN is high: the 74HC4066s connect the GPIO pins on each channel to the microcontroller so it can sense the voltage on that pin.
  • When GPIO_EN is low: the 74HC4066s go high-impedance, disconnecting the external GPIOs. The MCU is then free to assert one of the PAx lines to choose a MOSFET to turn on.
  • Once PAx has been asserted, the MCU raises GPIO_EN and sets OC1D's duty cycle, which causes the '574 to latch the selected MOSFET and to PWM it at the desired duty cycle. The '4066s connect Port A to the outside world again.

I haven't yet tested the above control scheme, but that's the theory anyway. :-)

The audio passes through a simple RC low-pass filter then is amplified by a NJR NJM2113D amplifier IC. The RC filter component values were roughly picked… I started with nominal values (1k and 100nF) with the intention of optimising later, then found that optimisation was not necessary as the performance was considered "acceptable" (there was no visible 250kHz carrier):

The synthesizer code itself is loosely modelled on the rather well regarded Commodore SID chip. I don't support the analogue filtering features of this chip, but the ADSR envelope generation is supported, as is square, triangle, sawtooth and noise waveforms,...

Read more »

  • Replaced MOSFETs on the I/O module

    Stuart Longland05/07/2018 at 06:48 0 comments

    So, I was rummaging around on the table (which looks like a bomb hit it… yes I have hoarding tendencies) and I managed to find the packet of MOSFETs I originally used to make the earlier prototype I/O board.

    These are Toshiba 2SK4017s, probably not the best pick but at 70c a pop, they were cheap.  They worked for the original version, and at 5A drain current, are more than sufficient for the task.

    Above is the re-built board.  I literally cut away the old MOSFETs (hey, should still be able to dead-bug them, but sod it, I've got 42 of them left), cleaned up the board a little, inserted these smaller MOSFETs, and soldered them in.  I had to replace two 0805 1k resistors which got damaged due to the end of the resistor overlapping the hole for the gate… but whatever, I've got nearly 5000 of those kicking around too.

    In short, it works.  I didn't try it with full power, but rather used a series resistor with 9V, but I could light up a button and detect a press on every single channel.

    I'll have to order some more MOSFETs.  Not sure whether to go with these same ones again, I think they're obsolete … but now I have a couple of datasheets to compare against since I now know what does work, and what doesn't.

  • New module status: GPIO good, MOSFETs not good

    Stuart Longland04/28/2018 at 12:22 0 comments

    So, I'm learning now to read datasheets a little more carefully.

    Finally got around to testing that board, and at first, I had some shorted connections to deal with and one dry joint.  No problem, a bit of scoring with the knife and a tap with the soldering iron, and we're in business.

    Apply 9V to the GPIO pin, and ~3V appears at the output.  Good enough, the AVR will recognise that.

    Now for the MOSFET, applying 5V to the input, switches the MOSFET.  Great.  Try it on the actual synth… sure enough I can make noise, but nothing lights up.  What gives?

    In this prototype I'm using Fairchild FQI4N80s, which I bought a tube of 50 of them.  Turns out these MOSFETs have 40ns turn-on delay, and a 100ns rise time.

    Doesn't seem like much, but then consider this: our PWM clock is 64MHz.  That means the pulse time can be as low as 15ns.

    They also can have a gate threshold as high as 5V… so borderline for this application.  Never mind, I'm sure they'll be useful in other projects.

    I have a couple of options in mind, both by Infineon: the IPS70R900P7SAKMA1 and the IRLU120NPBF.  Out of those two, the latter sounds like the better bet, I seriously don't need 700V Vds!

    It is tempting though to design a board based on the prototype though, as I think if I make room for a TO-220 or TO-251 (IPAK; not to be confused with the larger I²PAK), there are actually a lot of choices out there, and much of the time, the choice is not critical.

    If I do that, I'll be spacing out the KK connectors a bit, as that's another point: the plugs are just a wee bit wider than the sockets, so I need to make room for that.

  • Second revision I/O board nearly complete

    Stuart Longland01/21/2018 at 08:30 0 comments

    So last week, some more parts arrived for this project.  Crucially, some capacitors, and some MOSFETs.

    Turns out, the MOSFETs I got last time were not I²PAK … I thought that's what I ordered last time, but clearly not, because that's what these are, and they're bigger than the previous ones.

    No matter, lean them back like dominoes and they still fit.  I've got a tube of 50 of them.

    I was able to put the pull-down resistor in, and I basically fitted the MOSFETs along a track, scoring the track between the legs so they didn't short out.  For the 12ohm resistor to the drain, I'm doing half-veroboard-PCB, half-point-to-point construction to link the drain pin (annoyingly in the centre) to the outside world.

    I'll need to rustle up a 2-pin KK to act as the power input, and that board is done.  I might add two in parallel on here so a short lead can link from here to the mainboard to supply +12V.  This will go on the right-hand side (lower photo) just past where that jumper connects.

    After that, the next step is wiring up the buttons and switches.  The use of 4-pin connectors should greatly simplify the wiring since everything we need is on the one connector.

  • I/O module, MkII

    Stuart Longland12/25/2017 at 06:20 0 comments

    So some spare time today… I decide to construct a new I/O module to fix up the mistakes made with the previous iteration.  Mainly:

    • the TVS diodes… going for one with a higher clamp voltage so it doesn't smoke when 12V is applied
    • switching to a 4-pin connector on the output side, with pins for 0V, GPIO, DRAIN and +12V
    • fixing the pin-out on the input side so it matches the PCB.
    • rather than having jumper leads to make the boards separable, we'll make one monolithic board that plugs into all 8 channels simultaneously with one long connector.

    For the TVS diodes, I ordered some TPD2E007 in SOT23… thinking those would be a reasonable size for hand-soldering.

    Now… how the bloody hell am I going to solder these little tiddlers?  I had thought SOT-23 was about twice that size.  Never mind, can't un-buy them.

    The circuit is pretty much identical to what came before.  My MOSFETs and 4.7nF capacitors seem to have gone walkies, not sure where.  No doubt the arrival of replacements will summon them back.  I decided to use SMT for many parts on this build.

    0805 resistors and veroboard aren't a bad combo really, just have a sharp blade handy to cut the track where needed, and the resistor can straddle the gap made.

    For the TVS diodes, the common pin is to ground, so I made a bus bar running vertically down the PCB and scoring the tracks either side.  The common pins could be soldered to that, and the two I/O pins would straddle the division between each track.  Aside from me getting some parts off-by-one at first, this went well.

    The zener and schottky diodes of course, being through-hole, went on the other side of the PCB.

    I still have to locate where my MOSFETs have gone, and I think I found some 12 ohm resistors (through-hole).  I can use some 0805 1k resistors for the MOSFET gates.  So that's some MOSFETs and 4.7nF, probably 0805 size capacitors that need ordering in the new year.

  • Trying out the toy

    Stuart Longland08/10/2017 at 10:43 0 comments

    Well, at long last we got to try the toy out.  The plan is to mount the buttons on a board so people don't have to hold them up (made to resemble jellyfish as I understand).  That said, this quick test seems to be promising.

    The teenager for whom this whole project was built, seems to be enjoying it.

  • Building synth #2

    Stuart Longland07/15/2017 at 08:41 0 comments

    So… last weekend I got to trying out the I/O modules. I rigged up wiring harnesses for all five push-buttons and their associated LED strings.

    I used CAT5e since I've got loads of it around… and ran four strands up to each button, carrying: +12V, MOSFET drain, GPIO and 0V. I ran a resistor between +12V and GPIO to pull it high, the switch NO and common connected between GPIO and 0V. The button's illumination LEDs and the LED string both connected in parallel between +12V and MOSFET drain.

    So far so good. I have just a 3-pin connection on the I/O module, carrying all but the +12V. That remaining wire I hooked to +12V directly on the input feed. Not having a 0V feed going direct to the power supply though was my mistake.

    If this happens, the 0V reference on the I/O module is open-circuit, and the zeners, meant to protect the MCU from +12V, don't do anything. So I suspect a MC14066 copped a belt of +12V by mistake!

    Not sure, but I thought I'd play it safe and build a new one anyway. I started on it earlier this week and finished it this afternoon. This time around I opted to put LEDs on the outputs of the 74HC574. No current-limiting resistors, since they're meant to be ⅛ duty cycle anyway, and if they smoke, well, who cares?

    This highlighted a glitch on the GPIO_EN signal during programming, LEDs would illuminate during MCU programming. A pull-up helps here.

    I tested using a 9V supply from my electronics kit, which has AA cells in it (somewhat stale ones) this time around. Handily, the plugs for the LED strings have LEDs in them themselves, and they work at 9V, so we can use those to see what the LED string would do.

    On the software side, I finally fixed polyphonics and a key-sticking issue. One of my I/O modules has stopped working for whatever reason, but the others are working fine, as can be seen here:

    The other issue I have to chase is some leakage on the blue and white buttons: the plugs for them are not meant to be glowing unless pressed, but you note they are glowing significantly, and get brighter when those buttons are pressed. I might have to re-visit those connections. Otherwise though, very good progress today.

  • 74HC573 replaced with '574… I/O modules built

    Stuart Longland07/02/2017 at 09:08 0 comments

    So… earlier in the week I received some 74HC574s (the right chip) to replace the 74HC573s I tried to use.

    My removal technique was not pretty, wound up just cutting the legs off the hapless 74HC573 (my earlier hack had busted a pin on it anyway) and removing it that way. Since the holes were full of solder, it was easier to just bend the pins on the '574 and surface-mount it.

    This afternoon, I gave it a try, and 'lo and behold, it worked. I even tried hooking up one of the LED strings and driving that with the MOSFET… no problems at all.

    I had only built up one of the modules at this stage, so I built another 5 on the same piece of strip board.

    The requirement is for 5 channels… this meets that and adds an extra one (the board was wide enough). For the full accompaniment and to have ICSP/networking via external connections, a second board like this could be made, omitting the MOSFETs on four of the channels to handle the ICSP control lines and reducing the capacitances/resistances to suit.

    Somewhere I have some TVS diodes for this board, but of course, they have legs, upon which they got up and ran away. Haven't resurfaced yet. I'm sure they will if I buy more though. The spare footprint on the top-left of the main board is where one TVS diode goes, the others go on the I/O board, two for each channel.

  • 74HC573, no substitute for the '574

    Stuart Longland06/11/2017 at 05:42 0 comments

    So… when laying out this board, I decided I'd swap the 74HC374 for the much nicer '574 for managing the MOSFETs. No problem, well, one minor snag, neither Jaycar nor Altronics carry the '574.

    They carry the '374… Jaycar is where I got mine originally. They also carry the very similar '573. I had intended to order some '574s for when the boards arrived, but they sort of turned up unexpectedly… so didn't get a chance.

    The fundamental difference? Apart from the '574 being edge triggered, the '573 also is active high on the logic enable pin. I had wrongly assumed it was active low.

    Naturally, I did try to hack around this fundamental difference:

    Tried to get that leg in focus, but it's difficult when the LCD of the camera is such low resolution (and the viewfinder is an even lower resolution LCD). Basically, I nibbled the leg of the IC with my sidecutters and bent it up. To the pad, I solder the gate of a 2N7000 MOSFET, bend the drain pin up to meet the now floating-in-air LE pin, and run a resistor (a 3k3) to Vcc.

    That works somewhat… it might be possible to introduce some more state machine cycles to handle the kludge… although the real fix is to use the correct part in the first place.

  • First board built

    Stuart Longland06/10/2017 at 08:58 0 comments

    So, I haven't yet tried out the MOSFET outputs, but nearly all the GPIO inputs work. I say nearly… there is one that doesn't on channel 4.

    I can test by shorting out the 0V and GPIO pins with a multimeter probe. Not sure why one channel isn't working yet, that I'll have to debug tomorrow.

    It is worth noting that the MC14066s here are older than I am if I am reading the date codes correctly. Still, they've been kept in a tube all these years, so no reason why they'd suddenly pop. More probable, I've goofed somewhere in the wiring of this.

    At worst, I should be able to de-solder the faulty chip (if that is the case) and put another one in its place… I have plenty lying around. The fact that its mate on the other side is working fine, is promising.

    The up side is this board doesn't look like a big mess of wires like the last prototype. Once I get the faulty channel sorted, I should be able to make the I/O modules that will provide the MOSFET outputs, ESD protection and switch debouncing.

    One thing I'll probably do in future: use bigger vias for my jumper wires, and actually mark on the silk screen component values and the jumper wire routes.

    Did some probing… turns out my jumper wire wasn't making good contact with the via … a dry joint. Definitely I'll make the vias bigger next time!

  • Boards have arrived

    Stuart Longland06/09/2017 at 07:33 0 comments

    So, I had a surprise delivery this morning… 10 PCBs for the new synthesizer.

    These are just two-layer affairs… with the idea being that anyone can manufacture these themselves. The top layer if made at home is done just by covering one side of a double-sided PCB with tape. The other can be done by hand with a dalo pen, using photographic methods or using toner transfer.

    One thing I did have originally, and lost when I told Kicad to delete all footprints when re-working the design, is the mounting holes in the corners, something I'll have to re-add.

    I'll have to pick up some 74HC574s (or perhaps '573s, since that's what the hobby shops sell… won't matter for this project, either will do) and get soldering this weekend.

View all 15 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates