Anyone familiar with Matlab + Simulink?

JohnCU

Banned
Dec 9, 2000
16,528
4
0
We built a... robot-type machine with 2 degrees of freedom to move a marble through a maze for our design project (it can move in the x-direction or y-direction).

I have encoders on both motors and my program is set up so that I can input a step function, with the amplitude being the numbers of degrees I want the motor to turn, which moves the marble, etc. I coded a PID controller to provide feedback so that the mover stops (after some small transient) when it reaches the point that it needs to be.

However, right now, all my actions are based on time. If I move, say, 10 inches to the right, and then I need to move up immediately 2 inches (the mover competes with other movers by how fast it can traverse the maze), I have to input 1 step of 10 inches, then measure that time, then input another step when that one finishes to push it up. My program is basically a bunch of steps offset from each other by times that I've estimated. Not exactly precise. Right, Up, Left, Up, Right, Up, etc...

This is fairly tedious, and not very flexible. If I could find a way to make my own code that tells the mover to advance to the next position only after the previous position has been settled (+/- 5%?) then I could make it faster by simply adjusting the gain of my amplifier.

The code would be incredibly simple in C, but so far no one knows how to get this to work in Simulink using Matlab.
 

bobsmith1492

Diamond Member
Feb 21, 2004
3,875
3
81
Is Simulink a separate program from Matlab, or is it just the name of the company? I've used Matlab but don't know about Simulink...

Do you have some way of getting data into Matlab from your encoder? Have you used Matlab before, or are you looking for someone with REALLY in-depth knowledge and experience with it? I couldn't help you there, but with some of the basics, maybe...
 

jmcoreymv

Diamond Member
Oct 9, 1999
4,264
0
0
I'm not sure I can help you with your specific question, but I've used Simulink before. If you are new to it, you should expect to spend a lot of time debugging stuff because it is VERY picky about how stuff is connected up. In fact, when I used Simulink for my thesis, I spent more time trying to get the stupid blocks to work together than I actually spent implementing the real system.
 

coolingoff

Member
Aug 6, 2006
40
0
0
Simulni is like an additional package to Matlab.

"If I could find a way to make my own code that tells the mover to advance to the next position only after the previous position has been settled (+/- 5%?)"
How about using an additional input from the 'outside world', like a mition sensor which can detect the displacement. You can build a mini-sub system with that, which can tell
your main program when the motion is complete.
 

tex1138

Junior Member
Apr 5, 2005
11
0
0
Having only used Simulink once, I can't give you an exact answer, but here's another thought for you to consider....

Presumably the output of your control loop is the error signal, i.e. the difference between the desired condition and the actual condition. How about if you compare the error signal to zero with an appropriate amount of margin; simultaneously, you differentiate the signal and compare the derivative to zero with an appropriate amount of margin. This second condition makes sure that you don't call the action "done" too quickly if your system is underdamped and it shoots right past the desired end point.

I'm imagining that your sequence of steps (right, up, right, etc.) could be an array that is input into the control loop sequentially, since the end conditions would be the same in every case. If you find that it's taking too long to settle, then you have some tuning to do on your P, I, and D :)