Arduino powered Vileda cleaning robot

I needed a robot platform for a project and bought a Vileda A3 cleaning robot cheaply from ebay, advertised as not working but a new battery fixed that! (Battery for Vileda M-488a fits this A3 model)

Opening it up:

we find the expected motors for the wheels, fan, main brush and edge brush. The wheels are equipped with optical encoders. Other sensors include the left and right bumpers, wheel drop switches and cliff detectors. The top lid holds three buttons and a red and green LED. There is a 360° IR reflector installed but this is not populated with a detector.

There is a self-contained NiMH battery charger board under the top lid:

Rather than totally replace the existing PCB I decided to just replace the microcontroller (an 8051 clone) so I could keep the existing motor drivers, connectors etc

After a bit of reverse engineering I came up with the following PCB  pin assignments:

μC Pin Function Arduino Pin/Dir Notes
1 Right Bumper D6 In  HIGH on bump
2 Over current In  Unused
3
4 Right wheel forward D10 Out PWM  IN1
5 Right wheel backward D9 Out PWM  IN2
6
7 Fan & Side brush motor Out  Unused
8 Wheels up D13 In  All 3 wheels OR’ed
9 L switch D12 In  LOW when pressed
10 L switch LED D11 Out  Active LOW
11
12 M switch A0 In   LOW when pressed
13 S switch A1 In   LOW when pressed
14 Green LED A2 Out  Active LOW
15 Red LED A3 Out  Active LOW
16 M switch LED A4 Out  Active LOW
17 S switch LED A5 Out  Active LOW
18
19
20 GND
21 Left wheel forward D3 Out PWM  IN4
22 Left wheel backwards D5 Out PWM  IN3
23 Left bumper D2 In  HIGH on bump
24 Speaker D4 Out
25
26 Main brush motor Out  Unused
27
28
29
30
31
32
33
34
35 Left wheel encoder D7 In
36
37
38
39 Right wheel encoder D8 In
40 +5V regulated

N.B. pin 9 was wired as an 8051 interrupt circuit so I modified PCB to make it a simple switched input (removed C23 and R89 and wired J7 pin 4 directly to µC pin 9).

I didn’t need the cliff sensors so didn’t trace those out.

The motor driver chip is an Allegro A4954 dual 2A/40V h-bridge. Current limit is pre-set. Pins IN1-IN4 of this chip are routed to the microcontroller.

Not much room around the PCB in-situ so I removed the microcontroller, soldered flying leads directly to the PCB and routed them to the indicated arduino pins. I wanted to keep the Rx/Tx pins free so only had 18 pins to play with. It should be possible to multiplex some inputs if needed in the future. Here is the hacked board under test:

and here it is embedded back in the robot:

The PCB is a tight fit and once the main brush motor is removed there is just enough space for the Arduino to sit in its place.

A simple program was written to exercise the main features. Here is a short video showing the response to bumpers and a quick demo routine that cycles through the LEDs, plays a tune and does a little dance.

 

 

 

Scratchy

 

Santa delivered a vinyl record player this year! We had great fun listening to old records from our past. One of the best things about the vinyl experience is the excellent user interface, with touch, feel and even smell. But our record collection is not in the best shape and after a while I missed the less scratchy digital downloads I’d become used to. So I looked for a way to combine the user interface of vinyl with the more predictable quality of mp3 files, and the result was Scratchy!

The idea is to connect the turntable audio output via a black box to an Android app, which listens to what is being played, identifies the album, and plays a digital version of it. At the top level the system looks like this:

Record Player -> Black Box -> Android App -> Amplifier -> Speakers

The black box has two main purposes:

  1. to trick the android phone into thinking there is a microphone attached. This just requires a 2.2k resistor from the mic input to ground. Any value resistor above 1k will do, lower values may trigger the phone to mute the audio.
  2. to drop the voltage from line level to mic level and to combine the stereo channels into one. A simple 100:1 resistor divider does the job. This is not needed if the turntable outputs a low level signal.

Here is the schematic:

And here is a view inside the black box:

 

In normal operation the android app runs in a loop as follows:

  1. Listen for a new record being played
  2. Identify the album
  3. Play a digital version of the album
  4. Continue to listen to the turntable output and stop the currently playing album if a period of silence is heard (needle up)
  5. Back to 1

Album identification is done by listening to the first five seconds of audio, fingerprinting it, and then looking up the fingerprint in a database. Fingerprinting is based on an algorithm published by Shazam (ref).  The incoming audio is split into 0.1 second samples which are Fourier-transformed, and a set of representative note pairs extracted. See the linked reference for more details on how this works.

The app is trained to recognise new albums by switching to Learn mode, entering the name of the m3u file that it corresponds to, and then playing the album.  When audio starts, the app will fingerprint about 7 seconds of it and store the fingerprint together with the m3u filename in a database.

The source album doesn’t need to be of high quality – old scratched records work just as well, as long as the first few seconds can be played and recognised. It is even possible to associate a digital album with a completely different physical record!

Here is a short video of Scratchy in operation:

The android app was written in C# using the Xamarin framework. Full source code can be found here: https://github.com/ynformatics/scratchy

I hope you find it useful.

iPhone Polarisation Camera

This project describes the construction of an iPhone accessory which allows pictures of polarised light to be captured.  It is based on previous work by David Prutchi which should be referred to for more details.

Principles of operation

The device is based on a screen from an auto-darkening welder’s mask purchased on eBay. This is constructed from a liquid crystal panel sandwiched between two cross polarised sheets. When no voltage is applied to the liquid crystal it rotates incident light by 90 degrees and so the light passes through fairly unimpeded. When about 5V is applied the rotation drops to zero degrees and blocks the light.

Removing one of the polarised sheets produces a voltage-controlled polariser. Prutchi showed that there exists a voltage between 0 and 5V where the incident light is rotated by 45 degrees. By taking three images at 0, 45 and 90 degrees the degree and angle of polarisation can be determined for each pixel in the scene and visualised.

The precise voltage at which 45 degree rotation occurs varies over time so a way is need to calibrate the polariser. In this design a piece of polarising sheet is placed at 45 degrees and light from the iPhone’s flash-light is shone through and detected with a photo-transistor. By varying the voltage across the polariser, a minima in transmitted light occurs when the 45 degree polarisers cross. This minima can be detected and used to set the corresponding 45 degree voltage reference.

ds1054

Bottom trace – polariser voltage. Top trace – light detected by the photo-transistor. A clear minima can be seen.

The iPhone’s flash-light is also used to synchronise the change in polarisation with the image taking. The iPhone blinks the flash-light after every three images have been taken. The device uses this flash to reset the 0,45,90 sequence to a known state.

ds1054

Top trace (blue) – light pulses from photo-transistor. Bottom trace (purple) – synchronised voltage applied to the polariser.

Firmware

An Arduino is used to control the polariser. A photo-transistor located facing the iPhone’s flash-light LED is connected to both an external interrupt pin and an analog pin. Short pulses on the LED cause interrupts in the Arduino code which are used to synchronise the polariser. Long pulses on the LED cause the Arduino to enter calibration mode.

The time interval between synchronisation pulses is continuously measured and divided into three equal parts. On receiving a synchronisation pulse the voltage is set to 0V for one part, to the 45 degree voltage for one part and finally to 5V for one part.

Voltage for the polariser is supplied from an Arduino PWM output pin. To get a reasonably stable output the PWM frequency was increased to 32 kHz and smoothed with a second order RC filter.

The liquid crystal display will be damaged by a constant DC voltage so a CMOS switch is used to alternate the polarity. A 2 kHz square wave generated from a free running Arduino timer is used to drive the switching.

schematic

 

Hardware

The polariser was mounted on a cheap iPhone cover so that it covered the camera lens and the flash-light led. The photo-transistor was mounted in a strip of wood and taped to the polariser facing the iPhone flash light. For calibration a small strip of polarising film was cut at a 45 degree angle and inserted between the photo-transistor and the polariser. The circuit was made up on a scrap of strip-board. A separate battery pack was used to power the device.

IMG_6112

Assembled device

head detail

Camera head detail

iPhone App

The iPhone app is responsible for the UI and image processing. It is written in Swift.

Image frames are continuously captured from the camera. The time for three images to be captured is measured. A minimum of 60 ms per image is required and if needed intermediate frames are skipped to allow the polariser enough time to change between states.  The flash-light is blinked after every 3 images to synchronise the polarisation. The blink is delayed by a variable amount to shift the alignment of frames to the changes in polarisation. A slider is provided to alter the alignment delay.

When three images have been received corresponding to 0, 45 and 90 degrees polarisation, they are processed to generate a representation of the scene which is displayed on the screen. Custom GL kernels are used to solve the Stokes equations and generate either an RGB or HSV visualisation of polarisation parameters. These calculations run on the phone’s GPU and so are easily able to keep up with the camera’s frame rate.

A “Calibrate” button turns on the flash-light for 2 seconds. This triggers the Arduino to run a calibration of the 45 degree voltage level, and provides the light to do so.

A selector allows a choice between RGB or HSV visualisation.

A “Shutter” button takes a picture by saving the latest processed image to the camera roll.

Full source code for the Arduino and iPhone is available here.

Example Images

IMG_6002[1]

Laptop cover illuminated at a shallow angle from rear showing horizontal polarisation (HSV)

IMG_6075

CD jewel case in front of laptop screen showing stress patterns (HSV)

 

IMG_6111

Car, RGB visualisation

IMG_6106

Car, HSV visualisation

Nixie Voltmeter Clock

IMG_5882

I recently acquired a vintage nixie tube multi-meter on eBay, with the not so original idea of converting it into a clock.

However, rather than hack around with the internal circuitry, I decide to see if I could keep the meter intact and use the existing voltmeter functionality to display time.  The basic idea is to send the meter a voltage corresponding to the time, so e.g. 12:45 becomes 12.45V. The meter has a 20V range which displays a fixed 2 decimal places which suits my purpose just fine. Unfortunately there is a hard limit to 20V on this range so a full 24 hour clock is not possible, but a 12 hour clock and maybe a 20 hour clock are.

The high level schematic is:

RTC -> Arduino -> DAC ->Multi-meter

IMG_5880

 

Each minute on the display corresponds to 10mV so the DAC must be at least this resolution. I used an AD5501 which has 12bit resolution and can work at up to 60V. For my needs I used the 30V range which works out at 7.3mV per bit, just enough. This DAC also has an integrated voltage reference which reduces the component count. It comes in a TSSOP package so was soldered onto a breakout board for easier prototyping.

For the RTC I used a DS3231 module. This is accurate to about 1 min/year and has a battery backup. It can be controlled from the arduino over an I²C bus.

The Arduino runs a simple program which at every new minute gets the current time, calculates the required voltage for the time, offsets it by a calibration factor and sends it to the DAC. The program also accepts a few commands over the serial port to calibrate the display and set the current time.

Here is everything running on a breadboard:

Breadboard layout

For power, rather than tap into the internal multi-meter power buses I hooked up a simple 240VAC/5VDC module with a cheap Chinese boost converter to give 15V for the analogue power.

The meter has space inside for a battery so there was no need to miniaturise the component layout and I just wired the modules together on a bit of strip-board, fixed it to an insulating base and popped it into the meter.

 

Capture

Connecting various lab instruments to ethernet

I have an assortment of lab instruments that I’d like to control from a PC. They have a range of connection options: RS232, USB, GPIB, Ethernet and support the SCPI protocol. Decided to standardise on Ethernet.

The three Rigol devices all have Ethernet connectivity so I assigned them all fixed IP addresses via the front panels, plugged into the LAN, and then connected via telnet (putty) to port 5555.

Rigol DP832

Responded to *IDN? query OK

Rigol DS1054Z

Responded to *IDN? query OK

Rigol DSA815

No reply to *IDN? query 🙁 I suspected the DSA815 did not like the CRLF line termination from putty and sure enough, sending just a LF terminator (0x0a) from a simple test program worked OK.

The other two older machines did not have an Ethernet port, so I connected via two Ethernet/RS232 adapters.  I used the USR-TCP232-2 module from eBay. This doesn’t provide any hardware flow control so will need to bear that in mind for the PC control software.

The instructions were not the clearest but in the end configuration was straightforward.  Plug the device into the LAN and run the USR-TCP232-T24V5.1.0.1.exe setup program. Click “Search in LAN” and you should see your device in the list. Select “TCP Server” mode, give it a new IP address and set the subnet mask and default gateway for your router.  Set the module port to 5555 to match that used by the Rigols. Configure the RS232 port as needed.  Then click “Set selected item via LAN”.

Keithley 2015 THD

Set RS232 comms to 19200,N,1,1 from the front panel.  The 2015 has a female RS232 connector and needs a M/M serial cable (crossover 2<>3, 3<>2, 5<>5).  Set to no flow control for now. It also has the option of XON/XOFF flow control which might come in handy.

HP 33120A

Set RS232 comms to 9600,N,1 from the front panel.  This unit requires 2 stop bits. It also requires pin 6 (DSR) to be held high when hardware flow control is not used. The unit has a male RS232 connector and needs a M/F null modem cable (2<>2, 3<>3, 5<>5, 6<>6). On the USR-TCP232-2 module I soldered a jumper lead from the +5V power pin to pin 6. Does the job.

IMG_5852

HP 34401A

Same as HP 33120A above.

MolPad released to Windows App Store

Description

MolPad is a chemical structure drawing app specifically designed for tablets. It allows you to draw chemical structures freehand with a finger, stylus or mouse, just as you would with pencil and paper. The raw ink is converted on the fly to an underlying connection table. Both chemical bonds and handwritten atomic symbols are recognised, cleaned and incorporated into the structure.
screenshot_11222014_123756

Features

  • Intuitive to use
  • Designed specifically for tablets
  • Chemically intelligent
  • Recognises bonds and basic atomic symbols
  • Gesture support for drawing rings
  • Supports industry-standard Molfile format

Find MolPad here.

Feedback and suggestions for improvement welcome!