- Do this every 15 minutes
- Take a snapshot of the field day site with the Webcam, overlay some text and a timestamp on the image
- Encode the snapshot image into an SSTV AFSKsignal
- Turn the PTT line ON
- First play some voice audio files that do announcements of the beacon, what it is doing, and maybe the same time announce where our field day site is located, the website to find more info etc..
- Play(transmit) the SSTV AFSK image sound to send the image over the air
- End the transmission with a quick audio CW ident
- Turn the PTT Off.
6) I also decided I wanted to be able to have an accurate timestamp on the images. But the Raspberry Pi has no accurate clock built-in and it resets its clock to 1969 on bootup everytime. It is totally dependent on having normally getting a time source over the network via NTP to set its clock with during the operating system startup. But on Field Day it will be running at an isolated location with no network/internet connectivity. So it would not be able to have an accurate time as is. I found a easy to add RTC clock chip that is available on a little board that plugs right into the first 6 pins on the Raspberry Pi header. The RTC is called “RasClock”, made by AfterThought Software and available from several vendors on the net which sell Raspberry Pi accessories. I got the RTC board, connected it to the Pi, and got it running in just a few minutes. Now the Pi has a perfectly accurate on-board clock and will bootup with the correct time already set. Now putting timestamps on the webcam snapshots will be easy and accurate.
I also purchased one of the little micro SD card holders made by the same people, and found it solved the problem I had of every so often accidentally bumping the regular SD card that always stuck out a little bit from the board. This would often cause the Raspberry Pi to reboot or start having io errors which forced me to reboot to get it to work again. I did not like the way that the SD card slow was designed on the Raspberry Pi to begin with myself, but their little micro card hides the SD totally under the board and makes it impossible to bump and solves that design issue.
Ok, now to document the actual build of this SSTV Beacon.
Here is a couple of images of the basic physical connections made between the Raspberry Pi, and the IC-2100 radio.
Here is the circuit diagram of all the connections I ended up making.
Without the MCP3008 ADC stuff it turned out actually very simple to do. You can see in the pictures above how much room that left in the middle of the breadboard after I took it out.
- I used a NPN transistor to take the 3.3V HIGH signal of the Raspberry Pi GPIO digital output pin and use it to switch the MIC PTT to ground and activate the push to talk line.
- There is a simple voltage divider on the 1/8 audio out from the Raspberry Pi’s built-in soundcard to attenuate the audio before it goes into the MIC input line and keep from overloading and distorting the mic input.
- And there is just a 1k resistor inline with the 5V/0V squelch detection signal from the radio in order to protect the Raspberry Pi GPIO input pin from getting any excessive current. Normally you would want to use a 5v-to-3v logic level converter, or maybe at least a voltage divider when connecting a 5v device to the GPIO pins, but I measured only a few mA of current on this signal from the radio, and everyone says that the Pi seems to work fine with 5v incoming on its 3v logic inputs without much problem anyway.
After the physical circuit design comes the software work.
- For webcam snapshots: fswebcam – this is the utility that takes the snapshot from the webcam device and creates a jpg
- To encode the image into SSTV: I originally thought about doing digital SSTV but I ran into some problems. Its very much a new thing and the software out there not very reliable, and it also is very wide bandwidth and requires nearly crystal clear signals to work. And I found that the hardware driver for the Raspberry Pi on board broadcom soundcard introduces a bit of noise into the audio and this would causing problems with the digital signal. I decided to stick to old fashioned analog SSTV which are very robust in their transmissions. I chose the ROBOT36 image encoding because it only takes 36-seconds(hence the name) to transmit the image which is important since this will be taking over our club repeater every 15 minutes, and its the most popular encoding format used for automated systems such as the SSTV pictures from satellites, space probes etc. They even use ROBOT36 for the SSTV on the ISS, and it was used on the MIR space station. It’s not the best image quality SSTV encoding type, because its so fast, but its a good trade off between quality and speed which I put more importance on speed of transmission. For the source code, I found a decent robot36 encoding C program someone had written here: https://gist.github.com/anonymous/5723053/, that I downloaded and compiled on the Pi. This simply takes the image file, and turns it into a wav audio file with the SSTV signal that you can then playback and transmit.
- Controlling the Raspberry Pi GPIO digital input/output: There are libraries for nearly every popular programming language from C, Java, Perl, Python, Ruby, etc.. but I chose to just use a simple set of utilities that allow you to control the GPIO lines from the command line and in shell scripts which was perfect for the sort of cron job I wanted to write for this application. They are available here: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/
- Audio Files: The other thing I have is I generated several voice wav file recordings to play each time along with the image for announcements etc. You can generate these with the built in text to speech feature built into MacOS, or you can use one of the websites on the internet that can do this for you. I also have a 1200hz tone, that will start the beacon transmission, and I used a website to generate a wav file of a CW ident that is the last thing that gets transmitted.
Putting all of those things together and using them as the building blocks, I wrote a shell script that I will use to be called every 15 minutes from a cron job.
Here is the source of the shell script that runs the job. Its pretty self explanatory, and well commented. The last thing I added was the logic to “listen” to the radio for 10 seconds, and make sure it didn’t hear anything before it begins its transmissions. And if it does hear something, then wait 30 seconds and try again. Hopefully it will be a nice polite little automated beacon on our repeater and play nice with others.
Cron Job Shell Script Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
#!/bin/bash
#
# This is the cron job to do an SSTV beacon transmissions for W4CN Field Day 2013
#
# 06/2013 – Don Hoover WS4E
#
export SSTVDIR=/home/pi/SSTV
cd $SSTVDIR
# Set some variables
GPIO_PTT=6
GPIO_SQL=11
DEBUG=1
# Initalize the GPIO ports
/usr/local/bin/gpio mode $GPIO_PTT out
/usr/local/bin/gpio mode $GPIO_SQL in
####################################
### Do image capture from webcam ###
####################################
# capture image and save
/usr/bin/fswebcam –jpeg 95 –skip 2 -F 2 –deinterlace –banner-colour “#10263A93“ –shadow –title “W4CN“ –subtitle “ARTS Field Day“ –info “Cherokee Park“ –crop 320×240 -d /dev/video0 –save ${SSTVDIR}/webcam.jpg
# Run program to encode webcam.jpg to webcam.wav audio file
${SSTVDIR}/robot36
####################################
### Listen to the SQL Signal ###
####################################
# Listen to the sql signal line from the radio so
# we don’t transmit over top of anyone and be good neighbors
# on the repeater
OK_CONTINUE=0
TRY_COUNTER=1
MAX_TRIES=4
while [ $OK_CONTINUE == 0 ];
do
# Listen for 10 seconds
echo “Listening for 10 seconds Try=$TRY_COUNTER“
for i in {1..10}
do
SIGNAL_DETECTED=0
# Get the Squelch port status
SQL_STATUS=`/usr/local/bin/gpio read $GPIO_SQL`
echo “Squelch=$SQL_STATUS“
if [ $SQL_STATUS == 0 ]; then
echo “..Signal Detected“
SIGNAL_DETECTED=1
fi
sleep 1
if [ $SIGNAL_DETECTED == 1 ];then
echo “..Stop Listening Early“
break # exit listen for loop
fi
done
if [ $SIGNAL_DETECTED == 1 ]; then
echo “Signal Detected…sleeping for 30 seconds and then try again.“
sleep 30
if [ $TRY_COUNTER -gt $MAX_TRIES ]; then
“Reached Max Tries….aborting program“
exit
fi
TRY_COUNTER=$[TRY_COUNTER + 1]
else
echo “OK Nothing heard for 10 seconds…Continuing“
OK_CONTINUE=1
break # ok continue no need to try again, exit while loop
fi
done
###############################
### OK Now Transmit Beacon ###
###############################
# Reset output audio volume levels
# TODO
# PTT ON
/usr/local/bin/gpio write $GPIO_PTT 1
#
# Transmit beacon voice messages before the sstv image
#
/usr/bin/aplay ${SSTVDIR}/1200tone.wav
sleep .25
/usr/bin/aplay ${SSTVDIR}/this_is_the_w4cn_field_day_beacon.wav
sleep .25
/usr/bin/aplay ${SSTVDIR}/arts_club_field_day_is_at_cherokee_park.wav
sleep .25
/usr/bin/aplay ${SSTVDIR}/at_gps_coordinates.wav
sleep .25
/usr/bin/aplay ${SSTVDIR}/this_beacon_transmits_every_15_minutes_during_field_day.wav
sleep .25
/usr/bin/aplay ${SSTVDIR}/the_next_transmission_will_be_a_webcam_image_sent_via_sstv.wav
sleep .25
/usr/bin/aplay ${SSTVDIR}/visit_w4cn_dot_org_for_more_information.wav
sleep 1
#
# Transmit SSTV Image
#
/usr/bin/aplay ${SSTVDIR}/webcam.wav
# End with CW ident
sleep 1
/usr/bin/aplay ${SSTVDIR}/ws4e_cw.wav
sleep 1
############################
### Complete and Cleanup ###
############################
# PTT OFF
/usr/local/bin/gpio write $GPIO_PTT 0
/usr/local/bin/gpio write $GPIO_PTT 0
# Cleanup
rm -f ${SSTVDIR}/webcam.jpg
|
Wednesday, November 21, 2012
Well, I have officially joined the 43ft vertical club. The ubiquitous 43ft these days seems to be turning into the vertical antenna equipment of the G5RV.
Having a couple of days off, I finally got a chance to do the full install of this antenna, just in time for winter.
First I had to run a new coax line of RG-213 out to the back corner of the yard from the shack. I took the ‘shallow trench’ made with a spade approach which I have used in the past. I also am starting to like RG-213 more than LMR-400. The specs are nearly the same, but the RG-213 has a solid PE (looks like hard plastic) dielectric inside it, where the LMR-400 has foam. I think the RG-213 will actually hold up better long term outdoors and buried. I have concerns about LMR-400’s foam getting full of water seeping in the coax over long term. But, that being said I do have 2 runs of LMR400 already in the ground that have been there for about 4 years now with no problems. But if I ever have to replace them, I think will go with RG-213 next time for those as well.
After the coax was run, I decided I needed to upgrade my single point ground panel. I had used a pretty nice all aluminum NEMA box I got from a surplus site when we first moved into this house(see it in this previous blog post), it was kinda small inside being only 8×8 inches and it was going to be very full by the time I put a 3rd coax line and polyphaser through it. I had originally purchased some of the nice watertight cable feedthrough couplers from DX Engineering to use with my box, so I went to their website to look at ordering some more for this new cable run, but then I came across a new offering. They now offer their own nice weatherproof box, along with some of those coax feed through couplers, an aluminum panel for inside, and even a little copper bar to use in mounting copper strap like I have to the grounding panel. Pretty much everything you need to setup a single point ground box. AND, it was 13×14 so quite a bit bigger than the one I originally used. I decided to spend just a little more money and get the whole kit. Really, at $49.95 this is a very good price.