baptie Posted May 12, 2012 Report Posted May 12, 2012 Hi, I have a motor outputting 30pulses/rev at the encoder. With output shaft measured I get a calc of 0.1295mm/pulse. I made up a function block with st: Length_x = dint to real (raw_x) Length_x = raw_x * 0.1295 Length_x_mm = real to dint (length_x) when added to the program my scan rate jumps from 3.2ms cycle time to 7.ms as the shaft is moving all the time. I was wondering if I can do the calc in ST but simply bring in raw_x * 0.1295 = length_x_mm without the dint to real/real to dint conversion in a hope that cycle time will decrease? Thanks in advance Quote
baptie Posted May 15, 2012 Author Report Posted May 15, 2012 Is there an alternative in ladder logic that I can: Take a dint, convert to real, multiply with constant and convert back to dint for 'mm' output? What I have works but it's running slower than I wish. Quote
Michael Walsh Posted May 15, 2012 Report Posted May 15, 2012 I created a scaling block to do the same conversion and dumped it into a CJ2H PLC. I don't know what PLC you are using, but a CJ2H with 3 instances of the scaling block has a scan time of about 0.5 ms. I know that you are using a slower PLC, but it should still not add that much time. I think that your code does not look correct. Here is what I wrote (image monitoring inside of one instance): Here is the actual .cxf file if you want to import it to CX-Programmer: Scale FB.zip If you attach your code, I can look at it / modify it here and respond. Quote
Sergei Troizky Posted May 15, 2012 Report Posted May 15, 2012 *0.1295= *1295 then /10000, and no need in reals. Quote
baptie Posted May 16, 2012 Author Report Posted May 16, 2012 I am using a CP1L taking input from High speed Counter. This is a copy of the actual code: Thanks for the above Sergei but the calculation overspilled as the count is actually: *10296 / 100000 The sum is required to cope with 300M conveyor, after 21M the counter overspilled as the calculation was massive. Quote
Michael Walsh Posted May 16, 2012 Report Posted May 16, 2012 Just do it the old fashioned way - with ladder. I just ran the following test: With one simple rung of ladder (no scaling) as shown below: The scan time values were as follows: Mean: 0.4ms Max: 0.8ms Min: 0.3ms With the function block method that we have been discussing: Mean: 3.0ms Max: 3.6ms Min: 2.7ms With the following ladder rung (which does the same thing as your FB): Mean: 0.4ms Max: 0.8ms Min: 0.3ms Very little difference when adding your scaling function using good ol' ladder. I would just use the ladder. Quote
baptie Posted May 17, 2012 Author Report Posted May 17, 2012 Ohhhhh - now that looks like it would work a treat. I will give it a shot first thing, test on test bed first. ........a/w the dawn Quote
baptie Posted May 18, 2012 Author Report Posted May 18, 2012 Worked a treat!!!!!!! Now back down at 3.2 - 3.5ms. Many thanks for all assistance, I may even sleep this weekend now, lol. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.