Arduino SV3

SV3 Library for the Arduino

This class is common to all SV3 devices. These devices share a common command set and it is presented in the following methods. The class can be used stand alone but it is normally incorporated into a specific device class. When incorporated in this way the methods here are available for use.

Methods Inherited from Bserial

baud(rate)
handshake(uint8_t rtsPin, uint8_t ctsPin)
flush()
putch(char c)
unsigned char puts(char *s)
unsigned char buffer()
char getch()

SV3(rxPin, txPin, baud_rate, address, ack)

The constructor provides a connection to BSerial, Baud rate and sets the address and ACK character. This will not initialise the device but it will associate the device with an address. The address can be found on the data sheet and is normally 'a', 'b' or 'c' by default.

Two or more devices can share the same bus and so if device A and device B were connected and thay had addresses 'a' and 'b' respectively then the following code would be used:

SV3 deviceA(5,4,9600,'a',6);
SV3 deviceB(5,4,9600,'b',6);

Although they are connected to the same serial bus each can now be identified by their address, so:

deviceA.id(); // get id of device A
deviceB.id();

the above would bring back the ID of the particular device. ACK is normally set to 6 and if left off will default to 6.

init()

Initialises the connected devices by sending 3 carriage returns. This will also set the Baud rate of the device to that of the host. For devices where the Baud rate has been fixed, there is no need for this initialisation.

active()

This will return 1 if the device is connected and working okay, it will only work when one device is connected, for further information about multiple devices see the data sheet in the multiple devices section.

getch_t()

Gets a character from the device with a time out, if there is a time out the function will return 0.

wack()

Wait for acknowledge. All commands will return an ACK character, unless changed the default is 6. This function (okay method) will wait for the ACK or time out. The time out takes about 300 to 500mS

read(char *buf)

Reads the serial input until either an ACK is received or a time out occurs. The characters are put in the buffer provided so it must be large enough to hold all of the characters.

id()

Returns the device ID as an integer, the ID is the number following the BV.

firmware(char *buf)

The firmware version is placed in the buffer as text, of if it is 2.07 then the returned value in the buffer will be "2.07"

reset()

Resets the device. it must be run again after this.

readEE(char from, char bytes, char *buffer)

Reads the EEPROM at the given 'from' address for the specified number of 'bytes' into a supplied 'buffer'. The result is a string with decimal numbers separated by comma; e.g. "0,44,201,77"

writeEE(char location, char value)

Writes 1 'value' to the EEPROM at the given 'location'.