hasy1000 Posted July 26, 2023 Report Posted July 26, 2023 Hi guys, I am having difficulty in understanding and implementing the scaling of 32 or 16 bit binary data using Mitsubishi DSCL2 instruction. I just don't understand what to pass in its parameters particularly s2 parameter. I tried many variables but I get errors. Please can someone provide an example how to implement that and scale any float no, for example 1200.00 to 100.00 using this instruction with output scale 0-100 being 100 at maximum for the sensor value of 1200.00 I am attaching pdf for DSCL2 instruction taken from Mitsubishi manual for help. and the error I am getting on my melsoft. instructions_manual.pdf Quote
Gambit Posted July 26, 2023 Report Posted July 26, 2023 The DSCL2 instrucion is scaling with the option to have multple ranges. However this is only for intger values (16 or 32 bit)> You would either convert your real to intger values do the scaling and then make them floats again. or just multiply the reals with the Gain and add the offset In you case (0-1200) to (0-100) the gain would be 0.0833333 and the offset 0. 1 Quote
hasy1000 Posted July 26, 2023 Author Report Posted July 26, 2023 5 minutes ago, Gambit said: The DSCL2 instrucion is scaling with the option to have multple ranges. However this is only for intger values (16 or 32 bit)> You would either convert your real to intger values do the scaling and then make them floats again. or just multiply the reals with the Gain and add the offset In you case (0-1200) to (0-100) the gain would be 0.0833333 and the offset 0. First, thank you for your quick response. I know the gain and offset formula. In fact, I have used the same formula previously in my other project. However in this case, I want to specifically see how to use this instruction for my understanding. OK lets consider them integers. Could you please provide me what to write in the parameters like s1, s2, d ? please provide me an example. I just gave you an example of 1200 and to scale it to 10. thank you looking forward to your reply. Quote
glavanov Posted July 26, 2023 Report Posted July 26, 2023 (edited) Let's say DSCL2(SM400,D0,D100,D200); D0 (and D1) is the input value that you need to scale (32Bit integer) D100 (and D101) stores the number of coordinate points that you want the function to work within (32Bit integer). If D100=2 D102 (and D103) is point 1.X value (32Bit integer) D104 (and D105) is point 2.X value (32Bit integer) D106 (and D107) is point 1.Y value (32Bit integer) D108 (and D109) is point 2.Y value (32Bit integer) D200 (and D201) is the scalled output value (32Bit integer) Always keep the input value within 1.X to 2.X range or the instruction will end with error DSCL_Ladder.gx3 DSCL_Ladder.gx3 Edited July 26, 2023 by glavanov 1 Quote
hasy1000 Posted July 26, 2023 Author Report Posted July 26, 2023 1 hour ago, glavanov said: Let's say [DSCL D0 D100 D200] D0 (and D1) is the input value that you need to scale (32Bit integer) D100 (and D101) stores the number of coordinate points that you want the function to work within (32Bit integer). If D100=2 D102 (and D103) is point 1.X value (32Bit integer) D104 (and D105) is point 1.Y value (32Bit integer) D106 (and D107) is point 2 .X value (32Bit integer) D108 (and D109) is point 2.Y value (32Bit integer) D200 (and D201) is the scalled output value (32Bit integer) Always keep the input value within 1.X to 2.X range or the instruction will end with error DSCL_Ladder.gx3 Thank you for the detailed reply. just one thing, how the coordinate points works? Does not get this thing straight into my head. I want 0-1200 to scale into 0-10. So the values should be assigned so I can get the correct scaling output? Quote
BobLfoot Posted July 26, 2023 Report Posted July 26, 2023 1 hour ago, glavanov said: Let's say DSCL2(SM400,D0,D100,D200); D0 (and D1) is the input value that you need to scale (32Bit integer) D100 (and D101) stores the number of coordinate points that you want the function to work within (32Bit integer). If D100=2 D102 (and D103) is point 1.X value (32Bit integer) D104 (and D105) is point 2.X value (32Bit integer) D106 (and D107) is point 1.Y value (32Bit integer) D108 (and D109) is point 2.Y value (32Bit integer) D200 (and D201) is the scalled output value (32Bit integer) Always keep the input value within 1.X to 2.X range or the instruction will end with error DSCL_Ladder.gx3 DSCL_Ladder.gx3 If I am reading this thread and example correctly the following statements are true: RawMin is 0 and corresponds to 1.X or D102/D103 RawMax is 1200 and corrsponds to 2.X or D104/D105 EuMin is 0 and corresponds to 1.Y or D106/D107 EuMax is 10 and corresponds to 2.Y or D108/D109 The RawValue comes from SM400 The EuValue is found in D200/D201 after the scaling function is scanned. Gurus please corect me if I am wrong, it has been a couple decades since I used a Mitsi PLC. Quote
glavanov Posted July 26, 2023 Report Posted July 26, 2023 (edited) SM400 ( special auxiliary relay always on for the IQ-F/R resies) is the enabling bit for the DSCL2 instruction in structured text programming mode. D0 is the RawValue in this example... Edited July 26, 2023 by glavanov Quote
hasy1000 Posted July 26, 2023 Author Report Posted July 26, 2023 2 hours ago, glavanov said: Let's say DSCL2(SM400,D0,D100,D200); D0 (and D1) is the input value that you need to scale (32Bit integer) D100 (and D101) stores the number of coordinate points that you want the function to work within (32Bit integer). If D100=2 D102 (and D103) is point 1.X value (32Bit integer) D104 (and D105) is point 2.X value (32Bit integer) D106 (and D107) is point 1.Y value (32Bit integer) D108 (and D109) is point 2.Y value (32Bit integer) D200 (and D201) is the scalled output value (32Bit integer) Always keep the input value within 1.X to 2.X range or the instruction will end with error DSCL_Ladder.gx3 DSCL_Ladder.gx3 unfortunately, this program is not working properly :( Quote
glavanov Posted July 26, 2023 Report Posted July 26, 2023 In simulation with R04CPU this example works fine. Never tested it in ST on actual PLC, but i use the ladder instruction on many PLCs on our factory floor with no issue... Quote
hasy1000 Posted July 26, 2023 Author Report Posted July 26, 2023 (edited) 2 minutes ago, glavanov said: In simulation with R04CPU this example works fine. Never tested it in ST on actual PLC, but i use the ladder instruction on many PLCs on our factory floor with no issue... I am testing your code with R08 cpu and with the same ladder logic code though I usually work with ST language. unfortunately, cannot getting scaled output at D200. Don't know why Edited July 26, 2023 by hasy1000 Quote
Gambit Posted July 26, 2023 Report Posted July 26, 2023 post your demo project and ill have a look Quote
hasy1000 Posted July 26, 2023 Author Report Posted July 26, 2023 2 hours ago, Gambit said: post your demo project and ill have a look thank you all for all your inputs. I have downloaded and changed K values according to my own scaling and it is working just perfect. thank @glavanov :) 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.