Home


Last Modified: 31 October 2002

RS232 / CAN Port 
type 6393 V1.02

General Information


General

This 6393 DIN rail device can be used to monitor and control a CAN network 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.

Special CAN format messages are used to control the 6393 RS232 baud rate, CAN baud rate and filter settings via the RS232 interface. These messages use 2 of the reserved CAN identifiers; 2034  and 2035.


CAN message format

A CAN message (as seen by the user) exists of 4 fields:

  1. Identifier (ID, 11 bits). Allowed range 0 - 2031, reserve range 2032 - 2047
  2. Remote Transmission Request (RTR, 1 bit). Used by some applications to request a message
  3. Data Length (DL, 4 bits). Allowed range 0 - 15. Indicates the amount of following data bytes
  4. Data. 0 - 8 bytes with application dependent data

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.


RS232 message format

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

Although DL field can have a value from 0-15. Any value > 8 will be treated as 8.

When the RTR bit is high, no data is expected; the next received byte is interpreted as the first byte of the next CAN message....

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 6393 ignores the first byte when its value is 255 (all ones).
So sending 9 characters of all ones guaranties that the 6393 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 6393) can be used.
When inactive (< -5V) the 6393 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 6393 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 6393 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. The counter can be read with a special RS232 command.


Example

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

Special commands

To be able to configure the 6393 special commands are used.
These messages are using the same format as all others, 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 6393 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

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

Get CAN Bus Speed

1st byte 2nd byte 3rd byte
FEh 41h 03h

The 6393 replies with:

1st byte 2nd byte 3rd byte 4th byte 5th byte
FEh 43h 03h lsb msb

Set Filter

In order to get only the 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 6393:

1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte
FEh 65h Index 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 6393 replies with the echo of the command (so it can be verified...)

1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte
FEh 65h Index Data 0 Data 1 Data 2 Data 3

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.

The filter setting is used in further CAN communication.


Fill 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 ID filter

The 6393 replies with the echo of the command:

1st byte 2nd byte 3rd byte 4th byte
FEh 62h 64 Data

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.


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.

The 6393 replies with:

1st byte 2nd byte 3rd byte 4th byte 5th byte 6th byte 7th byte
FEh 65h Index Data 0 Data 1 Data 2 Data 3

Get Status

Read some internal status of the 6393:

1st byte 2nd byte 3rd byte
FEh 61h FFh

The 6393 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 256 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 6393) X
7 When nonzero, the 6393 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)
X
Lost Messages - The amount of CAN messages lost due to RS232 buffer overflow.
  • When more CAN messages are received then the internal (1024 byte) RS232 transmit buffer can handle, this counter is incremented and the CAN message is lost.
  • When the counter goes from 0 to 1 (1st lost message) this 5 byte reply message (event) will automatically be transmitted once by the 6393.
  • The counter value will stick to 255 if more messages are lost.
  • The counter is cleared when it was requested with the Get Status command
X

Start

Start receiving CAN messages.

1st byte 2nd byte 3rd byte
FEh 61h FDh

The 6393 replies with the echo of the command:

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 6393 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 6393 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 6293 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 6393 replies with the echo of the command:

1st byte 2nd byte 3rd byte
FEh 61h FBh

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 6393 replies with the echo of the command:

1st byte 2nd byte 3rd byte
FEh 61h FCh

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 6393 replies with the echo of the command:

1st byte 2nd byte 3rd byte
FEh 61h FAh

Re-programming can take up to 0.5 second. Node has to be re-started (at 9600 Baud RS232 speed) by a power cycle or a start command.


Factory defaults.

When a 6393 node 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
Filter setting CAN ID range 0 up to and including 2031 are enabled set set
Start at power on Enabled set set

How to get connected and how to use the commands

After power on the 6393 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:

  1. De-activate your RTS output (CTS input of 6393). This disables relaying CAN messages to the RS232 output.
  2. Initialize the RS232 PC port with your standard application communication speed (or 9600 Baud if the 6393 is still in its factory default)
  3. Send 9 characters FFh to the 6393 to be sure any pending message is flushed OR wait 10 seconds (when waiting 10 seconds it is guaranteed that no illegal CAN message will be send over the CAN bus)
  4. Send the Stop command (3 bytes FEh, 61h, FEh) to the 6393 and wait for the reply (same 3 bytes).
  5. When needed, initialize the RS232 speed, CAN speed, filter settings and Start at power on setting, activate the RTS output and send the Start command.

How to use the commands:


Compatibility

The 6393 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


Home