Tuesday, June 17, 2014

6-stage CD4013 clock divider

So, following on from my last post demonstrating an Arduino-based clock divider, I made another one with just dual-flipflop (CD4013) logic chips. This design divides into powers of two, from /1 to /32, using six flipflop units. Nothing fancy or ground-breaking - just implementing something I found on Wikipedia.

It seems that it needs the input clock pulse voltage to be reasonably close to the IC supply voltage. When I ran it at 12V supply with 5V input pulses it didn't seem to work very well at all. 6V supply with 5V pulses seems to work quite reliably. This can be improved by feeding the input clock line with a MOSFET.

Essentially this is an implementation of the cascading arrangement depicted here. The only parts not noted in that diagram are:

  • The additional flipflops, which are wired in exactly the same way
  • RESET and SET lines on each CD4013 must be tied low
  • The usual power supply rails

Sunday, June 15, 2014

Arduino clock generator + divider experiment

Lately I've been learning about modular synths. One of the common things modular folks use to control things is a pulsed clock. This afternoon Tiina and I wandered down to Redfern to check out a meeting of the New Sound Waves modular synth group. The guys there had synced up their modulars and assorted other equipment with a shared clock source and were collaboratively making music. Pretty cool stuff.

Anyway, I decided to try to make my own clock divider. Didn't take long to get something working, and you can see the results in the video above. The genuine Arduino Uno is generating a simple square wave on pin 13, which you can observe with the built-in LED. The Freetronics clone is triggering on the rising edge of the square wave and operating a clock divider with /1 through /8 outputs. The /1 through /4 divider outputs are attached to a little test-LED board I made a while back. You can see that it has a bug caused by my forgetting to reset the tick counter.

To actually use this in a modular synth it would need to tolerate inputs in the range -12V to +12V, maybe via a bunch of MOSFETs. It might be easier to just ditch the AVR and use flip-flops

Sunday, January 19, 2014

Rescuing an "unhappy" EM406A GPS

I'm not sure of exactly what happened, but while I was mucking about with my datalogger this afternoon, the EM406A GPS sensor started emitting what looked like garbage in place of the usual NMEA sentences. A little googling revealed a thread on the Arduino forums which contained a link to Ken's blog post over at DIYDrones. I grabbed a copy of Ken's code and tried it out.

As the comments in the code indicate, some mucking about with the baud rate was indicated. Attempts at 57600 and 38400 seemed to make no difference, but after trying 9600 baud I got a single NMEA sentence followed by a bunch of binary data (presumably SiRF), and feeling encouraged at that result, I tried the magic at 4800 baud and also changed the configured baud rate (see lines 53-55 in the below code) to 4800. It worked, and now my EM406A is emitting NMEA sentences and no binary SiRF data.

Along the way I adjusted the code to take advantage of the extra USARTs available on an Arduino Mega2560 board. The GPS is connected to RX1/TX1, and some status messages are emitted to the usual Serial console. After attempting the rescue process, it also starts dumping the data stream from the GPS onto the Serial console so you can see immediately if it was successful or not.

Summary: happy and very relieved - didn't want to buy another sensor! Post a comment and don't forget to thank Ken if this was useful to you - this is his rescue code, not mine!

Friday, January 3, 2014

My highlights of 2013

  1. March: Seeing Opeth live in concert again, at Enmore Theatre in Sydney. Mikael Akerfeldt appears to have his growl back. Hands-down the best gig I've ever been to, of any genre. Can't wait for their next tour (and mooted new album, also)
  2. April-May: Visiting the UK and especially Finland with my friend Tiina. I'd visited the UK back in 1984 when I was a wee lad, but didn't really remember anything. Was great to go back. But... Finland was stunning. We spent two weeks exploring it. Definitely going back there. Also on the way back to the UK (we flew home from London) I ticked off another bucket-list item - we visited the original Legoland in Billund, Denmark. I'd wanted to go there ever since I saw pictures of it (I think in one of those Lego Ideas books published by Lego) back in primary school.
  3. June: Visiting Japan very briefly, spending three nights in Tokyo, ostensibly to see Van Halen's concert at the Tokyo Dome. While there I caught up with an old friend who now lives in Tokyo, and ticked off another bucket list item - spending a few hours ogling all the wonderful things at the Toyota Automobile Museum near Nagoya. The Shinkansen (bullet train) to Nagoya was also pretty interesting.
  4. October: Acquired a new motorcycle - 2013 KTM 990 SuperMoto R. Ludicrous fun. Sounds wonderful. Somewhat impractical fuel range. Completely unsuited to highway slab rides, but brilliant for sporty rides and generally being a hooligan, which is just what I'd wanted

sampling multiple analog signals asynchronously with Arduino

So while I was assembling a fellow #arduino denizen's synth project on a breadboard, he commented that Arduino's analogRead hadn't been fast enough to read the pots. After poring over the AVR ATmega328 datasheet for a while I was able to get an interrupt-driven analog-to-digital conversion happening. This is documented in many folks' blogs but most of the pages I've seen only demonstrate one, and I needed four. His acidmatic synth is now rather a lot of fun to twiddle, and I will keep hacking on it, and build a permanent version in an enclosure.

Stripped-down demo code follows. Note that this requires an analog reference signal to be wired up to the AVR. This can actually be done in software if you just want it to be set at Vcc or some other voltage visible to the microcontroller, but I was getting very tired and that part of the datasheet was not making any sense. On my 16Mhz ATmega328, the below code yielded somewhere north of 2000 samples per second per pot. Easily enough for this application.