Control of Stepper motor using Matlab

6 次查看(过去 30 天)
Hello all,
I have written a very simple piece of code, to run my stepper motor using matlab:
clc;
clear all;
dio=digitalio('parallel','lpt1');
addline(dio,0:7,0,'out');
flag = 'ture';
while flag == true
putvalue(dio,[1 0 0 1 0 0 0 0])
flag = input('true/false','s');
end
Since, I don't have parallel port in my laptop, so I will taking help of another pc, if someone can verify that the code will run fine, I would be thankful.
What I am trying to do is to run the code and allow the stepper motor to keep running unless flag is true.

采纳的回答

Alok
Alok 2011-11-2
Done :) with the same

更多回答(1 个)

Walter Roberson
Walter Roberson 2011-11-1
No, in general you are going to run in to problems with that code. You are using 8 output lines on a parallel port. Standard parallel ports only have 5 output lines. If your system happened to have an EPP (Extended Parallel Port) rather than a typical parallel port, then it would be possible to go beyond 5 output lines, but some configuration setup might have to be done to change in to EPP mode.
Are you trying to send [1 0 0 1 0 0 0 0] as a wave-form? If so then what you are doing is the wrong way to proceed. addline() is for using multiple simultaneous I/O wires, not for determining the waveform to be sent over a single wire.
Please be warned that with a parallel port, outputs are not latched: any particular wire is given time to move to its output state, and then a strobe signal is asserted indicating that the state of the wires has settled enough to read. The wires must hold that state for a period to allow time for the strobe to travel to the receiving port, but after the mandated time, the output wires are free to float.
If you are trying to create a voltage pulse signal to provide the motive power for the motor to turn one rotation, then you will likely find that the timing requirements for the pulse to the motor are tighter than can be promised with a parallel port signal. In such a case, usually the minimum you can get away with is a D/A convertor, and it is common for it to be impractical to control bit by bit and to instead need to have a signal generator that you send commands to. Sending commands is the technique used for (e.g.) Arduino.
As you are starting a new project, it is recommended that you avoid using the parallel port unless it is a requirement that you cannot negotiate a change to. Parallel ports will not be supported for digital I/O in future releases. There is a discussion of this over here
  3 个评论
Alok
Alok 2011-11-2
hey walter, today I tried this code on the pc and it just worked fine, with few changes :), thank you for your help...
Walter Roberson
Walter Roberson 2011-11-2
Apologies, I was getting input and output confused. There are only 5 input data pins on a standard parallel port (and none of them were _intended_ for data.)
A simplified output timing diagram can be found at
http://www.beyondlogic.org/spp/parallel.htm#3
"The host then checks to see if the printer is busy. i.e. the busy line should be low. The program then asserts the strobe, waits a minimum of 1uS, and then de-asserts the strobe. Data is normally read by the printer/peripheral on the rising edge of the strobe."

请先登录,再进行评论。

社区

更多回答在  Power Electronics Control

类别

Help CenterFile Exchange 中查找有关 Classical Control Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by