Unity Pro DINT To 4 Byte Conversion

toddster900

Member
Join Date
Oct 2011
Location
England
Posts
35
Hi All

I have recently had cause to start using Unity Pro but am still struggling with it a bit. I a trying to convert a speed reference for a drive being controlled over coms from a DINT to 4 BYTEs. I have managed to do it as follows.

(*Speed Setpoint*)
DINT_AS_WORD (IN := SV001_DB.Drv_SP,
LOW => Delete_SP1,
HIGH => Delete_SP2);

WORD_AS_BYTE (IN := Delete_SP1,
LOW => SVD001.Outputs.Free1[4],
HIGH => SVD001.Outputs.Free1[5]);

WORD_AS_BYTE (IN := Delete_SP2,
LOW => SVD001.Outputs.Free1[6],
HIGH => SVD001.Outputs.Free1[7]);

However, this required me to create two additional tags every time I want to do this. "Delete_SP1" and "Delete_SP2". Is there a way I can achieve this without creating any additional tags.

ST is also not my preferred language but I can see the benefits in it at times and am trying to improve my understanding and use of the language.

Thanks
 
You can code this also with function blocks at fbd editor, then there is no need to use additional tags. (connect function blocks with lines)

If you want use still st-coding, then I would make first derived function block (own function block where is inside this same code with function blocks/FBD editor)

After you have maked your own function block, you can call it on st-code and you need only variabels for inputs and outputs. (of course you can use your own DFB with every program language at Unity)
 
Last edited:
Hi Lare

Thanks for the response. I had considered writing a FB to do it as you suggested but I had hoped that it may just be my lack of knowledge on ST that was holing me back. If it is not possible I will move forward with that solution.

Thanks again
 
This maybe also works, use array varible with %MW address, then make another variable (dint) with same %MW address. PLC copies data "indirectly" with help of %MW adress from type to type.

(this method don't need any block coding, it has cons and pros.) = Not easy allways to undestand how data copies from variable to variable, Unity also warns that same memory is overlapping with variables)

byte.jpg
 
Much easier to program in the FBD language
3 function blocks connected by links and job done
I find the FBD language much easier and clearer to use. I would never go back to ladder
 

Similar Topics

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
137
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
381
Hi All, I haven't installed Unity Pro in years and needed to install it recently. I initially tried installing Version 11.1 and the whole...
Replies
3
Views
631
Hello i want to implement a Read_var / Write_var functions to communicate with a modbus tcp device at the moment i use the unity simulator at the...
Replies
4
Views
1,854
Hi, I've exported a PL7 application to the .FEF file succesfully. Imported the .FEF file in my Unity Pro project, but two of the five sections in...
Replies
0
Views
752
Back
Top Bottom