Monthly Archives: March 2013

Audio synthesis and sharing the timers

We’re using the Mozzi sound synthesis library for Arduino to allow the robots to produce sound.  Our synthesis is implemented on the auxiliary circuit (environmental), which is also responsible for interfacing with all environmental sensors.  The main challenge with using Mozzi is that the library disables Arduino time functions millis(), micros(), delay(), and delayMicroseconds(), which we use often with various sensors.  Once Mozzi has been started, the library does not provide a method of stopping and regaining use of the timers.  Our solution is outlined below.

Mozzi modifies the following registers when starting up: TCCR0A, TCCR0B, OCR0A, TIMSK0, TCCR1A, TCCR1B, OCR1A, TIMSK1. Therefore, before starting Mozzi we backup the values of these registers:

byte _TCCR0A = TCCR0A;
byte _TCCR0B = TCCR0B;

etc… for the other registers.

When we want to stop Mozzi, we simply restore the backed up values:

TCCR0A = _TCCR0A;
TCCR0B = _TCCR0B;

etc… for the other registers.

These routines are wrapped in a custom audio library used for managing sound.

Orientation IR

Les bateaux sont équipés de récepteurs infrarouges afin de communiquer et de s’orienter entre eux. Le deuxième prototype est équipé de 6 récepteurs, pour une plus grande précision angulaire, comparativement à 4 pour la version précédente. En plus les entrés sur cette dernière version sont analogiques et non numériques, ce qui augmente la précision à +/-5 degrés.

Tous les entrés sont dirigés premièrement dans un inverseur pour être ensuite accumulé dans une porte logique OU à six entrés. Ensuite le signal est inversé une dernière fois avant la lecture. 

Eagle_IR_orientation

Schéma du système de communication et d’orientation infrarouge

Le filtre est constitué d’un amply op et d’un réseau RC pour être indépendamment filtré afin d’être lu par des convertisseurs analogues suivant chaque réception de paquet IR validé. Voici une visualisation des entrés analogiques.

MAX_IR_orientation

Exemple de patch MAX/MSP qui démontre l’amplitude des données infrarouges à l’entré des convertisseur.

Les émetteurs leds IR (QED234) se sont avérés très puissants, c’est a dire que les signaux étaient perçus par tout les capteurs  (TSOP39338) en même ce qui faussait l’orientation. Nous avons du abaisser la puissance de ceux-ci. Le circuit officiel sera donc doté de selecteur de puissance automatique pour ajuster les longueurs de transmission dépendemment de l’environnement des bateaux.

Magnetic interference between the motor and the compass

Compas_magnet

We ran into a major issue today with our HMC6352 compass which had worked fine up til now. The problem arises when we move the servo motor that makes the pump rotate. It changes the magnetic field (because of the coil in the motor that drives the pump) which results in the compass losing direction. If there is too much exposure, the compass is stuck into this bad state even when the motor is away, until it is recalibrated.

The HMC6352 datasheet gives some insight into that issue. There are three ways in which to reduce interferences. First there’s the calibration mode, which we were already using to adjust the compass. The problem with it is that is presupposes a stable magnetic field which isn’t our case because the pump moves along 180 degrees to navigate.

Second is what the datasheet refers to as the set/reset function. This one is a bit more obscure but basically I believe that over time, when in the presence of a magnetic field, the sensor accumulates static and needs to be “reset”. The way to call the reset function is not clear at all but by digging in the datasheet I found a mention on p. 8 about the “update bridge offsets” message which reads “Update Bridge Offsets (S/R Now)”, so I guess the message calls the reset function. I have tried it and didn’t notice any difference but I need to do more investigation.

Finally, on p. 13 there are informations about the amplifier filter which basically controls the sensitivity of the sensor. By adding a resistor between pins CA1 and CA2 you can reduce the gain and thus the sensitivity:

An optional gain reducing resistor (Rext) could also place across the feedback loop of the amplifier stages. With the amplifier set with the internal 1200 k-ohm feedback for ±750 milli-gauss maximum magnetic field flux density, a second 1200k-ohm external resistor would halve the gain and permit ±1.5 gauss capability if desired. Gain can be reduced for up to ±6 gauss capability for magnetometry-only applications or compassing with significant magnetic stray fields nearby.

We did a test with a 1200kΩ resistor but we didn’t notice a major difference. We yet have to try with a bigger resistor (the datasheet is not clear on the maximum resistor you can use but it suggests you can get up to a “±6 gauss capability” so by doing a simple calculation we esimate the maximum resistor to reach that gain to 8700kΩ).

Another idea we tried was to enclose the motor in a magnetic shield made of aluminium foil, but even with 1 inch of foil it’s still doing major interferences (although it’s a little bit better). We could try using a material with a higher electromagnetic permeability such as mu metal which is way more permeable than aluminium.