Antenna switching

From SatNOGS Wiki

Sometimes it is necessary / useful to be able to switch between different antennas. In this way the observations can take place on different bands, or it is useful to have only one feeder, with excellent performance in terms of attenuation, from the antennas to the receiver.

Read carefully the full thread in [ https://community.libre.space/t/antenna-switching-project/2311 ], where it's possible to find different solutions, ranging from "parallel" control exploited via GPIO pins, to "serial" solution via USB connection or via RS485 (under tests) for longer physical connections.

Several parts (software & hardware) are necessary to activate this kind of control. Once the type of control has been established there are some software setting to be done, mainly to write scripts which will be performed before and after the observations.

Firstly, run 'sudo satnogs-setup' , then into "Advanced" section edit the parameter SATNOGS_PRE_OBSERVATION_SCRIPT to <path_to_script>preob.sh -f {{ FREQ }}.

In the same manner in satnogs-setup set the parameter SATNOGS_POST_OBSERVATION_SCRIPT to <path_to_script>postob.sh

This, for example, is the content of preob.sh and postob.sh, invoked by the client to switch the correct antenna using an USB serial connection. Pay attention to the exact syntax and to the following described permissions on scripts and users:


  • preob.sh : called just before observation starts, set the right antenna and write to the local satnogs log.


#!/bin/bash
#set the ports up to known state and disable close between calls
stty -F /dev/ttyUSB0 9600 -hupcl

date=`date +"%d/%m/%y %H:%M:%S %Z"`
freq=0

while getopts f: option
do
case "${option}"
in
f) freq=${OPTARG};;
esac

if ([ $freq -ge 399900000 ] && [ $freq -lt 470000000 ]) ;
then
    echo "$date --> 399.9 to 470 frequency, ANT0 selected" >> /home/pi/tests/satnogs_log.txt
    echo -e "ANT0\n" > /dev/ttyUSB0
fi

if ([ $freq -ge 136000000 ] && [ $freq -lt 150100000 ]) ;
then
    echo "$date --> 136 to 150.1 frequency, ANT1 selected" >> /home/pi/tests/satnogs_log.txt
    echo -e "ANT1\n" > /dev/ttyUSB0
fi

if ([ $freq -ge 24000000 ] && [ $freq -lt 30000000 ]) ;
then
    echo "$date --> 24 to 30 frequency, ANT2 selected" >> /home/pi/tests/satnogs_log.txt
    echo -e "ANT2\n" > /dev/ttyUSB0
fi

done
  • postob.sh : called at observation end, puts RF relays in ‘deactivated’ position and to setup a know switch position.


#!/bin/bash
# disable all relays... no power waste!

date=`date +"%d/%m/%y %H:%M:%S %Z"`
echo -e "ANT0\n" > /dev/ttyUSB0
echo "$date antenna switch reset " >> /home/pi/tests/satnogs_log.txt


Please take note about the following mandatory permissions, because the scripts are executed as “satnogs” user:

  • sudo usermod -a -G dialout satnogs, to access serial device by satnogs user
  • sudo usermod -a -G pi satnogs, to permit execution to satnogs as member of pi group
  • touch satnogs_log.txt, to create the log file
  • chmod 666 satnogs_log.txt, to permit everybody writing on this file
  • chmod +x preob.sh, set script to be executable
  • chmod +x postob.sh, set script to be executable


To test the whole stuff try to execute:

./preob.sh -f 435000000

./postob.sh

tail ./satnogs_log.txt

and satnogs_log.txt should contain something like:

18/02/21 12:15:25 GMT --> 399.9 to 470 frequency, ANT0 selected
18/02/21 12:30:23 GMT antenna switch reset