The Satellite System is designed to make it easy to create device images that can be remotely controlled over a transport mechanism, such as USB.
A Satellite board is controlled through the use of Components. A Component is an individual controllable entity on the board. A Component could be a single button, a single output, or anything else that can sensibly accept commands and give replies. Components can be configured to accept and receive arbitrary blocks of data, meaning that they can be used to implement almost anything.
On the host side we use the Satellite library to communicate with the Satellite. We can connect to the Satellite, query its components, send commands to them, and receive data back from them. The library is C++-based and can be used to create applications that can talk to Satellite boards. Included is a tool exercising many of its functions (
sattool). The library also has Ruby bindings.
We will be using the Satellite System to create an image that we can use to remotely control the lights on the Chocolate board.
We begin with a simple
board chocolate 0.2 rascal +singlepwmled +components
Similarly to the LED blinker example we specify the board name, hardware version, and CPLD image in use. For this application however, we include two extra options:
The first option
singlepwmled indicates that we wish to expose the five RGB LEDs as a single PWM-controlled RGB LED. The MCU lines used will be PC0-2, which will be configured for PWM. During initialisation, the Rascal image will be instructed to use those lines to control the LEDs.
The second option,
components specifies that we should automatically create Components for the resources we have created with other options. In this case the option will create three
PWMOut components, each of which control the three PWM outputs PC0-2. In this setup, this provides indirect control of the LEDs via those components.
For this project, the
sat.cfg configuration file is enough. We do not need a
custom.cpp file or an
Init() function this time.
The image is built and flashed to the board in the usual way:
Once the image has been flashed, we can use the
satdev tool to communicate with the Satellite.
The commands used in this video are:
sattool -q -C -OA 0.1: Set all three outputs to 10% brightness.
sattool -q -C -O 0 0.002 -O 1 0.100 -O 2 0.002: Set the RED channel of all LEDs to 0.2%, green to 10%, and blue to 0.2%, producing a green colour.
sattool -q -C -O 0 0.020 -O 1 0.050 -O 2 0.200: Set the RED channel of all LEDs to 2%, green to 5%, and blue to 20%, producing a blue/cyan colour.
sattool -q -C -OAP 500: For each channel, in order, turns that channel on, and then off again.
- The Ruby command at the end sets the three outputs to random values from 1% to 11% in an endless loop with a small delay.
Alternatively we could use the Satellite Library to write our own application that controls the Components directly.
USB Control of Individual LEDs
Thus far we have been controlling the five RGB LEDs together as if they were a single LED. The RGB LEDs can also be controlled individually.
We will make a small change to our
sat.cfg file to allow this:
board chocolate 0.2 rascal +allpwmled +components
allpwmled option indicates that we wish to use fifteen individual PWM lines to control the five RGB LEDs. The specific lines used are either dedicated hardware PWM lines (PC0-3) or hardware-capable PWM lines (timer counter output lines). This allows us to individually control the three channels of each of the RGB LEDs.
components option is used again, although this time it will create fifteen
PWMOut components, once for each PWM output.
We can then use similar commands to control the individual LEDs.
The Ruby command at the end functions similarly to the previous example, except this time it changes an individual RGB LED each time, cycling around in a clockwise direction.