|
RS232 / CAN Port General Information
|
General
This RS232 / CAN port DIN rail device can be used to monitor and control a
CAN network
for 11 bits and 29 bits CAN ID's via its RS232 interface.
The
new device is ready to work on its factory defaults.
It receives CAN format messages on its RS232 input and sends these directly
to the CAN bus.
With its identifier filter, it checks CAN messages on the CAN
bus. Matching messages will be transmitted over the RS232 interface.
Specially formatted messages are used to control the RS232 baud rate, CAN baud rate and filter settings via the RS232 interface. These messages use 2 of the reserved (11 bit) CAN identifiers; 2034 and 2035.
From version 2.00 up, this RS232 / CAN port can handle standard and extended CAN frames (with 11 bit or 29 bit identifiers).
V2.01 automatically stops the application if the configuration is read or changed. In fact, the only commands that will not stop the application are 'Start' and 'Get status'
There is a command shortlist table for faster reference.
CAN message format
A CAN message (as seen by the user) exists of 4 fields:
When the RTR bit is high, the Data Length is (unmodified) ignored and no data bytes are sent with the message.
When the Data Length is greater then 8, it is treated as if it was 8.
This version of the RS232 / CAN port has 2 modes of operation.
Special commands given via the RS232 input of the device are used for configuration, status and control. These commands always use the standard mode RS232 message format, even when the device is put into extended mode.
Filter
The message ID filter works differently for standard (11 bits ID) or extended (29 bits ID) messages:
STANDARD MESSAGE:
EXTENDED MESSAGE
Standard mode RS232 message format (also used for commands to RS232 / CAN port)
The first 3 fields of the CAN message are packed in the first 2 bytes of the RS232 message:
| 1st byte | 2nd byte | ||
76543210 IIIIIIII |
765 III |
4 R |
3210 LLLL |
| ID | RTR | DL | |
Extended mode RS232 message format
The first 3 fields of the CAN message are packed in the first 3 or 5 bytes of the RS232 message:
Standard message, with 11 bits ID:
| 1st byte | 2nd byte | 3rd byte | ||
76543210 0000LLLL |
7 0 |
6 x |
543210 000III |
76543210 IIIIIIII |
| DL | SF | RTR | ID (msb first) | |
Extended message, with 29 bits ID:
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte | ||
76543210 0000LLLL |
7 1 |
6 x |
543210 0IIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
| DL | SF | RTR | ID (msb first) | |||
The SF field selects the standard 11 or extended 29 bits identifier.
Although DL field can have a value from 0-15. Any value > 8 will be treated as 8.
When the RTR bit is set to one, no data is expected; even if the DL field indicates that there is....
All RS232 messages are transmitted / received with 8 data and 1 stop
bit.
The Baud rate can be configured..
A ten second time-out is used when receiving RS232 messages (message is canceled when not completed within 10 seconds), this is quite long because our beloved Windows may sometimes be doing other things for a while.
To be able to synchronize a crashed application, the device ignores the first
byte when its value is 255 (all ones).
Sending 12 characters of all ones
guaranties that the device sees the first non 255 byte as a valid first byte.
To synchronize the RS232 stream to the PC, the hardware RTS output of the PC
(CTS input of the device) can be used.
When inactive (< -5V) the device
does not start transmitting a new message over the RS232, although it finishes
the message in progress.
When for some reason the CAN bus is so busy that the device cannot send CAN messages, it de-activates its RTS output (CTS input of the PC) to stop buffer overflow / lost messages (from PC to CAN). When this happens (RTS inactive) it is still possible to send the special RS232 / CAN port commands, by ignoring the handshake line.
When too many CAN messages are received (too many ID's enabled or messages are generated too fast), an internal messages lost counter is incremented. A special RS232 command is sent when this occurs for the first time. The counter can be read with a special RS232 command.
Example (standard mode)
We want to transmit a CAN message with CAN ID 1000, RTR = 0 and 3 data bytes (containing the ASCII characters 'CAN').
The first 2 bytes of the message have to be calculated: (ID * 32) + (RTR * 16) + DL. In our example this will be 32003, which is 7D03 hexadecimal.
5 bytes will have to be transmitted via the RS232 (all byte values are given hexadecimal).
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte |
| 7Dh | 03h | 41h | 43h | 4Eh |
Example (extended mode)
We want to transmit a CAN message with CAN ID 12345678h, RTR = 0 and 3 data bytes (containing the ASCII characters 'CAN').
8 bytes will have to be transmitted via the RS232 (all byte values are given hexadecimal).
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte | 6th byte | 7th byte | 8th byte |
| 03h | 92h | 34h | 56h | 78h | 41h | 43h | 4Eh |
Special commands
To be able to configure the RS232 / CAN port, special commands are
used.
These messages always are using the standard mode RS232 message format,
but using the reserved CAN ID's.
These messages will not be transmitted over
the CAN bus.
These messages are executed even when the RTS handshake output
of the device is inactive.
How to get connected can be found here.
Set RS232 Baud rate
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte |
| FEh | 43h | 01h | lsb | msb |
There is no reply to this message.
This command sets the RS232 speed that will be used in further RS232
communication
(the setting is stored in EEPROM, factory default is 9600
Baud).
| Allowed speed | lsb | msb |
| 1200 | B0h | 04h |
| 2400 | 60h | 09h |
| 4800 | C0h | 12h |
| 9600 | 80h | 25h |
| 19200 | 00h | 4Bh |
| 38400 | 00h | 96h |
When this command is given, the device is stopped, (see stop command).
NOTE: after this command a delay of at least 10 mS is needed before next command can be handled (internal RS232 initialisation).
Set CAN Bus Speed
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte |
| FEh | 43h | 03h | lsb | msb |
There is no reply to this message.
This command sets the CAN bus speed that will be used in further CAN
communication
(the setting is stored in EEPROM, factory default
is 50 kBaud).
| Allowed speed | lsb | msb |
| 10 kBAUD | 0Ah | 00h |
| 20 kBAUD | 14h | 00h |
| 50 kBAUD | 32h | 00h |
| 125 kBAUD | 7Dh | 00h |
| 250 kBAUD | FAh | 00h |
| 500 kBAUD | F4h | 01h |
| 1000 kBAUD | E8h | 03h |
When this command is given, the device is stopped, (see stop command)
Get CAN Bus Speed
| 1st byte | 2nd byte | 3rd byte |
| FEh | 41h | 03h |
The device replies with:
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte |
| FEh | 43h | 03h | lsb | msb |
Set standard Filter
In order to get only the (11 bit ID) CAN messages of interest, a CAN ID
filter table can be set up to enable the CAN messages to receive.
This CAN ID
filter table contains 1 bit for each CAN ID. The table is 256 bytes long (256 *
8 bits = 2048 ID's).
Setting up the table requires up to 64 messages to the device:
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte | 6th byte | 7th byte |
| FEh | 65h | Index 0 - 63 |
Data 0 | Data 1 | Data 2 | Data 3 |
Some ID to byte/bit position examples;
| ID | Index | Data # | Bit # |
| 000h | 0 | Data 0 | 0 |
| 007h | 0 | Data 0 | 7 |
| 01Fh | 0 | Data 3 | 7 |
| 020h | 1 | Data 0 | 0 |
| 03Fh | 1 | Data 3 | 7 |
| 7E0h | 63 | Data 0 | 0 |
| 7FFh | 63 | Data 3 | 7 |
The device replies with the echo of the command.
This table will be stored in EEPROM memory, factory default is all bits set.
This
storing is done in background, so the 64 setup messages can be sent without
delay.
When this command is given, the device is stopped, (see stop command)
Fill Standard Filter
In order to enable or disable all CAN ID's at once, the fill filter command fills the whole filter with the same value:
| 1st byte | 2nd byte | 3rd byte | 4th byte |
| FEh | 62h | 64 | Data |
The value of the data byte is copied into all 256 locations of the standard (11 bits) ID filter
The device replies with the echo of the command:
Directly after the fill filter command, the user can send one or more Set filter commands. This makes it possible to enable just one ID with only 2 messages (fill filter with all zeros, set filter with just one ID enabled at the desired index).
The table will be stored in EEPROM memory. This storing is done in background., so the fill / set messages can be sent without delay.
The filter setting is used in further CAN communication.
When this command is given, the device is stopped, (see stop command)
Set Extended Filter
In order to get only the CAN messages of interest, a CAN ID filter table is
set up to enable the CAN messages to receive.
Setting up the table requires
up to 64 messages to the device:
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte | 6th byte | 7th byte |
| FEh | 65h | Index 65 - 128 |
76543210 000IIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
The device replies with the echo of the command
This table will be stored in EEPROM memory
This storing is done in background, so the 64 setup messages can be sent
without delay.
The storing will start 100 mS after the last Set Filter
command is given.
The filter setting is used in further CAN communication.
When this command is given, the device is stopped, (see stop command)
Fill Extended Filter
When less then 64 ID's are to be programmed in the filter, the user should give a Fill Extended Filter command with Data set to 0xFF. Directly after the fill filter command, the user can send one or more Set extended filter commands. This makes it possible to enable just one ID with only 2 messages (fill filter with all 0xFF, set filter with just one ID enabled at the desired index).
| 1st byte | 2nd byte | 3rd byte | 4th byte |
| FEh | 62h | 129 | Data |
The value of the data byte is copied into all 256 locations of the ID filter
The device replies with the echo of the command:
Directly after the fill filter command, the user can send one or more Set filter commands. This makes it possible to enable just one ID with only 2 messages (fill filter with all zeros, set filter with just one ID enabled at the desired index).
The table will be stored in EEPROM memory. This storing is done in background., so the fill / set messages can be sent without delay.
The filter setting is used in further CAN communication.
When this command is given, the device is stopped, (see stop command)
Set message ID filters
This command sets up one of the three parameters for the extended CAN message mask filters.
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte | 6th byte | 7th byte | |
| FEh | 65h | ||||||
| 130 |
76543210 000MMMMM |
76543210 MMMMMMMM |
76543210 MMMMMMMM |
76543210 MMMMMMMM |
Extended ID mask | ||
| 131 |
76543210 000IIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
Extended ID compare | ||
| 132 |
76543210 000MMMMM |
76543210 MMMMMMMM |
76543210 MMMMMMMM |
76543210 MMMMMMMM |
Extended global ID mask |
These parameters will be stored in EEPROM memory
The device replies with the echo of the command.
When this command is given, the device is stopped, (see stop command)
Get Filter
The filter settings can be read with this command:
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | Index |
The index value must be in the range 0 - 63, 65-128, 130-132
The device replies with:
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte | 6th byte | 7th byte | |
| FEh | 65h | 0 - 63 | Data 0 | Data 1 | Data 2 | Data 3 | standard mode filter |
| 65 - 128 |
76543210 000IIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
extended mode filter | ||
| 130 |
76543210 000MMMMM |
76543210 MMMMMMMM |
76543210 MMMMMMMM |
76543210 MMMMMMMM |
Extended ID mask | ||
| 131 |
76543210 000IIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
76543210 IIIIIIII |
Extended ID compare | ||
| 132 |
76543210 000MMMMM |
76543210 MMMMMMMM |
76543210 00000MMM |
76543210 MMMMMMMM |
Extended global ID mask |
When this command is given, the device is stopped, (see stop command)
Get Status
Read some internal status of the device:
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FFh |
The device replies with:
| 1st byte | 2nd byte | 3rd byte | 4th byte | 5th byte |
| FEh | 63h | FFh | Status | Lost Messages |
| Parameter | bit | Description | Cleared by Stop Command |
| Status | 0 | When this bit is nonzero, internal EEPROM programming is (still) busy with
updating changed configuration. This does not interfere with normal operation
but power supply should not be removed during programming.
Programming the ID table can take up to 0.5 second. |
- |
| 1 | When this bit is nonzero, an internal EEPROM programming failure occurred, the node should be replaced. | - | |
| 2 | When this bit is nonzero, an EEPROM checksum error was detected at power on. This can occur when power supply was removed during programming. This error can be recovered by resending all settings settings | - | |
| 3 | When nonzero, the node's power supply is either too low (< 9V) or too high (> 36V) | - | |
| 4 | When nonzero, the node's ambient temperature is either too low (< -20°C) or too high (> 70°C) | - | |
| 5 | When nonzero, the node's RS232 separated supply does not function | - | |
| 6 | When nonzero, the RS232 receiver had a buffer overflow (PC did not react on RTS output of device) | yes | |
| 7 | When nonzero, the device is started and will send CAN messages over the
RS232 interface: 1 = Start command (or power on start) executed (Application LED permanent on) 0 = Stop command executed (Application LED flashes 4 times / stays off for 2 seconds) |
yes | |
| Lost Messages | - | The amount of CAN messages lost due to RS232 buffer overflow.
|
yes |
Start
Start receiving CAN messages.
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FDh |
The device replies with the echo of the command. This can take up to 5 seconds when internal EEPROM programming is still busy (just after the filters are updated)
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FDh |
Only after this command is given or the start at power on configuration is set, the device will relay CAN messages to its RS232 output.
Stop
Stop receiving CAN messages, clear all RS232 message buffers, some status bits and the Lost Messages counter.
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FEh |
The device replies with the echo of the command:
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FEh |
RS232 speed, CAN speed, filter settings and EEPROM programming is not affected by this command. EEPROM checksum is re-checked.
Start at power on
This command sets an internal EEPROM bit, when this bit is set, the device will start relaying CAN message after power on (no start command needed). This is the factory default.
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FBh |
The device replies with the echo of the command:
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FBh |
When this command is given, the device is stopped, (see stop command)
No Start at power on
This command clears an internal EEPROM bit, when this bit is clear, the 6293 will NOT start relaying CAN message after power on (no start command needed).
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FCh |
The device replies with the echo of the command:
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FCh |
When this command is given, the device is stopped, (see stop command)
Reset defaults
This command executes a stop command, then re-programs the EEPROM to some of the factory defaults.
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FAh |
The device replies with the echo of the command, after the re-programming is finished (can take up to 5 seconds).
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | FAh |
Node has to be re-started (at 9600 Baud RS232 speed) by a power cycle or a start command.
When this command is given, the device is stopped, (see stop command)
Activate extended mode
This command sets an internal EEPROM bit, when this bit is set, the 6293 will work in extended mode: the RS232 message format and the filter are different. The factory default is no extended mode
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | F8h |
The device replies with the echo of the command. The filter may have to be setup after this command
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | F8h |
When this command is given, the device is stopped, (see stop command)
Activate standard mode
This command clears an internal EEPROM bit, when this bit is set, the 6293 will work in standard mode: the RS232 message format and the filter are different. This is the factory default
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | F9h |
The device replies with the echo of the command, and then switches to extended mode.
| 1st byte | 2nd byte | 3rd byte |
| FEh | 61h | F9h |
When this command is given, the device is stopped, (see stop command)
When a RS232 / CAN port is new, or after the 'reset defaults' command, some or all of the following settings are stored in EEPROM:
| Setting | Value | New node | Reset defaults command |
| Node ID | last 2 digits of serial number | set | no change |
| CAN bus speed | 50 kBaud | set | no change |
| RS232 speed | 9600 Baud | set | set |
| Standard Filter setting | CAN ID range 0 up to and including 2031 are enabled | set | set |
| Start at power on | Enabled | set | set |
| Extended mode | Disabled | set | set |
| Extended Filter setting | All entries are cleared | set | set |
| Extended Global Mask | 01FFFFFFFh | set | set |
| Extended ID Mask | 0 | set | set |
| Extended ID Compare | 0 (enabling all extended CAN message ID's) | set | set |
How to get connected and how to use the commands
After power on the device is initialized according to the EEPROM settings for the RS232 speed, the CAN speed, the filter settings and the Start at power on bit.
How to get connected:
How to use the commands:
Send the complete filter setting by sending 64 messages to the device
Compatibility
The device can be used by CFG6000/WIN6000 as CAN interface, the same way the 6390/6392 work (using the 6390/6392 interface mode, see AN002).
| Connections
|
RS232 PC
3 RXD -> 2 TXD -> 5 GND -> 8 RTS -> 7 CTS -> |
RS232 6393
2 TXD 3 RXD 5 GND 7 CTS 8 RTS |
||||||||||||||||||||
|
||||||||||||||||||||||
| Diagram
|
||||||||||||||||||||||