Output a square wave with tuneable frequency and phase delay

조회 수: 7 (최근 30일)
Tom
Tom 2013년 4월 8일
I am trying to output two square waves to control a stepper motor. I need to be able to change the phase difference between the two waves to control the direction of the motor and I need to change the frequency of the waves to control the speed. I also need to control the number of cycles to control how far the motor travels.
Please help as I have tried quite a lot of different ways and had no success.
  댓글 수: 1
Jon
Jon 2013년 4월 8일
Are you running a loop in MATLAB that sends its output to some physical i/o, or is it in Simulink. Please clarify

댓글을 달려면 로그인하십시오.

답변 (1개)

Jonathan Epperl
Jonathan Epperl 2013년 4월 8일
Showing us some of your prior attempts would certainly help, since we then could avoid suggesting stuff you already tried.
Anyway, whenever I needed square waves, I used a sine wave together with logical operators, e.g.
f = @(t) (sin(2*pi*t)>0)-(sin(2*pi*t)<=0)
should get you a square wave with frequency 1. Adapt it to your needs.

카테고리

Help CenterFile Exchange에서 Specialized Power Systems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by