The original dtv2ser project uses a custom made board with an ATmega8 to provide the interface between a serial port and the DTV dtvtrans software. The layout and the schematics for the board are freely available but unfortunately most users have difficulties to create the HW from scratch.
With the Arduino platform an AVR ATmega platform was released to the public that is available very easily and rather cheap. This document describes how to transform an off-the shelve Arduino board into a dtv2ser device. The HW modifications required are very simple and this allows even unexperienced users to create their own device.
2. HW Requirements
- An “Arduino 2009” aka “Arduino Duemilanove” board with ATmega168 or ATmega328
- 3x LEDs (red, green, blue)
- 3x 220 Ohm Resistors
- A DB9 female connector (for the DTV joystick port)
- some wire
The Arduino2009 has an ATmega168/328 with 16 MHz clock frequency on the board and provides a USB/Serial connector with a FT232 chip that has HW RTS/CTS handshaking support.
You can use one of the many Arduino clones (Seeduino, …) if they have similar HW parameters.
Update (26.2.2012): Even the new Arduino Uno is supported. As it does not have a FT 232 USB chip with HW RTS/CTS on board it does not allow you to enable HW handshaking as described on this page. You rather have to buy an extra FT232 break out board (e.g. from sparkfun) with RTS/CTS signals available and then connect TxD, RxD, RTS, CTS, and GND from this board to your Arduino on the mentioned pins. This Forum64 thread gives instructions on this mod (in german). Then the same firmware can be used.
The Arduino2009’s USB to serial connector is used with 250kB/s as a transfer rate. Please make sure that your host operating system allows to set this non-standard speed. Its reported to work on Mac OS X and Windows with the FTDI drivers.
3. HW Build Instructions
The vanilla Arduino board does not allow to control the HW CTS serial signal from the AVR chip. But this is required to allow high performance data transfer for the dtv2ser firmware. Fortunately, this signal of the FT232 chip is available on the solder pad X3 and can be added by soldering a wire from there to a pin that is connected to the AVR port labeled “DIGITAL 2”.
. Solder Pad X3 DIGITAL .
. 4 3 2 1 .
. (x) (x) (x) (x) .
. | * 3
. +----------------------------------> * 2
. * 1 TX
. * 0 RX
3.2 Add the dtv2ser LEDs
The dtv2ser uses three LEDs in green, orange and red to signal its internal status to the user. In this step we add those LEDs by simple connecting them with a resistor each to the DIGITAL pins 8, 9 and, 10. The positive side of each LED is connected to +5V that is available on the POWER connector.
. Red LED
. Reset * +------>|----| 220 |--------------* DIGITAL 10
. 3V3 * | Orange LED
. 5V *---------+------>|----| 220 |--------------* DIGITAL 9
. GND * | Green LED
. GND *--+ +------>|----| 220 |--------------* DIGITAL 8
. Vin * |
. v This line is used in section 3.3
3.3 Add the joystick connector
Finally, the Arduino needs to be connected to your DTV. As dtvtrans uses one of the joystick ports for communication it is quite common to use a DB9 standard joystick connector for this.
The 6 signal lines and GND need to be soldered to the DB9 (female) connector and on some pin headers to get connected to the Arduino on the connector labeled “ANALOG IN”.
. DB9 Connector DB9 ANALOG IN
. (rear view) 1 * ----------- * 0
. 2 * ----------- * 1
. 1 2 3 4 5 3 * ----------- * 2
. * * * * * 4 * ----------- * 3
. * * * * 6 * ----------- * 4
. 6 7 8 9 9 * ----------- * 5
. DB9 POWER CONNECTOR (see 3.2)
. 8 * ----------- * GND
3.4 Add RTS Line to the AVR
The RTS line is available on the left solder pad of the unpopulated resistor found on the right hand side of the X3 pads. Have a look at the picture above to find the exact location. The RTS line needs to be connected to port DIGITAL 3 on the AVR.
. Solder Pad X3 DIGITAL .
. 4 3 2 1 .
. (x) (x) (x) (x) .
. +----------------------> * 3
. | * 2
. * * * 1 TX
. unpopulated solder pads * 0 RX
Do NOT connect the line to the right pad and do NOT short circuit poth pads. The right line is the RESET line and will restart your board every time RTS is triggered… You have been warned 😉
That’s it! Now your arduino is a dtv2ser board 😉
4. Flash the firmware
All software including the firmware is included in the dtv2ser release archive on the dtv2ser homepage.
New (3.1.2011): Recompiled Firmware with AVR GCC 4.3.3 and -fno-inline to avoid timing problems in inlined code.
- For Arduino 2009 with ATmega 328: dtv2ser-0.5a-250000-arduino2009-atmega328.zip
- For Arduino 2009 with ATmega 168: dtv2ser-0.5a-250000-arduino2009-atmega168.zip
New (3.1.2011): Fixed timing issue with AVR GCC 4.3.3 and added RTS support (requires RTS line as described above)
- For Arduino 2009 with ATmega 328: dtv2ser-0.5b-250000-arduino2009-atmega328.zip
- For Arduino 2009 with ATmega 168: dtv2ser-0.5b-250000-arduino2009-atmega168.zip
I use the avrdude command line tool to flash the firmware.
But you can use any downloader SW that supports flashing the arduino.
The firmware file is called “dtv2ser-x.y-250000-arduino2009-atmega168.hex” with x.y being the current version of dtv2ser. This file comes with this distribution.
Connect your Arduino board to your Mac or PC and find out the serial port where it is connected (here on my Mac: /dev/cu.usbserial-A7006RWQ, on PCs something like COM5, on Linux /dev/ttyUSB0).
The following command flashes the firmware:
> cd server > make prog_arduino2009 LDR_PORT=<serial port>
or without Makefile call (for Arduino 2009 with ATmega 168):
> avrdude -p m168 -c arduino -P <serial port> \ -b 19200 -U flash:w:dtv2ser-0.5a-250000-arduino2009-atmega168.hex
Or on a board with ATmega328 (Thanks to giox!):
> avrdude -p m328p -c arduino -P <serial port> \ -b 57600 -U flash:w:dtv2ser-0.5a-250000-arduino2009-atmega328.hex
Some bootloaders (esp. for the ATmega 328) use a higher baudrate, e.g. 38400. Adjust the -b switch accordingly.
If everything worked fine then your newly attached Green LED goes on after a reset.
5. Using dtv2sertrans Host SW
Starting from version 0.4 the dtv2sertrans SW directly supports the arduino board. See the manual for this tool for further details.
Note the following:
- The arduino uses a baud rate of 250kB/s and not 240kB/s as set as default.
So you have to specify the -s switch or set the DTV2SER_SPEED environment
> ./dtv2sertrans -s 250000 ...
- Due to its HW the Arduino is reset every time the serial port is opened from dtv2sertrans. With this behaviour it is not possible to keep parameter settings during calls of dtv2sertrans. Therefore it is advisable to perform all parameter commands on the same command line and concatenate the commands with +. Additionally. you can save changed parameters to the EEPROM to have them survive a reset.
> ./dtv2sertrans .... + param set_byte 0 5 + .... > ./dtv2sertrans .... + param set_byte ... + param save
That’s it! Have fun using dtv2ser…