Classic Ladder and thread timing
- tropostudio
- Offline
- Junior Member
Less
More
- Posts: 39
- Thank you received: 4
13 Jul 2023 15:41 #275352
by tropostudio
Classic Ladder and thread timing was created by tropostudio
I am retrofitting a circa1995 Howa VMC from a Meldas 520 controller to LinuxCNC. As of today, all the original IO (~ 40 inputs & 40 outputs) are operational on 2 MESA 6i24 cards, along with 7 Mitsubishi servos on one of Dmitry Yurtaev's YDSMP2 cards. This is all on a servo-thread period of 888888ns, as required by the Mitsu serial protocol. I have full ladder documents for the machine, and was looking to translate it into ClassicLadder. LinuxCNC docs mention ClassicLadder can't update rungs faster than 1ms. A couple of questions:
- Should I create a separate thread that is a multiple of the 888888ns servo-thread to run the ladder (1.7777...ms)?
- Is there a particular reason for the cap of the ClassicLadder refresh rate at 1ms, other than being set in SRC?
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19408
- Thank you received: 6507
13 Jul 2023 17:59 #275358
by tommylight
Replied by tommylight on topic Classic Ladder and thread timing
Never used ClasicLadder, so this is just what i think.
ClasicLadder should run at servo period speed, so if you have it at 888888 it will be running at that same speed, not 1ms.
Maybe it is possible to run ClasicLadder on a base period and set that base period at say 444444, this should update stuff twice per every cycle of servo period, if that is enough for what you need.
Base period can run much faster, but i do not know if ClasicLadder is able to run at those speeds.
Should not be hard to give it a try, though.
Have a look at existing components of LinuxCNC, a lot can be done with those also.
linuxcnc.org/docs/html/hal/components.ht...d_bitwise_components
There are a lot to go through, but i linked the logic ones.
ClasicLadder should run at servo period speed, so if you have it at 888888 it will be running at that same speed, not 1ms.
Maybe it is possible to run ClasicLadder on a base period and set that base period at say 444444, this should update stuff twice per every cycle of servo period, if that is enough for what you need.
Base period can run much faster, but i do not know if ClasicLadder is able to run at those speeds.
Should not be hard to give it a try, though.
Have a look at existing components of LinuxCNC, a lot can be done with those also.
linuxcnc.org/docs/html/hal/components.ht...d_bitwise_components
There are a lot to go through, but i linked the logic ones.
Please Log in or Create an account to join the conversation.
- tropostudio
- Offline
- Junior Member
Less
More
- Posts: 39
- Thank you received: 4
13 Jul 2023 18:24 #275362
by tropostudio
Replied by tropostudio on topic Classic Ladder and thread timing
Thank you for the info. This is what I gathered from the LinuxCNC manual:
"13.4.2 Realtime Module
Loading the Classic Ladder real time module (classicladder_rt) is possible from a HAL file, or directly using a halcmd instruction.
The first line loads real time the Classic Ladder module. The second line adds the function classicladder.0.refresh to the servo
thread. This line makes Classic Ladder update at the servo thread rate.
loadrt classicladder_rt
addf classicladder.0.refresh servo-thread
The speed of the thread that Classic Ladder is running in directly affects the responsiveness to inputs and outputs. If you can turn
a switch on and off faster than Classic Ladder can notice it then you may need to speed up the thread. The fastest that Classic
Ladder can update the rungs is one millisecond. You can put it in a faster thread but it will not update any faster. If you put it in
a slower than one millisecond thread then Classic Ladder will update the rungs slower. The current scan time will be displayed
on the section display, it is rounded to microseconds. If the scan time is longer than one millisecond you may want to shorten the
ladder or put it in a slower thread."
I downloaded the linuxcnc_master file and glanced at the classicladder source files. A few of the config files having timing defs based on 1, 10, 100 ms intervals. I'm thinking that may be for convenience in setup and Modbus programming when the code was first written, and nothing 'sacrosanct' about the interval. Could require a lot of checking and recompiles to change it.
I have a hunch once I start translating pages of ladder and get more conversant in it, I may wish I'd just gone after this differently. But you have to figure the Japanese engineers that designed this machine back in 1995 knew what they were doing. The quality of the hardware is incredible.
"13.4.2 Realtime Module
Loading the Classic Ladder real time module (classicladder_rt) is possible from a HAL file, or directly using a halcmd instruction.
The first line loads real time the Classic Ladder module. The second line adds the function classicladder.0.refresh to the servo
thread. This line makes Classic Ladder update at the servo thread rate.
loadrt classicladder_rt
addf classicladder.0.refresh servo-thread
The speed of the thread that Classic Ladder is running in directly affects the responsiveness to inputs and outputs. If you can turn
a switch on and off faster than Classic Ladder can notice it then you may need to speed up the thread. The fastest that Classic
Ladder can update the rungs is one millisecond. You can put it in a faster thread but it will not update any faster. If you put it in
a slower than one millisecond thread then Classic Ladder will update the rungs slower. The current scan time will be displayed
on the section display, it is rounded to microseconds. If the scan time is longer than one millisecond you may want to shorten the
ladder or put it in a slower thread."
I downloaded the linuxcnc_master file and glanced at the classicladder source files. A few of the config files having timing defs based on 1, 10, 100 ms intervals. I'm thinking that may be for convenience in setup and Modbus programming when the code was first written, and nothing 'sacrosanct' about the interval. Could require a lot of checking and recompiles to change it.
I have a hunch once I start translating pages of ladder and get more conversant in it, I may wish I'd just gone after this differently. But you have to figure the Japanese engineers that designed this machine back in 1995 knew what they were doing. The quality of the hardware is incredible.
Please Log in or Create an account to join the conversation.
- dm17ry
- Offline
- Elite Member
Less
More
- Posts: 180
- Thank you received: 66
13 Jul 2023 19:28 #275367
by dm17ry
Replied by dm17ry on topic Classic Ladder and thread timing
i want to clarify, maybe it will help you.
though the servo thread is running at 0.88ms, communication with servo amps happens every 4th cycle, i.e. 3.55ms period. it is so because the command packet includes 32-bit target position plus four 16-bit offsets at 1/4th period. i think MDS-A-SVJs ignore those, but MDS-x-V being "advanced" amps may use it to bring the effective cycle period to 0.88ms.
so i think if you run the classic ladder in servo thread - that should be enough even if it somehow will slow down to 1ms...
though the servo thread is running at 0.88ms, communication with servo amps happens every 4th cycle, i.e. 3.55ms period. it is so because the command packet includes 32-bit target position plus four 16-bit offsets at 1/4th period. i think MDS-A-SVJs ignore those, but MDS-x-V being "advanced" amps may use it to bring the effective cycle period to 0.88ms.
so i think if you run the classic ladder in servo thread - that should be enough even if it somehow will slow down to 1ms...
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19408
- Thank you received: 6507
13 Jul 2023 19:43 #275370
by tommylight
Replied by tommylight on topic Classic Ladder and thread timing
It refers to 1ms as the usuall servo period is 1000000, but you have it at 0.88 so the CL will also run at 0.88ms.
Please Log in or Create an account to join the conversation.
- tropostudio
- Offline
- Junior Member
Less
More
- Posts: 39
- Thank you received: 4
13 Jul 2023 21:27 #275372
by tropostudio
Replied by tropostudio on topic Classic Ladder and thread timing
Thank you for the clarification on your board timing, Dmitry. And thank you for clarification on the ClassicLadder documentation, Tom.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7769
- Thank you received: 2053
13 Jul 2023 22:51 #275378
by cmorley
Replied by cmorley on topic Classic Ladder and thread timing
Cl is limited to 1ms on the source.
From memory I couldn't get it to run efficiently at a faster rate.
You could change the source to try. I'll have to look for the file name when I get home.
From memory I couldn't get it to run efficiently at a faster rate.
You could change the source to try. I'll have to look for the file name when I get home.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7769
- Thank you received: 2053
14 Jul 2023 03:38 #275394
by cmorley
Replied by cmorley on topic Classic Ladder and thread timing
The following user(s) said Thank You: tommylight, tropostudio
Please Log in or Create an account to join the conversation.
Time to create page: 0.071 seconds