(Opto) Photo Interrupter – pushing the limits

The z1670 photo interrupter from altronics ships with a 3mm gap through which an obstacle must pass to trigger a voltage drop that can be detected as  digital state change by something like an arduino. What if you want a wider gap? How far apart can the IR LED and the Detector be?

Electronics

About 13mm seems to be the sweet-spot (indoors on a mild day).

While I was able to measure a voltage drop at distances up to about 20mm (which could be detected as an Analog input to my Arduino project), it seems that things degrade pretty quickly after about 13mm. Using the resistor setup I describe here, 13mm gives an input reading of <100 as an analog input with gap open, and jumps to 1023 when closed – ideal for digital LOW/HIGH state change with good margin for error in differing conditions.

Here is the data:

Untitled

Creative Commons License

Fang - Mike Seyfang

TriBeardLesBones

Posted in Hobbies, phd, science | Tagged , | Leave a comment

Frankensteining old Internode router for WiFi on Telstra BigPond

Wrong.

In the end I had to set up two separate IP networks and get the Billion BiPAC 7404VGP to forward packets by setting up an ‘IP Alias‘. Set as DHCP relay agent.

Not as elegant as a single IP network but simple enough once you figure out the design and the funky terminology in the web based user interfaces for each device. However, the path to get there was anything but simple thanks to Telstra device locking, sloppy user interface design and firmware by Billion and an annoyance of half-arsed forum posts. With a bit of luck this blog post will save somebody (probably me) some pain when they try to re-use some old gear to get people on the internet.

  • Telstra have locked the thomson speedtouch 536 configuration to suit their BigPond network. My plan was to change the LAN IP address range from 10.0.0.x to 192.168.1.x to match the factory defaults of the Billion. Could have proceeded down the ‘update and unlock’ path but life is too short. The IP address for this router is 10.0.0.138 – whodathunk!
  • Couldn’t set  Billion LAN IP address range to 10.0.0.x The bipac7404vgp gave error “webserver:Invalid value 10″ every time I tried to set it’s LAN IP address to an unused address in this range.
  • Didn’t notice anything in the Billion configuraion User Interface that looked like it would forward packets from a 10.0.0.x network to a 192.168.1.x network until after I upgraded it to the latest firmware. (Doesn’t mean it wasn’t there, I just didn’t find it – and I cant be arsed going back old versions and looking).
  • Updating the bipac7404vgp firmware from a Mac running OSX snowleopard 10.6.8 was a pain in the arse.
    • The .zip files on the billion support downloads site contain another compressed ‘.afw’ configuration file which is what the firmware update interface is looking for
    • Many OSX methods for unzipping the .zip file give varying results.
    • Firmware Upload Failed
      Failed to write to file system.
      Failed to update FLASH chips.
      This may be due to a corrupt FLASH filing system.
      You can attempt to repair this by saving configuration.
      error
    • Use terminal in OSX to unzip the .zip file is the most reliable
    • Restart router using Factory defaults *BEFORE* attempting firmware upgrade
    • Still no joy
    • Out of desperation I grabbed the 7404VGPM firmware (even though every physical marking or configuration page said mine was a 7404VGP), unzipped the .zip using OSX terminal, restarted from factory defaults – this time it worked.
  • After the firmware update, I still couldn’t set the Billion’s IP Address to 10.0.0.x range but I did notice ‘IP Alias’ in the configuration pages for the first time.
  • Set up an IP Alias of 10.0.0.254 for the Billion with subnet mask of 255.0.0.0. Remember the SpeedTouch router address is locked at 10.0.0.138 and it’s DHCP server dishes out client addresses starting at 10.0.0.1.
  • Turn off DHCP server of Billion (set as DHCP relay agent).
  • Took the Billion around to the in-laws, used a spare Cat5 10baseT ethernet cable to connect from LAN port 1 on the Billion to the unused Ethernet Port on the Thomson Speedtouch (checked for the green link status light on each port – you guessed it, the first cable I tried failed!).

After a bit of fiddling around I managed to get an iPhone, iPad and my Android phone to connect to the WiFi from the billion, get an IP Address in the 10.0.0.1-20 range (shows up in the speedtouch status page at 10.0.0.138) and surf the world wide inter-tubes courtesy of a locked BigPond rooter. Yay!

Creative Commons License

Fang - Mike Seyfang

TriBeardLesBones

Posted in Computers and Internet | Leave a comment

LoLa Prototype v1.1 = SUCCESS

It Lives! A broomstick driven, photo interruptor sensor enabled pendulum that uses MIDI to make a sound for each half swing.

As part of my research for the Institute of BackYard Studies , I am prototyping various components for a Lightly Oscillating Linguistic Organ (LoLa) – a musical instrument that harnesses the sinusoidal beauty of the pendulum wave.

After much fecking around with magnetic reed switches, analog light sensors, mercury switches, mp3 players and android phones I have finally iterated toward a reliable setup.

  • A $2 Opto (or Photo) Interrupter sensor. For two bucks you get a little plastic gizmo that has an IR LED and detector separated by a 3mm gap. A couple of resistors and some fancy PCB wiring and you can make a digital input for the Arduino.
  • Arduino Sketch that detects a change of state on said digital input and sends a MIDI note command via the serial output.
  • A very simple 3 wire connection to a DIN 5 Connector for MIDI Output (Not quite MIDI standards compliant – need an opto isolator circuit for that).
  • MIDI to USB input to an old mac mini that was lying around (PowerPC – OSX 10.5).
  • SimpleSynth midi synth running on OSX 10.5.
  • MIDI Monitor for OSX to debug things.
  • Headphone output from mac mini to an old ghetto blaster in my shed to make noise louder.
  • A work of art! (in the making).

Here is what I learnt:

  • MIDI can be deceptively simple and frustrating
  • On arduino DUE when using the +5V MIDI DIN 5 circuit as per all the instructions out there just got jibberish. By pure chance I tried +3.3V and it works like a charm.
  • I probably spent as much time getting the sketch to reliably start with the MIDI sound I wanted (church bell) as I did on the rest of the MIDI work, including cabling.
  • I probably should have started with a photo interruptor already wired up as an Arduino sensor rather than go down the rabbit hole of circuit diagrams, datasheets and the futility of resistance!

Creative Commons License

Fang - Mike Seyfang

TriBeardLesBones

Posted in Hobbies, phd, science | Tagged , | Leave a comment

(Opto) Photo Interrupter – working properly as DIGITAL input to Arduino DUE

The z1670 photo interrupter from altronics is actually a BPI-3C1-13 by bright led electronics corp. This is how you connect it to an Arduino digital input at +5V.

Arduino5vOptoPhotoInterrupterBPI-3C1-13
I’m using an Arduino DUE so I used an external +5v power supply (from my model aeroplanes) always remembering to connect earth to common ground – arduino GND and the GND of my circuit.

*Note: this simplified circuit diagram does not quite match the physical layout of the pins. If you look closely at the ‘Top View’ schematic in the datasheet you will notice that the Collector (3) and Emitter (4) are physically located the other way around – which makes the wiring a little more messy.

The 220 ohm resistor between the +5V and Anode drives the IR LED input’s Forward Voltage in the range 1.2 – 1.5V at around 20mA. The 4.7K ohm resistor between the +5V and (3) Collector gives us a nice wide voltage change when an object is placed in the gap between the IR LED (1) (2) and the Detector (3) (4). I measured 96.5mV open and 5.31V closed. This gives a very sharp and reliable OFF/ON, LOW/HIGH, 0/1 digital input. Hooking up to an ANALOG input (A0) on my Arduino DUE showed values from the low 20′s open to 1023 closed – perfect!

So, how did I get that circuit diagram and those resistor values? I have to admit, I phoned a friend. My mate Ashley who actually understands this stuff explained the calculations like this:

  • Look at the ‘Forward Voltage’ Vf on data sheet which shows 1.2V typical to 1.5V max at 20mA. (5V-1.2V)/.02A = 190Ohm. 220Ohm is close enough.
  • Look at the ‘Light Current’ Il on datasheet 1.0 – 10 Ma. To get a nice strong voltage change across (3) Collector and (4) emmitter calculate the resistance required to leave about .5V with gap open. At 1mA the calculation is (5V-.5V)/.001A = 4500 Ohm.

Creative Commons License

Fang - Mike Seyfang

TriBeardLesBones

Posted in Hobbies, phd, science | Tagged , | 2 Comments

(Opto) Photo Interrupter – first look

Yay – my first electronic ‘explosion’ courtesy of an (ex) Photo Interrupter!
zd1901-photo-interrupter
In a hurry to have my first try at an optical switch, purchased yesterday from JayCar I did the following:

  • I used this zd1901 photo interrupter from JayCar (datasheet).
  • I copied the schematic from this post which had a 10k resistor between the + anode (long wires) and a 230 ohm resistor between the two short (- cathode) wires. That design was based on this RPI-574  datasheet .
  • Since I didn’t have a 230 ohm resistor I used a 100 (which measured at 180 on my multimeter) in series with a 103 10k potentiometer that I tried to dial in 230 ohm total.
  • All was going well until I figured a lower than 230 ohm resistor would be interesting to try, only I managed to provide a path of 0 ohm resistance for long enough to fry my IR led.

Schematic

Which resulted in:

  • A kinda / sorta working output voltage in the range 4.7 – 5 volts. Ranged from the high 900′s to 1023 on arduino analog input A0 by moving a piece of paper between the gap.
  • A failed attempt to use a variable resistor to drive the analog values from close to 0 up to 1023 so I could use it as a digital input to my arduino.
  • A short across what should have been a 230 ohm resistor resulting in a loud pop, smoke and a nasty smell!!!

Note to self:

The z1670 photo interrupter I got from altronics and it’s datasheet.

Creative Commons License

Fang - Mike Seyfang

TriBeardLesBones

Posted in Hobbies, phd, science | Tagged , | 2 Comments

LoLa platform for sensor testing

To figure out which sensors / switches will reliably trigger sounds from sixteen swinging pendulums on our proposed ‘Lightly Oscillating Linguistic Organ’, I decided to build a test bench. While doing so it occurred to me that like Professor Tanya Monro, I was building a ‘platform for sensing’ (albeit on a slightly smaller scale).

Here is what I did:

  • Hung an old broomstick from a ladder
  • Added a few bearings to make it swing better
  • Added a six inch piece of orange PVC conduit to the top of the broomstick (via some home sprinkler system pieces I had lying around)
  • Wired my sensors to servo leads (from my model planes) and stuck em to wooden pop-sticks (actually tongue depressors)
  • Whacked a cardboard box on the top with arduino, battery and breadboard with holes to shove my sensors into
  • Strapped an android phone running ‘AndroSensor’ to the bottom of the broomstick
  • Carted my laptop out to the shed and collected a bunch of data via arduino serial monitor & pasted into a spreadsheet & from a .csv file that an android phone’s sensors was writing to
  • Bunged the collected data into a few google spreadsheets for analysis by chart

LoLaSensorPlatformTestDataRun1

Here is what I learnt:

  • My $10 freetronics light sensor for android (that gives an analog output proportional to light intensity) mounted at the top is very reliable and copes with really sloppy swings.
  • A $1 glass reed switch under a strong magnet on the bottom of the broomstick works well (once you make it stronger by sticking to a wooden tongue depressor and cover in clear epoxy and when you figure out how to ‘de-bounce’ the signal). 
  • My $10 hall effect sensor for android mounted at the top is easy to use & check but hard to position well for consistent results. You need to have a very smooth swinging pendulum and find the exact centre.
  • The guys building the physical pendulum wave have expressed concern over perceived slowing due to the magnetic force on each pass. This should be measured & tested before giving up on the simple reed switch..
  • The ‘false positive’ readings I was getting from the magnetic reed switch is actually a well known phenomonen called ‘bounce‘ which can be de-bounced in software or via some rather ingenious circuitry! [I'm a little bit chuffed because before I discovered those links, I simply looked at my data on a graph and hacked my code to ignore state changes for a few hundred milliseconds after the first].

Photos:

LoLa sensor platform

Platform for sensing

Sensing platform ctd... LoLa sensors

LoLa sensors

LoLa sensors

LoLa sensors

Creative Commons License

Fang - Mike Seyfang

TriBeardLesBones

Posted in Hobbies, phd, science | Tagged , | Leave a comment

LoLa Prototype v1.0 = FAIL

As part of my research for the Institute of BackYard Studies , I am prototyping various components for a Lightly Oscillating Linguistic Organ (LoLa) – a musical instrument that harnesses the sinusoidal beauty of the pendulum wave. Inspired by a creative brain fart described in “Nightmare on IBYS street”, I set about prototyping the playing of sounds from android phone sensors.

After much googling around and substantial fiddling, here is what I did:

  • Searched around for quick and dirty ways to create an android app using PROCESSING to play sounds based on sensor input. Found out pretty quickly there are many can-o-worms and significant issues around latency.
  • Decided to simply mash up a few sensor / music apps for a V1.0 prototype. 
  • The AndroSenso app simply outputs raw data from each sensor and can make graph / log file recording for a period of time. After looking intently at accelerometer data I decided the Proximity Sensor would be a better option for my first prototype sound trigger.
  • The Proximity Actions app allows actions to be configured when various numbers of ‘waves’ past the proximity sensor are detected. It is pretty well thought out, behaves well in the background and can easily trigger music play / pause.

Here is what I learnt:

  • Latency, latency, latency – such a long wait before any sound starts. Varies depending on the state the phone is in, gets worse over time…
  • APPS: accelerometer sensor, physics Toolbox, androSensor (the most useful), proximity sensor finder, proximity sensor clib, sensor music player, music proximity, proximity actions (the most useful).
  • Good as it is, Proximity Actions has it’s limitations & points to a whole lot of pain in developing my own specific trigger app. A minimum of two ‘waves’ must be detected before and action can be triggered. The proximity sensor on the HUAWEI ascend g510 running android v4.1.1 is soooo frustrating. I could only get it to detect two waves with Max ave time at .4 sec & max wave timeout at .7 sec. And then it is frustrating as hell to reliably produce the two waves required to trigger the music.
  • And then there is the LATENCY. Not only is it horrible but it varies. I’m guessing the variation is due to the phone o/s swapping out or shutting down things like the music player after a while. Nearly a second delay at best, several seconds when things go pear shaped.
  • If it is crap as a prototype, things will probably get worse trying to hard code this and scale up to more than 8 devices swinging at once! My guess is that proximity sensors (and indeed others) would vary from phone to phone – making consistency difficult. From everything I read, latency is always going to be a problem. Finally, the phone is designed to provide a good phone experience – there are a lot of environment considerations to take into account when building an app to quickly trigger sounds, day in, day out..

Creative Commons License

Fang - Mike Seyfang

TriBeardLesBones

Posted in Hobbies, phd, science | Tagged , | 1 Comment