Dev.to · 10 min read

How to Use the SH-C30L USB-to-CAN Adapter with Arduino UNO and MCP2515

How to Use the SH-C30L USB-to-CAN Adapter with Arduino UNO and MCP2515

Controller Area Network (CAN) is one of those technologies that quietly powers a huge number of embedded systems. It is commonly found in cars, EVs, industrial controllers, robotics, and other distributed systems where multiple devices need to exchange data reliably over a shared bus. For development and debugging, it is useful to connect that CAN network to a computer. The problem is that a standard computer communicates through USB, while CAN uses a dedicated differential bus. A USB-to-CAN interface solves this problem by translating between the two. In this project, we will explore the DSD TECH SH-C30L USB-to-CAN adapter, learn how its different firmware modes work, connect it to a PC, and then use an Arduino UNO with an MCP2515 CAN module to create a simple bidirectional CAN communication setup. The goal is not just to make the hardware work, but also to understand what happens between the Arduino, CAN bus, USB adapter, and computer. SH-C30L USB-to-CAN Adapter Overview The SH-C30L is a compact USB-to-CAN interface designed to connect a computer directly to a CAN network. It is based on an STM32F072C8T6 microcontroller, which contains an integrated CAN controller. This allows the adapter to handle CAN protocol processing without requiring a separate external CAN controller. The microcontroller communicates with the computer through USB, while a dedicated CAN transceiver handles the physical CAN interface. The transceiver converts the controller's logic-level signals into the differential CAN_H and CAN_L signals used on a CAN network. One of the interesting aspects of the SH-C30L is its firmware flexibility. The adapter can work with Candlelight firmware, which allows it to operate with Linux SocketCAN and compatible CAN applications, or with SLCAN firmware, where it behaves more like a serial CAN interface. This makes the same hardware useful with different operating systems and software environments. The adapter supports both CAN 2.0A and CAN 2.0B frames, with CAN speeds of up to 1 Mbps. It also includes a switchable 120Ω termination resistor and a boot switch for entering firmware-update mode. For a small development setup, these features make the SH-C30L a useful alternative to more expensive professional CAN interfaces. Why Do We Need a Driver? When you plug a USB-to-CAN adapter into a computer, the operating system needs to know how to communicate with the device. On modern Windows systems, the SH-C30L can generally be detected using the operating system's built-in USB support, depending on the firmware installed. Linux provides even stronger native CAN support through SocketCAN. If the adapter appears as an unknown USB device, a driver may need to be installed manually. Therefore, the first troubleshooting step should always be checking Device Manager on Windows or the relevant USB/CAN interfaces on Linux. Software You Can Use The software required depends on the firmware and operating system. On Linux, SocketCAN is particularly useful. The can-utils package provides utilities such as: candump for monitoring CAN traffic cansend for transmitting CAN frames cansniffer for observing changing CAN data canbusload for checking bus utilization On Windows, Cangaroo provides a graphical interface for monitoring and transmitting CAN messages. It can also work with DBC files for decoding signals. For custom applications, Python is another useful option. The python-can library provides an interface for sending and receiving CAN messages from Python programs. Using the SH-C30L with Linux and SocketCAN Linux is particularly convenient for CAN development because CAN support is integrated into the operating system through SocketCAN. When the SH-C30L is running Candlelight firmware, it can appear as a native CAN interface such as can0. With SLCAN firmware, the setup is slightly different because the adapter is exposed through a serial interface and tools such as slcand can be used to create a CAN network interface. Using the SH-C30L with Python Python is useful when CAN communication needs to become part of a larger application. Instead of manually watching frames in a CAN analyzer, you can write a program that records messages, checks specific CAN IDs, generates test traffic, or communicates with another application. The connection method depends on the firmware. A Candlelight-based setup can use a SocketCAN interface such as can0, while an SLCAN configuration may use a serial port. Windows Testing with Cangaroo Windows users can use Cangaroo to verify that the SH-C30L is communicating correctly. Start by connecting the adapter to the PC and opening Device Manager. With the factory Candlelight firmware, the adapter may appear as a CANable/gs_usb-type device. Next, launch Cangaroo and open its measurement setup. If the adapter is detected correctly, the available CAN interface should appear in the interface list. Select the detected interface and configure the CAN bitrate to match the network. For example, if the CAN network operates at 500 kbps, the software must also be configured for 500 kbps. Once the interface is active and another CAN node is transmitting, frames should begin appearing in the monitoring window. This is a simple way to verify the adapter before connecting it to a more complicated embedded system. MCP2515 CAN Module Overview The Arduino UNO is a popular development board, but it does not include a native CAN controller. To add CAN functionality, an external CAN controller and transceiver are required. The commonly available MCP2515 CAN module solves this problem by combining an MCP2515 CAN controller with a CAN transceiver, often a TJA1050 on typical modules. MCP2515 CAN Controller The MCP2515 handles the CAN protocol itself. It communicates with the Arduino through the SPI bus and takes care of CAN frame transmission and reception. It supports standard 11-bit identifiers as well as extended 29-bit identifiers and provides hardware filtering and masking features. These functions are useful when a CAN network contains many different message IDs but the Arduino only needs to process a small subset. The MCP2515 also has an interrupt output. When a relevant CAN event occurs, the INT pin can notify the Arduino so that the microcontroller does not have to continuously poll the controller. TJA1050 CAN Transceiver The MCP2515 cannot directly drive the CAN_H and CAN_L lines. The TJA1050 transceiver handles this physical-layer conversion. It converts the digital CAN signals from the MCP2515 into the differential signals used on the CAN bus and converts incoming CAN bus signals back into logic-level signals for the controller. In simple terms: MCP2515 = CAN protocol controller TJA1050 = CAN physical-layer transceiver Together, they provide the Arduino with a practical CAN interface. 120Ω Termination CAN networks normally require termination resistors at both physical ends of the bus. Many MCP2515 modules include a 120Ω resistor that can be enabled or disabled with a jumper. Whether you should enable it depends on where the module is located in the CAN network. If the MCP2515 is one end of the bus, its termination can be enabled. If it is a middle node, the termination should normally be disabled. The SH-C30L also has a switchable 120Ω termination resistor, which makes it convenient to create a correctly terminated two-node test network. Crystal Oscillator The MCP2515 requires a clock reference for CAN timing. Common breakout boards use either an 8 MHz or 16 MHz oscillator. This is important when configuring the Arduino library. The oscillator frequency defined in the software must match the actual MCP2515 module. Using the wrong oscillator setting can result in CAN initialization or communication problems even when the wiring is correct. Interfacing Arduino UNO with MCP2515 The MCP2515 communicates with the Arduino UNO using SPI. For a typical UNO setup, connect: MCP2515 Arduino UNO VCC 5V GND GND CS D10 MOSI D11 MISO D12 SCK D13 INT Optional interrupt pin The CS pin can be changed in software, but the SPI data pins are normally connected to the UNO's hardware SPI pins. After connecting the SPI interface, the Arduino can configure the MCP2515 and exchange CAN frames through it. Connecting the MCP2515 to the SH-C30L The second part of the setup is the CAN bus connection. Connect: MCP2515 SH-C30L CAN_H CAN_H CAN_L CAN_L GND GND The CAN_H and CAN_L lines must not be swapped. A common ground is also recommended for this non-isolated setup. If the MCP2515 and SH-C30L are the two endpoints of the test bus, enable the 120Ω termination on both devices. With two 120Ω resistors in parallel, the measured resistance between CAN_H and CAN_L should be approximately 60Ω when the system is powered off. How the Complete System Works Once everything is connected, the communication path looks like this: Arduino UNO │ │ SPI ▼ MCP2515 │ │ CAN_H / CAN_L ▼ SH-C30L │ │ USB ▼ PC / Laptop When the Arduino sends data, it first transfers the information to the MCP2515 through SPI. The MCP2515 packages the information into a CAN frame and passes it to the CAN transceiver. The transceiver places the differential signal onto CAN_H and CAN_L. The SH-C30L receives that CAN frame, converts it into a USB-compatible representation, and forwards it to the computer. The process also works in the opposite direction. A CAN frame generated by the PC is sent through USB to the SH-C30L. The adapter places it on the CAN bus, where the MCP2515 receives it. The Arduino can then read the frame through SPI and process the information in its program. This gives us a simple bidirectional CAN communication link between Arduino and a computer. CAN Termination: Don't Skip This Termination is one of the first things to check when a CAN network does not behave as expected. For this two-node test setup, the MCP2515 and SH-C30L represent the two ends of the bus. Therefore, both ends should have 120Ω termination enabled. With power removed, measuring between CAN_H and CAN_L should give approximately 60Ω because: 120Ω || 120Ω ≈ 60Ω If you measure approximately 120Ω, only one termination resistor is active. If the measurement is significantly different, check the wiring and termination configuration. Troubleshooting Tips If no CAN messages are appearing, check the basics before changing the software configuration. Confirm that CAN_H is connected to CAN_H and CAN_L to CAN_L. Make sure all devices use the same CAN bitrate. Check whether the MCP2515 module uses an 8 MHz or 16 MHz oscillator. Verify that the correct MCP2515 CS pin is defined in your Arduino code. Check the termination resistors. Confirm that the SH-C30L is detected by the operating system. Make sure the selected firmware matches the software interface you are using. Use a common ground between the Arduino-side CAN hardware and the SH-C30L. CAN troubleshooting becomes much easier when you verify one layer at a time: first USB detection, then CAN adapter configuration, then CAN bus signaling, and finally Arduino communication. Where This Setup Can Be Used This setup is useful for experimenting with: Automotive CAN communication ECU development and diagnostics EV and battery-system communication Industrial controllers Robotics CAN-based sensor networks Embedded-system testing CAN protocol learning It is particularly useful for students and hobbyists because it provides a practical way to observe how CAN communication moves between an embedded controller and a computer. Conclusion The SH-C30L provides a convenient bridge between a computer and a CAN network, while the MCP2515 gives the Arduino UNO the CAN capability that it lacks internally. Putting the three pieces together creates a useful development platform: the Arduino generates or processes CAN messages, the MCP2515 handles CAN protocol communication, and the SH-C30L provides the connection to PC-based monitoring and debugging software. The setup also demonstrates an important concept in embedded systems: communication often involves multiple layers. SPI connects the Arduino to the CAN controller, the CAN transceiver handles the physical bus, and USB connects the CAN network to the computer. For complete step-by-step instructions, wiring details, code, and additional testing information, you can also refer to the original guide on Play with Circuit: https://playwithcircuit.com/how-to-interface-servo-motor-with-arduino/ If you're just getting started with CAN, this project is a good way to move from simply reading about the protocol to actually sending, receiving, and analyzing CAN frames.

This is a summary aggregated from Dev.to. Read the complete article on the original site:

Read full article at Dev.to

More Programming & Dev News