For proof of concept, I used the Gnuradio ATSC transmitter blocks to add the forward error correction to the video data. The encoded symbols are saved onto a microSD card. Since the micro struggled to read from the SD card fast enough I loaded the data into the 32MB ram on the P2 edge module and played it in a loop. I thought that this was the easiest way to feed a sustained 33mbps into the P2. Well, for 6.19 seconds :) It works! And the 6 seconds of video plays in a loop, with some pixelization as it restarts.
The Parallax P2 microcontroller has hardware to handle the heavy lifting for generating composite video signals. The quadrature modulator included for generating the chroma signal can also be used as a general purpose radio signal modulator.
The ATSC signal is vestigial side band, which means the lower side band signal is mostly filtered out. I knew from experience with Gnuradio that applying the root-raised-cosine filter to the output of the ATSC modulator is very computationally intensive. The signal could be pre-filtered with Gnuradio. However, the end goal is to run everything on the microcontroller. The transmitted symbols contain 33 Mbps of information. The filtered signal might need 6 megasamples per second with 8 bits for I and Q at a minimum. This would increase the storage requirement to 6M*16 = 96 Mpbs, over double. But because the P2 would upsample the data with a zero order hold the transmitted signal may not be much cleaner anyway.
For this project I opted to generate an unfiltered double side band signal. The cheap channel 3 modulators used in VCRs are also double side band for cost reasons.
This way the P2 video generation hardware would do all the work of reading symbols from memory and feeding them to the RF (chroma) modulator. The palette memory even maps the symbols to the appropriate RF levels.
ATSC has a segment sync and a field sync similar to NTSC video. Thus in order to keep synchronization we need the output loop to occur at a whole number of frames. One ATSC frame contains 2 fields of 312 packets each, for a total of 624 packets.
Each packet has Reed-Solomon error correction added lengthening it to 207 bytes. These are sent 2 bits at a time resulting in 828 symbols. Then a 4 symbol segment sync is added, lengthening it to 832 symbols. After every 312 packets a field sync is sent, adding another 832 symbols. Thus an ATSC frame is (832*312 + 832)*2 = 520,832 symbols long.
With the constraint of 32MB of PSRAM I determined that the largest whole number of frames that would fit was 128 frames. 128*520,832 = 66,666,496 symbols. Each symbol requires 3 bits but I opted to store 4 bits per symbol for simplicity. This would require 33,333,248 bytes of memory, filling the PSRAM to 99.34% capacity.
Since each frame is 624 packets, the input file would need to be 128*624 = 79,872 packets. Since an MPEG-TS packet is 188 bytes, the file would be 79872*188 = 15,015,936 bytes. The unix dd command is able to extract data of the exact size needed. Due care needs to be taken to ensure that the loop file starts with the MPEG-TS sync byte 0x47. Setting the start position to a multiple of 188 bytes worked.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.