USB Sabertooth Packet Serial Reference Manual

Similar documents
The Answer to the 14 Most Frequently Asked Modbus Questions

RS-485 Protocol Manual

Sample EHG CL and EHG SL10 16-bit Modbus RTU Packet

Kepware Technologies Optimizing KEPServerEX V5 Projects

Modbus and ION Technology

Building a Basic Communication Network using XBee DigiMesh. Keywords: XBee, Networking, Zigbee, Digimesh, Mesh, Python, Smart Home

Virtual Integrated Design Getting started with RS232 Hex Com Tool v6.0

Serial Communications

MANUAL FOR RX700 LR and NR

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Nemo 96HD/HD+ MODBUS

Master-Touch and ValuMass. Modbus Communications. INSTRUCTION MANUAL (Rev. 2.1)

DSX Master Communications

Web Site: Forums: forums.parallax.com Sales: Technical:

Process Control and Automation using Modbus Protocol

Consult protocol, Nissan Technical egroup, Issue 6

1.Eastron SDM220Modbus Smart Meter Modbus Protocol Implementation V1.0

B Robo Claw 2 Channel 5A Motor Controller Data Sheet

Technical Support Bulletin Nr.18 Modbus Tips

BLUETOOTH SERIAL PORT PROFILE. iwrap APPLICATION NOTE

Table 1 below is a complete list of MPTH commands with descriptions. Table 1 : MPTH Commands. Command Name Code Setting Value Description

SUDT AccessPort TM Advanced Terminal / Monitor / Debugger Version 1.37 User Manual

User Manual. AS-Interface Programmer

HOST Embedded System. SLAVE EasyMDB interface. Reference Manual EasyMDB RS232-TTL. 1 Introduction

Modbus and ION Technology

Weather Direct Displays show Lost Forecast (blank boxes in the picture icons)

Temp. & humidity Transmitter Instructions

ee-quipment.com ee203 RTCM USB Quick-Start Guide

EARTH PEOPLE TECHNOLOGY SERIAL GRAPH TOOL FOR THE ARDUINO UNO USER MANUAL

DAKTON µ BOX MANUAL µbox User Manual 1

Decimal Number (base 10) Binary Number (base 2)

NB3H5150 I2C Programming Guide. I2C/SMBus Custom Configuration Application Note

Work with Arduino Hardware

SMS Alarm Messenger. Setup Software Guide. SMSPro_Setup. Revision [Version 2.2]

Docklight V2.1 User Manual 08/2015. Copyright 2015 Flachmann und Heggelbacher GbR

PC Base Adapter Daughter Card UART GPIO. Figure 1. ToolStick Development Platform Block Diagram

BIT COMMANDER. Serial RS232 / RS485 to Ethernet Converter

Connecting UniOP to Telemecanique PLC s

Data Link Layer(1) Principal service: Transferring data from the network layer of the source machine to the one of the destination machine

MTS Master Custom Communications Protocol APPLICATION NOTES

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Bluetooth HID Profile

AN601 I2C 2.8 Communication Protocol. SM130 SM130 - Mini APPLICATION NOTE

Written examination in Computer Networks

USB / Data-Acquisition Module NOW LEAD-FREE

4511 MODBUS RTU. Configuration Manual. HART transparent driver. No. 9107MCM100(1328)

UDG1000 Hach PCX2200 Serial Port Input Driver configuration

RF Etch Monitor. Introduction

PRT3 Printer Module: ASCII Protocol Programming Instructions

MODBUS RTU compatible master and slave driver for High Performance Controllers

Driver Installation and Hyperterminal Operation of iload Digital USB Sensors

Using Xbee in Serial Communication

Omron I/O Driver (Series 2) Programmable Serial Interface Card

TruePort Windows 2000/Server 2003/XP User Guide Chapter

ENTTEC Pixie Driver API Specification

Computer Networks. Data Link Layer

TCP/IP MODULE CA-ETHR-A INSTALLATION MANUAL

Single channel data transceiver module WIZ2-434

Local Interconnect Network Training. Local Interconnect Network Training. Overview

8 data bits, least significant bit sent first 1 bit for even/odd parity (or no parity) 1 stop bit if parity is used; 1 or 2 bits if no parity

S4000TH HART. HART Communication Manual

Parallax Serial LCD 2 rows x 16 characters Non-backlit (#27976) 2 rows x 16 characters Backlit (#27977) 4 rows x 20 characters Backlit (#27979)

Speedlink software will run on Windows NT, Windows 7, and Windows 8; it will run on both 32 byte and 64 byte versions of Windows.

Bluetooth HC-06 with serial port module Easy guide

AN2680 Application note

Bidirectional wireless communication using EmbedRF

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

ROM Monitor. Entering the ROM Monitor APPENDIX

Application Note AN-00160

EZ-View Network Communications Guide

Hagenberg Linz Steyr Wels. API Application Programming Interface

RS485 & Modbus Protocol Guide

Modbus Communications for PanelView Terminals

How to setup a serial Bluetooth adapter Master Guide

Cart Interface Installation & Control Board Manual for M38 XP and RX Carts and Legacy M39 Carts

ESPA Nov 1984 PROPOSAL FOR SERIAL DATA INTERFACE FOR PAGING EQUIPMENT CONTENTS 1. INTRODUCTION 2. CHARACTER DESCRIPTION

RFID MODULE Mifare Reader / Writer SL031 User Manual Version 2.7 Nov 2012 StrongLink

Ethernet/IP Explicit Messaging Using Unity Software

To perform Ethernet setup and communication verification, first perform RS232 setup and communication verification:

SyRen 10 / SyRen 25 motor driver user s guide

Web'n'walk. Manager. for Windows USER MANUAL

RN-XV-RD2 Evaluation Board

AKD EtherNet/IP Communication

PRODUCT MANUAL SKX OPEN SKX ADVANCE ZN1RX-SKXOPEN. Edition 2 Version 1.1

KTA-223 Arduino Compatible Relay Controller

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

RS-232 Communications Using BobCAD-CAM. RS-232 Introduction

Step-by-Step Tutorial For Using LinkSprite UART- WIFI Module Model LS_UART_WIFI

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

COMPUTER BASED REMOTE CONTROL FOR LAYOUT OF SCALED MODEL TRAINS

Application Unit, MDRC AB/S 1.1, GH Q R0111

Lecture N -1- PHYS Microcontrollers

(Refer Slide Time: 00:01:16 min)

eztcp Technical Document Modbus/TCP of eztcp Caution: Specifications of this document may be changed without prior notice for improvement.

KD-204. Telephone Remote Switch. Operating Instructions

Web-Based Configuration Manual System Report. Table of Contents

A DIY Hardware Packet Sniffer

Prestige 623R-T. Quick Start Guide. ADSL Dual-link Router. Version 3.40

ACCESS 9340 and 9360 Meter Ethernet Communications Card ETHER

Transcription:

USB Sabertooth Packet Serial Reference Manual Copyright 2014 Dimension Engineering LLC

Table of Contents Plain Text or Packet Serial?... 3 Software Libraries... 4 Packet Format... 5 Example Code (Checksum)... 7 Example Code (CRC)... 8 Commands... 11 Set... 11 Get... 12 On the Web... 13 Revision History... 14 Index... 15 2

Plain Text or Packet Serial? USB-enabled Sabertooth motor drivers support two serial protocols, Plain Text Serial and Packet Serial: Plain Text Serial An extremely easy way to interact with the Sabertooth from a microcontroller or PC. For example, if you open up a terminal at 9600 baud (8-N-1), all of the following are valid commands you can type: M1: 0 M1: 2047 M1: -2047 M2: 500 M1: GET M1: GET B M1: GET C M1: GET T M1: SHUT DOWN M1: START UP Mixed mode (tank-style differential drive) is similarly easy with drive and turn: MD: 0 MT: 0 MT: 2047 Power outputs (P1 and P2, if configured as controllable outputs in DEScribe), freewheeling (Q1 and Q2), ramping (R1 and R2), and current limit (T1 and T2) can also be controlled. Plain Text Serial commands can, optionally, even be protected by a checksum. Sum the uppercase form of all non-space characters. Append a +, and then the hexidecimal form of the lower eight bits of the sum: M1:-2047+B2 If this interests you, see the manual's section on Plain Text Serial. Packet Serial Designed for high reliability even on noisy signal lines. Among Packet Serial's advantages, it uses checksums or optionally CRCs, its command packets are more compact, and it can share a S1 line with other SyRen and Sabertooth motor drivers as well as Kangaroo motion controllers running in Packet Serial mode. On the other hand, Packet Serial is more difficult than Plain Text Serial to implement correctly. If you decide to use Packet Serial, this documentation has all the necessary details. Alternatively, we've made libraries for several platforms. 3

Software Libraries We provide Packet Serial libraries for several platforms: Arduino http://www.dimensionengineering.com/arduino C#, VB.NET, and other.net Framework languages http://www.dimensionengineering.com/dotnet 4

Packet Format Packet Serial commands can be sent protected by either a checksum or a CRC: checksum - good for most applications - easier to implement - faster updates (uses one less byte per command than a CRC) CRC - good for safety-critical applications with noisier wiring - harder to implement - slower updates (uses one more byte per command than a checksum) - provides a Hamming distance of 4 Checksum-protected Packet Serial commands have the following format: Address (1 byte) The Sabertooth address. By default, this is 128. Address bytes have the high bit set. Command (1 byte) The command number. Value (1 byte) The command value. Checksum (1 byte) The low 7 bits of the sum of the address, command, and value bytes. Data (n bytes) Extra data the command needs, if any. Data Checksum (1 byte) The low 7 bits of the sum of the data bytes. If there is no extra data, you do not need to send this. See the Example Code (Checksum) section for sample implementations. CRC-protected Packet Serial commands have the following format: Address (1 byte) The Sabertooth address (by default, 128), plus 112. Adding 112 signifies that the command is CRC-protected. Command (1 byte) The command number. Value (1 byte) The command value. CRC (1 byte) See the Example Code (CRC) section. A 7-bit CRC computed from the address, command, and value bytes. The polynomial is 0x5B in Koopman notation. Data (n bytes) 5

Extra data the command needs, if any. Data CRC (2 bytes) See the Example Code (CRC) section. A 14-bit CRC computed from the data bytes. If there is no extra data, you do not need to send this. The lower 7 bits are written into the first byte, and the upper 7 bits into the second byte. The polynomial is 0x21E8 in Koopman notation. See the Example Code (CRC) section for sample implementations. 6

Example Code (Checksum) #include <stdint.h> /*! Writes a Packet Serial command into a buffer. \param address The address of the Sabertooth. By default, this is 128. \param command The command number. \param value The command value. \param data Extra data. \param length The number of bytes of extra data. \param buffer The buffer to write into. \return How many bytes were written. This always equals 5 + length, unless length is 0, in which case it equals 4. */ uint8_t writesabertoothcommand(uint8_t address, uint8_t command, uint8_t value, const uint8_t* data, uint8_t length, uint8_t* buffer) uint8_t i; uint8_t datachecksum; buffer[0] = address; buffer[1] = command; buffer[2] = value; buffer[3] = (address + command + value) & 127; if (length == 0) return 4; else datachecksum = 0; for (i = 0; i < length; i ++) buffer[4 + i] = data[i]; datachecksum += data[i]; buffer[4 + length] = datachecksum & 127; return 5 + length; /*! Writes a Set command into a buffer. \param address The address of the Sabertooth. By default, this is 128. \param settype 0 to set the value, 16 to send a keep-alive, 32 to set the shutdown state, or 64 to set the serial timeout. \param targettype 'M' for a motor output, 'P' for a power output, etc. \param targetnumber 1 or 2, or a Simplified Serial character like '1' or '2'. \param value The value to set to. \return How many bytes were written. This always equals 9. */ uint8_t writesabertoothsetcommand(uint8_t address, uint8_t settype, uint8_t targettype, uint8_t targetnumber, 7

uint8_t data[4]; data[2] = targettype; data[3] = targetnumber; int16_t value, uint8_t* buffer) if (value < 0) value = -value; data[0] = (uint8_t)((value >> 0) & 127); data[1] = (uint8_t)((value >> 7) & 127); return writesabertoothcommand(address, 40, settype + 1, data, 4, buffer); else data[0] = (uint8_t)((value >> 0) & 127); data[1] = (uint8_t)((value >> 7) & 127); return writesabertoothcommand(address, 40, settype, data, 4, buffer); Example Code (CRC) #include <stdint.h> /*! Computes a 7-bit CRC. \param data The data to compute the CRC of. \param length The length of the data. \return The CRC. */ uint8_t crc7(const uint8_t* data, uint8_t length) uint8_t crc = 0x7f; uint8_t i, bit; for (i = 0; i < length; i ++) crc ^= data[i]; for (bit = 0; bit < 8; bit ++) if (crc & 1) crc >>= 1; crc ^= 0x76; else crc >>= 1; return crc ^ 0x7f; /*! Computes a 14-bit CRC. \param data The data to compute the CRC of. \param length The length of the data. \return The CRC. */ uint16_t crc14(const uint8_t* data, uint8_t length) 8

uint16_t crc = 0x3fff; uint8_t i, bit; for (i = 0; i < length; i ++) crc ^= data[i]; for (bit = 0; bit < 8; bit ++) if (crc & 1) crc >>= 1; crc ^= 0x22f0; else crc >>= 1; return crc ^ 0x3fff; /*! Writes a CRC-protected Packet Serial command into a buffer. \param address The address of the Sabertooth. By default, this is 128. \param command The command number. \param value The command value. \param data Extra data. \param length The number of bytes of extra data. \param buffer The buffer to write into. \return How many bytes were written. This always equals 6 + length, unless length is 0, in which case it equals 4. */ uint8_t writecrcsabertoothcommand(uint8_t address, uint8_t command, uint8_t value, const uint8_t* data, uint8_t length, uint8_t* buffer) uint8_t i; uint16_t crc; buffer[0] = address + 112; buffer[1] = command; buffer[2] = value; buffer[3] = crc7(buffer, 3); if (length == 0) return 4; else for (i = 0; i < length; i ++) buffer[4 + i] = data[i]; crc = crc14(buffer + 4, length); buffer[4 + length] = (uint8_t)((crc >> 0) & 127); buffer[5 + length] = (uint8_t)((crc >> 7) & 127); return 6 + length; /*! Writes a CRC-protected Set command into a buffer. \param address The address of the Sabertooth. By default, this is 128. 9

\param settype 0 to set the value, 16 to send a keep-alive, 32 to set the shutdown state, or 64 to set the serial timeout. \param targettype 'M' for a motor output, 'P' for a power output, etc. \param targetnumber 1 or 2, or a Simplified Serial character like '1' or '2'. \param value The value to set to. \return How many bytes were written. This always equals 10. */ uint8_t writecrcsabertoothsetcommand(uint8_t address, uint8_t settype, uint8_t targettype, uint8_t targetnumber, int16_t value, uint8_t* buffer) uint8_t data[4]; data[2] = targettype; data[3] = targetnumber; if (value < 0) value = -value; data[0] = (uint8_t)((value >> 0) & 127); data[1] = (uint8_t)((value >> 7) & 127); return writecrcsabertoothcommand(address, 40, settype + 1, data, 4, buffer); else data[0] = (uint8_t)((value >> 0) & 127); data[1] = (uint8_t)((value >> 7) & 127); return writecrcsabertoothcommand(address, 40, settype, data, 4, buffer); 10

Commands USB Sabertooth Commands The USB-enabled Sabertooth command set exposes features such as 12-bit motor outputs, power outputs, control over freewheeling, motor current read-back, and User Mode variables. If you do not need these features, and want your code to be compatible with non-usb Sabertooth/SyRen motor drivers as well, you may want to use the legacy command set instead. Set Sets a value on the motor driver. Command The command number for Set is 40. Command Value The command value depends on what you are trying to set. The possibilities are: 0 - Value Sets the value. 16 - Keep-Alive A keep-alive will reset the serial timeout without taking any action. 32 - Shutdown A positive value shuts down the motor channel. A negative or zero value starts up the motor channel again. 64 - Timeout Sets the serial timeout, in milliseconds. A zero value uses the DEScribe setting. A negative value disables the serial timeout. If the value you are trying to set is negative, add 1 to this command value. Command Data The data for a Set is 4 bytes long: Value (2 bytes) The value to set the target to. The lower 7 bits are written into the first byte, and the upper 7 bits into the second byte. Target (2 bytes) The target. This can be a particular channel, such as M1, M2, MD (drive), MT (turn), P1, P2, Q1, Q2, R1, R2, T1, or T2. Alternatively, you can target all channels of a type: M*, P*, Q*, R*, or T*. M* does not include MD or MT. For the channel's number, if you use decimal 1 or 2, the channel will set regardless of Plain Text Serial address. If you use the character '1' or '2', the channel will set based on the motor driver's Plain Text Serial 11

Get address (settable via DEScribe). Gets a value on the motor driver. Command The command number for Get is 41. Command Value The command value depends on what you are trying to set. The possibilities are: 0 - Value Gets the value. 16 - Battery Gets the battery voltage, in tenths of a volt. 32 - Current Gets the motor current, in amps. 64 - Temperature Gets the temperature, in degrees Celsius. Command Data The data for a Get is 2 bytes long: Source (2 bytes) The source. This can be S1, S2, A1, A2, M1, M2, P1, or P2. For the channel's number, if you use decimal 1 or 2, the channel will get regardless of Plain Text Serial address. If you use the character '1' or '2', the channel will get based on the motor driver's Plain Text Serial address (settable via DEScribe). Reply The reply number is 73. Reply Value The reply value will match the command value, or the command value plus one if the value is negative. Reply Data The reply is 4 bytes long: Value (2 bytes) The value the source is set to. The lower 7 bits are in the first byte, and the upper 7 bits are in the second byte. Source (2 bytes) The source. 12

On the Web Click the following link to visit our main website: Dimension Engineering If you have questions, we can be reached via either of the following: Help Desk Contact Us Also, here are some software links you may find useful: DEScribe Libraries for Arduino Libraries for C# and.net 13

Revision History December 17, 2014: Fixed the CRC example code. December 9, 2014: Revised some of the copy. September 12, 2013: Initial public version of the Packet Serial Reference. 14

Index A Arduino 4, 13 B bit-packed numbers 5 C C# 4, 13 checksum 2, 3, 5, 7 CRC 2, 3, 5, 6, 8, 9, 10, 14 G Get command 12 L libraries 2, 3, 4, 13 P packet format 2, 5 Plain Text Serial 3, 11, 12 S Set command 7, 9 V VB.NET 4 15