Simulink model control servo by mpu9250

조회 수: 13 (최근 30일)
Aseel Mgig
Aseel Mgig 2019년 10월 12일
답변: MULI 2024년 11월 8일 12:58
Hello , i have build a simulink mode that contains a mpu9250 that give a raw data Which contains reading of accelometer and gyroscope and magnetometer .. i convert this raw data into yaw pith roll angles , i need to control a servo motor with any of these angle .. is there any direct way to do that. Please help Thanks

답변 (1개)

MULI
MULI 2024년 11월 8일 12:58
Hi Aseel,
To control servo motor using one of the yaw, pitch, or roll angles derived from your MPU9250 sensor in Simulink, you can follow the below steps:
  • Convert yaw, pitch, or roll angle to a duty cycle (1-2 ms pulse width) needed by the servo. This maps 0-180° to a 50 Hz PWM signal.
  • Connect the PWM block to the Arduino pin controlling the servo. This block can generate the PWM signals needed to control a standard servo motor.
  • You can use below formula to map angles to the appropriate duty cycle for the PWM signal. For example:
  • Connect the output of the angle-to-PWM conversion logic to the PWM block.
  • Deploy the model to the Arduino by selecting Run on board in the Simulink Hardware tab.
For more information on PWM block and related example you can refer to the below link
You can also refer to the below example which shows the control of a standard servo motor using Arduino.

카테고리

Help CenterFile Exchange에서 Simulink Supported Hardware에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by