CAN, RS232 and RS485
The AT1000 features multiple industrial communication interfaces, including:
- 1 CAN bus
- 2 RS485 buses
- 2 RS232 buses
Multiplexing Considerations​
As decribed in the introduction Some interfaces share GPIOs, meaning only one can be enabled at a given time:
Additionally:
- RS232 and RS485 internally share the same UARTs ports, meaning that:
- You can enable
RS232_0
andRS485_1
together. - You can enable
RS232_1
andRS485_0
together. - You cannot enable
RS232_0
andRS485_0
at the same time. - You cannot enable
RS232_1
andRS485_1
at the same time.
- You can enable
Summary of Shared GPIOs and UARTs​
Interface | Shared GPIOs / UARTs | Notes |
---|---|---|
CAN Bus | Shares GPIOs with RS485_0 | Only one can be enabled at a time |
RS485_0 | Shares GPIOs with CAN Bus | Only one can be enabled at a time |
RS485_1 | Dedicated GPIOs (GPIO26 & GPIO27) | No conflict with other interfaces |
RS232_0 | Shares UART with RS485_0 | Cannot enable both at the same time |
RS232_1 | Shares UART with RS485_1 | Cannot enable both at the same time |
The following diagrams summarize the multiplexing of the GPIO pins with the communication interfaces:
In order to avoid any confusion, we recommend following this standard procedure when using an industrial communication port:
- Start by enabling the port
- Disable to port when done using it.
If there are any conflicts (e.g. enabling an interface before disabling another one that uses the same resources), an error will be raised during the enable()
phase, allowing you to easily detect and correct any conflicts.
CAN Bus API​
The CAN bus supports enabling/disabling, termination resistance, setting message acceptance filters, transmitting, and receiving data.
- NodeJS
- Python
const at1000 = require("at1000");
let devices = at1000.find_devices(5); // Find devices with a 5s timeout
let tester = devices[0]; // Target the first detected device
let can = tester.can(); // Access CAN bus on AT1000
// Enable CAN bus on AT1000
can.enable();
can.set_baudrate(500000); // Set baudrate to 500k
// Enable 100Ω differential termination resistor
can.set_term(true);
can.set_rx_filter(0xFF9F, 0x25A); // Set CAN receive filter (mask: 0xFF9F, filter: 0x25A)
// Start receiving CAN messages
can.start_rx(); // Updated to use the 'can' variable
// Transmit a CAN message
can.tx(0x123, [0x11, 0x22, 0x33, 0x44]);
// Receive messages (returns an array of objects containing ID & data)
let data_rx = can.rx();
// Print received messages
data_rx.forEach(msg => {
console.log(`CAN Message ID: ${msg.id}, Data: ${msg.data}`);
});
// Disable CAN bus on AT1000
can.disable();
import at1000
devices = at1000.find_devices(5) # Find devices with a 5s timeout
tester = devices[0] # Target the first detected device
can = tester.can() # Access CAN bus on AT1000
# Enable CAN bus on AT1000
can.enable()
can.set_baudrate(500000) # Set baudrate to 500k
# Enable 100Ω differential termination resistor
can.set_term(True)
can.set_rx_filter(0xFF9F, 0x25A) # Set CAN receive filter (mask: 0xFF9F, filter: 0x25A)
# Start receiving CAN messages
can.start_rx() # Updated to use the 'can' variable
# Transmit a CAN message
can.tx(0x123, [0x11, 0x22, 0x33, 0x44])
# Receive messages (returns an array of objects containing ID & data)
data_rx = can.rx()
# Print received messages
for msg in data_rx:
print(f"CAN Message ID: {msg['id']}, Data: {msg['data']}")
# Disable CAN bus on AT1000
can.disable()
RS485 Bus API​
The RS485 bus supports enabling/disabling, termination resistance, transmitting, and receiving data.
- NodeJS
- Python
const at1000 = require("at1000");
let devices = at1000.find_devices(5);
let tester = devices[0];
let rs485 = tester.rs485(1); // Access RS485_2 bus on AT1000
// Enable RS485_2 bus on
rs485.enable(true);
// Enable 100Ω differential termination resistor
rs485.enable_term(true);
// Start receiving RS485 messages
rs485.start_rx();
// Transmit a message over RS485
rs485.tx([0xDE, 0xAD, 0xBE, 0xEF]);
// Receive data (returns an array of bytes)
let data_rx = rs485.rx();
// Print received bytes
console.log("RS485 Data Received:", data_rx);
// Disable RS485_2 bus
rs485.disable();
import at1000
devices = at1000.find_devices(5) # Find devices with a 5s timeout
tester = devices[0] # Target the first detected device
rs485 = tester.rs485(1) # Access RS485_2 bus on AT1000
# Enable RS485_2 bus on AT1000
rs485.enable(True)
# Enable 100Ω differential termination resistor
rs485.enable_term(True)
# Start receiving RS485 messages
rs485.start_rx()
# Transmit a message over RS485
rs485.tx([0xDE, 0xAD, 0xBE, 0xEF])
# Receive data (returns an array of bytes)
data_rx = rs485.rx()
# Print received bytes
print(f"RS485 Data Received: {data_rx}")
# Disable RS485_2 bus
rs485.disable()
RS232 Bus API​
The RS232 bus operates similarly to RS485 (except it does not require termination resistors).
- NodeJS
- Python
const at1000 = require("at1000");
let tester = at1000.open();
let rs232 = tester.rs232(1); // Access RS232_1 bus on AT1000
// Enable RS232_1 on AT1000
rs232.enable();
// Start receiving RS232 messages
rs232.start_rx();
// Transmit a message over RS232
rs232.tx("Hello AT1000");
// Receive data (returns a string)
let data_rx = rs232.rx();
// Print received message
console.log("RS232 Data Received:", data_rx);
// Disable RS232_1 bus
rs232.disable();
import at1000
tester = at1000.open()
rs232 = tester.rs232(1) # Access RS232_1 bus on AT1000
# Enable RS232_1 on AT1000
rs232.enable()
# Start receiving RS232 messages
rs232.start_rx()
# Transmit a message over RS232
rs232.tx("Hello AT1000")
# Receive data (returns a string)
data_rx = rs232.rx()
# Print received message
print(f"RS232 Data Received: {data_rx}")
# Disable RS232_1 bus
rs232.disable()
Summary​
The AT1000 provides CAN bus, RS485 buses and RS232buses with advanced control features.
These interfaces allow flexible testing of communication ports with error handling for invalid configurations.