Standalone SSTV using Arduino and OV7670

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.

ov7670_front

ov7670_back OV7670 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.

ad9850

AD9850 module

 

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.

avr-sstv_circuit

avr-sstv circuit

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.

Software

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:

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:

If all settings are done, the software can be compiled and flashed to the Arduino:

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:

MMSSTV receiving a picture from AVR-SSTV

MMSSTV receiving a picture sent by AVR-SSTV

Update – July 23, 2016


AVR-SSTV PCB

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.

Tested AVR boards

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.

Step one: cutting pins off the Nano board

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.


PCB with modification for Nano compatible boards

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.

Finally…

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?

This entry was posted in Projects. Bookmark the permalink.

9 Responses to Standalone SSTV using Arduino and OV7670

  1. Ricardo says:

    Tom Hello,
                      Your code has worked very well, I should be grateful for your work.
    Now I have the following problem:
    When receiving the images taken inside the house are very good and focused, with about 20 to 200 LUX.
    On the contrary the exterior, more than 20000 LUX, burn and leave completely white.
    If you understood the datasheet, the COM8 register configures the AGC, AWB and AEC and your code says:
    {OV7670_COM8, 0b11100111},
    What sets for AGC = ON, AWB = ON and AEC = ON.
    Do you have any idea why you can burn the image? Maybe a defect in the OV7670 module?
    Thank you for your time for me.
    Ric

    • Ricardo says:

      Again me,
      Yep !! Solved the problem in my module.
      You write in your code of main.c
      {OV7670_COM8, 0b11100111}, this configuration works fine in my room (10 to 150LUX), but burns the image if it is outside (5000 to 20000 or more LUX).
      Reading the datasheet OV7670 as default for COM8 8F, then change:
      {OV7670_COM8, 0b10001111}, and it works more clearly in my room and very well in the exterior.
      Maybe it will work for you and for others!
      Thank you for your work Tom.
      regards
      Ric

      • tom says:

        Hi Ricardo,
        I also experienced the problem that the camera could not handle outdoor light properly and was searching for a solution. Apparently you were faster 🙂
        I will soon update the code here and include your suggestions. Thanks very much for your help. It would be great to hear from your HAB projects.
        Greetings
        Tom

  2. Ricardo says:

    Hello Tom,
    You librery AD9850.c write:
    // generate W_CLK pulse
    PORTB |= (1 << PORTB2); // w_clk = 1
    PORTB &= ~(1 << PORTB2); // w_clk = 0
    PORTB2 is TX? and PORTB5 is WCLK?
    tnx.
    Ricardo

    • tom says:

      Hi Ricardo,
      You’ve got a good point there. This is an error in the library. On the original antenna analyzer project, W_CLK was connected to PB2.
      Apparently the AD9850 also works without the clock pulse during init. So it should be safe to just remove the two lines of code.
      Thanks for pointing this out.

      • Ricardo says:

        Hello Tom, I am who should thankyou for this piece of code.
        Will be able to put sstv on my next HAB.

        TNX
        Ricardo

  3. I liked your project !
    Can you send the compiled sketch for Arduino ?

    • Joan says:

      And I was just woirndeng about that too!

      • tom says:

        Hi,

        thanks for your interest in my project. Sorry i could not answer earlier.

        Did you try to compile the code yourself? It is very likely that you will need to change some parameters frequently during testing.

        If you are running windows, there is a great toolchain available at http://winavr.sourceforge.net/
        It includes all the needed libraries, a compiler and also avrdude.

Leave a Reply

Your email address will not be published. Required fields are marked *