T-Series/Commands/Set Device Mode/T-Joy

From ZaberWiki
Jump to navigation Jump to search

Warning: This is an "include" page. As such, its contents may be included in multiple other pages. To see a list of all pages that include this page, click on "What links here" in the bottom left navbar. If you make changes to this page, be sure that your changes are appropriate to all pages on which this content will be included. You are also encouraged to review our Zaber Wiki Editing Guidelines. This header will not be included in other pages.

Instruction Name Set Device Mode
Applies to T-JOY3
Firmware Version 5.xx since 5.04
Command Number 40
Command Type Setting
Command Data Mode
Reply Data Mode
Safe to retry? Yes
Returns Current Position? No
Persistence Non-Volatile
Summary Sets the Mode for the given device.

This command allows setting several options. Each option is controlled by a single bit within the command data. Most software you will encounter, including most of our demo software, represents all 4 data bytes as a single decimal value rather than specifying each bit individually. To determine what decimal value to use requires a basic understanding of how the data is represented in binary. The command data may be considered as a single 32-bit binary value. The least significant bit is bit_0, the next is bit_1, the next is bit_2, and so on up to the most significant bit_31. Each bit may have a value of either 1 or 0.

The corresponding decimal representation of this 32-bit data is given by:

Decimal value = (bit_0 * 1) + (bit_1 * 2) + ... + (bit_n * 2n) + ... + (bit_31 * 2^31)

Each bit controls a single mode option as described in the table below. To determine the data value to use with the Set Device Mode command, simply determine the desired value of each bit (1 or 0), and calculate the decimal value using the above formula. Note that not all 32 bits are currently used. Any unused or reserved bits should be left as 0.

For example, suppose you want all mode bits to be 0 except for bit_0 (disable autoreply), bit_14 (disable power LED), and bit_15 (disable serial LED). The Set Device Mode instruction should be sent with data calculated as follows:

Command Data
= 2^20 + 2^214 + 2^215
= 1 + 16384 + 32768
= 49153

Note that each instance of the Set Device Mode command overwrites ALL previous mode bits. Repeated commands do not have a cumulative effect. For example, suppose you send a Set Device Mode command with data of 1 to disable auto-replies. If you then send another Set Device Mode command with data of 16384 to disable the power LED, you will re-enable auto-replies since bit_0 in the 2nd instruction is 0.

The T-JOY has a default mode setting of 0 (all bits are 0).

Bit_n 2^n Description
bit_0 1 Disable Auto-reply
A value of 1 disables ALL replies except those to “echo”, “read”, “renumber”, and “return” commands. The default value is 0 on all devices.
bit_1 2 Reserved
bit_2 4 Reserved
bit_3 8 Reserved
bit_4 16 Reserved
bit_5 32 Reserved
bit_6 64 Enable Message IDs
A value of 1 enables Message IDs. In this mode of communication, only bytes 3 through 5 are used for data. Byte 6 is used as an ID byte that the user can set to any value they wish. It will be returned unchanged in the reply. Message IDs allow the users application to monitor communication packets individually to implement error detection and recovery. The default value is 0 on all devices. Prior to firmware version 5.06, this feature was called "Virtual Channels Mode" and did not behave reliably. We do not recommend enabling this mode of communications unless you have firmware version 5.06 or later.
bit_7 128 Reserved
bit_8 256 Reserved
bit_9 512 Reserved
bit_10 1,024 Reserved
bit_11 2,048 Reserved
bit_12 4,096 Reserved
bit_13 8,192 Reserved
bit_14 16,384 Disable Power LED
A value of 1 turns off the green power LED. It will still blink briefly, immediately after powerup.
bit_15 32,768 Disable Serial LED
A value of 1 turns off the yellow serial LED.