Unity Pro M software

pbaker88

Member
Join Date
Jul 2013
Location
Victoria
Posts
22
Gday all, im a bit of a newbie to structed text so i was wondering if anyone can give me a hand. Basically i want to know what the inital 'Index_x := 500' does in this snippet of code. Its written in the Unity Pro M software.

Index_x := 500 ;

Static_fct_ar[Index_x] := 4900 ;Dyn_fct_pg1_ar[Index_x] := 3400 ;

Dyn_fct_pg2_ar[Index_x] := 5 ;Dyn_fct_pg3_ar[Index_x] := 15 ;

Dyn_fct_pg4_ar[Index_x] := 24 ;Dyn_fct_pg5_ar[Index_x] := 36 ;

Dyn_fct_pg6_ar[Index_x] := 250 ;Dyn_fct_pg7_ar[Index_x] := 7000 ;

Dyn_fct_pg10_ar[Index_x] := 66 ;


Thanks any help would be greatly apprecated.
 
All the lines below are referring to arrays and the index_x value is the array location. So basically on the second line the 500th element of the static_fct_ar array is being loaded with 4900
 
Thanks GeoffC,

So in this next piece If Mem_xbt_68 is true it writes 520 into Index_x then the next line makes Idx_presel_fil_adj equal to 520?? If its not true then 'Dyn_fct_pg10_ar' equals 66 which is loaded in the first bit code i posted?

Index_x := 500 ;

IF Mem_xbt_68 THEN Index_x := 520 ;END_IF;

Idx_presel_fil_adj := Dyn_fct_pg10_ar[Index_x] ;

RETURN;


Thanks
 
Last edited:
if Mem_xbt_68= false

Then 500th element of Dyn_fct_pg10_ar (array) is copied to Idx_presel_fil_adj

if if Mem_xbt_68= true

Then 520th element of Dyn_fct_pg10_ar-array is copied to Idx_presel_fil_adj


if you'r array (Dyn_fct_pg10_ar) starts with memory address %MW1000 then on situation 1. memory word %MW1500 is copied, on 2nd situation %MW1520 is copied.

(On Unity you can use symbolic programming (unlocated) or symbols with %M or %MW addresses (located). So you also need to look if variables have address or not)
 
untiy pro M array

Thanks Lare.

Makes sense to me now until i try and track the memory location. The memory address for 'Dyn_fct_pg10_ar' (ARRAY 0..4095) is %MW10

So should be looking at %MW510 and %MW530?

There is also another line which is
MOVE_INT_AREBOOL(Dyn_fct_pg10, %M102:10); (*dynamic keys ap 10*)

Once i can get my head around this part i should be ok.

Thanks
 
"So should be looking at %MW510 and %MW530?" Yes

On animation table you can check this with real PLC or simulator, put %MW10[500] to animation table, you should see indirectly value of %MW510 now, same for %MW10[520] = %MW530

"There is also another line which is
MOVE_INT_AREBOOL(Dyn_fct_pg10, %M102:10); (*dynamic keys ap 10*)"

You need to take look bit pattern of integer variable Dyn_fct_pg10. Move int to arebool : 10 copies then bits from integer to bit addresses %M102...%M111

so if Dyn_fct_pg10 have address %MW10

=> after int_to_arebool :10 command

%MW10:X0 => %M102
%MW10:X1 => %M103
%MW10:X2 => %M104
%MW10:X3 => %M105
%MW10:X4 => %M106
%MW10:X5 => %M107
%MW10:X6 => %M108
%MW10:X7 => %M109
%MW10:X8 => %M110
%MW10:X9 => %M111

%MW10:X10..X15 NOT COPIED


int_to_arebool : 16 copies all 16bits from integer to 16 memory bits and so on...


p.s added image of screenshot, %MW1000=index for %MW10

%MW1000=500

=> %MW10[%MW1000] <=> %MW510

array_test.jpg
 
Last edited:
Thanks for your help Lare,

I had to put the array into the animation table to see the live values, I'll put it all together now and work it out how it works.

Thanks again.
 

Similar Topics

Is it possible to add another column to the top of the ladder programming sections? I have eleven default columns now and can not change this...
Replies
1
Views
1,952
Hi, It is my first time to use the redlion OIT software. I am using the crimson 3.0, I just want to know if it is possible to communicate the...
Replies
4
Views
7,385
Gentlemen, Is there someone who have an experience of using Unity Pro for Modicon M340 PLCs from schneider-electric as a software for training? I...
Replies
6
Views
6,270
Hello, I am using Unity pro V15. I have Quantum CPU 671 and Ethernet NOE 77101 configured. I have configured IO scanning on NOE. I have attached...
Replies
5
Views
175
HELLO MY FRİENDS ı have problem. ı tought you can solved thıs problem for me. First of all When I checked all the cable connections of the...
Replies
0
Views
402
Back
Top Bottom