Codepark

Stl 4bytes to real

10 posts in this topic

Using sysmac studio, i get 4bytes binary data Data[24], Data[25], Data[26], Data[27] like this,

the problem is that the 4bytes data represent my float data what can i do with that 4bytes lol

If u see below images you can understand my problem....

thank you all,

2A5E3EE2-4D2A-4DFC-96A1-0CDDC4260023.jpeg

BE446A8B-7C39-4DA6-BDEA-2F5449602191.jpeg

Share this post


Link to post
Share on other sites

Have a look at "AryByteTo" instruction.

1 person likes this

Share this post


Link to post
Share on other sites

Thanks for reply :) 

if arrbyteto function exist, it would be easy lol

Share this post


Link to post
Share on other sites
7 minutes ago, Codepark said:

if arrbyteto function exist, it would be easy lol

It does exist.

What controller are you using?

What is the Keyence device?

Is this EtherNet/IP?

1 person likes this

Share this post


Link to post
Share on other sites
38 minutes ago, IO_Rack said:

It does exist.

What controller are you using?

What is the Keyence device?

Is this EtherNet/IP?

 

thanks million again god bless the america

actually i am new in this company for the freelancer job

and i am used to web/app development lol

dealing with this machine friendly code make me come back school lab haha...

 

 

last, respect for the knowledge of this old-fashion, neccessary-evil language, hard to draw idea

AryByteTo

Keyence Device : lj-x8000e

controller : nx blabla?

and yes its EtherNet/ip connection using modem

https://www.manualslib.com/manual/1206594/Omron-Nj501-1500.html?page=506 gosh this make me feeeel soooo comfort....

thanks millionnnnn do u have any problem doing some work or other part lol 

 

will help u whatever i can do...

 

thanks again!!

 

ah can u recommend some ways to study dealing with sysmac studio with stl language?

Edited by Codepark

Share this post


Link to post
Share on other sites
4 hours ago, Codepark said:

can u recommend some ways to study dealing with sysmac studio with stl language?

I have found the help menu in Sysmac Studio to be quite thorough. If you are trying to work out how to code a particular function/function block, find it in the help menu, and have a look at the structured text examples for that function/function block.

If you are referring to some sort of reference material for ST coding generally, I haven't found anything comprehensive yet. If I have a specific problem that I can't find in the help menu, I normally check the forums and/or contact my Omron tech.

Edited by BE
Spelling
1 person likes this

Share this post


Link to post
Share on other sites

www.omronlearning.com for some basic intro to Sysmac classes... Omron also offers in person and virtual training classes.

1 person likes this

Share this post


Link to post
Share on other sites

its been really long time since i had access to Omron but... there may be (should be) option to use union. basically it is a special construct that has more than one variable type of same size. so in this case you could create one with 32bit data exposed as both integer and float. then you can write the integer (4 bytes) and read other (float) or the other way around. it is really just bit-by-bit copy but with different data type.

1 person likes this

Share this post


Link to post
Share on other sites

Union only works with BIT, BYTE, WORD, DWORD, LWORD.  Not Integer or Float.

1 person likes this

Share this post


Link to post
Share on other sites

You're better off looking at the Ethernet IP manual for the device you are communicating with and creating a structure that matches it and using that as your EIP variable. a byte array is a good way to test comms quickly and check that you are getting data from the EIP device but it is much easier to make a structure than convert every byte(s) into the necessary data you're trying to work with.

Programming -> Data -> Data Types -> Structures

Create a new one that matches the instance you are reading, should be well documented in the manual for the target device

1 person likes this

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