9xVoice Mod

From OpenRC Guides
Jump to: navigation, search

Introduction

This mod adds voice alerts to the 9x transmitter using a custom circuit board with an Atmel ATMega microcontroller that plays voice files contained on a microSD card.

After the manufacturer of the Emartee Sound Module used in the original voice mod, changed the firmware which made it unusable, a new design was created to remove the reliance on 3rd party hardware. This whole process is documented in the forum:

Audio (voice) - Stock 9X PCB

This mod is not for the faint of heart, as you'll need to be experienced in fabricating PCBs & flashing new Atmel ATMega microcontrollers. There are several approaches to doing this mod, I will describe the method using MikeB's PCB design.

Note that this guide is a work in progress, I'm documenting as I'm doing the mod.

IMPORTANT: There are a few mods to the original circuit, I am working on those, please do not use the current schematics & layouts until I update them.

The Build

The build process can be broken down into the following steps:

  • Manufacturing (or purchasing) an interface circuit board.
  • Installing only the components needed to set the fuses & flash the bootloader on the microcontroller.
  • Setting the fuses on the ATMega328 microcontroller.
  • Flashing the bootloader onto the ATMega328 microcontroller.
  • Installing the components needed to supply power to the microcontroller & provide a serial connection.
  • Testing power supply outputs.
  • Flashing the main code to the ATMega328 microcontroller with the serial connection.
  • Installing the rest of the components.
  • Installing speaker in the transmitter.
  • Install sound files on microSD card.
  • Connecting microSD card holder to the interface.
  • Connecting board to the transmitter.
  • Configuring the transmitter for voice.


DEFINITIONS

FUSE
A few bytes of permanent storage in the microcontroller that determine how the chip will act, whether it has a bootloader, what speed and voltage it likes to run at, etc. Note that despite being called 'fuses' they are re-settable and dont have anything to do with protection from overpowering (like the fuses in a home).
FLASHING
The process of writing a pre-compiled software program to the flash memory on the microcontroller.
BOOTLOADER
An application that is positioned in a special region of flash memory in the microcontroller with the purpose of reprogramming the microcontroller without an external programmer, like a USBASP


Interface Circuit Board

For this mod you will need a custom circuit board. Some of the following designs are double sided with plated through holes and better suited to be made by a PCB batching service. There are some designs on the forums that can be made at home. Although there may be subtle differences in pin positions & labeling, all the boards are based on the same design, so the basic process will still be the same.

The Eagle CAD schematic & layout files:

9xVoice by MikeB

All through hole components version

9xVoice MikeB TH v101.png


All surface mount components version

9xVoice MikeB SMD v101.png

MegaSound9X by HaGeHa

Original design (suited for home etching)

Converted to Eagle CAD

9xVoice HaGeHa SIP.png

AudioMega by Oliver

All surface mount component design (suited for home etching)

9xVoice Oliver SMD.png

Components needed

This Wiki will cover building the 9xVoice design by MikeB. The linked CSV files can be used to create an order on Digi-Key.

9xVoice by MikeB

Through Hole component design

BOM File

Surface Mount component design

Digi-Key Part Number BOM CSV

Digikey BOM
DIGIKEY PART # TYPE VALUE EAGLE DEVICE QTY
2N7002-FDICT-ND MOS FET 2N7002 NMOSSOT23 1
311-1150-1-ND CAPACITOR 10pF C-USC1206 1
311-1154-1-ND CAPACITOR 22pF C-USC1206 2
311-1167-1-ND CAPACITOR 470pF C-USC1206 1
311-1206-1-ND CAPACITOR 3900pF C-USC1206 1
311-1174-1-ND CAPACITOR 10000pF C-USC1206 1
311-1177-1-ND CAPACITOR 0.033μF C-USC1206 1
311-1179-1-ND CAPACITOR 0.1μF C-USC1206 6
399-3687-1-ND POLARIZED CAPACITOR 10μF CPOL-USA/3216-18R 3
399-5124-1-ND POLARIZED CAPACITOR 220μF CPOL-USCT7343 1
887-1081-1-ND CRYSTAL 12MHz CRYSTAL5X3 1
ATMEGA328P-AU-ND MICROCONTROLLER ATMEGA328P MEGA8-AI 1
BAT42W-FDICT-ND DIODE BAT81V DIODE-SOD123 4
BC848CMTFCT-ND NPN Transistor BC846ASMD BC846ASMD 5
AP7313-33SRG-7DICT-ND VOLTAGE REGULATOR LE33CZ XC63FPM 1
LM386M-1/NOPB-ND Low Voltage Audio Power Amplifier LM386M LM386M-1 1
NCP1117ST50T3GOSCT-ND VOLTAGE REGULATOR REG1117 REG1117 1
RMCF1206JT10K0CT-ND RESISTOR 10kΩ R-US_R1206 7
RMCF1206JT100KCT-ND RESISTOR 100kΩ R-US_R1206 2
RMCF1206JT10R0CT-ND RESISTOR 10Ω R-US_R1206 1
RMCF1206JT150RCT-ND RESISTOR 150Ω R-US_R1206 1
RMCF1206JT1K00CT-ND RESISTOR 1kΩ R-US_R1206 3
RMCF1206JT22K0CT-ND RESISTOR 22kΩ R-US_R1206 1
RMCF1206JT2K20CT-ND RESISTOR 2.2kΩ R-US_R1206 3
RMCF1206JT470KCT-ND RESISTOR 470kΩ R-US_R1206 1
RMCF1206JT470RCT-ND RESISTOR 470Ω R-US_R1206 1
RMCF1206JT47K0CT-ND RESISTOR 47kΩ R-US_R1206 2
RMCF1206JT4K70CT-ND RESISTOR 4.7kΩ R-US_R1206 1
RMCF1206JT560KCT-ND RESISTOR 560kΩ R-US_R1206 1

MegaSound9X by HaGeHa

TYPE VALUE PACKAGE QTY
800mA and 1A Low Dropout (LDO) Positive Regulator REG1117 SOT223 2
CAPACITOR 100nF C1206 6
CAPACITOR 100μF C1206 2
CAPACITOR 10pF C1206 1
CAPACITOR 10μF C1206 5
CAPACITOR 22nF C1206 1
CAPACITOR 22pF C1206 2
CAPACITOR 330pF C1206 1
CAPACITOR 47nF C1206 2
CAPACITOR 47μF C1206 1
CAPACITOR 4.7nF C1206 1
CRYSTAL 12MHz HC49US 1
Low Voltage Audio Power Amplifier LM386N-1 DIL08 1
MICROCONTROLLER MEGA328 DIL28 1
MOS FET 2N7002 SOT-23 1
NPN TRANSISTOR BC846 SOT23 5
RESISTOR R1206 1
RESISTOR 10Ω R1206 1
RESISTOR 150Ω R1206 1
RESISTOR 470Ω R1206 1
RESISTOR 100kΩ R1206 2
RESISTOR 10kΩ R1206 6
RESISTOR 1kΩ R1206 3
RESISTOR 22kΩ R1206 1
RESISTOR 2.2kΩ R1206 3
RESISTOR 470kΩ R1206 1
RESISTOR 47k R1206 2
RESISTOR 4.7kΩ R1206 1
RESISTOR 560kΩ R1206 1
Schottky Diodes BAT42 SOD123 4

AudioMega by Oliver

TYPE VALUE PACKAGE QTY
800mA and 1A Low Dropout (LDO) Positive Regulator REG1117-3.3 SOT223 1
800mA and 1A Low Dropout (LDO) Positive Regulator REG1117-5 SOT223 1
CAPACITOR 100nF C1206 5
CAPACITOR 10pF C1206 1
CAPACITOR 22nF C1206 1
CAPACITOR 22pF C1206 2
CAPACITOR 47nF C1206 2
CAPACITOR 4.7nF C1206 1
CRYSTAL 12MHz HC49UP 1
DIODE BAT42 SOD123 4
Low Voltage Audio Power Amplifier LM386M SO08 1
MICROCONTROLLER ATMEGA328-AU TQFP32-08 1
MOS FET 2N7002 SOT-23 2
NPN Transistor BC846ASMD SOT23 3
POLARIZED CAPACITOR 100μF CT6032 2
POLARIZED CAPACITOR 10μF CT6032 3
POLARIZED CAPACITOR 47μF CT6032 1
RESISTOR R1206 1
RESISTOR 10Ω R1206 1
RESISTOR 150Ω R1206 1
RESISTOR 100kΩ R1206 2
RESISTOR 10kΩ R1206 3
RESISTOR 1kΩ R1206 4
RESISTOR 2.2kΩ R1206 2
RESISTOR 33kΩ R1206 1
RESISTOR 470kΩ R1206 1
RESISTOR 4.7kΩ R1206 1
RESISTOR 560kΩ R1206 1

Building the Interface

Install components to set fuses & flash boot loader

Start with a bare PCB:

9xVoice Bare SMD PCB.JPG


Install the ATMega328, 12MHz crystal, two 22pF capacitors & the ICSP connector. This is all that needed in order to set the fuses & flash the bootloader onto the microcontroller.

Components required
NAME VALUE EAGLE DEVICE TYPE DIGI-KEY PART #
IC1 ATMEGA328P MEGA8-AI MICROCONTROLLER ATMEGA328P-AU-ND
Q1 12MHz CRYSTAL5X3 CRYSTAL 887-1081-1-ND
C7 22pF C-USC1206 CAPACITOR 311-1154-1-ND
C8 22pF C-USC1206 CAPACITOR 311-1154-1-ND
JP1 PINHD-2X5 PIN HEADER


9xVoice SMD Flash.jpg

Set the fuses on the MCU

Before you connect your USBASP to the interface, make sure your USBASP programmer outputs 3.3v, not 5v. You may need to remove a jumper to change the supply voltage:

9xVoice USBASP.jpg


Connect your USBASP programmer to the ICSP connector on the PCB. Note that pin 1 (MOSI) is at the bottom left on this specific board:

9xVoice SMD ICSP.jpg


Use AVRDUDE to set the fuses (note that the programmer has to be slowed down to set the fuses):

  • Low fuse: 0xFF
  • High fuse: 0xD6
  • Extended fuse: 0xFD (0x05)
avrdude -p m328p -P usb -c usbasp -B 100 -U lfuse:w:0xff:m -U hfuse:w:0xd6:m -U efuse:w:0xfd:m -v

The extended fuse may fail, accept the suggested value by select "n" at the prompt. Check the output for any other errors & make sure the fuses are correct:

avrdude: set SCK frequency to 8000 Hz
avrdude: AVR device initialized and ready to accept instructions 

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as 7
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.03s 

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xd6"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd6:
avrdude: load data hfuse data from input file 0xd6:
avrdude: input file 0xd6 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xfd"
avrdude: writing efuse (1 bytes):

Writing |                                                    | 0% 0.00s ***failed;
Writing | ################################################## | 100% 0.07s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xfd:
avrdude: load data efuse data from input file 0xfd:
avrdude: input file 0xfd contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0xfd != 0x05
avrdude: verification error; content mismatch

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D6
avrdude: safemode: efuse reads as 5
avrdude: safemode: efuse changed! Was fd, and is now 5
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

This command can be use to verify the fuses also:

avrdude -p m328p -P usb -c usbasp -U lfuse:r:-:i -U hfuse:r:-:i -U efuse:r:-:i -v

Flash the boot loader

Use AVRDUDE to flash the boat loader to the microcontroller:

The bootloader can be found here

avrdude -p m328p -P usb -c usbasp -U flash:w:optiboot_atmega328.hex:i -u -v

Check the output for errors:

avrdude: auto set sck period (because given equals null)
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed

         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: reading input file "optiboot_atmega328.hex"
avrdude: writing flash (32722 bytes):

Writing | ################################################## | 100% 7.30s

avrdude: 32722 bytes of flash written
avrdude: verifying flash memory against optiboot_atmega328.hex:
avrdude: load data flash data from input file optiboot_atmega328.hex:
avrdude: input file optiboot_atmega328.hex contains 32722 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 6.30s

avrdude: verifying ...
avrdude: 32722 bytes of flash verified

avrdude done.  Thank you.

Install components to flash main code

Install the components needed to flash the main code to the microcontroller, i.e. the power supply & logic level serial IO:

Components required
NAME VALUE EAGLE DEVICE TYPE DIGI-KEY PART #
IC2 LE33CZ XC63FPM VOLTAGE REGULATOR AP7313-33SRG-7DICT-ND
IC4 REG1117 REG1117 VOLTAGE REGULATOR NCP1117ST50T3GOSCT-ND
T2 2N7002 NMOSSOT23 MOS FET 2N7002-FDICT-ND
C1 0.1μF C-USC1206 CAPACITOR 311-1179-1-ND
C2 10μF CPOL-USA/3216-18R POLARIZED CAPACITOR 399-3687-1-ND
C3 10μF CPOL-USA/3216-18R POLARIZED CAPACITOR 399-3687-1-ND
C4 10μF CPOL-USA/3216-18R POLARIZED CAPACITOR 399-3687-1-ND
C5 0.1μF C-USC1206 CAPACITOR 311-1179-1-ND
D4 BAT81V DIODE-SOD123 DIODE BAT42W-FDICT-ND
D5 BAT81V DIODE-SOD123 DIODE BAT42W-FDICT-ND
C16 0.1μF C-USC1206 CAPACITOR 311-1179-1-ND

NOTE: If you substitute the 3.3v Regulator, make sure you get one with the same pinout (SOT23R or compatible): pin 1: GND, pin 2: OUT, pin 3: IN


9xVoice SMD FTDI.jpg

NOTE: Temporary diodes were used in the picture above for D4 + D5 & subsequently removed. Although they appear to be removed from the PCB in the following pictures, the correct surface mount components were installed later (visible in the last picture).

Check PCB power supply

Now would be a good time to connect a battery to the board & check the voltage regulators for correct voltage output. IC4 (NCP1117) should measure 5.0v between pins 1 & 2. IC2 (AP7313) should measure 3.3V between pins 1 & 3.

9xVoice SMD Power.jpg

Connect the serial programmer to the PCB

Connect the FTDI & power to the PCB:

Note TX -> RX & RX -> TX

9xVoice SMD FTDI Conn.jpg

You also have to connect power to the board as shown above.

Flash the main code via TTL

avrdude -p m328p -b 38400 -P COM4 -c arduino -U flash:w:amod_last.hex:i -u -v

Check for error messages:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed

         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "amod_last.hex"
avrdude: writing flash (7512 bytes):

Writing | ################################################## | 100% 3.76s

avrdude: 7512 bytes of flash written
avrdude: verifying flash memory against amod_last.hex:
avrdude: load data flash data from input file amod_last.hex:
avrdude: input file amod_last.hex contains 7512 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.70s

avrdude: verifying ...
avrdude: 7512 bytes of flash verified

avrdude done.  Thank you.

Install remaining components

9xVoice SMD Complete.jpg

Installation

Install speaker

Install a 8Ω speaker into the transmitter case. Speaker pictured is 40mm and is secured with hot glue.

9xVoice SMD Speaker.jpg

Fit Interface into 9x transmitter case

The board is attached to the transmitter case with screws into 2 unused holes above and to the inside of the gimbals. Slight trimming to the bottom edge of the interface board may be required to make it fit.

9xVoice SMD TestFit.jpg

Connect interface

Overview of connections:

9xVoice SMD Connections.JPG

Interface to transmitter

The interface has 8 wires that connect to the main transmitter PCB:

SUPPLY, GND
Supplies power to the interface
  • SUPPLY - connects to supply voltage. The end of the (tantalum) capacitor next to the 5V regulator (red wire), or on the switch PCB.
NOTE: The position where the white wire is soldered on will only provide battery voltage when the power switch is turned on, not when the trainer cable is plugged in. The pin directly next to the one indicated, will provide battery voltage when the trainer cable is plugged in and when the power switch is turned on.


9xVoice SMD Supply+.JPG
  • GND - connects to transmitter ground. Pad towards the right of the board (black wire).


9xVoice SMD Supply-.JPG
DB0, DB1, DB2, DB3
The four data lines DB0-DB3 (blue, green, yellow, orange wires) are connected to the via holes between the resistors leading to the LCD. They are in order, so DB0 goes in the leftmost via, then DB1 in the next and so on. To connect, it may be easiest to lightly tin the wire end, making sure it will go into the via, then tin the via so it is full of solder. Now heat the solder in the via, and push the tinned wire into the molten solder, making sure no wire strand misses the hole. If a strand does miss, remove the wire and re-strip and re-tin the wire. It is very difficult to get any loose strands back close enough together to go into the via hole. Work from DB0 to DB3, otherwise soldered in wires get in the way.
  • DB0 - connects to the ATmega64 pin 51 (AD0)
  • DB1 - connects to the ATmega64 pin 50 (AD1)
  • DB2 - connects to the ATmega64 pin 49 (AD2)
  • DB3 - connects to the ATmega64 pin 48 (AD3)
9xVoice SMD D0-D3.JPG
B7
  • B7 - connects to the ATmega64 pin 17 (PB7). Pad on pin 17 of the processor (purple wire).


9xVoice SMD B7.JPG
BEEPER
Connect stock beeper output to interface to retain warning sounds.
  • BEEPER - Connects to the switch PCB. The switch PCB in the picture had the haptic mod done previously, so your connection may be different.


9xVoice SMD Beeper.JPG

Backlight

BL
Connects the transmitter backlight if installed. Note that the back light wires will have to be desoldered from the connector and extended to reach the interface.
  • BL+ - connects to red wire on backlight
  • BL- - connects to black wire on backlight

Speaker

SP
Connects to the 30-40mm 8Ω speaker which has to be installed for this mod.
  • SP+ - connects to red wire on 8Ω speaker
  • SP- - connects to black wire on 8Ω speaker

MicroSD Card

The MicroSD card containing the voice files needs to be connected to the interface. There are many different methods to mount the card holder. It can be attached to the interface, or accessible to the outside if you cut a slot in the transmitter case. Typically a MicroSD breakout board is used, similar to this:

MicroSD Breakout.png


Connect the interface to the MicroSD card board as follows:

MicroSD Connections
Audio9x JP2 MicroSD
PIN NAME PIN NAME DESCRIPTION
1 MISO 7 DO Data out
2 GND 6 VSS/GND Supply voltage ground
3 SCK 5 SCLK Clock
4 3.3V 4 VDD/VCC Supply voltage
5 GND 6 VSS/GND Supply voltage ground
6 MOSI 3 DI Data In
7 SS 2 CS Chip Select

Other connections

RXD, TXD
RS232 level serial connection to PC for programming
MRD, MTD
Logic level serial connection to the ATmega64 on the main board of the transmitter.
  • MRD - connects to the ATmega64 pin 27 (PD2)
  • MTD - connects to the ATmega64 pin 28 (PD3)
LTXD, LRXD
Logic level serial connection for serial programming. (Used with a FTDI)
SGND
Signal ground for the serial programming connections
X1, X2, X3
Currently unused pins of the Mega328, for future expansion
JP4
Pins have to be connected (jumpered) to provide +5V to the LM386
S1
Provides supply voltage. Optional, connects to the correct pin on JP4 (top pin on this board) to provide supply voltage to the LM386

Configuration

Select supply voltage for the LM386 Audio Power Amp

There are 2 options for the supply voltage on the LM386, +5V or +Ub (battery). In most cases jumpering JP4 will select +5V and will work fine. However if you modify some of the resistor values to get more volume, you may have to move the jumper to connect the top pin of JP4 to S1 in order to get battery supply directly to the LM386. I'm using an older version of the PCB in the pictures which does not have the 3 pins close to each other to make voltage selection easier.

9xVoice SMD LM386 Power.jpg

Install voice files on MicroSD card

The sound file numbering scheme is different between open9x & er9x. Make sure you use to correct sound pack for you transmitter.

Sound files are copied into the root folder of the MicroSD card (for er9x & open9x), and are available from the following libraries:

Sound Pack Library

Audio files 22KHz 16 Bit for the new Sound Module

Configure transmitter

How to program the audio on er9x

Refer to the audio options in the Open9x user guide:

Open9x user guide

Debugging

Backlight doesn't turn on & sound files don't play

If this happens intermittently with the voice interface, the culprit is likely the ATMega328 on the voice interface. There has been several instances where replacing the MCU has solved the problem. If you have used a SMD version of the chip, use Chip Quik to remove the old one.


Created by Mbanzi