Wednesday, June 28, 2017

Trail: Nukan Kungun Hike - 2 Nights

I walked the Nukan Kungun Hike last weekend, just after the winter solstice. Although the days were short, I managed to do the majority of the walk on the second day. The Coorong has been special to me for a long time, and I've been planning to do this walk for at least two months.

This walk meanders around the small salt lakes, through scrubland and out across the Coorong at 42 Mile Crossing - all being very typically South Australian.


I caught the 6PM bus on the Friday night to Salt Creek, and walked 4 KM to Oystercatcher Campground. On the Saturday I walked to 42 Mile Crossing Campground and back - about 45 KM - and then back the 4KM to Salt Creek on the Sunday.

Note that the water was not drinkable at 42 Mile Crossing, even after boiling. Also, the middle third of the trail is not sign posted well, and its easy to lose the track - however, the general direction always remains either south east or north west.

The MLD Monk Tarp worked great with the Spark 2 sleeping bag. Even in the heart of the South Australian winter, I was warm and dry.














Saturday, June 10, 2017

Photos from Sound Bytes - June 2017




















Tuesday, June 06, 2017

Interfacing with a Toy - Process and Example

Overview
There are many ways in which to interface a toy with an electronic system.

The main considerations are:

  • What types of control does the toy have? 
  • With what can these types of control be replaced? 
  • To what should the replacement of control be mapped? 
For example, take a simple button on a toy. This can be replaced with a relay, 40106-based oscillator, 4066 switch IC, 4051 multiplexer IC, digital switching mechanism, mercury tilt switch, magnetic switch, mechanical switch. This can be mapped from the physical world (tilting, magnetism), analog electronics (using the resistance of a pot of a 40106 oscillator to set the triggering speed), MIDI (note on, note off, CC, pitch bend etc), serial (on / off), ethernet etc. 

Let's examine an specific example of implementing this process. A simple toy phone was taken apart, and controlled via Teensy and USB-based MIDI.





In particular:
  • The battery pack was disconnected. 
  • The toy was powered by the Teensy instead of batteries.
  • The speakers were disconnected. 
  • The audio output of the toy was routed through a digital pot for volume control
  • All buttons of the toy were disconnected
  • Three of the buttons were replaced with a multiplexing setup
  • The resistor clock of the toy was removed
  • The resistor clock was replaced with a digital pot for pitch control
  • Velocity, pitch bend and note events were mapped to the toy

This example brings together a number of different ideas: 





Disassembly 

This is the toy featured in this example. Of particular interest was the camera click sound for the camera button. 


The toy is opened up, and the circuit board is visually and functionally explored. 


This is the close up of the circuit board. 


Functionally, there are a number of points of interest, labelled A to J in the image. 
  • Point A is ground, and is connected to the negative terminal of the battery
  • Point B is 3V, and is connected to the positive terminal of the battery
  • Point C is a speaker terminal connection 
  • Point D is the other speaker terminal connection 
  • Point E is the connecting pin for the third row of buttons in the button matrix
  • Point F is the connecting pin for the second column of buttons button matrix
  • Point G is the connecting pin for the third column of buttons button matrix 
  • Point H is a connecting pin for the play button, which triggers a sound
  • Point I is one connection for the clock resistor
  • Point J is the other connection for the clock resistor 
Of note is that the main matrix of nine buttons (on the front face of the toy) are connected to the chip via nine pins. Three pins (labelled on the circuit board as P13, P12 and P11) represent the rows, and another three pins (labelled on the circuit board as P20, P21, P22) represent the columns. 



When a row pin and a column pin are connected (by pressing a key, for example), then a sound is triggered. Three pins are set as inputs, the other three as outputs. 

The software can set two outputs low and one output high (for instance, column 1 high, column 2 low, column 3 low) and then measure on the other three pins (therefore row 1, row 2, and row 3). 

If a given row is measured as high, then the combination of the current column and the measured row indicates which button is pressed. This process is repeated for all three columns. 

By connecting Point E from the previous image to Points G or H, this is making these column to row connections - and as a result, triggering the sound. 


The speaker and batteries are removed. 










Soldering

A set of six wires are prepared. The end of each wire is stripped back a little, and a small amount of solder is added to each end of the wire. These six wires will be soldered to points E, F, G, H, I and J so that the connections for the button pressing and pitch bend can be made to a breadboard. 

This is the underside of the circuit board. Conveniently, points F, G and H are all through-hole connections, with a small copper area perfect for soldering on the front side. The wires can be sent through the holes from the underside, and then soldered to the front side easily. 


The toy is now completely removed from the casing. The black wire is ground, the red wire is 3V, the the white wires to the bottom of the board are the speaker connections. 


Four wires are soldered to points E, F, G and H. These will be connected to a multiplexer, so as to replace three of the buttons. In the case of point E, the copper surface had to be scratched back using a screwdriver - this made it possible to attach solder and hence the wire to it. 


The clock resistor is desoldered. One wire is soldered to point I, another wire is soldered to point J. In both cases, a small amount of additional solder onto the circuit board made it easier to connect the wire to the circuit board. 










Hardware Setup 


The toy is connected to a breadboard. The speaker outputs are connected to a digital pot. The key connections are connected to a multiplexer. The power supply terminals are connected to the 3V supply of the Teensy. 


The Teensy 3.6, 4051 multiplexer and MCP4241 digital pot are all placed on the breadboard. 

In terms of the breadboard setup, the following connections are made: 
  • Teensy ground to breadboard ground
  • Teensy 3V to breadboard power supply
  • Teensy digital pin 0 is connected to 4051 pin 6 (Enable)
    • This will enable a note on event to turn on a button, and a note off event to turn off a buttoin
  • Teensy digital pin 1 is connected to 4051 pin 11 (Address A)
    • This is bit 0 of the multiplexing address
  • Teensy digital pin 2 is connected to 4051 pin 10 (Address B)
    • This is bit 1 of the multiplexing address. Having 2 bits worth of addressing will allow the Teensy to control all three desired buttons
  • Teensy digital pin 10 is connected to MCP4241 pin 1 (SPI slave select)
    • This is the chip select signal for digital pot
  • Teensy digital pin 11 is connected to MCP4241 pin 3 (SPI master out slave in)
    • This is the data signal going from the Teensy to the digital pot 
  • Teensy digital pin 14 is connected to MCP4241 pin 3 (SPI clock)
    • This is the clock signal for digital pot
  • MCP4241 pin 4 is connected to ground
    • This is the Vss pin 
  • MCP4241 pin 14 is connected to 3V
    • This is the Vdd pin
  • MCP4241 pin 12 is connected to 3V
    • This is the shutdown pin, and is active when low
  • MCP4241 pin 11 is connected to 3V
    • This is the write protect pin, and is active when low
  • MCP4241 pin 8 is connected to the outside leg of a 1M potentiometer
    • The potentiometer will coarsely adjust the pitch of the toy
  • MCP4241 pin 9 is connected to one pin of the clock resistor on the toy
  • The middle leg of the 1M pot is connected to the other clock resistor connection on the toy
  • MCP4241 pin 5 is connected to ground
    • This is the grounding for the volume output of the toy
  • MCP4241 pin 6 is connected to the audio input signal connection of a sound card input
  • Ground is connected to the audio input ground connection of a sound card input
  • MCP4241 pin 7 is connected to the speaker output from the toy
  • 4051 pin 3 common pin is connected to the Point E of the toy (the row 3 pin of the keypad matrix)
  • 4051 pin 7 Vee is connected to ground
  • 4051 pin 8 gnd is connected to ground
  • 4051 pin 9 is connected to ground
    • This is bit 3 of the 4051 multiplexing address
  • 4051 pin 13 is connected to Point F of the toy
    • This is the first channel of the multiplexer
  • 4051 pin 14 is connected to Point F of the toy
    • This is the second channel of the multiplexer
  • 4051 pin 15 is connected to Point F of the toy
    • This is the third channel of the multiplexer
  • 4051 pin 16 Vcc is connected to 3V









Software and Mapping


This is the code used to control the toy. 

The code responds to MIDI data. Different pitches will trigger different buttons (out of the three connected buttons). Pitch bend will control the playback rate of the sound. Velocity will control the volume. 

The SPI library is included and a slave select pin is defined. In the setup function, the slave select pin, and pins used for the 4051 are set as outputs. Handlers are set for note data and pitch bend data. The SPI bus is started. In the loop function, the USB MIDI bus is read. 

The function that is executed when a note on message is received sets the volume digital pot based on the velocity, selects the appropriate button via the two address bits of the 4051, and sets enable to on for the 4051. This triggers a button, at a pitch, with a certain volume. 

The function that is executed when a note off message is received sets the volume to zero, and sets the enable to off for the 4051. 

The final function is an encapsulation that writes data to the MCP4241. 

Sunday, June 04, 2017

Trail: Waitpinga Road - 1 Night

I spent one night on the Heysen Trail, camping at the corner of Waitpinga and Range Road. This spot was about an hour's walk from the Encounter Bay public bus stop, two hours from the Victor Harbour stop.



A cold, but peaceful night. Walking back in the early morning was worth the view of fog in the valley, and looking down across the bay.