WS-TTL-CAN

From Waveshare Wiki
Jump to: navigation, search
WS-TTL-CAN
WS-TTL-CAN.png

TTL TO CAN
CAN, TTL
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Introduction

WS-TTL-CAN is a TTL UART to CAN module which is compact and easy to integrate, onboard high-performance MCU, with TTL and CAN conversion protocol, easily achieving UART to CAN via simple configuration. The CAN parameters (such as the baud rate) and serial port parameters of the device can be modified using the configuration software.

Features

  • Support the bidirectional data communication between CAN and TTL.
  • Supports device firmware upgrade via TTL, more convenient for firmware update and function customization.
  • ESD Protection, Anti-surge Protection, Excellent EMC Performance.
  • 14 groups of configurable filters.
  • Four operation modes: transparent conversion, transparent conversion with identifiers, format conversion, and Modbus RTU protocol conversion.
  • Offline detection and automatic recovery functionality.
  • Compliance with CAN 2.0B specifications, compatible with CAN 2.0A; complies with ISO 11898-1/2/3 standards.
  • Baud rate range: 10kbps ~ 1000kbps.
  • CAN buffer capacity of 1000 frames to prevent data loss.
  • High-speed conversion:At a serial port baud rate of 115200 and CAN rate of 250kbps, the CAN sending speed can reach up to 1270 extended frames per second (close to the theoretical maximum of 1309).
    At a serial port baud rate of 460800 and CAN rate of 1000kbps, the CAN sending speed can exceed 5000 extended frames per second.

Parameters

Model TTL TO CAN Converter
Host Interface CAN
Device Interface TTL (RS485 direction control included)
CAN Baud Rate 10kbps~1000kbps
Direction Control Hardware Automatic Control
Resistor Default 120R
Interface pin CAN-H, CAN-L, GND
TTL Baud Rate 1200bps ~ 460800bps
Direction Control Hardware Automatic Control
Interface pin TXD, RXD, GND
Button Press 1s Reset the system
Press and hold 5s Restore to the factory default
Indicator RUN Running status indicator, blinks at 1-second intervals when it is normally operated
Usage Environment Temperature Range -40~85℃

Pinout

WS-TTL-CAN-Pinout-2.png

Dimensions

WS-TTL-CAN-Dimensions.png

Device Configuration

Use USB TO TTL (or other USB to TTL devices) for initialization configuration. If you do not want to configure it, keep the factory setting.

Hardware Connection

  • Connect the USB to TTL device (the following is for connecting USB TO TTL):
WS-TTL-CAN USB TO TTL
GND GND
RXD TXD
TXD RXD

Software Operation

  • Open SSCOM, view the used COM port, and COM42 is currently used for the demonstration:

RS232-485-422 to can03.png

RS232-485-422 to can04.png

  • Select the language:

RS232-485-422 to can05.png

  • Select the COM port that corresponds to the USB TO TTL, and then open the serial port:

RS232-485-422 to can06.png

  • Click on Read Device Parameters.

RS232-485-422 to can07.png

  • If you need to modify the device parameters, you can directly modify it and click on "Save Device Parameters", and then click on "Restart Device" (for example, modifying CAN ID):

RS232-485-422 to can08.png

Module Usage Explanation

Transparent Conversion

  • In this mode, the converter promptly sends the received data from one bus to the other bus.

Serial Frame To CAN

  • The entire data of a serial frame is sequentially filled into the data field of a CAN message frame. Upon receiving a frame of data from the serial bus, the converter promptly transmits it to the CAN bus. The converted CAN message frame information (frame type section) and frame ID are pre-configured by the user and remain unchanged throughout the conversion process.
  • The format of the data conversion is illustrated in the diagram below.

RS232-485-422 to can09.png

  • If the length of the received serial frame is less than or equal to 8 bytes, characters from 1 to n (where "n" is the length of the serial frame) are sequentially filled into positions 1 to n in the data field of the CAN message (as depicted in the illustration where "n" is 7).
  • If the number of bytes of the serial frame is greater than 8, the processor starts from the first character of the serial frame and fills the first set of 8 characters sequentially into the data field of the CAN message. After transmitting this data onto the CAN bus, it proceeds to convert the remaining serial frame data to fill the CAN message's data field until all the data has been converted.
  • For example, in the CAN parameter settings, if "Standard Frame" is chosen and the CAN ID is filled with 00000060, note that only the last 11 bits are valid for standard frames. The converted CAN data appears as follows:

RS232-485-422 to can10.png

CAN Frame To UART

  • For the CAN bus, it promptly sends a frame after receiving a frame.
  • When converting, all the data in the CAN message field is converted to the serial frame in order, and the corresponding data format is shown below:

CAN Frame To UART01.png

  • If during configuration, the "Convert CAN Message to Serial" option is enabled, the converter will directly fill the "Frame Information" byte(s) of the CAN message into the serial frame.
  • Similarly, if the "Convert CAN Frame ID to Serial" option is enabled, it will fill all the "Frame ID" byte(s) of the CAN message into the serial frame.
  • For instance, if "Convert CAN Message to Serial" is enabled but "Convert CAN Frame ID to Serial" is not, the CAN frame converted to serial appears as illustrated below:

CAN Frame To UART02.png

Transparent Conversion With ID

  • Transparent conversion with ID is a specialized use of transparent conversion that facilitates users in constructing their networks more conveniently and employing custom application protocols.
  • This method automatically converts the address information from a serial frame into the frame ID of the CAN bus. By informing the converter about the starting address and length of this address in the serial frame during configuration, the converter extracts this frame ID during conversion and fills it into the frame ID field of the CAN message. This serves as the ID of the CAN message when forwarding this serial frame. When converting a CAN message into a serial frame, the ID of the CAN message is also translated into the respective position within the serial frame. It's important to note that, in this conversion mode, the "CAN ID" setting in the "CAN Parameter Settings" of the configuration software is invalid. This is because, in this scenario, the transmitted identifier (frame ID) is populated from the data within the aforementioned serial frame.

UART to CAN

  • Upon receiving a complete serial data frame, the converter promptly forwards it to the CAN bus.
  • The CAN ID carried within the serial frame can be set within the configuration, specifying its starting address and length within the serial frame. The range for the starting address is from 0 to 7, while the length ranges from 1 to 2 for standard frames and 1 to 4 for extended frames.
  • During conversion, based on the pre-configured settings, all CAN frame IDs within the serial frame are entirely translated into the frame ID field of the CAN message. (If the number of frame IDs within the serial frame is fewer than the number of frame IDs within the CAN message, the filling sequence in the CAN messages is frames ID1 to ID4, with the remaining IDs filled with "0".) The rest of the data undergoes sequential conversion as shown in the diagram.
  • If a single CAN message frame does not complete the conversion of the serial frame data, the same ID continues to be used as the frame ID for the CAN message to convert until the entire serial frame has been completely converted.

CAN Frame To UART05.png
For example, the initial address of the CAN ID in the serial frame is 0, the length is 3 (in the extended frame), and the serial frame and the converted CAN message are as shown below. Note that the two frames of CAN messages are converted in the same ID.
CAN Frame To UART06.png

CAN Frame to UART

If the initial address of the configured CAN ID is 0 in the serial frame and a length of 3 (in the case of extended frames), the CAN message and the result of converting it to a serial frame are shown below:
CAN Frame To UART07.png

Format Conversion

  • This is the simplest mode of use and the data format is agreed to be 13 bytes, which contains all the information of the CAN frame.

Conversion Explanation

  • Data conversion format as shown below. Each CAN frame includes 13 bytes, and they include CAN information + ID + data.

RS232 Conversion Format01.png
RS232 Conversion Format02.png
RS232 Conversion Format03.png

Modbus Protocol Conversion

  • Convert the standard Modbus RTU serial data protocol to the specified CAN data format, and this conversion generally requires the editable CAN bus device message.
  • The serial data must be compliant with the standard Modbus RTU protocol, otherwise it can not be converted. Please note that CRC parity can not be converted to CAN.
  • The CAN formulates a simple and efficient segment communication format to realize Modbus RTU communication, which does not differentiate between host and slave, and users only need to communicate according to the standard Modbus RTU protocol.
  • The CAN does not require CRC checksum, and after the converter receives the last CAN frame, the CRC will be added automatically. Then, a standard Modbus RTU data packet is formed and sent to the serial port.
  • In this mode, the [CAN ID] of the [CAN Parameter Setting] of the configuration software is invalid, because the identifier (frame ID) sent at this time is filled by the address field (node ID) in the Modbus RTU serial frame.

Serial Frame Format (Modbus RTU)

  • Serial parameter: baud rate, data bits, stop bits, and parity bits can be set via configuration software.
  • The data protocol needs to conform to the standard Modbus RTU protocol.

CAN Frame Format

  • The CAN side designs a set of segment protocol formats, which defines a method for segmenting and reorganizing a message that is greater than 8 bytes in length, as shown below.
  • Note that when the CAN frame is a single frame, the segmentation flag bit is 0x00.

RS232 CAN Frame.png

  • The CAN frame message can be set by the configuration software (remote or data frame; standard or extended frame).
  • The transmitted Modbus protocol starts from “Data 2” byte, if the protocol content is more than 7 bits, and the rest of the protocol content is converted in this segmented format until the conversion is complete.
  • Data 1 is a segmentation control message (1 byte, 8bit), and the meaning is shown below:

Segmentation Mark
The segmentation mark occupies one bit (Bit7) and indicates whether the message is segmented or not. "0" indicates a separate message, and "1" indicates a frame in a segmented message.
Segmentation Type
The segmentation type occupies 2 Bits (Bit6, Bit5), and indicates the types of the message in this segment message.
RS232 CAN Frame02.png
Segmentation Counter
Occupies 5 bits (Bit4-Bit0), used to distinguish the serial number of segments in the same frame Modbus message, enough to verify whether the segments of the same frame are complete.

Conversion Example

  • The serial port side Modbus RTU data (in hex).
01 03 14 00 0A 00 00 00 00 00 14 00 00 00 00 00 17 00 2C 00 37 00 C8 4E 35
  • The first byte 01 is the Modbus RTU address code, converted to CAN ID.7-ID.0;
  • The last 2 bytes (4E 35) are Modbus RTU CRC checksums, which are discarded and not converted.
  • The final conversion to the CAN data message is as follows:
    Frame 1 CAN message: 81 03 14 00 0A 00 00 00 00
    Frame 2 CAN message: a2 00 00 14 00 00 00 00 00
    Frame 3 CAN message: a3 00 17 00 2C 00 37 00
    Frame 4 CAN message: c4 c8
  • The frame type (standard or extended frame) of the CAN message is set via the configuration software;
  • The first data of each CAN message is filled with segmented information (81, a2, a3, and c4), which is not converted into Modbus RTU frames, but only serves as acknowledgment control information for the message.

RS232 Conversion Example-2.png

  • The conversion principle of data from the CAN side to ModBus RTU is the same as the above, after the CAN side receives the above four messages, the converter will combine the received CAN messages into a frame of RTU data according to the CAN segmentation mechanism mentioned above, and add CRC checksum at the end.

RS232 Conversion Example-3.png

Verify Functions

TTL TO CAN Test

Use USB-CAN-A and USB TO TTL to demonstrate.

Hardware Connection

  • Connect to CAN device:
WS-TTL-CAN - CAN USB-CAN-A
CAN H CAN H
CAN L CAN L
  • Connect to TTL device:
WS-TTL-CAN - TTL USB TO TTL
GND GND
RXD TXD
TXD RXD

Software Operation

  • Open USB-CAN-A-TOOL.
  • Select the corresponding COM port of the USB-CAN-A, and click on "Open".

RS232 Software Operation-1.png

  • Select the baud rate of the CAN device as 250kbps, click on "Set and Start" , input the data to send, and select "Cycle".

RS232 Software Operation-2.png

  • Open an SSCOM, select the corresponding COM port of the USB TO 4CH Serial Converter's Port D, and open the serial port.

RS232 Software Operation-3.png

  • In the SSCOM software, check "Hexshow", "sendHex" and "Show Time and Package", input the data to be sent.
11 22 33 44 55 66 77 88

RS232 Software Operation-4.png

  • Select data in USB-CAN-A_TOOL, click on "Send selected frame".

RS232 Software Operation-5.png

  • And then you can see that it transmits and receives.

RS232 Software Operation-6.png

  • Or you can click on "Send every...ms/Time".

RS232 Software Operation-7.png

  • And then you can see that it transmits and receives.

RS232 Software Operation-6.png

Resource

Software

Document

FAQ

 Answer:
  • Please press and hold the reset button for more than 5 seconds until the indicator blinks continuously (factory restored), and then reconfigure the communication parameters as required.

{{{5}}}


 Answer:
  • Please note that the received data frame type. If the received data type is an extended frame, the frame ID is 0xFFFFFFFF & CAN_ID. If the received data type is a standard frame, the frame ID is 0x000007FF & CAN_ID, which is not related to the frame type configured by the software (in transparent conversion mode).
  • Use the one configured by the software as the frame type when sending data, as follows:

RS232 TO CAN FAQ02.png

{{{5}}}


 Answer:

Yes, the CAN interface is connected to a 120ohm resistor by default.

{{{5}}}


 Answer:

The DIR pin on the board serves the purpose of configuring the interface. When a customer needs to adjust the TTL interface to an RS485 interface (requiring RS485 chip support), they can use this pin. If the interface is not expanded to RS485, then leave this pin floating (unconnected).

{{{5}}}


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)