hasy1000

DSCL2 scaling Instruction usage problem

13 posts in this topic

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

mitsi.png

Share this post


Link to post
Share on other sites

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 person likes this

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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 by glavanov
1 person likes this

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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...

DSCL2.jpg.a55f81a4e5fc352e4307772b20c5da

Edited by glavanov

Share this post


Link to post
Share on other sites
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 :(

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites
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 by hasy1000

Share this post


Link to post
Share on other sites

post your demo project and ill have a look

 

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now