** To provide serial communication between the server and the junction box a Launchpad board without chip is used. (So we are just using it as a USB-serial converter) [[File:2011-03-13 17.16.09.jpg|thumb|left|450px|sdfsdfsd]][[File:2011-03-13 19.36.21.jpg|thumb|right|450px|sdfsdf]]<br />

+

** To provide serial communication between the server and the junction box a Launchpad board without chip is used. (So we are just using it as a USB-serial converter) [[File:2011-03-13 17.16.09.jpg|thumb|left|450px|sdfsdfsd]][[File:2011-03-13 19.36.21.jpg|thumb|right|450px|sdfsdf]]<br style="clear: both" />

** An ATX PSU is used to provide the neccesary 12V DC to the junction box.

** An ATX PSU is used to provide the neccesary 12V DC to the junction box.

Revision as of 01:46, 12 July 2011

This installation, aka the small spacecontrol, is active, we are working on a second version, the big spacecontrol.

Software

Arduino

The Arduino is connected directly to relay board. The code on is is a simple state machine that decodes everything that comes in through the serial connection and set the relays accordingly. Format:

%(Relay-nuber)#(state)

For example the sending the following string to the Arduino sets relay 2 to ON:

%2#1

CGI

To allow remote control we use two different scripts that are stored in the servers cgi-bin folder. On Ubuntu 10.10 using Apache2 this folder is located at /usr/lib/cgi-bin. The applications must be made executable before the can be run. (chmod +x) To make sure the CGI scripts can access the serial port the user www-data needs to be added to the dialout group.

sudo usermod -a -G dialout www-data

Every time one of these scripts is executed the serial port is opened and the appropriate commend is send to the Arduino. To get these commands to work smoothly some delays and serial reads needed to be inserted. A lot of effort went into trail and error to find these delays. There is definitely room for improvement here. One idea is to make a daemon that continuously manages the serial connection.

To the play command work you also need to add user www-data to the group pulse-access.

sudo usermod -a -G pulse-access www-data

WWW

To make the CGI scripts accessible a webpage was made and stored in the folder /var/www/spacecontrol, it's reachable via http://spacecontrol.