Hello !
Under simulink I need to build a clock which does the following.
It goes linearly from 0 to 720 and when reaching, it gets the value 0 and start again. How can I build this with the blocks in SIMULINK ? I have really no idea.
If a function "reset clock" exist, that would be great, otherwise I have no idea.
Thanks in advance for your help ! :-)
Matt.
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
4/25/2012 7:12:07 PM |
|
"Matt " <mathieu.horsky@gmail.com> wrote in message
news:jn9ia7$32t$1@newscl01ah.mathworks.com...
> Hello !
>
> Under simulink I need to build a clock which does the following.
>
> It goes linearly from 0 to 720 and when reaching, it gets the value 0 and
> start again. How can I build this with the blocks in SIMULINK ? I have
> really no idea.
>
> If a function "reset clock" exist, that would be great, otherwise I have
> no idea.
>
> Thanks in advance for your help ! :-)
Take a look at the Math Function block's Mod option.
--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
|
|
0
|
|
|
|
Reply
|
slord (13267)
|
4/25/2012 7:27:35 PM
|
|
Thank you for your answer !
Following your advice, I came across this thread :
http://www.mathworks.com/matlabcentral/newsreader/view_thread/44275
Problem is that I need to have ratio set at 1 and by doing this, there is a divide by 0 problem so I cannot use that function. Triangular wave can be built using Taylor Dev' but I don't know how can I put that in a Simulink file !
Surely someone already had to do such thing :-)
Matt.
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
4/25/2012 7:47:07 PM
|
|
"Matt " <mathieu.horsky@gmail.com> wrote in message
news:jn9kbr$cgp$1@newscl01ah.mathworks.com...
> Thank you for your answer !
>
> Following your advice, I came across this thread :
>
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/44275
>
> Problem is that I need to have ratio set at 1 and by doing this, there is
> a divide by 0 problem so I cannot use that function. Triangular wave can
> be built using Taylor Dev' but I don't know how can I put that in a
> Simulink file !
>
> Surely someone already had to do such thing :-)
Try these in MATLAB:
x1 = 715:725;
[x1; mod(x1, 721)]
x2 = 719:(1/8):721;
[x2; mod(x2, 720)]
You can mimic this code using the block I mentioned.
--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
|
|
0
|
|
|
|
Reply
|
slord (13267)
|
4/25/2012 9:20:27 PM
|
|
Yes it is exactly what I have to do, now I'm gonna figure out how to use this with SIMULINK blocks ! :-)
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
4/25/2012 9:35:17 PM
|
|
This is what the Limited Counter block does:
http://www.mathworks.com/help/toolbox/simulink/slref/counterlimited.html
Phil.
|
|
0
|
|
|
|
Reply
|
phil986 (300)
|
4/25/2012 11:02:39 PM
|
|
Hmmm I didn't find something useful in there I'm afraid. But I did experiments and using the following SIMULINK blocks :
http://img208.imageshack.us/img208/9899/block1k.jpg
I'm getting the following result :
http://img191.imageshack.us/img191/1050/block2d.jpg
My questions now are :
1) How can I make the vertical drop from 720 to 0 a REAL vertical line ?
2) How can I choose when the drop happens ?
Thanks a lot in advance ! :-)
Matt.
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
4/26/2012 12:24:12 PM
|
|
The limited counter gives discrete steps.
If you want a ramp then use the following:
1. An Integrator, set to Show State Port, and be resettable at an external rising edge.
2. A Constant of 1 fed into the integrator input.
3. A Compare To Constant set to > 720, with a boolean output, and zero crossing detection on.
4. Feed the output of the integrator stateport (the one coming out of the top of the integrator) into the input of the Compare To Constant.
5. Feed the output of Compare To Constant into the integrator's reset port.
The output of the integrator is then what you want.
Phil.
|
|
0
|
|
|
|
Reply
|
phil986 (300)
|
4/26/2012 2:55:12 PM
|
|
Fantastic Phil this is exactly what I need ! Do you know how can I change the frequency of the signal (aka being able to chose when it goes to 0 rather than having it set to 720) ? :-)
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
4/26/2012 3:34:13 PM
|
|
The ramp/integrator will reset anytime the reset signal rises.
You can use any logic you want to create that signal.
Comparing to a constant (as with 720 in this case) is only one of an infinite number of possibilities.
Phil.
|
|
0
|
|
|
|
Reply
|
phil986 (300)
|
4/26/2012 5:10:12 PM
|
|
Thank you Phil I got it now ! Many thanks ! :-D
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
4/26/2012 7:04:30 PM
|
|
Sorry for bringing this back up but following the problem of the timer which has now been solved, I'm facing another problem related to this issue.
I'm using a lookup dynamic table to simulate a camshaft, but the output values are not correct. Here is the schema :
http://img708.imageshack.us/img708/3840/aacw.jpg
I'm resetting the signal every 360 (which is 360°), and the xdat and ydat values are :
xdat (camshaft angle) : [0 50 100 200 250 360]
ydat (valve lift) : [0 0 4 4 0 0]
But as you can see below, the output is not correct, it seems there is an offset :
http://img441.imageshack.us/img441/5050/aac2.jpg
I don't know what's the problem, any help would be welcome ! :-)
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
4/27/2012 8:46:07 AM
|
|
I can't get a model that looks like this,
> http://img708.imageshack.us/img708/3840/aacw.jpg
to give anything other than the expected x-y plot (i.e. rising from 0 at x=50 and falling to 0 at x=250).
What changes have you made to the solver, any sample rates, and the stop time of the model?
What's the value of the conversion constant?
Phil.
|
|
0
|
|
|
|
Reply
|
phil986 (300)
|
4/27/2012 1:35:21 PM
|
|
Indeed Phil you were right, I had set a timestep and it was too big compared to the simulation time ! Now everything is sloved, I thank you again once again for your interest in my case ! :-)
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
4/27/2012 2:49:07 PM
|
|
On Apr 27, 4:49=A0pm, "Matt " <mathieu.hor...@gmail.com> wrote:
> Indeed Phil you were right, I had set a timestep and it was too big compa=
red to the simulation time ! Now everything is sloved, I thank you again on=
ce again for your interest in my case ! :-)
Many thanks for Matt and Phil for discussing this topic. I found
something very useful for my project.
Hoang.
|
|
0
|
|
|
|
Reply
|
hoangpham8182 (1)
|
5/18/2012 8:27:27 AM
|
|
My problem isn't totally solved. I had a closer look at the block system I did, following Phil's advice, and I must say it isn't exactly doing what it should be. Here is the the block schema :
http://img339.imageshack.us/img339/5820/7201d.jpg
Normally the scope should show the signal going up to 720, down to 0, and up again. Problem is that it doesn't go up to 720 :
http://img684.imageshack.us/img684/3784/7202k.jpg
Could anybody let me know what the problem is ? Also if there is another solution than using integrator to do this job, I would be really happy because I'm afraid the integration method may compromise some operation I may have to do later on.
Thanks a lot ! :-)
Matt.
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
6/13/2012 7:17:10 AM
|
|
"Matt" wrote in message <jr9epm$b4d$1@newscl01ah.mathworks.com>...
> My problem isn't totally solved. I had a closer look at the block system I did, following Phil's advice, and I must say it isn't exactly doing what it should be. Here is the the block schema :
>
> http://img339.imageshack.us/img339/5820/7201d.jpg
>
> Normally the scope should show the signal going up to 720, down to 0, and up again. Problem is that it doesn't go up to 720 :
>
> http://img684.imageshack.us/img684/3784/7202k.jpg
>
> Could anybody let me know what the problem is ? Also if there is another solution than using integrator to do this job, I would be really happy because I'm afraid the integration method may compromise some operation I may have to do later on.
>
> Thanks a lot ! :-)
>
> Matt.
I know it has been only 1 day, but I am stuck in this project, so any help is warmly welcome ! :-)
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
6/13/2012 8:29:07 PM
|
|
Creating the given model from scratch gives without changing any default settings gives a hit at exactly 720.
What solver are you using?
Have you made any changes to any of the block default settings?
What sort of issues are you expecting the integrator to give you in other arts of your model?
Phil.
|
|
0
|
|
|
|
Reply
|
phil986 (300)
|
6/14/2012 3:26:07 AM
|
|
"Phil Goddard" <phil@goddardconsulting.ca> wrote in message <jrblkf$9ki$1@newscl01ah.mathworks.com>...
> Creating the given model from scratch gives without changing any default settings gives a hit at exactly 720.
>
> What solver are you using?
> Have you made any changes to any of the block default settings?
>
> What sort of issues are you expecting the integrator to give you in other arts of your model?
>
> Phil.
I found that the issue was a too big time step (despite time step being already set to 0.0001 !). But reducing the time step size (using "ode3" solver) is increasing the simulation time by quite some margin. Is there another way to achieve this 0-720-0-720... function without the use of integrator ? :-)
|
|
0
|
|
|
|
Reply
|
mathieu.horsky (76)
|
6/14/2012 7:07:07 PM
|
|
This is a solver selection issue -- with a fixed step solver (ode3 for instance) you are never going to get a vertical line.
The peak will be one time period before 720 would nominally be reached and this will slope (very steeply) down to 0 at the time where you are wanting 720 to be reached.
It doesn't matter how you implement it -- using an integrator or any other way -- you cannot get around that that is the way a fixed step solver works.
On the other hand, with a variable step solver you will get a time step epsilon before the time and another epsilon after the time giving the impression of a vertical line.
Phil.
|
|
0
|
|
|
|
Reply
|
phil986 (300)
|
6/17/2012 4:06:07 AM
|
|
|
19 Replies
34 Views
(page loaded in 0.305 seconds)
Similiar Articles: ntpd, boot time, and hot plugging - comp.protocols.time.ntp ...... file and let it start all over again? >> >> Does this afect the time for ... 83.509 -0.371 0.725 -[name] .GPS. 1 u 720 ... that could make it go from 0 ... Reference to non-existent field 'axes1' - comp.soft-sys.matlab ...As it goes along, it >> plots the closest match ... except when I stop the scan and then >> start it up again. ... Hold Function On Simulink (for graph) - comp.soft-sys ... Converting from Y-m-d h:m:s - comp.protocols.time.ntp... give me proper time if I am to be compared to other system Thanks again ... days, y100; /* Start by setting March = month zero ... most calculation time in my Simulink ... time reset, syncronisation lost and Large PPM values - comp ...... Oct 19 17:37:36 srv3 ntpd[19356]: time reset 0 ... then running hwclock will create it again ... Leap second bug? - comp.protocols.time.ntp... sec freq -6.720 ppm error 0 ... Error while evaluating TimerFCN for timer 'timer-1' - comp.soft ...... stack) to the code to give me something more to go upon ... ExecutionMode', 'fixedSpacing', 'Period', 2.0); disp 'Starting the timer' start(T ... create excel plot with MATLAB? - comp.soft-sys.matlab... appropriate files, and analyzes them all one at a time ... on %% eCO.Chart.ChartType = 65; % view it again ... So I would need the following in a loop: start ... A problem with performance - comp.graphics.api.opengl2) Are you building new display lists every time ... com> wrote in message news:45d766b0$0$8741 ... context, I have problems, so I will have to start from ground level and go ... Reading packets into a buffer - comp.os.linux.networking ...... the results back to CPU, then repeat the process again by ... Hand the second buffer to the GPU and go back to libpcap ... what I tried: buffer = [for i in range(23)]; buffer[0:5 ... OpenGL SDK for windows - comp.graphics.api.opengl... under linux and when i want to make a release i go ... It took me too some time to start realizing how OpenGL worked ... graphics.api.opengl... sp4, I'm using Visual C++ 7.0 ... Size of "Hello world" - comp.lang.c++> > > > > - Alf (wondering) At that time you can ... To go further (if your platform supports ... In 32-bit Windows that went up to 720 bytes. In 64-bit Windows, it's risen again ... .g64 images - comp.sys.cbm... as much as possible, I would like to go for ... With the ZipCode Collection V2.0 ... would lose some enormous amounts of time and energy before it would start to work. Modelling chains - comp.cad.solidworksLets go for the fence. So now, edit the sketch again and add a single fitspline to ... with just the sketch before burning time ... soft-sys.matlab Convert M file to Simulink ... What is quadrature sampling - comp.dspAt the transmitting end, you start with a pair of bits ... When the measurements are spread uniformly in time and ... OK, again without being overly pedantic what do you ... Neural network using matlab - comp.ai.neural-netsGo to Google Groups and search on greg-heath ... For a baseline start with design linear and logistic I-O ... the naive constant classifier y = mean(t')' = [0.75; 0 ... problem with mixed c and fortran code - comp.lang.fortran ...} Notice that since this goes back to F77 where there ... are good: if we always agreed from the start there ... to have its length > known at compile time. Again, I don't ... Clock that goes from 0 to 720 and start again (... - Newsreader ...Thread Subject: Clock that goes from 0 to 720 and start again (SIMULINK) Usenet replayers subject overview of "comp.soft-sys.matlab"Clock that goes from 0 to 720 and start again (SIMULINK) Multiple x axes for same y axis in scatter plot ; Solving a 2D ODE with boundary conditions using hermite-spline ... 7/25/2012 11:39:19 PM
|