lamboom

Ramping function .. Using REPEAT, UNTIL, END_REPEAT

6 posts in this topic

Hi...  This is kinda simple.. but.. methinks I may have a problem using the wrong Data Type with the REPEAT, UNTIL, END_REPEATE function:

I'm trying to create a ramping function at the start of a position stream.  The idea is to start the first point at zero and take 3 seconds to ramp up tp a preset "Percentage" of full amplitude of a changing position curve... Here's the curve in blue:

                  LinMotMovePosition.jpg.4939b1c7dafa876cd

Normally, at first start of this curve, there is a rapid rise from zero ... which is too almost too fast.. I would like to bring the curve into operation, slowly... from zero .. Like a Volume Control .. :-)

Here, I'm trying to use the REPEAT..UNTIL ...END_REPEAT ...   The plan was to start at zero.. then, each CPU cycle add .0001 to "Num" ... and keep doing that until Num is greater than 3.

During this time, Num/3.0 is being used to multiply the position signal.   I'm expecting Num to go from 0.0  to  3.0 in 3000 CPU cycles  ..

                 58b86e019a1a0_RampTime.jpg.2212bc8968819

But... It doesn't .. instead it instantly (or, perhaps takes just a few CPU cycles) jumps to 3.0 :

                         58b86e0584df7_RampTime_002.jpg.70a15ca46

 

Anyone out there know of a better way ro ramp a signal from zero to full in a set time?

Thanks much... Regards, Michael

 

Edited by lamboom

Share this post


Link to post
Share on other sites

Don't use the repeat function.  It is a loop and will do it all in one scan.  Just use an if then statement like this:

H3Q72HtCNy9PAAAAAElFTkSuQmCC

This will add 0.0001 to Num each primary period.  If it is too fast, make 0.0001 smaller.  If it is too slow, make 0.0001 larger.

You could also not have this execute every scan and use a timer to trigger when it adds the amount if you wish for the step to be 0.0001, but need it to go slower. 

When ready to have this execute again, simply move a Real#0.0 into NUM.

Share this post


Link to post
Share on other sites

Michael ...  Ya know,  I really don't want to thank you with just words...  On "Game of Thrones"  John Snow's Wildling girlfriend always said "Words are wind" ...  

There must be a way to show my appreciation ?      Regards, Michael

PS.. Wow.. I didn't know loops do it all in one scan .. that explains a lot!

Edited by lamboom

Share this post


Link to post
Share on other sites

Michael .. You're a wonderful person.  :-)

      58b88f9686d8b_RampTime_003.thumb.jpg.b8c

Thanks!  (words .... sigh)

 

Edited by lamboom
Wrong picture

Share this post


Link to post
Share on other sites

Hi

Michael is bang on about the loop executing in one scan. 

You should also take a look at the Instuction Reference for CTU Count Up instruction. This is a good way to count between cycles, even just trigger on every scan. 

There is also the TON instruction which counts time up to a certain maximum and has the current Elapsed Time as an output. However the output is Time format and imagine you prefer the number from CTU which you can use in formulas, Sin etc

Regards

BB

Share this post


Link to post
Share on other sites

Berti -Thanks for the reply.  That picture was placed by mistake.. it showed the same thing that was at the top of this thread, plus the math for generating the sine summation in the large picture of the IF-THEN working to help "ramp" the start-up ...   The math was created by innoaloe, on another thread.    

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now