| Controlling a Solenoid Example Last Modified: 2008-02-07 | | |
| Acroname Robotics | PDF webpage version | ||
| Overview Devantech has created a relay control board that is capable of controlling up to 8 relays. This example demonstrates how a BrainStem GP 1.0 controller can communicate with the RLY08 across the I2C bus to trigger a relay. The source code and wiring configuration are designed so the solenoid is released when the relay is turned on. Circuit Schematic In the following schematic, a BrainStem GP 1.0 is connected to the Devantech RLY08 controller across the I2C bus. The BrainStem serves as the I2C master and has the appropriate pull-up resistors on the SDA and SCL lines. A solenoid was attached to relay number 5 of the RLY08, but could be attached to any open relay position. Embedded on the RLY08 board is a Schottky diode across the relay coil to protect the control IC. This simplifies the necessary wiring at the RLY08 terminals - the only wiring necessary is the solenoid to the appropriate screw terminals. In order to keep the solenoid pin locked into place while the relay is turned off, the source power was wired into the common (or C) screw terminal. Power is constantly applied to the solenoid while the relay is turned off by wiring one solenoid wire the the normally closed (NC) position and the other to ground. This releases the pin when the relay is turned on. An alternative configuration having power only applied when the relay is turned on can be accomplished by wiring the solenoid to the normally open (NO) screw terminal. ![]() Wiring diagram for interfacing the RLY08 to a BrainStem GP 1.0. Source Code - TEA Example This code uses the TEA language which is very similar to ANSI C. It is compiled using the BrainStem Console with the steep command. The code uses a TEA library written specifically for the RLY08 board, released in software published in April of 2007. The example is only a very simple illustration of triggering a relay on and off. The following code prints to the Console a message, turns all the relays off, waits a little bit, turns the desired relay on, waits a little longer, and turns the relay off before exiting the program. /* filename: rly.tea */
#include <aPrint.tea>
#include <aCore.tea>
#include <aRLY08.tea>
#define RLY08ADDR (char)0x70
#define RELAY 5
#define DELAY 10000
void main() {
// Output to the Console that we are running
aPrint_String("\n Running RLY test.\n");
// Make sure all relays are turned off
aRLY08_SetRelaysOff(RLY08ADDR);
// sleep for 1 second
aCore_Sleep(DELAY);
// Trigger the desired relay by turning it on
aRLY08_SetRelayOn(RLY08ADDR,RELAY);
// sleep for 5 seconds
aCore_Sleep(5*DELAY);
// Trigger the desired relay by turning it off
aRLY08_SetRelayOff(RLY08ADDR,RELAY);
// sleep for 1 second
aCore_Sleep(DELAY);
} // main
Revision History:
| |||
| voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy © Copyright 1994-2008 Acroname, Inc., Boulder, Colorado. All rights reserved. |