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

{{{name6}}}

Introduction

Detailed parameter and function description.

Product Description

It 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 flash the image (need to use the DIP switch to switch).
  4. To ensure the normal power supply of CM4, please do not connect other devices when using the Type C interface to flash 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 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
PI-RUN: CM4 restarts 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
WIFI-DIS: Disable WiFi 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 Flashing

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

New System

It is turned off by default. To turn it on, you need to add the following content in config.txt:
sudo nano /boot/config.txt

dtoverlay=uart3
dtoverlay=uart4
dtoverlay=uart5

COM1 occupies GPIO4/GPIO5 (BCM code 4/5), the device number is ttyAMA1
COM2 occupies GPIO8/GPIO9 (BCM code 8/9), the device number is ttyAMA2
COM3 occupies GPIO12/GPIO13 (BCM code 12/13), the device number is ttyAMA3

COM0 executes:

sudo raspi-config
Go to Interface Options --> Serial Port --> <No>  -->  <Yes>
Turn off the serial port login, and turn on the hardware serial port
Reboot

COM0 occupies GPIO14/GPIO15 (BCM code 14/15), the device number is ttyS0

Old System

It is turned off by default. To turn it on, you need to add the following 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), the device number is ttyAMA0
COM1 occupies GPIO4/GPIO5 (BCM code 4/5), the device number is ttyAMA3
COM2 occupies GPIO8/GPIO9 (BCM code 8/9), the device number is ttyAMA4
COM3 occupies GPIO12/GPIO13 (BCM code 12/13), the device number is ttyAMA5


If other serial ports are enabled, they need to be commented out to to be turned off, for example:< br>

 #enable_uart=1

Note: The default is automatic mode, and the sending and receiving mode is automatically switched. You can modify the 0R resistance on the back if program control of sending and receiving is required.

  • Mode switching: Each channel is controlled by two 0R resistors
    • Semi-automatic mode: The 0R resistors are 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 resistors are 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

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

CSI DSI

New Version (Bookworm)

The DSI screen is 800x480 resolution screen by default, please refer to the corresponding WIKI for other resolution screens

When using the official base board Compute Module 4 IO Board, note that the J6 jumper cap needs to be connected


DSI

#Add the following to the config.txt file:
sudo nano /boot/firmware/config.txt
#DSI0 (V1~V3)
dtoverlay=vc4-kms-dsi-7inch,dsi0
#DSI1 (V4)
dtoverlay=vc4-kms-dsi-7inch,dsi1

CSI

  • Add the following to the config.txt file:
  • sudo nano /boot/firmware/config.txt
    Mode CAM0 setup statement CAM1 setup statement
    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
    IMX296 dtoverlay=imx296,cam0 dtoverlay=imx296,cam1
    IMX708 dtoverlay=imx708,cam0 dtoverlay=imx708,cam1
  • Use the shortcut Ctrl+o to save the file, then press Enter
    CM4-NANO-B-CSI-03.png
  • Use the shortcut Ctrl+x to exit the editor
  • Reboot the device
    sudo reboot
  • Note:

    1. The single-port camera can only work on CAM0, that is, it is not possible to use CAM1 port alone. But you can use the CAM0 port alone, or connect the dual cameras
    2. If the device is recognized, and the startup prompt "Camera frontend has timed out!" appears, please update "sudo rpi-update"
    
    Test Camera
    1. Enter the camera detection command, and you can see that the camera has been detected
      libcamera-hello --list-cameras

      CM4-NANO-B-CSI-01.png
    2. Display the camera screen to the desktop
      libcamera-hello -t 0
    3. Take a photo
      libcamera-jpeg -o test.jpg
    4. Record a 10s video
      libcamera-vid -t 10000 -o test.h264

    Other commands
    Check if the camera is detected

    libcamera-hello --list-cameras
    

    Open the corresponding camera

    libcamera-hello  --camera 1
    libcamera-hello  --camera 0
    

    Take a photo

    libcamera-jpeg -o test.jpg
    #You can add --camera to specify the camera
    


    #The new system uses dual cameras
    #Remove camera_auto_detect=1 in config.txt
    #camera_auto_detect=1
    
    #Add
    dtoverlay=imx219,cam1
    dtoverlay=imx219,cam0
    
    #Where imx219 is the camera sensor model and other sensors are supported
    dtoverlay=ov5647,cam0
    dtoverlay=imx219,cam0
    dtoverlay=ov9281,cam0
    dtoverlay=imx477,cam0
    dtoverlay=imx519,cam0
    
    #Then reboot
    reboot
    
    #Open camera
    libcamera-hello -t 0
    or
    libcamera-hello
    
    
    #Other instructions:
    #Check if the camera is detected
    libcamera-hello --list-cameras
    
    #Open the corresponding camera, preview for 5 seconds
    libcamera-hello  --camera 1
    libcamera-hello  --camera 0
    
    #Take photos
    libcamera-jpeg -o test.jpg
    
    #Shoot video
    libcamera-vid -t 10000 -o test.h264
    
    #You can add --camera to specify the camera
    #-t <duration> option allows the user to choose how long the window is displayed in milliseconds

    For more commands, you can click here.

    • Note: If using a DSI interface display there will be an HDMI disabled, even if just compiling the corresponding file without connecting a DSI screen.
    • Connecting either HDMI port will allow output of an image, regardless of which HDMI port is used. If two HDMI screens are connected, only HDMI0 has an image output.
    • To enable two HDMI ports, remove the configuration from config.txt:
    • And then reboot it.

    Please refer to Raspberry Pi manual.

    Old System Version (Buster and Bullseye)

    Configure Files

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

    wget https://files.waveshare.com/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/
     #Execute (for version V1~V3)
     sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp0-double_cam.dts
     #Execute (for version V4)
     sudo  dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob-disp1-double_cam.dts
    
     Add the following to the config.txt file:
     sudo nano /boot/config.txt
     Change dtoverlay=vc4-kms-v3d to
     dtoverlay=vc4-fkms-v3d
    
     #When using any DSI, HDMI1 has no image output, even if you are not connected to the DSI screen, as long as you compile the corresponding file, then HDMI1 will have no 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

    Record Test

    Connect to the camera and the DSI display:
    1. Please make sure it is connected under powering off.
    2. Connect to the power.
    3. The display will be booted after waiting for a few seconds.
    4. If it fails to boot, check whether /boot/dt-blob.bin exists, and reboot it if it exists.

    Old Version (Buster)

    The camera needs to run raspi-config, select Interfacing Options -> Camera -> Yes -> Finish -> Yes, reboot the system, open enable camera, and then restart to save the changes.

    Test the Raspberry Pi camera.
    Check the screen of the first connected camera:

    sudo raspivid -t 0 -cs 0
    

    Check the screen of the second connected camera:

    sudo raspivid -t 0 -cs 1
    


    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

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



     Answer:

    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)