2-CH TRIAC HAT

From Waveshare Wiki
Jump to: navigation, search
2-CH TRIAC HAT
2-CH TRIAC HAT

2-CH CAN FD HAT, SPI interfaces
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Introduction

Dual Channels Bidirectional Triac HAT for Raspberry Pi, Integrated MCU, Commands Control, UART / I2C.

More

Note: This is a relay device and the circuits are exposed. DO NOT touch the components onboard! We recommend you add an insulated enclosure when using.
The device will get hot when working, the higher the output power, the hotter it is. The device will cut off the output signal to protect the TRIAC when the temperate reaches 125°C. We recommend you add cooling devices to let the TRIAC HAT work normally under 80°C.

Features

  • AC voltage: 100~600V
  • AC current: 0~20A
  • Dimensions: 65 × 56.5 (mm)
  • Working voltage: 3.3V/5V
  • Interfaces: UART/I2C
  • Controller: STM32F030
  • UART data rate: 1200 ~ 921600bps
  • I2C data rate: ≤1Mbps

Interfaces

PIN Description
VCC 3.3V/5V power input
GND Ground
RX/SCL UART data output/I2C clock
TX/SDA UART data input/I2C data

Jumpers

You can change the communication interfaces with the jumpers. Note that you can also change the DIP switch which is on the backside for different interfaces.

Jumpers Interfaace
A I2C
B UART

Commands

UART

0x57 0x68 Register address Parameter H Parameter L Parity Bit

I2C

I2C Address Register Address Parameter H Parameter L

Register

0 x 01: Mode.

1: Voltage adjustment. It outputs a voltage according to the conduction angle.
0: Switch Mode. Only support turns on and off.

0 x 02: Channel enable.

3: Enable two channels.
2: Enable Channel 2 and disable Channel 1.
1: Enable Channel 1 and disable Channel 2.
0: Disable both channels.

0 x 03: Channel _1 Angle Conduction angle of Channel 1.

0 to 179

0 x 04: Channel _2 Angle Conduction angle of Channel 2.

0 to 179

0 x 05: Configure the frequency of the power grid.

0x32   50Hz
0x3C  60Hz

0 x 06: reset

0 to 65536: Reset after n (ms)

0 x 07: Configure the baud rate (n*100)

12~9216
Connect RX/SCL and TX/SDA can reset the baud rate to 115200

Work with Raspberry Pi

Notices

  • HIGH VOLTAGE WARNING

2-CH-TRIAC-HAT-15 960.jpg 2-CH-TRIAC-HAT-13 960.jpg

  • Solders are exposed on the backside.

Please add nylon standoffs to Raspberry Pi for protection. Do not touch it by hand.
2-CH-TRIAC-HAT-4.jpg

  • Reference connection:

2-CH-TRIAC-HAT-17 960.jpg


Install Library

If you use bookworm system, only the lgpio library is available, bcm2835 and wiringPi libarary cannot be installed or used. Please note that the python library does not need to install, you can directly run the demo.

BCM2835

#Open the Raspberry Pi terminal and run the following command
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz
tar zxvf bcm2835-1.71.tar.gz 
cd bcm2835-1.71/
sudo ./configure && sudo make && sudo make check && sudo make install
# For more, you can refer to the official website at: http://www.airspayce.com/mikem/bcm2835/

WiringPi

#Open the Raspberry Pi terminal and run the following command
cd
sudo apt-get install wiringpi
#For Raspberry Pi systems after May 2019 (earlier than that can be executed without), an upgrade may be required:
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
# Run gpio -v and version 2.52 will appear, if it doesn't it means there was an installation error

# Bullseye branch system using the following command:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
. /build
gpio -v
# Run gpio -v and version 2.70 will appear, if it doesn't it means there was an installation error

lgpio

wget https://github.com/joan2937/lg/archive/master.zip
unzip master.zip
cd lg-master
sudo make install 
#for more details, you can refer to https://github.com/gpiozero/lg
  • Install Python libraries:
# python2
sudo apt-get update
sudo apt-get install python-pip
sudo pip install RPi.GPIO
sudo apt-get install python-smbus
sudo apt-get install python-serial
# python3
sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install RPi.GPIO
sudo apt-get install python3-smbus
sudo apt-get install python3-serial

Examples

Open the terminal and download demo codes by following commands:

sudo apt-get install p7zip
wget https://files.waveshare.com/upload/e/ef/2-CH_SCR_HAT_code.7z
7zr x 2-CH_SCR_HAT_code.7z -r -o./2-CH_SCR_HAT_code
sudo chmod 777 -R 2-CH_SCR_HAT_code
cd 2-CH_SCR_HAT_code/RaspberryPi/
C codes

Open the terminal and run the codes by the following commands:

cd c
make clean
make
sudo ./main

Expected result: Connect a lamp to the output port, and connect the input supply, you can find that the brightness of the lamp is changed.
Note: Only WIRINGPI and DEV_LIB are supported if you use the UART interface.
WIRINGPI, DEV_LIB, and USE_BCM2835_LIB are all be supported for I2C Interface.

Python code

Open a terminal and run the codes by the following commands:

cd python
cd examples
sudo python main.py
#If you need to modify the interface protocol, modify data_mode in main.py to be equal to 1 or 0
#data_mode=1 for UART
#data_mode=0 for I2C

Expected result: Connect a lamp to the output port, and connect the input supply, you can find that the brightness of the lamp is changed.

Web control

The example is based on the Python Web frame.
Open the terminal, and install the bottle as below:

sudo apt-get install python-bottle
cd Web_python
sudo python main.py

Open the browser (host PC or telephone, we recommend you to use Chrome browser) and go to [IP of Raspberry Pi]: 8080.
2-CH TRIAC HAT Web 001.jpg

Working with Jetson Nano

Install libraries

sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install Jetson.GPIO
sudo groupadd -f -r gpio
sudo usermod -a -G gpio your_user_name
sudo cp /opt/nvidia/jetson-gpio/etc/99-gpio.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger

Examples

Download the demo codes by the following commands.

sudo apt-get install p7zip
wget https://files.waveshare.com/upload/e/ef/2-CH_SCR_HAT_code.7z
7zr x 2-CH_SCR_HAT_code.7z -r -o./2-CH_SCR_HAT_code
sudo chmod 777 -R 2-CH_SCR_HAT_code
cd 2-CH_SCR_HAT_code/RaspberryPi/
C codes

Open a terminal and run the following commands.

cd c
make clean
make
sudo ./main

Expected result: Connect a lamp to the output port, and connect the input supply, you can find that the brightness of the lamp is changed.
Note: DEV_LIB is only supported by the C codes.

Python codes

Open a terminal and run the following commands:

cd python 
cd examples
sudo python main.py
#If you need to change the interface protocol, change the data_mode to be equal to 1 or 0 in main.py
#data_mode = 1 for UART
#data_mode = 0 for I2C

Expected result: Connect a lamp to the output port, and connect the input supply, you can find that the brightness of the lamp is changed.

Load testing

Output Power With Fan Without Fan
1800W 75℃ 105℃
1000W 50℃ 75℃
600W 35℃ 50℃

The TRIAC may be destroyed if the working temperature is higher than 50°C for a long time, once the temperature reaches 125°C the device will force to protection status and cut off output. You should add cooling devices for normally working.
WARNING: DO NOT short the circuit, the TRIAC may burst if the circuit is shorted.

Resources

Demo codess

Documents

FAQ


 Answer:
Check whether the jumper cap and the toggle switch are in the B position, if there is no response, short-circuit the two pins TX/SDA and RX/SCL, then power on and off, disconnect the short circuit, the baud rate is restored to 115200.


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)