This project is a continuation of SSTV with AVR, which started as a software mod of an Arduino antenna analyzer. After I found out that it is actually possible to transmit SSTV pictures with the capabilities of the AVR, the next step was to make it standalone with an additional camera module.
An interesting option is the OV7670 camera chip. Modules with this chip and some additional optics can be bought on Ebay. There are two versions of the module available: one with an additional AL422 buffer chip and one without buffer. As the camera chip outputs data at 24MHz, the buffer is necessary to properly read the images with the Arduino.
The camera module connects to the Arduino over a two wire bus which is similar to I2C but has some different definitions of the NACK and ACK bits. Thus it is possible to write the internal registers of the OV7670 using the AVR ‘2-Wire Serial Interface’ (TWI) but not possible to read them back.
Then there are additional VSYNC and HREF outputs which give information about the picture timing and a parallel bus to read data from the fifo chip.
The connections to the AD9850 module are identical to the preceding project (SPI with an additional reset and update pin). As the wiring is a little more complex this time, I made a circuit diagram.
In addition to the arduino connected with the two modules, there is also some power supply providing 5V and 3,3V. With the jumper, either 5V or something above 6.5V can be chosen as input voltage.
The transistor at the top right of the circuit is there to amplify the signal of the AD9850 to provide roughly 10dBm of output power.
Right now this is just connected via jumper wires on my breadboard. But I will design a PCB soon – so stay tuned for updates.
The software for this project is (besides the additional camera interfacing) a bit simpler than the other SSTV project. As there is already a buffer chip between the camera and the arduino, there is only one software FIFO between the arduino and the AD9850 chip (the other SSTV project uses two fifos – an additional one between the serial input and the Arduino). The unpacking and flashing is very similar to SSTV with AVR, where all steps are described in detail.
Before the software is ready to be flashed into the microcontroller, the callsign and transmit frequency need to be set. This can be dome in the ‘avr/main.c’ file. Near the beginning of the file there are these three lines which define some basic parameters:
#define FREQUENCY 0 // set tx frequency in kHz here
#define MORSE_WPM 20 // morse speed in words per minute
#define WAIT_TIME 0x00FFFFFF // wait time between pictures - not an exact time measure
Set your preferred transmit frequency in the upper line, the morse speed in the middle line and the time between two pictures in the third line. The last parameter is set as some counter maximum value. It does not provide an exact time measure. So it requires some experimentation to find the right value here.
The callsign and some message, which is transmitted in morse code after the SSTV picture can be set right after the definitions in the following two lines:
char callsign = "DN9AAA";
char message = "sent with avr-sstv by ";
If all settings are done, the software can be compiled and flashed to the Arduino:
$ make flash
avr-gcc -Wall -g -mmcu=atmega328p -I lib/ -c -o main.o main.c
avr-gcc -Wall -g -mmcu=atmega328p -I lib/ -c -o lib/libad9850.o lib/libad9850.c
avr-gcc -Wall -g -mmcu=atmega328p -I lib/ -c -o lib/libmorse.o lib/libmorse.c
avr-gcc -Wall -g -mmcu=atmega328p -I lib/ -c -o lib/libov7670.o lib/libov7670.c
avr-gcc -Wall -g -mmcu=atmega328p -o main.elf main.o lib/libad9850.o lib/libmorse.o lib/libov7670.o
avr-size -C --mcu=atmega328p main.elf || avr-size main.elf
AVR Memory Usage
Program: 5652 bytes (17.2% Full)
(.text + .data + .bootloader)
Data: 1650 bytes (80.6% Full)
(.data + .bss + .noinit)
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
avrdude -p m328p -P /dev/ttyACM0 -c arduino -U flash:w:main.hex:i
avrdude: AVR device initialized and ready to accept instructions
[... some more avrdude status messages ...]
avrdude done. Thank you.
If everything went well, it should now start transmitting pictures. There is a lot of software to decode SSTV out there. One I really like is MMSSTV:
Update – July 23, 2016
The PCBs are here! If you would also like to build this project, you can order the PCB at this store (Note that the board is panelized with another board. However, this does not change the price for the PCB). You can also download all schematic and layout files with a single zip file. It includes a list of all parts with ordering information. As you might already see, there is no need to solder all parts to the backside. Especially the 5V voltage regulator is not needed as there is already one on the Arduino board.
I tested the board with an original Arduino Uno and with an Arduino Uno compatible board with a CH340 chip. With both of them, the system works very well and is able to transmit pictures via SSTV.
But the PCB was not designed for these Arduino boards. As I tried it with an Arduino Nano compatible board, it did fail. The reason is that on the Nano boards, some circuitry around the pins RX (Pin 0) and TX (Pin 1) is different such that the project won’t work anymore.
But the problem can be solved by soldering two additional wires to the board. First, the Pins TX, RX, D2 and A3 need to be cut off the Nano board as shown on the left (You can click on the images to get larger versions).
The second step is to solder two wires from the Nano board to the PCB. One from pin D2 to the pad where TX was and one from the pin A3 to the Pad where RX was. This step is shown in the pictures below. On the pictures, you can also see the mounted camera and DDS module.
In addition to the hardware modification, there are also some software modifications necessary to work with the changed pin functions. I uploaded the modified software here. The flashing of the chip works just like with the previous software. Be sure to set the correct serial port in the makefile. As soon as the software is on the AVR, it should start the SSTV transmission. Now, everything can be equipped with SSTV.
Update – March 25, 2017
Thanks to the help of Ricardo (see comments below), the SSTV project is now also able to handle more bright environments. Previously, in any outdoor scenario, the cam would deliver only white pictures.
With a new register setting in the OV7670 module, the internal AGC and AEC can now also handle bright light conditions.
There was also an error in the library libad9850 which was a remainder of the original antenna analyzer project. The fixed code with both modifications can be found here.
Although this project started as an experiment, I think it could be of some practical use. One field of deployment could be high altitude balloons. There are lots of people in the ham radio community who do such experimants. So if you are one of them, perhaps you would like to add some SSTV to your next project?