필터 지우기
필터 지우기

PWM signal Simulink on serial port

조회 수: 11 (최근 30일)
Jan De Vries
Jan De Vries 2011년 7월 30일
I need to connect my controller designed in Simulink to a brushless motor controller, which needs a PWM signal. This controller has a PWM connection cable (3 wires)
Is it possible to connect this controller to my PC (using serial port) and let Simulink send control signals to this motor controller?
  댓글 수: 3
Jan De Vries
Jan De Vries 2011년 8월 2일
It runs at 2400BPS, as far as I know
Arnaud Miege
Arnaud Miege 2011년 8월 2일
Normally a PWM signal would be in the region of 100's of kHz, if not MHz.

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

답변 (5개)

Walter Roberson
Walter Roberson 2011년 8월 2일
Simulink is not supported on any system that is old enough to allow direct pin-level control of a system serial port. Unless, that is, you are talking about generating code for a controller: some of those might be able to handle it.

Arnaud Miege
Arnaud Miege 2011년 8월 2일
The Instrument Control Toolbox allows you to send data on the serial port with the Serial Send block. As I said in my comments, I am not sure this will be nearly fast enough for a PWM signal.
Arnaud
  댓글 수: 3
Arnaud Miege
Arnaud Miege 2011년 8월 2일
Agreed. Jan, you need a proper PWM output signal, which means you need something like Real-Time Windows Target or xPC Target, which the appropriate I/O card.
Jan De Vries
Jan De Vries 2011년 8월 2일
Ok, so it's not possible to create a PWM signal using my serial card.
Below I added some more info, can I generate the signal I described using Matlab and a serial/USB port?

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


Jan De Vries
Jan De Vries 2011년 8월 2일
Ok thanks for all your replies!
I want to control a brushless thruster. Because this is a brushless device, it has a special brushless controller connected to it, to convert my control signal to a brushless motor signal.
The brushless controller has a PWM input cable, which can be connected (according to the manual) to a "Parallax Servo Controller". This device can either be connected via USB or serial to a PC. It needs a TTL signal; that is some binary code right? Can I use matlab to send code to this device?
  댓글 수: 4
Jan De Vries
Jan De Vries 2011년 8월 2일
Thanks, Arnaud! I've been asking around a lot lately - and this is by far the most usefull information I received as it made a few concepts more clear to me!
Jan De Vries
Jan De Vries 2011년 8월 2일
And also thanks Walter ofcourse!

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


Jan De Vries
Jan De Vries 2011년 8월 3일
I found some more info about the brushless motor controller (ESC);
The ESC generally accepts a nominal 50 Hz PWM servo input signal whose pulse width varies from 1 ms to 2 ms. When supplied with a 1 ms width pulse at 50 Hz, the ESC responds by turning off the DC motor attached to its output. A 1.5 ms pulse-width input signal results in a 50% duty cycle output signal that drives the motor at approximately half-speed. When presented with 2.0 ms input signal, the motor runs at full speed due to the 100% duty cycle (on constantly) output.
Can I produce these signals using matlab's serial communication (like fwrite() etc)?
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 8월 3일
No; if it can be done directly through MATLAB then it would have to be through analogio(). The serial devices supported by MATLAB's serial() object are intended to be UARTs or emulations thereof, with byte-level output framed with start and stop bits.
The Parallax Servo Controller takes commands about positioning and emits appropriate pulses: that is the way to go in your situation.

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


Jan De Vries
Jan De Vries 2011년 8월 3일
Ok right now I have the following code to send to my PSC:
ser = serial('COM3')
set(ser,'BaudRate',2400, 'Terminator', 'CR')
fopen(ser)
fwrite(ser,[33 83 67 86 69 82 63 13], 'uint8', 'sync')
out = fscanf(ser)
fclose(ser)
delete(ser)
clear ser
I keep getting a warning with the fscanf(ser) command:
Warning: A timeout occurred before the Terminator was reached.
ans =
1.0
Is there something wrong? I used the fwrite command to send the ascii code for the command "VER?", with $SC (33 83 67) being the preamble and CR (13) being the carriage return (so the command line is $SCVER?CR)
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 8월 3일
Arnaud mentioned using !SC as the preamble; that is the same preamble that I found documented.
You should, by the way, be able to use
fprintf(ser, '%s', '!SCVER\n')
which would be more readable. Or
fwrite(ser, sprintf('!SCVER\n'), 'uint8', 'sync')

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

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

Help CenterFile Exchange에서 Pulse width modulation (PWM)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by