• sales

    +86-0755-88291180

Raspberry Pi CM4-ETH-RS485-BASE-B User Guide

Introduction

Detailed parameter and function description

Product Description

My name is CM4-ETH-RS485-BASE-B, which is an expansion board that can be used with Raspberry Pi Compute Module 4, and supports 7-36V DC power supply and 5V DC DC power supply of Typc-C interface. Onboard four isolated RS485 interfaces, 100M+1000M dual network ports, HDMI interface, two CSI interfaces and two USB interfaces, etc...

Precautions for use

  1. Do not plug and unplug any device except USB and HDMI when it is powered on
  2. Confirm the fan voltage before connecting, only support 5V
  3. The Type C interface can be used as a power supply or as a USB interface to burn the image (need to use the DIP switch to switch)
  4. In order to ensure the normal power supply of CM4, please do not connect other devices when using the Type C interface to burn the image.
  5. When CM4 is in normal use, it needs to provide 5V 2A power supply for CM4. Otherwise, there may be problems such as automatic shutdown, frequency reduction and so on.
  6. USB2.0 is closed by default, if you need to open it, you need to add dtoverlay=dwc2,dr_mode=host in config.txt

Product Size

CM4-ETH-RS485-BASE-B


Compute_Module 4 core board

Onboard resources


Interfaces

LabelNameInstruction
1CM4 connectorApplicable to all editions of Compute Module 4
2IO-VREFSelect GPIO logic voltage, selectable 3.3V (default) or 1.8V
3RTC-I2C:I2C bus selection for RTCOptional SDA0 & SCL0 (default) or GPIO2 & GPIO3
4RTC INT:RTC Interrupt pin selectionD16:RTC Use GPIO16 to receive interrupt signal when generating interrupt (default)

GL-EN:CM4 is powered off when RTC generates an interrupt
PI-RUN:CM4 restarts when RTC generates an interrupt

5SYSTEM:System FunctionWP-DIS: Prevent EEPROM from being overwritten

BT-DIS:Disable bluetooth function, only works on CM4 version with antenna
WIFI-DIS:Disable WiFi function, only works on CM4 version with antenna

6BOOT SwitchON: Boot as USB Tpye-C interface

OFF:Boot to eMMC or Micro SD card

7PWR & USBWhen the BOOT switch is "ON", it can be used as a programming port and a power supply interface

When the BOOT switch is "OFF", it is only used as a power supply interface

8HDMI0HDMI Display interface, support 4K 30fps output
9USBTwo-way USB2.0 interface, support USB device insertion
10ETHERNET0CM4 native Gigabit RJ45 Ethernet port
11ETHERNET1USB expansion 100M Ethernet port
12CAM0 & CAM1Two MIPI CSI camera interfaces
13BuzzerGPIO22 control
14FANFour-wire fan interface, only supports 5V fans, PWM speed regulation (GPIO18 control, no speed measurement)
15RTC Battery interfacecan be connected to CR2032 button battery
16RS485 Transceiver indicatorTXn: transmit information indicator of channel n

RXn: Receive information indicator for channel n

17User LED lightUSER0: GPIO20 control

USER1: GPIO26 control

18PWRRaspberry Pi power indicator
19ACTRaspberry Pi working status indicator
20DC 7~36VDC power supply interface
21Power supply terminalDC power supply terminal, support 7~36V wide voltage input
22RS485 TerminalFour-way isolated RS485 interface, pitch 5.08mm
23Jumper CapOptional 120R Balance Resistor Jumper Cap
24RS485 mode switchFull-auto: automatic mode, the program operation is simple, the load capacity is weak

Semi-auto: semi-automatic mode, need to manually switch the transceiver mode, high reliability, strong load capacity

25Encryption chipATSHA204 encryption chip, which can perform multiple encryption to ensure data security and reliability
26Micro SD card slotFor inserting a Micro SD card with the system to start the Compute Module 4 Lite

How to use

Precautions

Do not plug or unplug any device while it is powered on

RS485

It is closed by default. If you want to open it, you need to add content in config.txt:
sudo nano /boot/config.txt

dtoverlay=uart0
dtoverlay=uart3
dtoverlay=uart4
dtoverlay=uart5

COM0 occupies GPIO14/GPIO15 (BCM code 14/15), device number ttyAMA0
COM1 occupies GPIO4/GPIO5 (BCM code 4/5), device number ttyAMA1
COM2 occupies GPIO8/GPIO9 (BCM code 8/9), device number ttyAMA2
COM3 occupies GPIO12/GPIO13 (BCM code 12/13), device number ttyAMA3
If other serial ports are opened, the comments need to be closed, for example:

 #enable_uart=1

RTC

To enable I2C connected to the RTC controller, you need to set the dtparam=i2c_vc=on configuration file. RTC is on i2c-10, address is 0x51 (7-bit address)

sudo nano /boot/config.txt
#Add at the end
dtparam=i2c_vc=on
#Add # in front of dtparam=audio=on
#dtparam=audio=on
#Save and exit, restart
sudo reboot

Downloader

Open the Raspberry Pi terminal and execute the following commands:

sudo apt-get install p7zip-full
sudo wget https://www.waveshare.net/w/upload/4/42/PCF85063_code.7z
7z x PCF85063_code.7z -O./
cd PCF85063_code

C code

Execute the following instructions to compile and execute the test program

cd c
sudo make clean
sudo make -j 8
sudo ./main

The experimental phenomenon is as follows:

Python

Enter the python program directory

cd python/example

Run the routine, the program supports python2/3

# python2
sudo python main.py
# python3
sudo python3 main.py

The experimental phenomenon is as follows: 

FAN test

  • Support PWM speed regulation, no speed detection function
  • Note: Before connecting, please confirm the fan voltage and the power supply of the actually connected fan

Open the Raspberry Pi terminal and execute the following commands:

wget https://www.waveshare.net/w/upload/d/d1/CM4-ETH-RS485-BASE-B-Example.zip
unzip CM4-ETH-RS485-BASE-B-Example.zip -d ./CM4-ETH-RS485-BASE-B-Example
cd CM4-ETH-RS485-BASE-B-Example/FAN/

c code

Compile and execute the test program

cd c
sudo make clean
sudo make
sudo ./main

Phenomenon: Enter the duty cycle as prompted to change the fan speed

python

Enter the python program directory

cd python

Run the routine, the program supports python2/3

# python2
sudo python FAN.py
# python3
sudo python3 FAN.py

Phenomenon: first press the prompt to input the frequency, 5K is recommended, and then cycle the input duty cycle to change the fan speed

CSI

Note: The following is the general description of CM4, the specific equipment is different: this module has no DSI interface, and only HDMI0.

configuration file

CSI and DSI are disabled by default. When using camera and DSI, three I2C devices, I2C-10, I2C-11, and I2C-0, will be occupied.
Start up as follows:

wget https://www.waveshare.net/w/upload/7/75/CM4_dt_blob_Source.zip
 unzip -o  CM4_dt_blob_Source.zip -d ./CM4_dt_blob_Source
 sudo chmod 777 -R CM4_dt_blob_Source
 cd CM4_dt_blob_Source/
 #If using two cameras and DSI0 execute
  sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
  #If using two cameras and DSI1 execute
  sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
  #When using any DSI, HDMI1 has no image output, even if you do not connect the DSI screen, as long as you compile the corresponding file, then HDMI1 will not output
  #If you need to restore, delete the corresponding dt-blob.bin: sudo rm -rf /boot/dt-blob.bin
  # After execution, turn off the power and restart the CM4

Recording test

Then connect the camera and DSI screen:

  1. Make sure the connection is in the power-off state
  2. Connect Power
  3. Wait a few seconds for the screen to start up
  4. If it fails to start, check whether /boot/dt-blob.bin exists, and restart it if it exists.
  5. The camera needs to run raspi-config, select Interfacing Options->Camera->Yes->Finish-Yes, reboot the system, open the enable camera, and then restart to save the changes.

Reference
Test the Raspberry Pi camera View the first camera connected to the screen:

sudo raspivid -t 0 -cs 0

View the picture of the second camera connected:

sudo raspivid -t 0 -cs 1

If using the latest Raspberry Pi OS (images after October 30, 2021):

libcamera-hello -t 0

Or

libcamera-hello
  • NOTE: If using the DSI interface the display will have an HDMI disabled, even if just compiling the corresponding file without connecting the DSI screen.
  • Any connection of two HDMIs can output images, not limited to that HDMI. If two HDMI screens are connected, only HDMI0 has image output.
  • If you want to enable both HDMI, delete the dt-blob.bin file with the following command:
sudo rm -rf /boot/dt-blob.bin
  • And then restart

Refer to the Raspberry Pi manual

Encryption

Onboard encryption chip, not enabled by default
Please refer to the data sheet and official library for use: [1]