Code for controlling the tracking antenna. (Currently an arduino mega)
An arduino controls 2 servos for plane tracking (pan and tilt). Communication from the xbee if achieved with an ethernet shield. There is a simple debug interface through serial.
Libaries
- MatrixMath
- Adafruit_Sensor
- Servo
- SPI
- Ethernet
- Adafruit LSM303DLHC
Installation
- Install the Arduino development environment
- Install the following libraries using the Arduino Library Repository
- Servo
- SPI
- Ethernet
- Adafruit LSM303DLHC
- Install the following libraries by downloading and including the files:
- Matrix Math
- Adafruit Sensor
Connecting to the Network
- Plug in router and connect Arduino Ethernet Shield to ethernet port on router. (If using the wired router, also connect the computer otherwise the WIFI network should work).
- ENSURE YOU ARE CONNECTED TO THE CORRECT NETWORK.
- Using data-relay-station navigate to the install directory of the data-relay-station and launch a terminal or CMD window.
- Type
py data_relay.py
to start the data-relay-station. Alternatively, use simulation file by typingpy data_relay.py --simfile <filename.csv>
- Determine the IP Address of the router. You can do this by typing
ipconfig /all
in a CMD window (on windows). - Choose an IP address for the Arduino. It must be within the valid subnet. Typically, the first few numbers of the IP address are shared with the router. If it isn't, you may be doing something wrong. Replace the line
IPAddress ip(192,168,1,107); //this is for the arduino
with the correct address. Note, this may be changed in the future, where the arduino will self-initialize its IP address. - Determine the IP address of the computer. Once again, you can do this by typing
ipconfig /all
in a CMD window. Replace the IP address in the lineIPAddress server(192,168,1,103); //pi or computer that is hosting the data
. This once again may be dynamically allocated in the future, using a data-relay-station broadcasting feature. - You can detect a succesful connection by opening up the Arduino serial monitor, or by checking the data-relay-station terminal output for a familiar IP address.
A successful data-relay-station connection may look as such:
Quick setup guide:
- Set INITIALISATION to 0.
- Be careful when the code uploads as the antenna may swing unpredictably.
- Turn the base of the antenna to point eastish
- At this point you can verify the antenna is recieving telemetry data. set DEBUG to 1 and open arduino serial monitor
- Hold the plane next to the antenna, and update the INITIAL_LATTITUDE, INITAL_LONGITUDE, INITIAL_ALTITUDE.
- Set INITIALISATION TO 1. again be careful about the unpredictabe swing.
- Put the plane on the runway, some distance away from the antenna is needed for fine tunning the angle.
- Rotate the base of the antenna until it point at the plane. it should already have been decently close.
- Check the altitude (tilt) seems correct.
- Check there are no wire to snag as it rotates.