Pan Tilt Hat
Libraries:
Raspberry Pi Blockset /
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.
Note
To generate code C/C++ code for this block, you must have an Embedded Coder® license.
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.openShellOpen the
/boot/config.txtfile in a text editor.To activate the PCA9685 kernel module, add this code to the
/boot/config.txtfile.dtoverlay=i2c-pwm-pca9685a
Save and close the
/boot/config.txtfile.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
0x40for the pan tilt hardware, indicated by UU.
Examples
Ports
Input
Parameters
Extended Capabilities
Version History
Introduced in R2022a


