Description Usage Arguments Value Note Author(s) See Also Examples
Switch individual channels on or off in the USB interface card, or read its current state.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | gce8_port(port = getOption("gce8_port"), name)
gce8_name(port = gce8_port())
gce8_relays(names, port = gce8_port(), name = gce8_name(port))
gce8_list()
gce8_open(port = gce8_port(), name = gce8_name(port))
gce8_close(port = gce8_port(), name = gce8_name(port))
gce8_ready(port = gce8_port(), name = gce8_name(port))
gce8_cmd(relay, on = TRUE, port = gce8_port(), name = gce8_name(port))
gce8_get(port = gce8_port(), name = gce8_name(port))
gce8_set(state = FALSE, port = gce8_port(), name = gce8_name(port))
|
port |
The comm port to use (this is a virtual comm port using the FTDI virtual port driver available for Windows, Mac OS and Linux). If a number (x) is provided, the port is assumed to be 'comx', which is only a valid assuption under Windows. Use fully qualified name on Linux or Mac). |
name |
The name of the device. With |
names |
A vector of eight character strings to use to define the name of the eight relays. Missing data represent unused relays. |
relay |
The number, or name of the relay to switch. |
on |
Do we switch the relay on or off? Can be a boolean, 0/1 or "0"/"1". |
state |
The state of the relays. Can be a vector of eight items
(otherwise, recycling rule applies), either boolean, integers 0/1, or
anything that automatically coerces into boolean. Missing values are accepted
and they will match relay that are not modified. The vector can also be
named, and in this case, names will be match to the names used for the 8
relays: R1-R8, or anything else specified using |
Most functions return TRUE
in case of success and FALSE
or a
try-error
object in case of failure., except:
gce8_port()
and gce8_name()
return the port and name of a card,
gce8_list()
returns the list of currently connected cards,
gce8_relays()
returns a vector of eight character strings with the name of
the eight relays (dot . substituted for missing values)
gce8_get()
returns a named vector of eight booleans indicating the state
of the eight relays. Names are the current names of the relays, or the
default names R1-R8.
Functions gce8_cmd()
, gce8_get()
and gce8_set()
functions use a
mechanism to reconnect in case of lost connection. For instance, if the USB
cord is unplugged and plugged again, connection is lost, but these functions
can recover it. It only takes about 1 sec more to replug the card. If you
forgot to connect with gce8_open()
, these functions will do this
automatically for you. However, you should always use gce8_close()
once you
have done with the card, in order to free the comm port handle. This will
works too if the main power of the card in shut off and on again, but take
care that all relays do return in off state and your program is not
necessarily aware of that situation, unless you use gce8_get()
. For
critical applications, do prefer using gce8_set()
and always specify all
eight relays state instead of using gce8_cmd()
.
Those cards come from GCE Electronics.
Philippe Grosjean Philippe.Grosjean@umons.ac.be
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
# If the USB interface card is connected to com5, this should work:
options(gce8_port = 5)
# On the Mac, use: options(gce8_port = "/dev/cu.usbserial-A4003CDu")
gce8_open() # Note that this is facultative, since I connect on first use!
gce8_cmd(5, 1)
gce8_get()
gce8_set(FALSE)
gce8_close() # On the other hand, this is required to free the port!
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.