Silicon ChipRudder Position Indicator For Power Boats - July 2011 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: The quest for ultra-low distortion
  4. Feature: Australia Hears . . . And So Do I by Ross Tester
  5. Feature: Control Your World Using Linux by Nenad Stojadinovic
  6. Book Store
  7. Project: Ultra-LD Mk.3 200W Amplifier Module by Nicholas Vinen
  8. Project: A Portable Lightning Detector by John Clarke
  9. Project: Rudder Position Indicator For Power Boats by Nicholas Vinen
  10. Feature: A Look At Amplifier Stability & Compensation by Nicholas Vinen
  11. Project: Build A Voice-Activated Relay (VOX) by John Clarke
  12. Vintage Radio: Hotpoint Bandmaster J35DE console radio, Pt.1 by Maurie Findlay
  13. Advertising Index
  14. Outer Back Cover

This is only a preview of the July 2011 issue of Silicon Chip.

You can view 30 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • Computer Bits (July 1989)
  • Computer Bits (July 1989)
  • Computer Bits (August 1989)
  • Computer Bits (August 1989)
  • Computer Bits (September 1989)
  • Computer Bits (September 1989)
  • Computer Bits (October 1989)
  • Computer Bits (October 1989)
  • Computer Bits (November 1989)
  • Computer Bits (November 1989)
  • Computer Bits (January 1990)
  • Computer Bits (January 1990)
  • Computer Bits (April 1990)
  • Computer Bits (April 1990)
  • Computer Bits (October 1990)
  • Computer Bits (October 1990)
  • Computer Bits (November 1990)
  • Computer Bits (November 1990)
  • Computer Bits (December 1990)
  • Computer Bits (December 1990)
  • Computer Bits (January 1991)
  • Computer Bits (January 1991)
  • Computer Bits (February 1991)
  • Computer Bits (February 1991)
  • Computer Bits (March 1991)
  • Computer Bits (March 1991)
  • Computer Bits (April 1991)
  • Computer Bits (April 1991)
  • Computer Bits (May 1991)
  • Computer Bits (May 1991)
  • Computer Bits (June 1991)
  • Computer Bits (June 1991)
  • Computer Bits (July 1991)
  • Computer Bits (July 1991)
  • Computer Bits (August 1991)
  • Computer Bits (August 1991)
  • Computer Bits (September 1991)
  • Computer Bits (September 1991)
  • Computer Bits (October 1991)
  • Computer Bits (October 1991)
  • Computer Bits (November 1991)
  • Computer Bits (November 1991)
  • Computer Bits (December 1991)
  • Computer Bits (December 1991)
  • Computer Bits (January 1992)
  • Computer Bits (January 1992)
  • Computer Bits (February 1992)
  • Computer Bits (February 1992)
  • Computer Bits (March 1992)
  • Computer Bits (March 1992)
  • Computer Bits (May 1992)
  • Computer Bits (May 1992)
  • Computer Bits (June 1992)
  • Computer Bits (June 1992)
  • Computer Bits (July 1992)
  • Computer Bits (July 1992)
  • Computer Bits (September 1992)
  • Computer Bits (September 1992)
  • Computer Bits (October 1992)
  • Computer Bits (October 1992)
  • Computer Bits (November 1992)
  • Computer Bits (November 1992)
  • Computer Bits (December 1992)
  • Computer Bits (December 1992)
  • Computer Bits (February 1993)
  • Computer Bits (February 1993)
  • Computer Bits (April 1993)
  • Computer Bits (April 1993)
  • Computer Bits (May 1993)
  • Computer Bits (May 1993)
  • Computer Bits (June 1993)
  • Computer Bits (June 1993)
  • Computer Bits (October 1993)
  • Computer Bits (October 1993)
  • Computer Bits (March 1994)
  • Computer Bits (March 1994)
  • Computer Bits (May 1994)
  • Computer Bits (May 1994)
  • Computer Bits (June 1994)
  • Computer Bits (June 1994)
  • Computer Bits (July 1994)
  • Computer Bits (July 1994)
  • Computer Bits (October 1994)
  • Computer Bits (October 1994)
  • Computer Bits (November 1994)
  • Computer Bits (November 1994)
  • Computer Bits (December 1994)
  • Computer Bits (December 1994)
  • Computer Bits (January 1995)
  • Computer Bits (January 1995)
  • Computer Bits (February 1995)
  • Computer Bits (February 1995)
  • Computer Bits (March 1995)
  • Computer Bits (March 1995)
  • Computer Bits (April 1995)
  • Computer Bits (April 1995)
  • CMOS Memory Settings - What To Do When The Battery Goes Flat (May 1995)
  • CMOS Memory Settings - What To Do When The Battery Goes Flat (May 1995)
  • Computer Bits (July 1995)
  • Computer Bits (July 1995)
  • Computer Bits (September 1995)
  • Computer Bits (September 1995)
  • Computer Bits: Connecting To The Internet With WIndows 95 (October 1995)
  • Computer Bits: Connecting To The Internet With WIndows 95 (October 1995)
  • Computer Bits (December 1995)
  • Computer Bits (December 1995)
  • Computer Bits (January 1996)
  • Computer Bits (January 1996)
  • Computer Bits (February 1996)
  • Computer Bits (February 1996)
  • Computer Bits (March 1996)
  • Computer Bits (March 1996)
  • Computer Bits (May 1996)
  • Computer Bits (May 1996)
  • Computer Bits (June 1996)
  • Computer Bits (June 1996)
  • Computer Bits (July 1996)
  • Computer Bits (July 1996)
  • Computer Bits (August 1996)
  • Computer Bits (August 1996)
  • Computer Bits (January 1997)
  • Computer Bits (January 1997)
  • Computer Bits (April 1997)
  • Computer Bits (April 1997)
  • Windows 95: The Hardware That's Required (May 1997)
  • Windows 95: The Hardware That's Required (May 1997)
  • Turning Up Your Hard Disc Drive (June 1997)
  • Turning Up Your Hard Disc Drive (June 1997)
  • Computer Bits (July 1997)
  • Computer Bits (July 1997)
  • Computer Bits: The Ins & Outs Of Sound Cards (August 1997)
  • Computer Bits: The Ins & Outs Of Sound Cards (August 1997)
  • Computer Bits (September 1997)
  • Computer Bits (September 1997)
  • Computer Bits (October 1997)
  • Computer Bits (October 1997)
  • Computer Bits (November 1997)
  • Computer Bits (November 1997)
  • Computer Bits (April 1998)
  • Computer Bits (April 1998)
  • Computer Bits (June 1998)
  • Computer Bits (June 1998)
  • Computer Bits (July 1998)
  • Computer Bits (July 1998)
  • Computer Bits (November 1998)
  • Computer Bits (November 1998)
  • Computer Bits (December 1998)
  • Computer Bits (December 1998)
  • Control Your World Using Linux (July 2011)
  • Control Your World Using Linux (July 2011)
Items relevant to "Ultra-LD Mk.3 200W Amplifier Module":
  • Ultra-LD Mk3 200W Amplifier Module PCB [01107111] (AUD $15.00)
  • Ultra-LD Mk3/Mk4 Amplifier Power Supply PCB [01109111] (AUD $15.00)
  • Ultra-LD Mk.3 Power Supply PCB pattern (PDF download) [01109111] (Free)
Articles in this series:
  • Ultra-LD Mk.3 200W Amplifier Module (July 2011)
  • Ultra-LD Mk.3 200W Amplifier Module (July 2011)
  • Ultra-LD Mk.3 200W Amplifier Module, Pt.2 (August 2011)
  • Ultra-LD Mk.3 200W Amplifier Module, Pt.2 (August 2011)
  • Ultra-LD Mk.3 200W Amplifier Module, Pt.3 (September 2011)
  • Ultra-LD Mk.3 200W Amplifier Module, Pt.3 (September 2011)
Items relevant to "A Portable Lightning Detector":
  • Portable Lightning Detector PCB [04107111] (AUD $15.00)
  • Portable Lightning Detector PCB pattern (PDF download) [04107111] (Free)
  • Portable Lightning Detector front and top panel artwork (PDF download) (Free)
Items relevant to "Rudder Position Indicator For Power Boats":
  • Rudder Position Indicator PCB Set [20107111/2/3/4] (AUD $80.00)
  • ATtiny861 programmed for the Rudder Position Indicator Sensor/Transmitter [2010711A.HEX] (Programmed Microcontroller, AUD $15.00)
  • ATtiny861 programmed for the Rudder Position Indicator Receiver/Display [2010711B.HEX] (Programmed Microcontroller, AUD $15.00)
  • Firmware (HEX) files and C source code for the Rudder Position Indicator [2010711A/B] (Software, Free)
  • Rudder Position Indictor PCB patterns (PDF download) [20107111/2/3/4] (Free)
Articles in this series:
  • Rudder Position Indicator For Power Boats (July 2011)
  • Rudder Position Indicator For Power Boats (July 2011)
  • Rudder Position Indicator For Power Boats, Pt.2 (August 2011)
  • Rudder Position Indicator For Power Boats, Pt.2 (August 2011)
Items relevant to "A Look At Amplifier Stability & Compensation":
  • SPICE simulation data for Amplifier Stability & Compensation article (Software, Free)
Items relevant to "Build A Voice-Activated Relay (VOX)":
  • VOX PCB [01207111] (AUD $15.00)
  • VOX (Voice Activated Relay) PCB pattern (PDF download) [01207111] (Free)

Purchase a printed copy of this issue for $10.00.

A Rudder Indicator For Power Boats, Pt.1 By NICHOLAS VINEN Manoeuvring a medium-sized or large boat at low speeds can be very difficult and it is even more difficult if you don’t know where the rudder(s) is pointing before putting the engine(s) into gear. Trouble is, in most boats, after swinging the wheel back and forth several times, you have no idea. Take the guesswork out of steering with this Rudder Position Indicator. H ERE IS A typical scenario. You are reversing your flybridge twinengined cruiser into a berth (doesn’t everyone have one of these?). You must do it at low speed (pretty obvious!) and you can’t use the rudder to steer with since rudders don’t work at low speeds. The only way to steer is to use the motors. Normally, in a twin-engined boat, you make sure the rudders are centred and then you manoeuvre the boat by nudging the motors into and out of gear and using very judicious (tiny!) amounts of throttle or none at all. For example, if you are going forward, you can steer to port (left, if you’re a landlubber) by putting the port engine into reverse and the starboard engine into forward gear. Or you might just leave 62  Silicon Chip the starboard engine in neutral while nudging the port engine in and out of reverse gear. Going in reverse is a whole different ball-game. Now you are looking at the rear of the boat while you manoeuvre it into a narrow berth. In this case, if you want to steer to the left going backwards, you put the starboard engine into reverse and the port engine into forward . . . or combinations of those settings. All the while, you have to cope with the effects of currents and wind. It can be a nightmare. It can be even harder in a singleengined boat. The rudder still doesn’t work at low speeds and you don’t have the luxury of two motors to do the steering. In this case, you do have to use the rudder but in order to get the boat to respond to the rudder, you have swing it hard over, in one direction or the other, and give the motor a quick stab of power in forward or reverse gear to push the stern of the boat in the required direction. Sounds tricky, doesn’t it? Well, it is. Going back to the twin-engined boat for a moment, before you can start these low-speed manoeuvres, you must have the rudder centred. But since typical boats require many turns from lock-to-lock, it is almost impossible to know when the rudder is centred. The practical way to do it, is count the turns from lock-to-lock and then halve it, to centre the rudder. So if it is six turns from lock to lock, you turn the wheel fully to port or starboard and then wind the wheel siliconchip.com.au back by three turns. Trouble is, it’s easy to lose count when you’re winding the wheel back and forth. How much easier it would be if you had an electronic rudder indicator! Commercial rudder indicators are fitted to some boats but they are very expensive. So that was the brief. The skipper of SILICON CHIP can’t steer his boat (hope I won’t get into too much trouble for this . . .) and he wanted an electronic indicator. Being the autocratic type that he is, who was I to argue? His justification is that the project would have other applications, so here is the result. This Rudder Position Indicator consists of two units, each of which mounts in a small sealed box with a transparent lid. The sensor unit monitors the movement of the rudder arm and transmits information to a receiver unit via a UHF radio link at 433MHz. The receiver display unit is portable so that it can be moved from the flybridge driving position to the helm inside the cabin. It shows the rudder position using an array of high brightness LEDs, with adjustable brightness to suit indoor and outdoor use. Features The rudder display can show one of seven positions: three steps to port, three to starboard and one when it is centred. The port, starboard and centre positions use different LED colours to Specifications & Performance Rudder Position Resolution................................................. seven steps, plus centre indication Sensor Type ...........................................................................................magnet and reed switch Communication Method ..........................................433MHz UHF digital wireless transmission (Amplitude Shift Keying) Range ...........................approximately 20m (depending on antenna orientation and obstacles) Power source ..................................................................... 4 x AAA cells or external 12V supply Battery life (sensor unit) ........................................approximately two years with 4 x AAA cells Battery life (receiver) .....approximately two years on standby or 2-8 hours in use, depending on LED brightness Size (each unit) ..................................105 x 75 x 40mm with a protruding 15cm whip antenna make the direction more obvious at a glance. For extra precision in setting the rudder straight ahead, the middle LEDs flash when the rudder arm is directly over the central sensor. Both the sensor and receiver units are fitted with short whip antennas (about 15cm) to provide sufficient range for use on larger boats. In most boats, the hydraulic steering arms are located in a compartment called a “lazarette” and this may or may not be lined with aluminium foil coated insulation, to cut down noise and heat. In this case, it may be necessary to run a coaxial cable from the sensor unit to a whip antenna mounted outside this compartment, to allow the signal to reach the helm position(s). The same comment applies if the boat has an aluminium or steel hull. Both the sensor and receiver units can be powered from an internal battery (which can be rechargeable) or from an external 12V power source. An external power source can also be used to trickle charge the internal batteries. The approximate charge state of both batteries is indicated on the display unit. The sensor unit is always powered, so you don’t have to switch it on and off each time. Even so, its low current drain means that it will run for at least a year on four AAA cells. Just how long depends on how often you use it and the cell type used. If you use goodquality alkaline cells, the transmitter battery could last two years or more. Many boats have a 12V lead-acid battery in the lazarette and in that case, you can omit the sender unit’s The sender unit (left) uses seven reed switches to detect the rudder position. It transmits data to the receiver unit (right) via a 433MHz wireless link. siliconchip.com.au July 2011  63 ACTUATOR PIVOT HYDRAULIC RAM RUDDER ARM ADDED ARM S1 MAGNET (UNDER ARM) S2 S3 © 2011 S4 CON5 SC RUDDER BEARING S5 CON6 S6 SENSOR UNIT S7 (HORIZONTAL PLATFORM) RUDDER So for the final design, each unit is based around a microcontroller which does virtually all the work, in combination with a wireless transmitter or receiver module. Most of the time, the micros are in a low-power sleep mode, keeping the battery drain down to about 15µA (including current for the regulator). When active, the micro wakes up and performs the necessary tasks before going back to sleep. Each unit comprises two PCBs: a lower control board which hosts the battery, micro and most other components, and an upper board which hosts either the reed switches (sender unit) or the display LEDs (receiver unit). All boards are the same shape and size and fit snugly into the sealed boxes, so only the top board is visible through the clear lid. Basic operation Fig.1: how the sensor unit is arranged. It’s mounted on a platform and is activated by a magnet on the underside of an arm that’s attached to the rudder shaft. internal battery and use that as a power source instead. The UHF link makes installation easy; there is no need to run wires from the rudder to the helm which can be a major task in a typical large power boat. Design concept The first aspect we considered was how to sense the rudder position. There are four obvious sensor types to choose from: a rotary switch, a potentiometer, an optical sensor or reed switches. In each case, either the sensor needs to be attached to the rudder shaft or an arm must be attached to the shaft with the sensors arranged in an arc above or below it, so that the arm triggers one at a time. Rotary switches and potentiometers tend to wear out fairly quickly with continuous use and they can also be fouled by water, grease or dirt in a marine environment, unless they are fully sealed. An optical sensor is a better choice but is the most power-hungry 64  Silicon Chip option and it also requires the most complicated wiring, as both the light source(s) and sensor(s) require power. So we settled on reed switches, with a magnet attached to a cranked arm that is mounted on the rudder shaft. Seven reed switches are arranged in an arc below the arm so that as the arm moves, the magnet passes over them, closing each reed switch in turn. Fig.1 illustrates this arrangement. While it is possible to design these circuits using discrete logic and special-purpose ICs (in fact, we initially tried to do just that), there are several advantages to a microcontroller-based solution. First, if we use a microcontroller in each unit, fewer parts are required. Since we want to fit the display unit into a small box with an internal battery (so it’s easily portable), this is important. Also, because the microcontroller in the sensor unit can drive current through the reed switches intermittently, the battery drain can be kept very low. For an overview of how the two units are configured, refer to Fig.2, the block diagram. The sensor unit (left) contains the reed switches for rudder position sensing and the microcontroller to monitor them. When the switch state changes, the micro powers up the 433MHz transmitter module and sends a data packet containing the new position. This packet is amplitude shift keyed (ASK) and bi-phase encoded. The receiver/display unit (right) is portable and only listens for packets when it is switched on. When it receives a valid packet, the microcontroller decodes it and extracts the new rudder position. It then displays this position by determining which row of high-brightness LEDs is lit. The display unit incorporates a boost regulator. This is necessary to drive the series strings of five LEDs that form the main display. With a typical forward voltage of around 2V, at least 10V is required to drive each string (slightly more due to the 100Ω series current limiting resistor they share). The boost regulator develops roughly 12V at 20mA when the LEDs are lit, from a nominal 6V battery (it can operate down to about 3V). It can also run off an external 12V supply, in which case very little or no boosting is needed. In this case, a series resistor in the power supply input ensures that the LED voltage doesn’t exceed 12V, even if the supply voltage is up to 14.8V (eg, when a lead-acid battery is on charge). Note that while the wireless modsiliconchip.com.au LED DISPLAY RUDDER ARM WITH MAGNET S N MICROCONTROLLER (IC1) REED SWITCHES 433MHz TRANSMITTER 433MHz RECEIVER BATTERY MICROCONTROLLER (IC2) DECODER/ DRIVER (IC3) BATTERY BOOST REGULATOR Fig.2: this block diagram shows how the sensor and receiver units are configured. The reed switch outputs are processed by microcontroller (IC1) which then powers up the 433MHz transmitter module to send a 16-bit data packet on the new rudder position. This signal is picked up by receiver and processed by another microcontroller (IC2). This then drives a LED display (consisting of series LED strings) via decoder/driver IC3. ules are referred to as operating at 433MHz, the actual frequency band used is 433.05-434.79MHz. Sensor unit details The micro in the sensor unit is in low-power “sleep” mode almost all the time. Its 32kHz watchdog timer (WDT) is continuously running and this “wakes it up” several times a second (maybe it sleeps quite poorly!) to check the reed switch state. To do so, it turns on an internal pull-up current source for each input and checks the voltage. The current sources are then immediately disabled and remain off until the next time, to conserve power. Further action is only taken if the switch states differ from the previous reading. Otherwise, the period the micro spends running is very short and the power consumed during these periods is negligible. When a change in reed switch state is detected, the 433MHz transmitter module is powered up. Several 16bit packet pairs are transmitted with a short delay between each, in case interference corrupts one or more of the packets. Each packet pair encodes the updated rudder position, battery charge state and a unique identifier number, which is randomly generated when the battery is inserted. Once five complete packets have been sent, the transmitter is shut down and the device goes back to sleep until another rudder movement occurs. Packet protocol The format of the 16-bit data packets is shown in Fig.3. The bi-phase data is encoded by the microcontroller before being sent to the transmitter module, which modulates the amplitude of its 433MHz RF output accordingly. Each packet contains 14 bits of data siliconchip.com.au along with two start bits. With bi-phase encoding, a zero is encoded with one level change between bits (low-to-high or high-to-low) while a one is encoded the same way but with an additional level change in the middle of the bit. The advantage of bi-phase encoding is that the bit timing and the data are encoded together, so the transmitter and receiver can re-synchronise the timing for each bit. The receiver records the signal level one quarter and three quarters of the way through each encoded bit and if they differ, it records the bit as a one. It also times the level changes before and after this, to determine when to sample the next bit. The first data bit value determines the meaning of the following three bits. If this first bit is a zero then the next three encode the rudder position, with 0-6 indicating one of the seven possible positions and seven indicating that the centre reed switch has opened but no other switches have closed. This is used to indicate whether the rudder is precisely centred. If the first data bit is instead one, then the following three bits encode the transmitter’s battery state. Zero means that it is fully discharged, while PACKET RUDDER START TYPE POS. OR BITS 0 or 1 BATTERY RAW DATA BIPHASEENCODED DATA TO TRANSMITTER MODULE seven indicates full charge. In either case, the next eight bits contain the transmitter’s unique identifier (ID), which is generated based on random noise sampled by the ADC module. This number does not change unless the battery is removed. The receiver remembers the transmitter’s ID and ignores any packets from transmitters with different IDs, until it too is power cycled. Finally, there are two checksum bits which are the bottom two bits of the total number of ones in the transmission (ignoring the start bits and the checksum). This is similar to parity and it allows the receiver to detect if any single data bit has been scrambled during transmission (or in some cases, when multiple bits are affected). If the checksum does not match the received data, the packet is ignored. This reduces the chance of an incorrect display as the result of interference or marginal reception. Display unit details When it is not in use, the micro in the display unit is in low-power sleep mode and so the drain on the battery is minimal. When the single pushbutton TRANSMITTER UNIQUE ID (8 bits, 256 combinations) CRC-2 1 1 0 1 0 0 0 1 1 1 0 1 0 0 1 0 32 x 200s = 6.4ms Fig.3: the 16-bit data packet format. The data is bi-phase encoded and each packet contains two start bits and 14 bits of data. Bits 4-6 encode either the rudder position or the battery state, depending the state of the first data bit (0 = rudder position, 1 = battery state). July 2011  65 Table 1: Battery Voltage Jumper Options Battery type........................................................................................................ JP1 pins shorted Four non-rechargeable AAA (nominal 6.0V)........................................................................1&2 Four rechargeable AAA (nominal 4.8V)................................................................................3&4 12V lead-acid (nominal 12.9V).............................................................................none (or 2&3) is pressed, the micro wakes up and activates the boost regulator, which it controls via software. This generates power for the LEDs (12V) and the 433MHz receiver module (5V, derived from the 12V rail via a linear regulator). Initially, only the battery state LED(s) are lit (indicating the unit’s own battery voltage) and it waits for a data packet. Upon reception, assuming that it is valid, the display is updated to show the new rudder position. The display remains in this state until the rudder moves again and a new packet is received, or the unit is shut off (either manually or through a long period of inactivity). Since the transmitter’s battery state is sent at the same time as the updated rudder position, this can be shown on the display unit. It is distinguished by the micro flashing the battery level LEDs while it is being displayed. After a few seconds, the flashing ceases and the display unit’s own battery state is once again shown instead. If no new packets are received for 10 minutes and the button has not been pressed, the unit automatically shuts down to conserve battery power. It can also be turned off by holding down the pushbutton for about one second. Short presses on the button cycle through three possible LED brightness settings, which suit indoor use and outdoor use, with and without direct sunlight. On the lower brightness settings, the battery lasts longer. One additional feature we have hinted at helps you to tell whether the rudder is dead centre. When the magnet is moved away from the centre, the middle reed switch opens before any of the adjacent switches close. In this case, we don’t know which way the rudder has moved, only that it is no longer centred. Taking advantage of this, the middle (yellow) row of LEDs initially flashes when the central reed switch is closed. When it opens, a packet is transmitted which causes the flashing to cease. If the rudder is moved back to the centre 66  Silicon Chip again, the middle switch closes and so the flashing resumes. Power supply options As stated, both units can be operated without external power connections, using their internal battery only (four AAA cells). These can be rechargeable and with an appropriate connector, can be recharged without having to open the unit up. Since the transmitter unit’s battery should last more than a year, alkaline cells are a practical proposition and the unit can be opened to replace them. However, the batteries in the display unit only last a few hours if it is used at maximum LED brightness. So in this case, either external power or low self-discharge NiMH batteries recharged from 12V are the most practical options. External power is practical for the transmitter, since it does not move and is usually located near a 12V lead-acid battery (its load on that battery would be minimal). On a boat with a single helm position, the receiver unit could be hard-wired too, although it’s more flexible to run it from its internal battery. If a charge connector is used for either unit, it should ideally be a sealed type, to prevent moisture ingress. If you use a regular connector, we recommend applying silicone sealant on the inside once it has been installed, to reduce the chance of water entering the enclosure. The sensor unit has provision for a PCB-mount DC connector. If this is used, a hole must be cut into the side of the box. This is not recommended if there is any possibility of water being present where it is mounted. Battery life For either module, when the micro is in sleep mode, the continuous 15µA current draw works out to around 473mAh/year. At this rate, four 900mAh NiMH AAA batteries should last about two years. Rechargeable cells must be low self-discharge types or else their own internal discharge will be much higher than this and they will go flat if left uncharged for more than a few weeks. Good-quality alkaline cells generally contain more energy than NiMHs so they should last even longer than two years. The sensor unit’s current increases to 15mA for about 100ms when the rudder position changes. This equates to an energy consumption of around 1mAh for every 2400 rudder position changes. If you take two trips a week and each trip involves 1000 position updates, that means a drain of just 43mAh/year, so rudder movements don’t really figure into the battery life. For the display unit, the situation is more complicated. Driving the highbrightness LEDs can consume 100mA or more continuously, depending on battery voltage and brightness setting. At this rate, with similar cells as we have described above, we would expect 6-9 hours of use per charge. Due to internal resistance and falling battery voltage, the battery life at full LED brightness will be more like 2-3 hours. As you would normally only turn the unit on when leaving the marina (or dock) or returning to it, that should be more than enough for a single trip. It’s probably a good idea to recharge the cells after each outing. It can be kept on trickle charge when it is not in use, so it’s always ready to go. When the display unit is switched off, the micro consumes about the same power as the sensor unit does. So a fully-charged battery will lose about half its charge per year if left untouched. Sensor circuit description The circuit for the sensor unit is shown in Fig.4 and the highlighted section shows the reed switches on the upper board. The battery holder for the four AAA cells is on the lower board. They can be trickle charged from 12V via CON1 or CON2, depending on which is installed. CON1 is a 2-way terminal block which can be wired to a separate chassis power connector, while CON2 is a PCB-mount DC connector. The same connectors can be used for permanent power if the unit is hardwired. When trickle charging the battery, the 390Ω resistor limits the charge siliconchip.com.au siliconchip.com.au K A LED 1.5k 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8 9 10 11 12 K 2011 SC  REED SWITCHES ON UPPER BOARD *CHANGE VALUE TO 220 0.5W IF HIGH CAPACITY NiMH AAA CELLS ARE USED, OR TO 100 0.5W IF 12V EXTERNAL POWER IS USED PERMANENTLY. S7 S6 S5 S4 S3 S2 S1 CON2 RUDDER POSITION INDICATOR SENSOR UNIT 1 2 1 2 CON3 A CON5 100nF K ZD1 16V BATTERY B1 (6V) CON1 A 16 6 1N5819 AGND A 1.5k 11 PA7 GND IC1 ATTiny861 PB4 8 PB5 9 PB6 PB1 PB2 PB3 1 2 3 4 7 PB0 PA4/ADC3 14 20 19 PA1 17 PA3/AREF 18 PA2 13 PA5 12 PA6 PA0 K  LED1 2V 82k B A E ZD1 K Q1 BC547 C B 1.5k E C 12k Q2 BC327 2 VR1 5k TP1 100nF 10 5 15 RESET Vcc AVcc 100nF 100F GND OUT IN A (FAST BLOW) Fig.4: the sensor circuit is based on microcontroller IC1, an ATTiny861. It decodes the reed switch outputs on its PB0-PB6 ports, powers up the 433MHz transmitter module from its PA0 & PA1 outputs and sends data to the transmitter from port PA2. A 3V rail to power IC1 is derived via 3-terminal regulator REG1, while PA7 turns on transistors Q1 & Q2 as required to sample the battery voltage at port PA4/ADC3. JP1 is used to select the battery type. OUT GND IN E 1 4 433MHz TX MODULE 3 100nF LM2936Z B C BC327, BC547 4 3 BATTERY 2 VOLTAGE 1 JP1 CON4 ANTENNA WIRE +3V 100 Vcc REG1 LM2936Z-3.0 K D1 1N5819 F1 500mA 390* 12V + DC IN – current to about 20mA. Its value can be reduced if high-capacity cells are used, allowing them to charge faster. For example, if 900mAh AAA cells are used, a 220Ω 0.5W resistor increases the charge current to around 40mA. In either case, the charge time for a completely flat battery is around 24 hours. In practice, the battery will normally be only partially discharged so eight hours should be sufficient. If the module is to be powered permanently from a 12V supply (eg, an external lead-acid battery), use a 100Ω resistor instead. A 500mA fuse protects the power source from a board fault. Schottky diode D1 provides reverse polarity protection (it drops less voltage than a standard diode). Zener diode ZD1 protects the circuit from voltage spikes which may occur when a lead-acid battery is on charge (due to load dumps and so on). If the spike is particularly bad, the fuse will blow, protecting the unit from damage. REG1 regulates the incoming voltage down to 3V (or 3.3V depending on the exact type used). Microcontroller IC1 and the 433MHz transmitter module run off this voltage. The LM2936Z regulator specified is designed for automotive use, so it is robust enough for a marine application. It has a quiescent current of below 15µA with a light load such as a micro in sleep mode. The micro draws less than 1µA in sleep mode, hence the low current drain when the device is idle. Regulator stability is ensured by a 100nF input bypass capacitor and a 100µF output filter capacitor. While low drop-out regulators require capacitors with an ESR value within a certain range, the range in this case is very large (0.01-8Ω) so virtually any 100µF electrolytic capacitor is suitable. REG1’s 3-3.3V output is also bypassed with a 100nF capacitor. The microcontroller (IC1) is an ATTiny861. These are easy to obtain at a reasonable price and have all the necessary features for this application: low power consumption in sleep mode, plenty of program (flash) memory, an analog-to-digital converter (ADC) for battery voltage monitoring and enough digital I/O pins for our purposes. The micro consumes less current at 3V or 3.3V than at 5V. Its ADC power supply (AVcc) is filtered with a 100Ω resistor and 100nF capacitor, removing July 2011  67 68  Silicon Chip siliconchip.com.au (FAST BLOW) F2 500mA A ZD2 16V K D2 1N5819 A K 100nF Vcc 1 2 3 7 14 433MHz RX MODULE 4 47F IN 16 15 1.5k 12k +12V K C E Q5 BC337 A D3 1N4148 B 1.5k L1 100H C Q4 BC327 E C 1.5k 1k E Q3 BC547 12k B 4 82k 100F JP2 B 2.2k 1 BATTERY 3 VOLTAGE 2 GND OUT RUDDER POSITION INDICATOR DISPLAY UNIT CON9 ANTENNA WIRE 100nF 100F GND OUT REG3 78L05 +12V +5V IN REG2 LM2936Z-3.0 11 9 8 13 12 IC2 ATTiny861 A K 16 6 ZD1 AGND PB3 PB2 PB1 PB0 PB4 GND PA7 ADC9/PB6 OC1D/PB5 ADC4/PA5 PA6 18 PA2 20 PA0 14 PA4 PA1 PA3/AREF 13 12 3 4 A A 14 2 D3 D2 P3 P2 P1 P0 K K 8 GND +12V +5V O9 O8 O7 O6 O5 O3 O2 O1 O0 IC3 O4 74LS145 16 Vcc TO POWER SWITCH CON8 VR2 5k +5V 15 2V TP2 1 7 17 19 100nF 100 10 5 15 RESET Vcc AVcc 100nF +3V 1 E 11 10 9 7 6 5 4 3 2 B C BC327, BC337, BC547 100 100 IN OUT GND LM2936Z 12 11 10 9 8 7 6 5 4 3 2 1 TO LEDS CON7 Fig.5: the receiver circuit also uses an ATTiny861 microcontroller (IC2). The data from the 433MHz receiver module is fed to its PA7 port and processed, with the decoded binary data appearing at ports PB0-PB3. These drive a 74LS145 4-to-10 binary decoder with open collector outputs which in turn drive the LEDs on the display board (see Fig.5) via connector CON7. Inductor L1, diode D3, transistor Q5 and the 47μF capacitor at D3’s cathode form a boost converter which is controlled from IC2’s PA6 port using transistors Q3 & Q4. This provides a +12V rail for the LED display and drives REG3 to derive a +5V rail for IC3. SC 2011 BATTERY B2 (6V) 390* *CHANGE VALUE TO 220 0.5W IF HIGH CAPACITY NiMH AAA CELLS ARE USED, OR TO 100 0.5W IF 12V EXTERNAL POWER IS USED PERMANENTLY. CON6 12V + DC IN – A LED1 A LED2  A LED3 K LED4 A CON10 1 2 3 LED6 A LED8 A K A LED12 K K K A A A A LED15 K  A LED16 LED17 K A K A  LED22 A A LED26 LED28  A LED29 A A K A  A  LED31 K K  K  LED30 LED27 K A K  K K   LED25 A  LED23 K K  K K A  LED24 LED21 A   LED18 LED20 K  K A   LED13  K  K  LED19 LED14 tive divider and then to IC1’s ADC3 pin. When PA7 is high it also drives a high-brightness LED (LED1), indicating that the transmitter is active. Ports PA0 & PA1 also supply power to the 433MHz transmitter (Tx) module. With a 3V supply, the transmitter module receives at least 2.8V (0.2V is lost due to the internal resistance of the micro’s output transistors). When the transmitter is powered up, output PA2 is used to send the data burst to the transmitter module. When the transmitter is not powered, PA2 is kept low. The antenna is a ¼-wavelength whip, measuring about 164mm and soldered to a PC pin on the lower board. This gives a useful range of approximately 20 metres, even with the user’s body between the transmitter and the receiver. This can vary somewhat, depending on the obstacles between the two units and the relative antenna orientation. A K  LED11 A  LED9 LED10 K  K K   LED7 A  LED5 A K   A K  K 4 5 6 7 8 9 10 A LED32 11 12  K A LED33  A LED34 K FROM CONTROL BOARD SC 2011  K Display unit (+2V) (+10V) RUDDER POSITION INDICATOR LED ARRAY PCB CATHODE DOT LEDS K A Fig.6: the LED array board consists of seven strings of series LEDs (LEDs1-31) to give a visual indication of rudder position plus three LEDs (LEDs32-34) to indicate the battery condition. It’s driven from CON7 of the receiver board. digital switching noise injected by the other circuitry and hence improving ADC conversion stability. The reed switch sensors are connected to the PORTB pins PB0-PB6 (pins 1-4 & 7-9), via pin header socket CON5 on the upper board. IC1 has internal current sources for each reed switch which can be turned on and off by software. Each has a source impedance of 20-50kΩ, sourcing 60-150µA when enabled. IC1’s PA0, PA1, AREF, ADC3 and PA5-7 (pins 11-14, 17 & 20) are used to monitor the battery voltage. A jumper shunt placed on pin header JP1 tells the micro what type of battery is being used, so that it knows what voltage range to expect. There are three possible options, indicated by the different combinations shown in Table 1. The microcontroller (IC1) reads the jumper position using pins PA5 and PA6. PA0-1 and trimpot VR1 provide the ADC reference voltage (AREF). This siliconchip.com.au is set to 2V. No current flows through VR1 unless PA0 and PA1 are sourcing current (ie, they are driven high to +3V), saving power when the ADC is not in use. The ADC is only used for brief periods so the circuitry to supply AREF is only active during this time (and for one minute after power is applied, allowing VR1 to be trimmed). The battery/supply voltage is sampled at the ADC3 pin, via a 12kΩ/1.5kΩ divider. This converts the battery voltage (0-18V) into a range which can be handled by the ADC (0-2V). As with the AREF divider, current does not flow through it unless the battery voltage is actually being read, to save power, as controlled by pin PA7. This is driven high while ADC3 is being sampled, turning on NPN transistor Q1 and sinking current from the base of PNP transistor Q2, turning it on as well. This allows current to flow from the battery (after the fuse and diode D1) into the 12kΩ/1.5kΩ resis- Figs.5 & 6 show the circuit for the receiver unit. Fig.5 depicts the lower board circuitry, while Fig.6 shows the LED array circuit on the top board. The power supply for the receiver unit is identical to that used in the sensor unit, except there is no provision for an on-board DC connector. That’s because this unit is more likely to be exposed to spray and such a connector would be too likely to allow water ingress. As for the sensor unit, the 390Ω resistor in series with CON6 should be changed for use with high-capacity cells or permanent 12V power. This is important, since the receiver unit can draw significantly more current than the sensor unit. This resistor must not be omitted, otherwise the LEDs could be over-driven if the 12V battery supply is on charge. Microcontroller IC2 is the same type as before but its role is a little different. The PORTB pins PB0-PB3 drive IC3, a 74LS145 4-to-10 binary decoder with open collector outputs. This in effect gives IC2 10 open-collector outputs, one of which can be driven low at any given time (or they can all be turned off). The binary decoder’s outputs can handle voltages up to 15V (although the off-state leakage current can be significant even at 10V; enough to dimly light LEDs). Each output can sink up July 2011  69 Parts List: Rudder Position Indicator SENSOR UNIT 1 PCB, code 20107111, 98.5 x 68mm 1 PCB, code 20107112, 98.5 x 68mm 1 sealed ABS box with clear lid, 105 x 75 x 40mm (Altronics H0321) 1 433MHz transmitter module (Jaycar ZW3100, Altronics Z6900) 1 2-way mini terminal block, 5.08mm pitch (CON1) 1 PCB-mount DC connector (optional*) (CON2) 2 M205 fuse clips 1 M205 500mA fast-blow fuse 1 5kΩ sealed horizontal trimpot (VR1) 1 4 x AAA PCB-mount battery holder (Jaycar PH9270) 2 M2 x 6mm machine screws and nuts (Element14 507118/1419445) 4 AAA cells (Alkaline or NiMH) (optional*) 1 4-way pin header (JP1) 1 jumper shunt (for JP1) 1 40-pin header socket, 2.54mm pitch (cut down to 12-way [CON3] & 4-way sockets) 1 20-pin DIL socket 2 PC pins 1 200mm length 1.5mm diameter enamelled copper wire 1 300mm length 0.7mm diameter tinned copper wire 7 glass-encapsulated NO reed switches (Jaycar SM1002, Altronics S5150A) 1 reed switch trigger magnet 2 15mm tapped Nylon spacers 2 M3 x 20mm machine screws 2 M3 nuts 1 small crimp wire joiner 1 small IP67-rated chassis connector* Semiconductors 1 ATTiny861 microcontroller programmed with 2010711A.hex (IC1) (Altronics Z5110 or Futur­ lec ATTINY861-20PU) 1 LM2936Z-3 ultra-low quiescent current linear regulator (REG1) (Digikey**) 70  Silicon Chip 1 BC547 NPN transistor (Q1) 1 BC327 PNP transistor (Q2) 1 1N5819 Schottky diode (D1) 1 16V 1W zener diode (ZD1) 1 high-brightness red LED (LED1) Capacitors 1 100µF 16V electrolytic 4 100nF MKT Resistors (0.25W, 1%) 1 82kΩ 1 220Ω 0.5W* 1 12kΩ 1 100Ω 0.5W* 3 1.5kΩ 1 100Ω 1 390Ω* * Depends on power supply chosen, see text ** Alternative part LM2936Z-3.3 (Element14 1564641) DISPLAY UNIT 1 PCB, code 20107113, 98.5 x 68mm 1 PCB, code 20107114, 98.5 x 68mm 1 sealed ABS box with clear lid, 105 x 75 x 40mm (Altronics H0321) 1 433MHz receiver module (Jaycar ZW3102, Altronics Z6905) 1 2-way mini terminal block, 5.08mm pitch (optional*) (CON6) 2 M205 fuse clips 1 M205 500mA fast-blow fuse 1 5kΩ sealed horizontal trimpot (VR1) 1 100µH 250mA axial RF inductor 1 4 x AAA PCB-mount battery holder (Jaycar PH9270) 2 M2 x 6mm machine screws & nuts (Element14 507118/1419445) 4 AAA cells (alkaline or NiMH) 1 4-way pin header (JP2) 1 jumper shunt (JP2) 1 12-way header socket, 2.54mm pitch (or cut down a 40-way socket) (CON7) 1 20-pin DIL socket 1 16-pin DIL socket 2 PC pins 2 15mm tapped Nylon spacers 2 M3 x 20mm machine screws 2 M3 nuts 1 small IP67-rated chassis connector* 1 small IP67-rated momentary pushbutton switch (Jaycar SP0656, Altronics S0961) 14 ultra-bright 1206 or 1210 SMD red LEDs (Digikey 754-1165-1ND) 14 ultra-bright 1206 or 1210 SMD green LEDs (Digikey 754-11621-ND) 6 ultra-bright 1206 or 1210 SMD yellow LEDs (Digikey 754-11661-ND) 1 200mm length 1.5mm diameter enamelled copper wire 1 300mm length 0.7mm diameter tinned copper wire 1 50mm length red light duty hookup wire 1 50mm length black light duty hookup wire 1 100mm length blue light duty hookup wire 1 small crimp wire joiner Semiconductors 1 ATTiny861 microcontroller programmed with 2010711B.hex (IC2) (Altronics Z5110 or Futur­ lec ATTINY861-20PU) 1 74LS145 4-to-10 binary decoder (IC3) 1 LM2936Z-3 ultra-low quiescent current linear regulator (REG2) (Digikey**) 1 78L05 5V linear regulator (REG3) 1 BC547 NPN transistor (Q3) 1 BC327 PNP transistor (Q4) 1 BC337 NPN transistor (Q5) 1 1N5819 Schottky diode (D2) 1 1N4148 small signal diode (D3) 1 16V 1W zener diode (ZD2) Capacitors 2 100µF 16V electrolytic 1 47µF 16V electrolytic 4 100nF MKT Resistors (0.25W, 1%) 1 82kΩ 1 390Ω* 2 12kΩ 1 220Ω 0.5W* 1 2.2kΩ 1 100Ω 0.5W* 3 1.5kΩ 3 100Ω 1 1kΩ * Depends on power supply, see text ** Alternative part LM2936Z-3.3 (Element14 1564641) siliconchip.com.au to 80mA. Seven of the outputs (pins 1-7) are used to drive 5-LEDs strings, to indicate the rudder position, while the three remaining outputs (pins 8-10) drive individual LEDs to form a simple battery meter. The series LED strings have a common anode which is connected to the 12V rail via a 100Ω current-limiting resistor. The total forward voltage for each string is around 10V (5 x 2V), so the maximum DC current per LED is around (12V - 10V) ÷ 100Ω = 20mA. In practice, due to additional loss­ es, such as the saturation voltage of the 74LS145’s output transistors, the LEDs run at a slightly lower current than this. However, because we have specified very efficient LEDs, they are still very bright. It’s a compromise because we if we ran them at a higher current, they would dim somewhat as the battery discharged. That’s because the boost regulator generating the 12V rail becomes less effective as the boost ratio increases. A 5V rail is derived from the 12V supply using regulator REG3. This rail powers both IC3 and the 433MHz receiver module. This is a little wasteful of energy (its efficiency is 5/12 = 42%) but it allows us to operate the receiver even if the battery voltage is well below 5V. That can easily be the case with four standard cells, especially if they are rechargeable. Note that REG3 has a 100µF output filter capacitor and this doubles as a bypass capacitor for IC3. The battery indicator LEDs run off the 5V rail, since they are not connected in series. A second 100Ω current limiting resistor is shared between them; they run at a higher current of around (5V - 2V) ÷ 100Ω = 30mA. Because only one of IC3’s outputs can be active at any time, the battery LEDs must be multiplexed with the rudder display LEDs. Running them at a higher current allows them to be driven at a low duty cycle, keeping the rudder position LEDs as bright as possible with a high duty cycle. ADC9. This allows closed loop control. Transistor Q5 is driven with a 187.5kHz PWM signal from output pin OC1D (pin 8) via a 1kΩ resistor. If the 12V rail is too low, IC2 increases the PWM duty cycle to bring it up and vice versa. PNP transistor Q4 allows the boost regulator to be switched off by interrupting the battery current to it. This is important since a boost regulator’s output voltage can never be less than one diode drop below its input voltage and we need to turn the 12V rail fully off to conserve power in sleep mode. Q4 is driven by NPN transistor Q3 via a 2.2kΩ resistor, with Q3 in turn driven from output pin PA6 of IC2 via an 82kΩ current-limiting resistor. When PA6 is low, Q3 is off and so is Q4, so no voltage is applied to the boost regulator. Q3 and Q4 also control the current flow through the resistive divider which is used to monitor the battery voltage. This involves another 12kΩ/1.5kΩ divider, the output of which is monitored by the ADC4 port of IC2. This is done so that the power consumption is reduced when the unit is not operating. Boosted supply Battery monitoring The boost regulator which develops the 12V supply consists primarily of inductor L1, NPN transistor Q5, diode D3 and a 47µF capacitor (at D3’s cathode). The voltage across the 47µF capacitor is fed back to the micro via a 12kΩ/1.5kΩ resistive divider, to pin The display unit has similar battery monitoring circuity to the sensor unit. The connections are slightly different though; for example, the trimpot (VR2) to set AREF (VR2) is now permanently connected to +3V rather than ground, so the other end must be pulled to siliconchip.com.au This photo shows the lower board used in the sensor unit. It carries the microcontroller and its support circuitry plus the 433MHz transmitter module (top right). ground by IC2’s PA1 port to allow the ADC to operate. PA1 also serves as a digital input to detect presses of the pushbutton switch wired to CON8. In this role, VR2 acts as a pull-up resistor and pressing the button pulls PA1 low, which is detected by the microcontroller. If the power is off, this triggers an interrupt which wakes the micro up. If it is already awake, it uses an internal timer to determine the length of the press; longer presses send it to sleep while shorter presses step through the LED brightness settings. As with the sensor unit, a jumper shunt on 4-pin header JP1 determines the expected battery voltage – see Table 1. When the 433MHz receiver (Rx) has power (ie, when the boost regulator is switched on), data is fed through to PA7 (pin 11) of IC2. Since the receiver runs off 5V and the micro off 3V, the receiver’s digital output can swing up above IC2’s power supply voltage. This causes PA7’s clamp diode to conduct and the 1.5kΩ series resistor limits the current which flows under this condition. As with the transmitter, the receiver’s antenna is soldered to a PCB pin on the lower board. It is orientated so that the unit can be held with the LEDs facing the user while it is operating. That’s it for this month. Next month, we will give the full assembly details and explain how to set up and test the two units. We will also give instructions on installing them in a boat. SC July 2011  71