Pan Tilt Hat
Add-On Required: This feature requires the Simulink Support Package for Raspberry Pi Hardware add-on.
Libraries:
Simulink Support Package for Raspberry Pi Hardware /
Basic
Description
Use the Pan Tilt Hat block to control the pan and tilt motions of hardware using the PCA-9685-based PWM I2C driver. This block accepts pan and tilt angles in the range –90 to 90 degrees. The PCA9685 driver controls the movement of the pan and tilt hardware module in two degree of freedom (DoF), namely along the horizontal and vertical axes, respectively.
Activate, Load, and Verify PCA9685 Kernel Module
Follow these steps to activate and load the PCA9685 kernel module on your Raspberry Pi® hardware and then use the Pan Tilt Hat block in your Simulink® model.
Execute these commands on the MATLAB® Command Window to open the Raspberry Pi terminal.
r=raspberrypi('<Raspberry Pi IP address>','<Raspberry Pi username>','<Raspberry Pi password>'); r.openShell
Open the
/boot/config.txt
file in a text editor.To activate the PCA9685 kernel module, add this code to the
/boot/config.txt
file.dtoverlay=i2c-pwm-pca9685a
Save and close the
/boot/config.txt
file.Reboot your Raspberry Pi.
To load the PCA9685 kernel module on your Raspberry Pi, execute this code in the Raspberry Pi terminal.
sudo modprobe pwm-pca9685
To verify whether you have successfully loaded the PCA9685 module on your Raspberry Pi hardware, execute this code in the Raspberry Pi terminal.
i2cdetect -y <i2c bus number>
For example,
i2cdetect -y 1
Observe that the PCA9685 kernel module reserves an I2C address
0x40
for the pan tilt hardware, indicated by UU.
Ports
Input
Parameters
Version History
Introduced in R2022a