Johan, Soder,
First: we dont know what "type" we should use to write code in: ladder, instruction list, structured text, sequential function chart or function block diagram. Which is "the easiest" and which is "the best"? Or should we use different for different kinds of parts in the program?
The way you build your analysis is fully yours. Obviously for sequences you might prefer SFC, but could write in FBD or even IL either. There is no choice definetly better than another one. If now you're talking about your drive management I would choose a mix between SFC (cycles and macro-analysis), ST (data management and calculation) and ladder (built-in function calls). At the end of the process despite the fact you used several editors your codes are translated in IL. You can check this in your navigator and figure out what is the ladder code equivalent to SFC or ST programs.
Second: we aren't that good with interrupt programming
Your program does not seem to be that difficult (based on Soder's explanations). I would be surprised that it requires an interrupt program. Also try to enlight this point: why do you want to control your motion by timers ? Basically you don't need timers. Only coordinates have to be defined.
In case you absolutely need to test your motor with a timer:
build a timer in any program editor, launch a F171, F174 or whatever you choose. At the end of the timer (pulse) you only write h9 in DT90052 than you write h0 in the scan. No interrupt required. Nothing more.
R0---(DIFU)---[F171 ....]
R903A------[TMX10 K50] <- timer 10, time base 0.1s, select value 50
R903A--T10--[F0 H9 DT90052]--[F0 H0 DT90052]
As soon as R0 is on the motor starts... and stops after 5 seconds.
But try like this (pretty accurate and much more simple):
R0---(DIFU)---[F171 ....]
That's it, assuming that your low/high freq are both 1khz and your preselection is 5000, 5000 pulses are generated in 5sec. My point is: now the final position is known and can be read. Use this method with different values of your low/high freq. Please... TRY IT right now!
I took a look at the DT90052 and I understod the "concept". Is this how I make the unit stop in my interrupts above?
Yes, it would be the best way for you to work. But also keep in mind that:
neither interrupts, nor timers, nor forced stop are required
. In F171 mode your motion automatically stops when a target value is reached.
Keep it simple! Just play with the F171 and adjust: your control code, your frequencies, your target values. With a single set of data, you might achieve the whole job by only changing the target values in absolute mode: start from 0, go to 5000, go to 2000 (direction changes), go to 4500 (direction changes), home (see below). How to know that the motion is running: R903A is ON (channel 0). How to know that the target position is reached: falling edge of R903A plus current value of DT90044/45 matching your current target.
On our units we have 3 sensors. One in each end and one at 1/4 of the length. Is that what means with "home"? And what is then "near home"? Or is this some "virtual value" that we write in our code (like a Target Value)? Is 0 = one end of our linear unit and e.g. 100000 = is the other end?
Well, there is no rule... YOU actually do BUILD the rules. According to the mechanical "step" of your motion you might decide that one end of your unit is -3755 and the other one is +7269. It would be also nice that a sensor gives a mechanical zero in between. What happens when you plan to reach a position in an accurate manner? Let's say you're driving at 65mph, and suddenly brake when you're in front of an indicator. Your car wouldn't stop immediatly. You know that we all begin to brake far before the indicator, and this way can finally brake and stop. During the home return you want your motor to run as fast as possible. But you also may need to stop each time exactly at the same place. This is why a near home sensor is added. When this sensor is seen the motion slows down and finally reaches the home position at very low speed. No matter if you don't have any near home sensor. If you're looking for enhanced accuracy, this sensor can be simulated: during your home return, check your elapsed value. When the value is close enough to zero, then write a 1 in the bit 4 of DT90052 (DT90052 OR h10 --> DT90052).
Don't forget to erase the bit when the home return is achieved AND to use the differential counter clear output (wired to the servo-drive).
Johan, discuss with Soder. You should post here a schematic of your project (or one for each basic step).
Laurent