scalling issues

Just for your infomation when you select FX series (fx0-3U) it only works in compatible mode, either ladder only or Structured lad/FBD/ST but using the higher level PLC's like the Q it can use pure ladder in the old way as well as the structured mode it must be some limitation they put on it as the FX range is on it's way out being replaced by FX5. so you either just accept the monitor mode rounding up but actually uses the 7dp actual value within the program or you re-write your code into structured project, it can still do ladder but not limited like the old ladder. but in a structured project when using the Z index registers you have to use the actual address not the global label which cannot be displayed, so instead if you want to use indexing then create the array of the words/bits.
Sothere are two ways to do it forst create an array of the tags i.e. My_array(0..200) of real & a tag called something like pointer as integer
Then move 123 to pointer then indirectly address it by My_array[Pointer] or if you prefer move 123 to Z0 then do the same i.e. My_Array[Z0]
 
Here is the binary search. It took me a while to get it sorted, and I am not sure I did it optimally (can GxW2 not put two comparisons on the same branch?). It works in the simulator.

It's only four rungs: one rung to initialize the search (attachment GxW2_binary_search_init.png); one (repeated six times; 133 in the image below) to execute the search; two rungs (158 and 178 below) to do the scaling between the adjacent table entries identified by the search.

I put only the last eleven entries from the APG-L Voltage vs. Pressure(Torr) table into the memory; if we enter the entire table with its 47 entries, then the MOV K20 D402 branch on the first rung changes to MOV K46 D402.

GxW2_binary_search.png
 

Attachments

  • GxW2_binary_search_init.png
    GxW2_binary_search_init.png
    14.6 KB · Views: 5
  • GxW2_voltage_pressure_table.png
    GxW2_voltage_pressure_table.png
    25.5 KB · Views: 5
  • GxW2_binary_search.pdf
    147.2 KB · Views: 3
  • GxW2binary_search.zip
    178.1 KB · Views: 2
Yes you can put two on one branch, however, you have not done it in FX but a Q processor, there are many differences, also, the D memory area is not all retentive the initial setting is D200-D511 & needs to be adjusted but only for 512 registers, so create a file in the PLC Parameters of the size you want it's in 1k steps. then use the R registers instead. Also note that in simulation mode the FX cannot write while processing you have to set PLC to stop but you can on an actual FX3U.
 
Yes you can put two on one branch, however, you have not done it in FX but a Q processor, there are many differences, also, the D memory area is not all retentive the initial setting is D200-D511 & needs to be adjusted but only for 512 registers, so create a file in the PLC Parameters of the size you want it's in 1k steps. then use the R registers instead. Also note that in simulation mode the FX cannot write while processing you have to set PLC to stop but you can on an actual FX3U.
Those are implementation details; I have a lot to learn about Mitsi.

And of course the 6 floating-point registers in [D300:D311] I originally mapped to [D300-D305] - d;Oh! Talk about your brain freezes - I stared at it forever before finally slapping my forehead ? :ROFLMAO:.

Here's an odd behavior I could not explain:
  • On the first rung, I could not put the table span (K20) into D401
    • It was overwritten to 0.
    • I had to put the K20 value into D402 instead
    • does one of the rungs working with register D400 (the half-step) overwrite register D401 as well?
      • I thought each D register held 16 bits?
That said, I did finally get it to work i.e. proper interpolation of those 47 table entries instead of expanding the table to have 801 pressure values with limited resolution. This logic could be refactored as a generic function equivalent to Logix's FGEN instruction i.e. to do piecewise-linear floating-point interpolation.

Sidebar: if the measured voltage is outside the table range, the algorithm does not fail or access memory outside the, and as written is extrapolates the data.
 
Not looked to closely at your code but there are a number of possible causes, these stem from using indirect addressing & Absolute addressing so the issue with possibly the Z index registers or the difference between words, doubles or floats. it certainly is not a problem with the software as every time this has occured to me it has been my mistake. The problem with the old ladder format is it uses absolute addressing so it is possible to mix up the variable types.
for example: let's assume you use D100 as a signed word then you can use it in a float function as the older ladder compiler only knows it's a register in other words when you create the symbols (comments) they are not used in the program.
If you use a structured project & symbolic addressing then you create the symbols & allocate the addresses ( or let the compiler auto allocate however, auto allocate cannot be read by any external device like an HMI as it will not know the address (I think this may change in the future when it is totally symbol based like RW, mainly used for local variables only accessable in the current block of code or global where they are exposed to all programs. When you use symbolic addressing (LAD/FBD/ST) then rather than use absolute addresses you use the symbols this way it knows the type i.e. word/float etc.
I might seem a bit weird but unlike RW Mitsubishi made their IDE's backward compatible with legacy systems (well more recent ones) this means that there is support for now EOL platforms without having to have multiple versions of IDE, earlier platforms did not have updatable firmware which in my mind is a good thing at least you could not brick a PLC or pay extortionate rates for firmware or software upgrades.
One other point, if memory is not a problem for those who are not as experienced then use only even numbers for D addresses that way it is less likely to cross boundaries i.e. D100, D102 for 16 bit words it does mean plenty of unused words but it is less likely you cross the boundary of floats & words.
now for the history (& possible future)
In the early 90's Mitsubishi started to implement the IEC platform this came in the release of GXIEC developer (I spent some time talking to the original designers) this was done by I believe an external company for Mitsi.
Again it was developed with existing platforms in mind as well as the newer ones. The problem is the existing platforms were absolute addressed based so it became a mix.
This was superceeded by GXWorks again supports legacy equipment hence the same as above.
The latest platforms need GXW3 & does not support all the older platforms however, as it needs some current ones is still symbolic & absolute based, I believe in the future this will become like RW unfortunately that means loads of versions of firmware/software, it remains to be seen if Mitsi will start to charge horrendous prices or tie people into expensive service contracts, currently most support is free I believe or was as I am now retired (although i'm registerd with them so I do have access.
The one problem with the Mitsubishi LAD/FBD/ST mode is that you either need to maintain the file or download the symbolic table to the PLC, if you do not then uploading it turns it back into ladder which unless experienced looks like a rats nest of code.
So if using Symbolic addressing then it makes sense to download it to the PLC (option on transfer), however, certainly on the older models like FX,A,Q processors if the program is large there may not be enough memory to contain both.
One of the main reasons for using a structured FBD/LAD program is that in the symbols it is possible to create say an array, but also create individual symbols for the same addresses like My_Array(0..100) of type real, Address D100 this automatically assigns two words to each element starting at D100, but it means that in the symbol table you can also create symbols for each variable in the array like Current Weight as Real, D100,
1733384176046.png
So rather than use My_Array[0] you can use it as Current_Weight directly.
Or create a UDT put in the types then when you use the array it's My_Array.Current_Weight[0]
 
The reason it is displaying 0.003 is that GXworks2 in ladder which is a compatible mode of GXDeveloper an old version displays 0.003 instead of 0.00288 I think it's limited to 3 decimal places whereas in a stuctured program it's the new version so displays it correctly, the only reason that GXWorks2 has this mode is to make it backward compatible with the older hardware.
see the same code in structured program FBD
View attachment 74502
But even in the ladder form as you have if it is displayed on an HMI & set to 5 decimal places it displays the correct value it is all down to the way GXDeveloper (in compatible GXWorks mode displays the data as you can see in the HMI below even though in ladder the monitor of the program shows it as 0.003.
View attachment 74504
ohhh i'm not finish yet at the program...thats why i'm testing the program in Gxwork2.....later i'll try to display it on hmi....thanks for the help @parky ....Your help is greatly appreciated...:)

p/s :: I don't know anything...im just a baby
 
Here is the binary search. It took me a while to get it sorted, and I am not sure I did it optimally (can GxW2 not put two comparisons on the same branch?). It works in the simulator.

It's only four rungs: one rung to initialize the search (attachment GxW2_binary_search_init.png); one (repeated six times; 133 in the image below) to execute the search; two rungs (158 and 178 below) to do the scaling between the adjacent table entries identified by the search.

I put only the last eleven entries from the APG-L Voltage vs. Pressure(Torr) table into the memory; if we enter the entire table with its 47 entries, then the MOV K20 D402 branch on the first rung changes to MOV K46 D402.

View attachment 74526
Thanks @drbitboy .....later i'll try this program also and see how it goes.....they have some command line that i'm not familiar with but its alright..i will try to search them......btw thanks a lot for the help :)

p/s :: I don't know anything...im just a baby
 
it certainly is not a problem with the software as every time this has occured to me it has been my mistake.
? ? ? ? ? ?

100% agree with this.

Sidebar: over a career programming at least a dozen different languages, I have found exactly one compiler bug (and that after a few decades); I am embarrassed to admit or guess how many times I thought I found a compiler bug.

I thought I found a bug in the GxW2 simulator, until saw this 32. LOL!

1733402622472.png
 

Attachments

  • 1733401726556.png
    1733401726556.png
    36.1 KB · Views: 3
  • 1733401796918.png
    1733401796918.png
    36.3 KB · Views: 3
Yep when you do integer maths it puts the result into Dx & remainder in Dx +1. but the manual does explain it then again it's chinenglish
That is why I posted about using only equal words not the odd, that way you don't get stung on that,
 
That binary search code as is will not work on an FX some math functions are different & those Special bits (SM) are different in FX & actually start at M8000
Can I try to get it to work for FX on the simulator, if I tell the Gx Works 2 simulatore that the device is an FXsomething (and do you know what that "something" would be)?
 
Here it is for an FX2N/FX2NC with its particular floating-point instructions. It works; like I said, that is an implementation detail.

Caveats
  • The D> D300 D100Z1 in the six binary rungs should be DECMP D300 D100Z1 M7 (being careful to avoid M10!),
    • but then I would have had to fiddle around with M9, and I am a lazy sod,
    • Anyway, D> ... is functionally equivalent,
      • as long as all the floating-point table entries are non-negative,
        • because exponent bits are more significant than mantissa bits.
  • The DMOV D200Z0 D308 could be DEADD D200Z0 K0 D308 to show the floating-point value, but it moves the bits either way.
 

Attachments

  • FX_binary_search.png
    FX_binary_search.png
    83 KB · Views: 2
  • FX_binary_search.pdf
    156.9 KB · Views: 4
  • FX_binary_search.zip
    178 KB · Views: 3

Similar Topics

Hi Guys I'm using Vijeo Designer as HMI, and we're monitoring the water levels in a water well of 6 meters deep. I created the water well in...
0
Replies
2,211
Views
Hello friends; I am new with Mitsubishi system. I need some example to handle the 4-20mA by using FX-2n-4AD which is attached with FX-1N-14M...
5
Replies
4,468
Views
Dear All; Good day. I have a flow meter range 5-70 Cm/hr and out is 4 to 20 mA. first i want to ask how i calculate that at 13 mA what is flow...
2
Replies
2,212
Views
Hi All I am doing a Tank Gauging project. In there all the tank parameter like level , temperature , pressure are coming into a master...
11
Replies
4,969
Views
i'm a newer in PLC programming... anyone please help me about how to do analog scalling in PLC, please sent me an example the ladder for this...
2
Replies
3,831
Views
Top