![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#1 |
Lifetime Supporting Member
![]() ![]() Join Date: Jul 2012
Location: IN
Posts: 944
|
Horner Cscape Tag based. Move real to int array
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? |
![]() |
![]() |
#2 |
Lifetime Supporting Member + Moderator
|
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)
__________________
≈ There are 2 kinds of people in the world... (1) Those that can derive answers from incomplete Data |
![]() |
![]() |
#3 | |
Lifetime Supporting Member + Moderator
|
Quote:
|
|
![]() |
![]() |
#4 |
Lifetime Supporting Member
|
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
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. viii) But I should be ignored. |
![]() |
![]() |
#5 | |
Lifetime Supporting Member
![]() ![]() Join Date: Jul 2012
Location: IN
Posts: 944
|
Quote:
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). |
|
![]() |
![]() |
#6 | |
Lifetime Supporting Member
![]() ![]() Join Date: Jul 2012
Location: IN
Posts: 944
|
Quote:
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. |
|
![]() |
![]() |
#7 |
Lifetime Supporting Member + Moderator
|
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 by Steve Bailey; September 23rd, 2023 at 10:27 PM. |
![]() |
![]() |
#8 | |
Lifetime Supporting Member
![]() ![]() Join Date: Jul 2012
Location: IN
Posts: 944
|
Quote:
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! |
|
![]() |
![]() |
#9 |
Lifetime Supporting Member
![]() ![]() Join Date: Jul 2012
Location: IN
Posts: 944
|
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! |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Accessing Studio 5000 Tag Based Alarms in Red Lion Crimson | einnh | LIVE PLC Questions And Answers | 0 | October 9th, 2020 12:51 PM |
Not able to understand this S7-code | drspanda | LIVE PLC Questions And Answers | 8 | November 13th, 2007 02:06 PM |
Cscape Horner ocs problem | Unregistered | LIVE PLC Questions And Answers | 1 | May 10th, 2007 06:55 PM |
Building an S7 Array Move Questions | DesertDog | LIVE PLC Questions And Answers | 19 | June 17th, 2004 11:51 AM |
Ideas needed for Siemens S7 program | tesalmin | LIVE PLC Questions And Answers | 12 | March 4th, 2004 02:40 PM |