Horner Cscape Tag based. Move real to int array

g.mccormick

Lifetime Supporting Member
Join Date
Jul 2012
Location
IN
Posts
961
I seem to be making this harder than it should be, and Its not making any sense.

I simply need to move a real variable to two integer variables that are an array.

Input is structure element real value, output to array elements [0] and [1].

If I select mov or block move I keep getting errors that the type is mismatched.

What am I supposed to select?
 
Use BTD command to move bit 0 (with a length of 16) into INT [0] and then another BTD moving bits starting at 16 into INT[1]
(didnt read the Horner disclaimer, perhaps there is an equivalent bit level move)
 
I simply need to move a real variable to two integer variables that are an array.
Could you explain what you mean by that? Suppose your REAL variable has a value of 3.14159. What values would you like to see in INT[0] and INT[1]? Splitting the lower and upper 16 bits of a 32-bit REAL variable into two 16-bit integers doesn't result in any meaningful data in either of the two INTs.
 
I think that if you write the real to a %R register e.g. %R1, then it will move the real value to two consecutive 16-bit registers i.e. %R1 and %R2, like this:
Untitled.png

Untitled1.png
 
Could you explain what you mean by that? Suppose your REAL variable has a value of 3.14159. What values would you like to see in INT[0] and INT[1]? Splitting the lower and upper 16 bits of a 32-bit REAL variable into two 16-bit integers doesn't result in any meaningful data in either of the two INTs.



Steve,
I know that it wont be meaningful in the ints. I need to move some data into registers that will be read via modbus. So I have an array of INTS starting at %R1..%R50.
I need to move the bits of my real variable into the 32bits of two consecutive array elements (ie. 32 bits into %R1 and %R2).
 
I think that if you write the real to a %R register e.g. %R1, then it will move the real value to two consecutive 16-bit registers i.e. %R1 and %R2, like this:



I am using the tag based, which auto assigns registers (messily I might add).

I have information in real variables at unknown register indexs (since the software automatically assigns them). I want to copy the bits from the reals into two consecutive elements of an array of INTs. This array of INTs I have created at specific registers so that the values can be read via modbus.
 
I had a feeling that might be your reason.
Horner used to pretty closely follow GE Fanuc's approach. If that is still the case, then you may be able to assign the same address to different variables. You could assign the REAL variable to %R00100, which would actually use %R00100 and %R00101. Then you could create a two-element INT array with a different variable name, but assign it to a starting address of %R00100. No need to use any MOVE instructions in logic.
I don't have the latest version of CScape, so I can't set it up myself to see if validates.
 
Last edited:
I had a feeling that might be your reason.
Horner used to pretty closely follow GE Fanuc's approach. If that is still the case, then you may be able to assign the same address to different variables. You could assign the REAL variable to %R00100, which would actually use %R00100 and %R00101. Then you could create a two-element INT array with a different variable name, but assign it to a starting address of %R00100. No need to use any MOVE instructions in logic.
I don't have the latest version of CScape, so I can't set it up myself to see if validates.

If I had started all of this on the register based software then I could have probably done that. As it is, I am writing in the "tag based" software. The tag based automatically assigns register values without the user needing too. It also allows structures and user defined function blocks. The reals that I am interested in are part of structures that I created.


I will try to create a real and ints at the same starting register then I can copy my structure real value to the sacrificial real. That may work!
 
Steve thank you for the idea!

That worked. I created 2 arrays (Array of ints 0-49 and array of reals 0-24) both starting at %R1. Now I can copy real values to the real array elements or mess with copying data into the integer array and the correct bits show up at the correct registers!

Thanks Steve!
 

Similar Topics

I am trying to set up a piece of equipment with a Horner HE-X4R. I'd like to use structured text and so far I'm just trying to get a basic On/off...
Replies
0
Views
70
I have a Horner PLC that is reading Ascii string from a device. When the device responds, it responds with the hex value in Ascii. I need to...
Replies
8
Views
2,382
I have recently intalled the latest version of Cscape 9.9. i am unable to connect the plc using Mini USB cable. unable to see the driver in...
Replies
2
Views
1,926
Hi I'm new on Horner PLC XL4 OCS using Cscape software. After establishing ethernet comm I can upload/download program to/from the XL4 just fine...
Replies
1
Views
1,218
Howdy folks. I've got a question for the brain trust. I have a project that is calling for a X5 to control a Toshiba P9 VFD. The requirements...
Replies
5
Views
1,843
Back
Top Bottom