Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need advice for using simulink for control of basic system

Status
Not open for further replies.

Bruit

Computer
Oct 14, 2010
7
US
Hello,
I have been told that simulink is a fairly good and easy way to design control systems.

What I'm trying to do should be very easy. I have a very simple system that I already have code to handle outputs and inputs to the physical equipment. The system consists of sensors, etc which have either an on or an off function.
What I want to do is be able to use simulink to control this system. It would be simple things like if sensor 1 is on, turn on motor 1. if sensor 2 is on do this, etc.

Everything I have found is more complex than what I need (involving transfer functions, various equations and so on).
If anyone could point me in the right direction as to what to look, read, or whatever, it would be much appreciated.
 
Replies continue below

Recommended for you

To be more specific, I need to continuously track several variables and respond to changes in them. I believe this may be a state space but everything I find assumes prior knowledge of control systems (which I do not have) and does not explain what various models and terms mean.

So what I want to do is something along the lines of:
if (x == 1 and y == 0){ //arbitrary condition
output1 = 1; //turn on something
}
if(some condition){
}
if(some other condition){
}

The inputs from sensors would be checked every 0.1 second and compared against these conditions.
 
It is not state space. It sounds like you need Stateflow, which is a Simulink package for state transition functions.

xnuke
"Live and act within the limit of your knowledge and keep expanding it to the limit of your life." Ayn Rand, Atlas Shrugged.
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
You can do all of that with an embedded function in Simulink.
Just requires that you know how to program in m-code.

You can even extract the states from a DE sing an S-function.

For example: your
"if (x == 1 and y == 0){ //arbitrary condition
output1 = 1; //turn on something
"
can be written almost exactly as it is in the embedded function. The 'x' and 'y' can be inputs to the function.

[peace]
Fe
 
@xnuke
Thanks a lot. I'll look into it.

@FeX32
That is true. However, I need some way to control how often and how long it takes for each sampling rate. My reason (hopefully not misguided) for looking into Simulink is to do just that.
e.g. the input needs to be read every x seconds, and should not take longer than x seconds to sample again. So other computations cannot delay the time to update the inputs.
 
You can change the "sampling rate" or solver tolerance in the Configuration Settings.
Click fixed time step and choose a time step 'x' that you are referring to.

[peace]
Fe
 
Simulink is not inherently parallel, therefore there is some danger that a simple program will experience timing conflicts.

However there are toolboxes available for all sorts of things, and blocks for sample and hold, for example.



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
@xnuke: Stateflow is exactly what I needed. Many thanks. You wouldn't believe how much time I wasted reading about simulink and its various features without ever coming across mention of stateflow.

Everyone else: thank you as well.

Yeah, simulink isn't exactly parallel, however I'm pretty sure what it does is good enough for my purposes. Right now I just want to get it to work (Having problems loading C++ dll's). I'll keep the sample and hold blocks in mind and look into it once I figure out what I'm doing wrong.
 
Seems to be a bit of an overkill, isn't it? From your description, you are looking for a finite state machine, or a giant CASE statement.

You might want to look at Labview, or something similar, since that's what Labview is actually designed for.

TTFN

FAQ731-376
 
Labview looks pretty cool.
Trust me, I wouldn't be using MATLAB if I had a choice. Unfortunately, I'm writing this for someone who wants it in MATLAB so that he can integrate it with his MATLAB programs for statistical data analysis. Although, I'm starting to wonder if that's necessary...
 
I don't know for sure, but my understanding is that Matlab can be integrated with Labview.

TTFN

FAQ731-376
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top