How to use I/O mode to control a servo motor?

Hello everyone, I am learning to use Arduino to control a servo motor. I successfully realized the this model, using external mode(run on the board), and the motor worked well. However, if I switch to I/O mode(run on the computer), the motor won't move at all. What other settings should I do?
I have another program that is too large to run on the board, so I want to try I/O mode first in this simple example. Any reply is welcomed. Thank you!

 Accepted Answer

Hi Cong Sun,
Not all the block support connected IO mode.
The blocks that support this IO mode are listed in the following page:
Other blocks which are not listed in this page will output 0s if you try to run in connecte IO mode.
Hope this helps!
Thanks,
Arun

6 Comments

Thank you Arun! this helped me a lot! I think I will try supported blocks. Have a nice day!
Dear Arun
Sorry to ask you again. I read the document and tried to build a pwm control system because PWM block is supported in connected IO mode. When I run in connected IO, the motor did rotate but only for a very very small angle, almost 0. I also ran the entirely same system on board, this time the motor worked well. Do you know why this program behave at different way? Thank you!
Hi Cong Su,
I see that you are using 50Hz frequency for the PWM. Changing of frequency is supported only for code generation and not for the connected I/O mode.
In connected IO mode, you will get the default frequency on the pin.
Could this be causing the issue?
Dear Arun
Thank you for the reply. I'm afraid yes because my servo motor does use 50Hz frequency PWM control. So do you have any idea about how to generate PWM signal with a designated frequency in connected IO mode?
Hi Cong Sun,
Changing of PWM frequency is not supported in Connected IO mode.
Dear Kumar
Thank you for the reply. I think I will try another way. Do you have plan to enrich the functions of Connected IO mode? Have a nice weekend!

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2022a

Asked:

on 24 May 2022

Commented:

on 24 Jun 2022

Community Treasure Hunt

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

Start Hunting!