Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Mathematics
General TopicsResearchOperations ResearchStatisticsMathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Math
Math Software
MapleMathematicaMATLABScilabSASSPSS

Math Forum / Math Software / MATLAB / July 2008



Tip: Looking for answers? Try searching our database.

RTW doubt n simulation time problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Trupti Ranka - 21 Jul 2008 08:18 GMT
Hi,

I have made a simple DC motor model in simulink with current
and velocity loop. The position output is converted into 17
bits and is sent serially to one pin of parallel port.

Now I want to make this simulation in real time so I started
reading documentation of RTW. After reading first few pages
I get a picture that it requires a host PC and a target PC.
The host PC will have Matlab which will generate a code for
target PC. Then the target PC will run it in real time. Am I
right?
But I just want the simulation to run in realtime on my
current PC having MATLAB. I don't have any target PC. Can I
do this using RTW?

Also the other problem I am facing is that the simulation is
very slow. The DC motor model and loops are fast but
converting position output to 17 bits and send them serially
to parallel port seems to take a lot of time. This ia how I
do it:
1) send the postion value to sample and hold block.
2) use a quantizer block and send the output to integer to
binary conversion block.
3) The 17 bits are send to embbeded matlab function block.
here I have written a long switch function which sends out
one bit at each clock pulse. After all 17 bits have been
sent a pulse is sent to sample and hold block to take the
next sample.

The quantizer, integer to binary converter and embebbed
matlab function are in a triggered subsystem. While he
sample and hold block is outside the triggered subsystem so
I have to use data read write and store blocks to send pulse
to sample and hold (Direct feedback to sample and hold from
triggered subsystem gives an error)

My question is: Is there a faster and better way to do this?

Thanks
Trupti
Guoliang Zhang - 21 Jul 2008 19:45 GMT
Do you want your DC motor model to run in real time or the whole simulation
(DC motor + controller) ? If you are building a so-called
H(ardware)-I(n)-(the)-L(oop) simulator out of the motor, you might want to
try xPC or real-time Windows option. The xPC requires a Target pc as you
mentioned; the real-time windows uses your current pc as "target".

hth

GZ

> Hi,
>
[quoted text clipped - 37 lines]
> Thanks
> Trupti
Trupti Ranka - 22 Jul 2008 05:19 GMT
Thanks..
I want to use the whole simulation in runtime (DC motor+
controller + encoder which has turned out to be a big block)
Trupti

"Guoliang Zhang" <zhangl@mathworks.com> wrote in message
<g62lfu$4cs$1@fred.mathworks.com>...
> Do you want your DC motor model to run in real time or the whole simulation
> (DC motor + controller) ? If you are building a so-called
[quoted text clipped - 47 lines]
> > Thanks
> > Trupti
Trupti Ranka - 22 Jul 2008 08:27 GMT
Sorry for mispelling: I want to run the whole simulation in
realtime and not runtime.
Trupti
Ankit Desai - 22 Jul 2008 14:43 GMT
"Trupti Ranka" <trupti_ranka@yahoo.com> wrote in message
<g64245$knj$1@fred.mathworks.com>...
> Sorry for mispelling: I want to run the whole simulation in
> realtime and not runtime.
> Trupti

Hi Trupti,

Sorry if I am confusing things further, but if you want to
communicate with an instrument/device via a serial port,
TCPIP or UDP you can try using Simulink blocks that come
along with Instrument Control Toolbox.

However this won't work if your goal is to just simulate and
not communicate with an external device.

-Ankit
Guoliang Zhang - 22 Jul 2008 17:24 GMT
Then i would suggest trying out the real-time windows target (a toolbox) for
your described problem.

but depending on how your model is constructed (complexity), the simulation
may or may not be able to run in real-time.

hth
GZ

> Thanks..
> I want to use the whole simulation in runtime (DC motor+
[quoted text clipped - 58 lines]
>> > Thanks
>> > Trupti
Trupti Ranka - 23 Jul 2008 05:56 GMT
I checked the RT block by Leonardo Daga. Using this you can
run a fast simulation in real time but not a slow
simulation. Is this true even with realtime workshop toolbox
of Matlab? i.e. a faster simulation can be slowed to
realtime but a slower simulation cannot be sped up to
realtime. If this is the case then I will have to work on
making my simulation faster.

Okay I will give more detials of my work. We are working on
servo modeling of an antenna. The present servo computer to
control the antenna is very outdated so we want to upgrade
it to PC104. Instead of testing PC104 directly on antenna we
are thinking of testing it first on antenna simulation on
MATLAB.

The current and velocity loops for antenna are there in
hardware  (electronic cards) but the position loop is there
in software (PC104). So my task is to simulate the anntena,
current and velocity loops in matlab. The postion output
will be given to PC104 which will complete the position
loop. As we are not working on actual anntena we don't have
encoder so I will have to simulate that also in Matlab.

At present instead of whole anntena we are only considering
only the motor with the loops and encoder simulation. This
itself is becoming very slow for required clock frequency of
encoder (about 15KHz). With the whole anntena model the
things become infinitely slow!!

Also we are not using TCP/UDP or any such communication protocol

"Guoliang Zhang" <zhangl@mathworks.com> wrote in message
<g651j7$afr$1@fred.mathworks.com>...
> Then i would suggest trying out the real-time windows target (a toolbox) for
> your described problem.
[quoted text clipped - 4 lines]
> hth
> GZ
Guoliang Zhang - 23 Jul 2008 20:42 GMT
The type of simulation you've described is called Hardware-in-the-Loop
simulation: running a model that describes the physical system in realtime
and test out the controller hardware.

what RTW is capable of doing is to generate C code that describes your
system to be modeled. Other add-ons from Mathworks (including xPC, real-time
windows) or third-party vendor tools (OPalRT, dspace) provide solutions
(hardware+software) to compile, download and run the RTW generated code onto
certain real time target  (PC, special hw, os etc.) and provides
digital/Analog IO to interact with the controller circuit. These are
different solutions that are priced differently with different capabilities
and performance. If you decide to stick with RTW and matlab, you can start
with xPC, which might be the best cost/performance for a starter project
like what you are doing.

just my 2 cents

GZ

>I checked the RT block by Leonardo Daga. Using this you can
> run a fast simulation in real time but not a slow
[quoted text clipped - 39 lines]
>> hth
>> GZ
Trupti Ranka - 24 Jul 2008 07:51 GMT
Thanks

"Guoliang Zhang" <zhangl@mathworks.com> wrote in message
<g681jj$gj0$1@fred.mathworks.com>...
> The type of simulation you've described is called Hardware-in-the-Loop
> simulation: running a model that describes the physical system in realtime
[quoted text clipped - 14 lines]
>
> GZ
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.