USB Control

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 sat.cfg file:

      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: singlepwmled and components.

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 Update() or Init() function this time.

The image is built and flashed to the board in the usual way:

    satdev flash

Once the image has been flashed, we can use the satdev tool to communicate with the Satellite.

The commands used in this video are:

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

The 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.

The 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.

< One-Minute LED Blinker
More Colours >
^ Overview ^

Garth is generally available for part-time, casual, and full-time appointments, ad-hoc, short-term or long-term. Click here for further information, or here for Garth's contact details.