CM4-ETH-RS485-BASE-B

From Waveshare Wiki
Jump to: navigation, search
CM4-ETH-RS485-BASE-B
CM4-ETH-RS485-BASE-B.jpg
Compute-Module-4
360px-Compute-Module-4-1.jpg
CM4-ETH-RS485-Box-B
Compute-box.png
{{{name4}}}

{{{name5}}}

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

  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 a 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
650px-CM4-ETH-RS485-BASE-B-details-size.jpg
Compute_Module 4 core board
Compute Module 4 IO Board 5.png

Onboard resources

800px-CM4-ETH-RS485-BASE-B-details-intro.jpg

Interfaces

Label Name Instruction
1 CM4 connector Applicable to all editions 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 generating interrupt (default)

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

5 SYSTEM: System Function WP-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

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 Two-way USB2.0 interface, support USB device insertion
10 ETHERNET0 CM4 native Gigabit RJ45 Ethernet port
11 ETHERNET1 USB expansion 100M Ethernet port
12 CAM0 & CAM1 Two 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: transmit information indicator of channel n

RXn: Receive information indicator for channel n

17 User LED light 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 Four-way isolated RS485 interface, pitch 5.08mm
23 Jumper Cap Optional 120R Balance Resistor Jumper Cap
24 RS485 mode switch Full-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

25 Encryption chip ATSHA204 encryption chip, which can perform multiple encryptions to ensure data security and reliability
26 Micro SD card slot For 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.

Image Burning

EMMC version click here
LITE version click here

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 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.

CM4-ETH-RS485-BASE-B-mode-switch.jpg

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

Downloader

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:
RTC PCF85063 c test.png

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:
RTC PCF85063 python test.png

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_Source.zip
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 execute
sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
# In the use of any DSI, HDMI1 no image output, even if you do not connect the DSI screen as long as the corresponding file compiled, that HDMI1 no output
# If you need to restore, delete the corresponding dt-blob.bin can be: sudo rm -rf /boot/dt-blob.bin 
#Execution is complete, power off and restart CM4


New Version (Bullseye)

Camera Config

  1. Execute the following commands to edit "/boot/config.txt" file.
    sudo nano /boot/config.txt
  2. Block or remove the automatic camera detection statement:
    CM4-NANO-B002.png
  3. 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.
    CM4-NANO-B003.png
  4. 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.
    • CM4-NANO - only CAM0 is used, so you only need to add "dtoverlay=imx219,cam0".

    CM4-NANO-B004.png
    5. Ctrl+x to exit the editor.
    6. Reboot the Raspberry Pi.

    sudo reboot
    

Camera Test

  1. Enter the camera detection command, you can see that the camera is detected by now.
    libcamera-hello --list-cameras
    

    CM4-NANO-B005.png

  2. Display the camera screen on the desktop.
  3. libcamera-hello -t
    
  4. Taking photos.
    libcamera-jpeg -o test.jpg
    
  5. Record a video of 10s.
    libcamera-vid -t 10000 -o test.h264
    
  6. Other Commands
    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.
    sudo raspi-config

    2. Choose Interfacing Options and enter.
    Interface.png
    3. Choose Camera:
    Camera.png
    4. Choose to enable the camera interface.
    Camera2.png
    5. The system prompts as follows:
    Prompt.png
    6. Back to the main interface, select Finish.
    Finish.png
    7. Reboot the system.
    Finish2.png


    Camera Test

    raspistill -o image.jpg
    
    • Test the recording function:
    raspivid -o video.h264 -t 10000
    
      • Where -t 10000 means recording for 10 seconds, users can adjust according to their own needs.
      • Please refer to CSI.

Encryption

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

Resources

Provide a full set of documents, procedures, data sheets, etc.

Documentation

Schematic

3D map

Program

Software

FAQ

 Answer:
a) Check whether dtparam -audio -on is blocked in /boot/config.txt.
b) Check whether the /boot/dt-blob.bin file exists, if it cannot be used, please delete it.
{{{3}}}
{{{4}}}

{{{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 AM GMT+8 (Monday to Friday)