PWM signal Simulink on serial port
Mostrar comentarios más antiguos
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 comentarios
Arnaud Miege
el 1 de Ag. de 2011
I doubt a serial connection will provide you with the bandwidth required for a PWM signal. I suspect you need a real-time operation. What frequency is your controller running at?
Jan De Vries
el 2 de Ag. de 2011
Arnaud Miege
el 2 de Ag. de 2011
Normally a PWM signal would be in the region of 100's of kHz, if not MHz.
Respuestas (5)
Walter Roberson
el 2 de Ag. de 2011
0 votos
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
el 2 de Ag. de 2011
0 votos
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 comentarios
Walter Roberson
el 2 de Ag. de 2011
PWM is not binary data: the width of each pulse needs to be individually controlled. That isn't going to happen with a standard serial port, which is going to want to send out pulses at a particular baud rate and is going to want to add a start bit and to impose the stop bit semantics.
Arnaud Miege
el 2 de Ag. de 2011
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
el 2 de Ag. de 2011
Jan De Vries
el 2 de Ag. de 2011
0 votos
4 comentarios
Arnaud Miege
el 2 de Ag. de 2011
Yes, I believe the Serial Send block I suggested should work for this. Make sure to add the correct header and terminator. Looking at http://www.crustcrawler.com/downloads/manuals/ServoController.pdf (p.3, Serial Command Format), it looks like you need '!SC' as a header and CR as a terminator.
Walter Roberson
el 2 de Ag. de 2011
RS232 ports such as are normally found on PCs are *not* TTL level. RS232 signals with both positive and negative voltages; TTL uses only positive voltages and is not tolerant of negative voltages.
You can get USB to TTL converter cables, such as at http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm
USB, unless specially programmed, has a lower limit of 40 ms latency and an upper limit of 125 KHz.
TTL is not a binary code: it is a signalling standard for how to represent logic levels. If I recall correctly, TTL _is_ allowed to hold signals for varying times, but it is also not uncommon for it to be used to transmit binary data.
When I reflect about how USB works and reflect on how the USB to TTL converter cables must work, it seems unlikely to me that a USB to TTL cable would be able to represent pulses of varying widths.
Reading the documentation for the Parallax Servo Controller, I see that Yes, TTL level is required for the "RS232" communications to the controller. This is the communications that starts at 2400 bps. It is, however, in the form of commands, with the commands instructing the controller what signals to send and for how long, so the communications to the PC does *not* need to be concerned about individual pulses. Or at least if you are using the BOE (Board of Education) board. Unfortunately there are parts of the documentation that are not clear to me.
Jan De Vries
el 2 de Ag. de 2011
Jan De Vries
el 2 de Ag. de 2011
Jan De Vries
el 3 de Ag. de 2011
0 votos
1 comentario
Walter Roberson
el 3 de Ag. de 2011
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
el 3 de Ag. de 2011
1 comentario
Walter Roberson
el 3 de Ag. de 2011
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')
Comunidades de usuarios
Más respuestas en Power Electronics Control
Categorías
Más información sobre Arduino Hardware en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!