![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#1 |
Member
![]() ![]() Join Date: Mar 2019
Location: Leiden
Posts: 6
|
![]()
Dear PLCtalk Forum,
I developed a generator for time-optimal trajectories with jerk limitation. You can access it online to calculate, display and download (XLSX or CSV) trajectories. https://www.trajectorygenerator.com/ojet-online The generation of jerk-limited trajectories is often used in automation and for the movement of large and precise machines (i.e. large telescopes), but also in robotics and CNC machines. Usually, a trajectory generator is placed in front of a control loop to generate a setpoint without discontinuities. Even though the topic of jerk-limited trajectories seems simple and there are hundreds of publications on the topic, most proposed solutions are either approximations (so the given motion constraints are either not exactly matched or not time-optimal), or only work for specific sets of parameters. What sets this trajectory generator apart is the possibility to provide a time-optimal solution for any given motion constraint. Another advantage is that arbitrary start and target motion states (hence position, velocity and acceleration) can be chosen. I put in quite some work and effort to develop this trajectory generator. The problem is way more tricky than it initally looks, as there are many different cases to consider. Finding a stable mathematical solution is also not straightforward. I hope you'll find the tool useful and I am really happy to listen to your feedback! Greetings, Stefan |
![]() |
![]() |
#2 | |
Member
|
Excellent!
Quote:
I have my own version that I will use to compare solutions when I get to work. I wrote a program to test different combinations of starting stoping and limits. I ran it for 200,000,000,000+ combinations to test mine. It took days. It is impossible to be thorough using human testing. I do not have my test cases because I am home. I will test your target generator over the weekend. Most of the hard cases are short moves where no limit is reached. Meanwhile, just so the people here know what it takes to do this will provide this link.https://deltamotion.com/peter/Maxima/Seg1234567.html Even the simple case requires solving 17 equations for 17 unknowns! Try solving that in a PLC! Good job!
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
|
![]() |
![]() |
#3 |
Member
![]() ![]() Join Date: Mar 2019
Location: Leiden
Posts: 6
|
Dear Peter,
thanks for this answer! I think everyone who has programmed such a trajectory generator is very quickly baffled by the complexity of the problem. The link you sent is an excellent example. You are also right that the problem without any motion constraints (that is jerk limitation only) is hard to solve, both setting up a good set of equations, but also to stabilize the problem numerically. I am looking forward to your test cases! Cheeco |
![]() |
![]() |
#4 |
Lifetime Supporting Member
![]() ![]() Join Date: Dec 2004
Location: Detroit, SE Michigan
Posts: 3,539
|
You guys are nothing short of amazing.
__________________
"You can live to be a hundred if you give up all the things that make you want to live to be a hundred." Woody Allen |
![]() |
![]() |
#5 |
Member
|
This is my version. Notice how much they are the same.
I will do testing later. I can save away the values for a motion profile in a file. I just counted. I found 35 bugs before I was done. I posted my directory where I computed the formulas for the different cases. There were about 70 although I only showed about 50 on one screen. There was one case where I wanted to move from one position, velocity and acceleration to another position velocity and acceleration. The setup looked relatively easy because there were 6 equations to solve for 6 unknowns. The solution took pages. On the sci.math.symbolic newsgroup I posted this problem. A professor from Fordham university saw the problem and simplified it some what. There was competition to see who could solve the problem most efficiently. Robert Lewis's Fermat program was best https://home.bway.net/lewis/ but the solution still too long to solve in a motion controller during a loop time. Robert Lewis used my example problem in a presentation because the problem looked so deceptively simple but was in fact very difficult. Now you guys have a clue what goes into the best motion controllers. You guys know I am writing a series of articles about doing motion control in PLCs and motion controllers. I know there is no way a PLC can compete unless the motion is extremely simple. BTW, the target velocities and accelerations are used to multiply by the target velocity and acceleration feed forwards so the target generator is very important in predicting the control output.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
![]() |
![]() |
#6 |
Member
|
I think I broke it
I used one of my 35 test cases. The Ojet target generator gave me an out of bounds error.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
![]() |
![]() |
#7 |
Lifetime Supporting Member
|
Bubba need now more coffee
When I have to tune a control loop, I usually poke the P and I buttons a couple three times and wait to see what happens. This seems a little more advanced than that.
![]() Bubba.
__________________
“Now will come the nay-sayers with all the reasons why you shouldn't do this. Some of them are teachers, and some of us are doers. Besides, you have got to let the smoke out of this equipment every now and then, or it starts to clog up the chimney.” ~Lancie1 |
![]() |
![]() |
#8 | |
Member
|
Cheeco and I are talking about the target generator not the control loop. The target generator is the most complex part of the motion controller.
Quote:
It really should be called auto tuning though. It should be called computer assisted tuning.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
|
![]() |
![]() |
#9 |
Member
![]() ![]() Join Date: Mar 2019
Location: Leiden
Posts: 6
|
Dear Peter,
I can confirm that it is indeed a bug. From how it seems now, it should be (hopefully) easy to correct. But even in a corrected version, the trajectory generator might behave different than you might expect. I introduced 2 flags which signal potential problems. Both are warnings related to leave the absolute motion boundaries.
To the bug you found: The "out of bounds" error is intentional, as your start vector (speed=12) is already outside the defined bounds (speed=10). In this case, a stop solution should be calculated that stops the motion with the given maxima for jerk and acceleration. This is not implemented correctly, as the speed and acceleration have still not decreased zero. I will have a look what went wrong here. Regarding the complexity and the calculation speed. I found a way to elegantly formulate the mathematical problem for the general solution with jerk limitation only. This allows an extremely fast solution of the problem. The code is entirely written in C, and on an 8-year old notebook, the software can calculate 100000 complete general solutions every second. I tested it on a Beckhoff PLC with 1ms cycle time, the processor load increased by only 2-3%. I am sure that the code runs sufficiently fast on any modern PLC as long as it has a double-precision FPU. |
![]() |
![]() |
#10 | |
Member
|
Cheeco, I don't think you should call the limits parameters. In my example the the target speed is initially 12 and the user gives a command speed of 10. Giving a motion command with a lower speed should be acceptable. Also, you should add a means of incrementing and decrementing numbers with a mouse like my target generator. It makes it easier to do testing.
Quote:
As for the speed. It is the initial command that takes most of the time. After that everything is planned out pretty much. I try to defer as much of the calculations as possible because there is no point in calculating everything just to have the user issue a new command where all the previous calculations are useless. When I get a hold of a competitor's motion controller I test the target generator. It is often hard to do because they usually don't have a nice interface like mine or yours. I am home now. I will look for another bug on Monday.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
|
![]() |
![]() |
#11 |
Member
![]() ![]() Join Date: Mar 2019
Location: Leiden
Posts: 6
|
Dear Peter, sometimes the wording I use is a little sloppy. I am also new to web programming, so even the admittedly basic interface took me already ages
![]() The question on how to behave outside the motion boundaries is indeed tricky. My philosophy was to set an error and stop the motion with the given jerk/acceleration boundaries. It is clean, it is simple and (hopefully) leads to defined, expected behavior. Other variants, like getting first inside the motion parameters and then continuing the motion would also be possible, but I decided against them. Regarding the speed: As you know, there are basically 2 different problems. The first one is hard: Decide which trajectory type is the right and calculate the proper switching times. Once this problem is solved, the second problem can be tackled: The evaluation of the trajectory values for arbitrary timesteps. This problem is - compared to the first one - very simple, as it is calculating linear, quadratic and cubic functions over and over again. The trajectory generator I developed can solve the first, hard problem - deciding which is the best trajectory for the given start and target values and the given motion boundaries, calculate the switching times and finally evaluating the trajectory - at a pace of ~100000/s on a standard PC, which allows for a real-time trajectory generation and evaluation. One nice feature is to generate trajectories on-the-fly: Instead of calculating a whole trajectory, you can just calculate the next timestep. The calculated vector will be the start vector for the next iteration. Even though technically not absolutely necessary, this iterative approach leads to a very elegant programming style. But I am also really interested how the problem of jerk-limited trajectories is currently solved in industry. Since I am not directly working in automation, it is really interesting for me how the problem is solved in practice! |
![]() |
![]() |
#12 | ||||||||||
Member
|
Quote:
The windows part is the main program. My target generator code is a DLL. Quote:
Quote:
Quote:
![]() Quote:
Where seg 0 is stopped seg 1 is accelerating with jerk >0 seg 2 is accelerating with jerk =0 seg 3 is accelerating with jerk < 0 seg 4 is constant velocity seg 5 is decelerating with jerk < 0 seg 6 is decelerating with jerk = 0 seg 7 is decelerating with jerk > 0 I included this info for the rest of the forum. Cheeco needs to add this cases below. seg 8 is a special case where current trajectory is higher than the command. That is the case you see in my last picture. seg 9 is similar to seg 8 except the current trajectory is much more negative than the current command. Quote:
Quote:
Quote:
Quote:
Quote:
[/quote] I have shown and told you a lot. you are on the right track. Now you must decide how far you want to go. I may make a video about this. It is interesting to see how the motion profiles changes as command parameters change.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
||||||||||
![]() |
![]() |
#13 |
Member
![]() ![]() Join Date: Mar 2019
Location: Leiden
Posts: 6
|
Its true that the segments 8 and 9 are not implemented in a way you implemented them.
I had also a look at your GUI and found it really appealing. It is interesting how many common elements our solutions share, despite different development paths! When taking a closer look at your posts, I realized that I missed a lot of information you wrote on the first time (maybe because I was busy looking for the bug). You mentioned that you are writing articles about motion controller. Are these articles available online or in a journal? I would be very interested to read some expert views on the topic! What I also realized from your posts is that a motion controller and a PLC are actually two different devices (ok, now that I read it again it's kind of obvious). But what I do still not quite understand how your setup looks like. I understood that the motion controller runs the target generator (hence the*.dll). Are the calculated trajectory points then passed to the PLC which executes the actual control loop? Where and how does the Windows software come into play? It is also clear that the performance results I obtained will look very differently on an embedded device. When you talk about an ARM class processor, are you referring to the computational power of a common PLC or a common Motion Controller? I am currently planning to port my code to a STM32 to see where I get in terms of performance. I am still very interested in your test cases. Today, I found the root cause for the bug you discovered, but I will need some days to implement a fix and thoroughly test the new version. Thanks for the support! |
![]() |
![]() |
#14 | ||||||
Member
|
Quote:
Quote:
Mostly I write about the closed loop algorithms. Quote:
Quote:
https://www.ghs.com/ The code is in a flash memory but gets copied to ram for faster execution. The fastest PLCs do the same. Quote:
Quote:
I sent you a private message with more information.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
||||||
![]() |
![]() |
#15 |
Member
![]() ![]() Join Date: Mar 2019
Location: Leiden
Posts: 6
|
Dear Peter,
I uploaded a bugfixed version of the trajectory generator. The first part of the trajectory looks now identical to your test case. As stated previously, in my implementation, a violation of the boundary conditions (or parameters) leads to a motion stop. OJET-online Testcase |
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Electronics Questions | peavey_wolfgang_2000 | LIVE PLC Questions And Answers | 4 | May 23rd, 2005 09:05 PM |
How AB Timers work. | PhilipW | LIVE PLC Questions And Answers | 0 | January 28th, 2005 03:47 PM |
1 input 3 outputs | guest | LIVE PLC Questions And Answers | 26 | February 8th, 2004 05:33 PM |
Exact SP reached at end of heating ramp time | JustDaveIII | LIVE PLC Questions And Answers | 12 | October 17th, 2003 05:07 PM |
lambda tuning – how is it calculated? | Ron Beaufort | LIVE PLC Questions And Answers | 4 | August 5th, 2003 12:45 PM |