CM4-ETH-RS485-BASE-B
| ||
| ||
| ||
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 a 7-36V DC power supply and 5V DC power supply of Type-C interface. Onboard four isolated RS485 interfaces, 100M+1000M dual network ports, HDMI interface, two CSI interfaces, two USB interfaces, etc...
Precautions for use
- Do not plug and unplug any device except USB and HDMI when it is powered on.
- Confirm the fan voltage before connecting, only support 5V.
- 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).
- To ensure the normal power supply of CM4, please do not connect other devices when using the Type C interface to burn the image.
- When CM4 is in normal use, it needs to provide a 5V 2A power supply for CM4. Otherwise, there may be problems such as automatic shutdown, frequency reduction, and so on.
- 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
Label | Name | Description |
1 | CM4 connector | Applicable to all versions of Compute Module 4 |
2 | IO-VREF | Select GPIO logic voltage, selectable 3.3V (default) or 1.8V |
3 | RTC-I2C: I2C bus selection for RTC | Optional SDA0 & SCL0 (default) or GPIO2 & GPIO3 |
4 | RTC INT: RTC Interrupt pin selection | D16: RTC Use GPIO16 to receive interrupt signal when interrupt (default) GL-EN: CM4 is powered off when RTC interrupts |
5 | SYSTEM: System Function | WP-DIS: Prevent EEPROM from being overwritten BT-DIS: Disable Bluetooth function, only works on CM4 with an antenna |
6 | BOOT Switch | ON: Boot as USB Type-C interface OFF: Boot to eMMC or Micro SD card |
7 | PWR & USB | When 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 |
8 | HDMI0 | HDMI Display interface, support 4K 30fps output |
9 | USB | 2x USB2.0 interface, support connecting to USB devices |
10 | ETHERNET0 | CM4 Gigabit RJ45 Ethernet port |
11 | ETHERNET1 | USB expansion 100M Ethernet port |
12 | CAM0 & CAM1 | 2x MIPI CSI camera interfaces |
13 | Buzzer | GPIO22 control |
14 | FAN | Four-wire fan interface, only supports 5V fans, PWM speed regulation (GPIO18 control, no speed measurement) |
15 | RTC Battery interface | can be connected to the CR1220 button battery |
16 | RS485 Transceiver indicator | TXn: N channel transmitting indicator RXn: N channel receiving indicator |
17 | User LED indicator | USER0: GPIO20 control USER1: GPIO26 control |
18 | PWR | Raspberry Pi power indicator |
19 | ACT | Raspberry Pi working status indicator |
20 | DC 7~36V | DC power supply interface |
21 | Power supply terminal | DC power supply terminal, support 7~36V wide voltage input |
22 | RS485 Terminal | 4-ch isolated RS485 interface, 5.08mm pitch |
23 | Jumper Cap | Optional 120R Balance Resistor Jumper Cap |
24 | RS485 mode switch | Full-auto: automatic mode, the demo operation is simple, the load capacity is weak Semi-auto: semi-automatic mode, need to manually switch the transceiver mode, higher reliability, larger load capacity |
25 | Encryption chip | ATSHA204 encryption chip, supports multiple encryptions to ensure data security and reliability |
26 | Micro SD card slot | For inserting a Micro SD card with the system to boot the Compute Module 4 Lite |
How to Use
Precautions
Do not plug or unplug any device while it is powered on.
Image Burning
USB 2.0
USB2.0 is disabled by default, if you want to enable it, you need to add dtoverlay=dwc2,dr_mode=host in config.txt.
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 ttyAMA3.
COM2 occupies GPIO8/GPIO9 (BCM code 8/9), device number ttyAMA4.
COM3 occupies GPIO12/GPIO13 (BCM code 12/13), device number ttyAMA5.
For old system:
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
Note: The default mode is automatic, and the sending and receiving mode is automatically switched; You can modify the 0R resistance on the back if you need program control to send and receive.
- Mode switching: each channel is controlled by two 0R resistors.
- Semi-automatic mode: the 0R resistor is on the "Semi-auto" end, and the user program controls the transceiver mode. (The following figure is in Semi-automatic mode.)
- Full-automatic mode: The 0R resistor is on the "Full-auto" end, and the transceiver mode is automatically switched according to the transmission direction.
RTC
To enable I2C to connect to the RTC controller, you need to set the dtparam=i2c_vc=on configuration file. RTC is on i2c-10, address is 0 x 51 (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
Demo Download
Open the Raspberry Pi terminal and execute the following commands:
sudo apt-get install p7zip-full sudo wget https://files.waveshare.com/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 the demo:
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 demo, 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://files.waveshare.com/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 demo.
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 demo directory:
cd python
Run the demo, and the demo 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
The following are general instructions for CM4, specific devices differ: this module has no DSI interface and only HDMI0.
Configuration file
CSI and DSI are disabled by default. When using the camera and DSI, it will occupy three I2C devices: I2C-10, I2C-11, and I2C-0.
- Open a terminal and run the following commands:
sudo apt-get install p7zip-full -y wget https://files.waveshare.com/upload/7/75/CM4_dt_blob.7z 7z x CM4_dt_blob.7z -O./CM4_dt_blob sudo chmod 777 -R CM4_dt_blob cd CM4_dt_blob/ # If using two cameras and DSI1, please execute: sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts # When using any DSI, there is no image output on HDMI1. Even if you do not connect a DSI screen, as long as the corresponding file is compiled, there will be no output on HDMI1. # To restore it, simply delete the corresponding dt-blob.bin file: sudo rm -rf /boot/dt-blob.bin #Execution is complete, power off and reboot CM4
New Version (Bullseye)
Camera Config
-
Execute the following commands to edit "/boot/config.txt" file.
sudo nano /boot/config.txt
- Block or remove the automatic camera detection statement:
-
Add the driver of the camera you are using, here I take IMX219 as an example and connect it to CAM0, and attach the adapter.
Model CAM0 Set Sentence CAM1 Set Sentence OV9281 dtoverlay=ov9281,cam0 dtoverlay=ov9281,cam1 IMX290/IMX327 dtoverlay=imx290,clock-frequency=37125000,cam0 dtoverlay=imx290,clock-frequency=37125000,cam1 IMX378 dtoverlay=imx378,cam0 dtoverlay=imx378,cam1 IMX219 dtoverlay=imx219,cam0 dtoverlay=imx219,cam1 IMX477 dtoverlay=imx477,cam0 dtoverlay=imx477,cam1 IMX708 dtoverlay=imx708,cam0 dtoverlay=imx708,cam1 - If you are using the official Raspberry Pi camera and only one camera is connected, there is no need to set the config file. If it is not an official camera, set the "dtoverlay" statement without the "cam" suffix.
- CM4-NANO - only CAM0 is used, so you only need to add "dtoverlay=imx219,cam0".
5. Ctrl+x to exit the editor.
6. Reboot the Raspberry Pi.
sudo reboot
Camera Test
- Enter the camera detection command, you can see that the camera is detected by now.
libcamera-hello --list-cameras
- Display the camera screen on the desktop.
- Taking photos.
libcamera-jpeg -o test.jpg
- Record a video of 10s.
libcamera-vid -t 10000 -o test.h264
Other Commands:
libcamera-hello -t
Check whether the camera is detected:
libcamera-hello --list-cameras
Open the corresponding cameras:
libcamera-hello --camera 1 libcamera-hello --camera 0
Take a photo:
libcamera-jpeg -o test.jpg #Add --camera to specify a camera
Old Version (Buster)
Camera Config
-
1. Execute the following command to enter the Raspberry Pi configuration.
- Test the recording function:
- Where -t 10000 means recording for 10 seconds, users can adjust according to their own needs.
- Please refer to CSI.
sudo raspi-config
2. Choose Interfacing Options and enter.
3. Choose Camera:
4. Choose to enable the camera interface.
5. The system prompts as follows:
6. Back to the main interface, select Finish.
7. Reboot the system.
Camera Test
raspistill -o image.jpg
raspivid -o video.h264 -t 10000
Encryption
Onboard encryption chip, not enabled by default.
Please refer to the datasheet and official library for use: [1]
Resource
Provide a full set of documents, procedures, data sheets, etc.
Documentation
Schematic
3D Drawing
Demo
Software
FAQ
b) Check whether the /boot/dt-blob.bin file exists, if it cannot be used, please delete it.
{{{5}}}
It is the ttyS0 instead. You can remove the line dtoverlay=uart0 and use the ttyS0 which is the ttyAMA0 before.
{{{5}}}
I'm sorry that we do not provide 3D drawing for the case.
{{{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)