Followers 0

# Rounding in Ramp function geenerator

## 14 posts in this topic

I already wrote a code for a ramping function in Step 7 but how would you round the corners between the ramp and the lower OR upper limits? Any suggestion is highly appreciated.

##### Share on other sites
Boltzmann Equation = 100 + (100/(1 + exp((V - X)/Slope))) V=midpoint of curve Change the value of the slope to change the response of the curve. I'd attatch a .xls file with examples, but I guess these types aren't allowed. Send me your email addy and I'll send it to you.

##### Share on other sites
Lobotomi, I believe you can attach anything if you first zip it. It would be interesting for everyone to see it.

##### Share on other sites
Thanks, I actually realized how dumb I was on the drive home. Hopefully everything you'll need is here. It's basically an equation to generate an "S" curve. I'm not sure this is what you're looking for. Boltzmann.zip

##### Share on other sites
Boltzmann Equation = 100 + (100/(1 + exp((V - X)/Slope))) Thanks for the xls file, Lobotomi. Unfortunately, my math isn't up to it. I understand the basic exp function. It's e raised to the power of the argument. To quote a source: 'e' is the base of the natural system of logarithms, or approximately 2.718282. But I also know that you need to get fancy when doing a complex exp such as you have given. How does one calculate such a complex exp() in a plc when no such handy command is available? Any chance you could show the steps (as in "Hi, I'm your Grandmother. Would you like milk with that?"). I don't mean real code, just a quick explain en Englaise. Jim Rowell

##### Share on other sites
Jim, you call it complex math ? And hard to implement in PLC you use ? Well, start useing more inteligent PLCs. I think Bobby shouldn't have problems with implementing this equation in Step 7.

##### Share on other sites
LOL! I didn't mean complex as in difficult. Complex meaning more than 2 arguments. Simple meaning one argument. Even the handy scientific calculator sitting on my desk will only perform exp() with a single argument. It gives incorrect results with 2 or more args. My math is not great but I do manage quite well thankyou. I'm sure if someone was to show me how to do it, I would agree that it's quite "simple" to perform. How about it Jacedk? Do you know? Or are you relying on Step 7?

##### Share on other sites
Gentlemen please!! I've personally never used that equation in a PLC. It was something that we were researching for a motion application in which we later implemented a motion controller that handled the curves internally. Here's one that works without exponents. Without_Exponents.zip Edited by Labotomi

##### Share on other sites
Sheesh! Talk about being led astray!!! :*-( When I could not get it to compute on my calculator with more than a single argument, I asked 4 different engineers about it. Three of them had no clue whatsoever (blank stares). The fourth indicated that you had to perform it differently when using multiple arguments but he could not remember the details. At that point, I posted here for help. I wish I'd first tried my next step which was to simply use a different calculator! Now it works no problem at all. With or without multiple arguments and with or without even using the exp function itself!!! So what was the problem? The friggin #\$%! calculator was faulty. Examples: 2+2 = 4; 2+2.6 = 4.6; 2+2.5 = overflow. Whoever heard of a calculator being wrong? Is nothing sacred? I feel violated. <grin> Anyway, sorry for the confusion & thanks to Lobotomi for the file. For those who want to use the equation without having access to the exp function, it's basically 2.718282 raised to the power of the argument. Piece of cake. Jim Rowell

##### Share on other sites
Dear Jim, Here you have answer how to do it without Step7 built-in functions (or calculator): exp(x)=1+x+(x^2)/2!+(x^3)/3!+... (that's Taylor series for real numbers). If you are also interested in exp(x), where x is a complex number, just let me know. And to make you feel better - I don't know this equation by heart but I know that it exists and where to find it. BTW, best wishes to the engineers you'd asked

##### Share on other sites
Thankyou Jacekd. That was the kind of answer I was hoping for. A quick net search failed to yield that (maybe too quick). I'll do some compares of the Taylor series and the aproximation thing and see what happens. As for the engineers, I guess it's like anything. Use it or lose it. Everyone forgets what they don't use and many engineers (many, many, many) don't really go into it out of true interest. The four I asked don't come under that category. They are very good at what they do but I've could write a book about some of the others. Examples: "That shiny thing is one of those leds, right?" or "Hey, I'm doing my basement so can you show me how to wire a 3-way switch?" or "Okay, we have 10 coolers at 15 amps each... so we should run a 3/0 down the line and tie em all into that, right?" or "Yes, it's a N.O. switch but I'm showing it closed on the drawing because the boom is hitting the switch when the machine is in the rest position so I need to draw it as Normally Closed, right?" or the latest one "We don't want to run another channel all the way from the E-Stop. Can't we just put a safety relay in the cabinet ahead of the contactor?". I've got a million of em. Jim Rowell

##### Share on other sites
Wow, Labotomi put some effort into his ramp! The easy way is to just generate a trapezoidal ramp and filter the result. new_SP = start_SP * rf + end_SP * ( 1-rf) where rf is the ramp fraction. rf starts at 0 and ramps to 1. SP(n) = K * SP(n-1) + (1-K) * new_SP K is a coefficient that is in the range of 0 to 1. Normal K is equal to T/(T+t) or more precisely exp(-t/T). where T is the time constant and t is the update rate. The larger K is the more rounded the ramp will be. This take a minimum of effort and CPU time.

##### Share on other sites
Dear Jim, I was taught that basic knowledge of math is a must for an engineer. Specially in the field of automation. A net search can't repleace basic knowledge one have. If someone don't know what he's looking for then he shouldn't even bother searching. And if someone has really understood principles then he usually would be able to recall some scratches giving him directions to start.

##### Share on other sites
An engineer needs a lot more than a basic knowledge of math. He needs a thorough grounding in it when he is starting out. Then when he settles down into his chosen area he may or may not need to continue with it. 90% of engineers use very little of it. Or rather they use an important but small part of what they learned. As for not bothering to search, that's pretty insulting. I'm sure the engineers I asked could have found the info had they had the time and interest. On the other hand, I know many, many PC software developers and few of them have more than very basic math skills. They get help there when they need it. As for me, I'm not an engineer. I don't have a good grounding in math. Nontheless, I've managed to perform some very interesting projects. Engineers don't necessarily make the best integrators or programmers. I do have a good grounding in programming and electrical theory. And I have many years of experience in the fields of general electrical and automation. I wish I knew more math. It's important but let's be realistic. Anything beyond basic trig or arithmetic is a very tiny part of what most of us do. I respect those who have different specific points of expertise. A little less bravado and a little more effort on your part would go a long way torward us all learning a little more. Jim Rowell