MagniV MCAT data Type Question 2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MagniV MCAT data Type Question 2

Jump to solution
2,768 Views
SW_Park
Contributor II

Hi..

Please contact us for a more detailed answer.

Re: MagniV MCAT data Type Question - NXP Community

I don't understand the answer in the link above.
Please explain in an easy way.

 

0 Kudos
Reply
1 Solution
2,731 Views
MichalH
NXP Apps Support
NXP Apps Support

No,

I was giving just an example using a signed integer short variable. In your/MCAT case, the input X value is of a Q-fract type which is a value betwen -1 and 1. This will generate real-world value between -Nmax to Nmax. I think there are two facts that might be confusing:

  • The fractional format itself needs to be understood. The fractional Q(0,15) variable can hold values between -1 and 1. It is still a 16 bit variable (not float), so if you look at the raw value, you will see values -32768 to 32767, but this is just a physical representation. You need to understand that the number is always in the <-1,1) range.
  • So, in the MCAT setting, a value X=1000 maps to value 1000*Nmax, this means that value X=1 maps to Y=Nmax which was the goal. The X2=1000 is maybe confusing because the X actually never goes up to 1000 (it only goes up to to 1), but still the formula is correct because also the Y2 is multiplied by 1000.

    You could also set the [X2,Y2] to [500, Nmax*500] or [10, Nmax*10] or [1, Nmax] and the effect would be the same (try it). I think the MCAT guys did use the [1000, Nmax*1000] due to some historic or experimental reasons. But still I think it is a correct setting.

Regards,
Michal

View solution in original post

0 Kudos
Reply
3 Replies
2,751 Views
MichalH
NXP Apps Support
NXP Apps Support

Dear @SW_Park ,

if I understand correctly your question posted to the other thread, you need more information about how the "Linear Transformation" of variable value works in FreeMASTER.

It is actually quite simple. The goal of the transformation is to re-calculate a value obtained from target MCU application to physical real-world units. 

For example, if there is an integer variable in the MCU application which goes from 0 to 32767 while it represents a rotation speed in range of 0..3000 rpms. In this case it very convenient to use the "Linear two points" transformation which convert an X-axis value to Y-axis value according to a simple linear graph.  There are two known points [0,0] and [32767,3000] in the graph as displayed below:

MichalH_0-1642579743132.png

So, with this settings, the FreeMASTER will use a value read from MCU and puts it to X axis of the graph and re-calculates it to corresponding Y-axis value.

The other way of recalculation is using a standard linear equation Y=a*X+b, where the variable value is used as X and the result of transformation is Y. This way is more convenient when you know your 'a' and 'b' coefficients of the formula.

Of course, the MCU variable value does not need to be just an integer. There are several variable types supported: signed and unsigned integers, IEEE floating point values and also fractional Q/UQ values which are nicely described e.g. here. The FreeMASTER transformation works in all cases, so for Q values, the X range is typically from -1 to 1 while the Y range represents the real-world units.

What is also nice about FreeMASTER is that this transformation also works in the 'inverse' direction. When you want to modify the value in Variable Watch, you actually enter the 'Y' real-world value and FreeMASTER re-calculates in back to 'X' when writing it to the MCU application.

Let me know if this clarifies the issue for you.

Best regards,
Michal

 

 

0 Kudos
Reply
2,738 Views
SW_Park
Contributor II

Hi. 
I understand the methodology.
But as you said, I think it's like the following.
x1, y1 = [ 0, 0 ]
x2, y2 = [ 32767, Nmax ]

However, the actual set values are as follows.
x1, y1 = [ 0, 0 ]
x2, y2 = [ 1000, Nmax x 1000 ]

I don't understand this part.

0 Kudos
Reply
2,732 Views
MichalH
NXP Apps Support
NXP Apps Support

No,

I was giving just an example using a signed integer short variable. In your/MCAT case, the input X value is of a Q-fract type which is a value betwen -1 and 1. This will generate real-world value between -Nmax to Nmax. I think there are two facts that might be confusing:

  • The fractional format itself needs to be understood. The fractional Q(0,15) variable can hold values between -1 and 1. It is still a 16 bit variable (not float), so if you look at the raw value, you will see values -32768 to 32767, but this is just a physical representation. You need to understand that the number is always in the <-1,1) range.
  • So, in the MCAT setting, a value X=1000 maps to value 1000*Nmax, this means that value X=1 maps to Y=Nmax which was the goal. The X2=1000 is maybe confusing because the X actually never goes up to 1000 (it only goes up to to 1), but still the formula is correct because also the Y2 is multiplied by 1000.

    You could also set the [X2,Y2] to [500, Nmax*500] or [10, Nmax*10] or [1, Nmax] and the effect would be the same (try it). I think the MCAT guys did use the [1000, Nmax*1000] due to some historic or experimental reasons. But still I think it is a correct setting.

Regards,
Michal

0 Kudos
Reply