Generate PWM signal through Parallel port

7 views (last 30 days)
Hello, I'd like to control an IGBT inverter trougth a parallel port. I used a Simulink model that I generated a PWM signal with a carrier frequency equals 20kHz. But when I measured that signal at the LPT1 port I found that its frequency doesn’t exceed 600Hz and as information; the switching frequency of the LPT1 is upper than 5MHz. Please help me to solve this problem!
Best regards,

Answers (2)

Fangjun Jiang
Fangjun Jiang on 8 Dec 2011
I have doubt about the feasibility that you can use Simulink and parallel port to generate a 20kHz PWM signal in real time. But let's take a quick shot to answer your question why you can only see up to 600Hz.
What is the time step of your simulation? The period of a 20kHz signal is 50 us. Within the 50 us period, if you want to be able to adjust the duty cycle of the PWM from 1% to 100% with incremental resolution of 1%, then you need a simulation step time of 0.5us. Did you set the simulation time step no larger than 0.5 us? Will your model be able to finish execution within 0.5 us?
My fair warning:
Don't try to use this to control the IGBT converter. Most likely, it will cause the IGBT chip or board to burn.

Walter Roberson
Walter Roberson on 9 Dec 2011
(A posting that is useful as background on the mechanism of writing to parallel ports: http://www.mathworks.com/matlabcentral/answers/22387-leds-and-speakers-controlled-with-matlab)
It does not surprise me that you were only able to reach 600 Hz frequency with the parallel port.
For one thing, parallel ports default to SPP mode -- the oldest signaling and rates available. MATLAB does not provide a mechanism to configure to other modes.
More of a problem is that MS Windows from NT on upwards has actively shielded parallel ports (and any direct hardware access in general, but more so for anything that uses IN/OUT instructions like parallel ports do) behind multiple layers of security, increasingly so in newer Windows versions. The layers of security mean slower access.
MathWorks has had a heck of a time trying to work around those security layers, and has already indicated that support for parallel ports will be withdrawn within a small number of releases because of the difficulties.
It is not recommended that any new projects be created using the parallel port, especially not for time-sensitive uses. Using a D/A converter is recommended instead.
You mention that you are using PWM, and you mention using a carrier frequency of 20 KHz. Does that indicate that your PWM pulses are only modified in integral multiples of 1/20000 seconds?
If you are attempting active pulse manipulation at the individual sample up to 20 kHz, you will not be able to achieve that within MATLAB. The maximum theoretical manipulation rate supported by any MATLAB toolbox is 5000 transfers per second, and very few people have been able to get above 2000 transfers per second; 1000 transfers per second is common. See http://www.mathworks.com/matlabcentral/answers/21974-event-triggered-square-wave
  3 Comments
Walter Roberson
Walter Roberson on 9 Dec 2011
A "transfer" in these terms is transferring a group of data associated with a single trigger. It could be multiple samples on the same channel, or it could be multiple channels at the same time, or it could be multiple time-points over multiple channels. The setup of the data transfer has much more effect than the amount of data transferred. I did not want to say "5000 samples per second" because multiple samples can be returned per transfer.
In response to your question, I looked back and tried to find the source of the 5000 number I have been quoting, and to ensure that I was correct about it being ICT (Instrument Control Toolbox) and to ensure that the number really is "interrupts". I did find that I have been using that number since February, but I cannot at this time find the original information that I based that on :(
My recollection is that I had been following the general topic in the newsgroup, but to the best of my memory, the 5000 was an update on that subject, posted by a MathWorks employee, and was given here in Answers. I think the message may have used "5k" instead of "5000", but that is probably moot as I cannot seem to find it again.
The perils of old age. (The perils of Questions getting deleted.)
Sigh.
Fangjun Jiang
Fangjun Jiang on 9 Dec 2011
I've done some work a while back using Windows 95. It's a C language S-Function for Simulink. It reads the clock or timer on the mother board and then set high/low of a digital outport. I don't remember exactly but my impression is that it is able to read the time difference in micro-seconds (us). This is consistent with the information in one of your links regarding Windows NT. But it's not stable. Sometimes it was delayed by some Windows background process. That is how I learned that you can't really use Windows for real-time control.
However, for "transfer rate", I would argue that it can be much faster than 5000 per second. I would think I can set the digital output to be high, after 25us, set it to be low, and after 25us, set it to be high again. So it will be a 20kHz square wave. Of course, this is not guaranteed. And if you want to make the "high" last from 0.5us to 50us (thus 1% to 100% duty cycle PWM), it will be much harder or impossible. Don't even try to use this to control the IGBT converter. Most likely, it will cause the IGBT chip or board to burn.

Sign in to comment.

Communities

More Answers in the  Power Electronics Control

Community Treasure Hunt

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

Start Hunting!