Modular Music Box – Notes to Mike Cook 1

Just to recap – there are 5 units

  • rotary sequencer – Arduino Mega 2010 + Adafruit Motor shield – I2C master
  • sound module – Fluxamasynth rev1.0 – I2C slave (this to check)
  • winder – Arduino Duemilanove – I2C slave
  • ballerina praxinoscope – via Adafruit Motor shield
  • battery

I’ll start with the ‘Winder’

Three main elements here for integration into a protoshield to sit on a DFRobot.com Arduino Duemilanove clone… :

  1. driving 12 orange 3mm LEDs – MV7744 – via a MAX7221 and the LedControl-library – or ideally a TLC5940 if you can get it to work with an I2C bus
  2. rotary encoder
  3. I2C


Arduino pins

Digi 2 – Encoder – button (interrupt)
Digi 8 – Encoder
Digi 9 – Encoder
Digi 12 – MAX7221 DIN
Digi 11 – MAX7221 CLK
Digi 10 – MAX7221 LOADCS
Analog 4 (SDA) – I2C
Analog 5 (SCL) – I2C
5V
(GND) COMMON GND

1. I referred to the Arduino: Playground The MAX7219 and MAX7221 Led drivers page and used that ‘Wiring and schematics’ diagram…

I calculated the RSet resistor value at ~17k – though it should probably have been 28k according to the table on the page (the MV7744 data sheet list Vf = 2.1V and If = 20mA) – but that’s for an LED matrix not individual LEDs – happy for you to work out what this should be….

2. From details at – http://tronixstuff.wordpress.com/?s=rotary+encoder – used their simple circuit diagram

Used Keith Neufeld’s Arduino Quadrature Encoder Library available here to download – and though initially it didn’t compile… reading further in the post I came across instructions to add:

#undef int
#undef abs
#undef double
#undef float
#undef round

after all the #include statements in the Arduino sketch – and bingo!

Does the rotary encoder need a capacitor? – 0.1uF – suitable for stabilising output – double check this

Also intending to use quistoph’s DebounceButton Arduino library – http://download.bleq.nl/DebounceButton_0.3.zip (link currently not working)⁃ to provide onPress(), onRelease, onHold(), onClick() functionality – which combined with the push button of the encoder could be useful as a ‘hidden’ control system – should we need it…

3. I2C

My colleague Nick discovered the requirements for a common ground for the I2C bus – so we’ll need to plan this into the circuitry of one of the boxes – probably the rotary sequencer?

I’ve attached a zipped folder of component datasheets, arduino library and Nick’s arduino sketches –

‘mmb_winder’ – includes my commented out code after an unsuccessful test with a TLC5940…

‘mmb_12cmaster’ – polls the I2C slave and runs a timer…

Nick’s localised the libraries to make moving files around a bit easier… and he’s added some commenting…

[UPDATE] – Mike responds…

1) Common ground for I2C is provided automatically as you have a common power supply for all modules, so no need to do anything extra.

2) I would strongly recommend that you use this circuit for the rotary encoder:-

The problem is first that they have a lot of contact bounce and trying to suppress this in software and determine the direction of rotation at the same time is a bit of a big ask and normally it won’t work. I don’t know if you noticed but some times the Project sketch would go in the wrong direction at times.

Posted January 4th, 2011

Comments are closed.