Technical Forum

STEP 7 Additional Software

Indirect Addressing when Using SCL

Thread Starter: Dave S   Started: 5/21/2006 4:46 PM   Replies: 12

« Previous thread Next thread »
12» Page 1 of 2 (13 items)
  5/21/2006, 4:46 PM
Joined 5/21/2006
Last visit: 5/22/2006
Posts: 1
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Hi,

I have an application that involves many complex calculations which need to be repeated many times therefore I would like to use indirect addressing however I cannot work out how to perform indirect addressing using REAL numbers from  within SCL, can anyone help me with this?


laugh
Top
  5/21/2006, 9:45 PM
Joined 1/7/2006
Last visit: 4/30/2013
Posts: 2667
Rating:
Rated: Excellent [4.06 out of 5 / rated 253 time(s)]. (253) 
Rated: Excellent [5 out of 5 / rated 2 time(s)]. (2) 

Hi Dave,

I have a example that i have written by my self some time ago.

You have to make first a few symbolic names, they are given in the start of the file thats hereby. This is because SCL couldn't have Global Data sad

The example have ANY-pointers and also indirect BOOL / INT / WORD / DWORD and REAL examples. When you don't understand a thing please ask me blink

The next sentence is a good example for a REAL indirect:
WORD_TO_BLOCK_DB(BufferTo.DB_Number).DD[ByteNrTo] := WORD_TO_BLOCK_DB(BufferSource.DB_Number).DD[ByteNrSource];
{this is a sentence from my example}


Attachment: SCL WriteAll.zip  (178 Downloads)

I hope that the answer will help, if you have still questions, don't hesitate to ask me.

All the best, Late
Never say never, think in solutions, not in trouble......

Top
Thank you for this post from:
  5/25/2007, 12:47 AM
Joined 8/10/2006
Last visit: 5/20/2013
Posts: 294
Rating:
Rated: Excellent [4.07 out of 5 / rated 27 time(s)]. (27) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Late,

Very nice.  Thank you for sharing your work!

Jim

cool
Top
  3/16/2012, 5:00 PM
Joined 10/28/2008
Last visit: 3/21/2013
Posts: 54
Rating:
Rated: Excellent [4.67 out of 5 / rated 6 time(s)]. (6) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Hi all.

I start with SCL programming. I have also problem regarding addressing real numbers in SCL.

I have DB with real point numbers. I want to simply make indirect addresing of this real numbers. But it seems that is not possible?
In the help I can read: " When accessing data of the types BYTE, WORD or DWORD, you must use one index only. The index is interpreted as a byte address. The extent of the access is specified by the size prefix."

I have tried do use real numbers in DB and access it. But with no succes.

My example: In this example all I want is only copy values from one DB to the another in FOR loop..... if SaveVar is DWORD value, everything is OK. But in my DBs there are floating point values. Is there any solution how to do this ? With real numbers (if I change SaveVar to REAL, it does not work).

Thank you for your answers...

Georgio

**********
FUNCTION FC60: BOOL

VAR
   ConVar : INT;
   Inkrement : INT;
END_VAR
VAR_TEMP
     cms1 : BOOL;
     cms0 : BOOL;
     dummy : BOOL;
     SaveVar : DWORD;
END_VAR
  
  // cms0 and cms1
     cms0 := cms0 AND NOT(cms0);   
     cms1 := cms1 OR NOT(cms1);
         
    ConVar := "MatrixA.DB".NoOfRow;
  
    FOR Inkrement:= 2 TO (ConVar + 2) BY 1 DO
        SaveVar:= "MatrixA.DB".DD[Inkrement];
        "MatrixB.DB".DD4 := SaveVar;
    END_FOR;
     
    FC60 := cms1;
END_FUNCTION
Top
  3/16/2012, 5:04 PM
Joined 10/28/2008
Last visit: 3/21/2013
Posts: 54
Rating:
Rated: Excellent [4.67 out of 5 / rated 6 time(s)]. (6) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
I have read the solution from Late, but has to be like this? Is there any faster solution ?

For now I want only to copy real values from one DB to another DB with indirect addressing, but I cant address real numbers in DB indirectly ?

Thank you for your answers.

Georgio
Top
  3/16/2012, 5:14 PM
Joined 1/28/2009
Last visit: 5/22/2013
Posts: 2863
Rating:
Rated: Excellent [4.1 out of 5 / rated 394 time(s)]. (394) 
Users with special expertise supervising conferences
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear  Georgio,
What do you think about using "Real_TO_Dword"
conversion!Rnf:lblSmileyTooltip_  think

You can try that or upload part of your program related to
the problem.Rnf:lblSmileyTooltip_

// To copy content a DB to another, possibly you can use SFC20

Best regards,
Hamid Hosseini

Attachment: SFC20.pdf  (32 Downloads)



=== Edited by hdhosseini @ 3/16/2012 5:23 PM [GMT ] ===



Human beings are members of a whole , In creation of one essence and soul
Sa'adi



Top
  3/16/2012, 5:27 PM
Joined 10/28/2008
Last visit: 3/21/2013
Posts: 54
Rating:
Rated: Excellent [4.67 out of 5 / rated 6 time(s)]. (6) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear hdhosseini.

I was thinking about using REAL_TO_DWORD and DWORD_TO_REAL but I think that it is working like conversion from real to DINT in FBD/STL (DI_R, ROUND, TRUNC, CEIL and FLOOR). But now I can see that in help:

REAL_TO_DWORD

Copies the bit string


DWORD_TO_REAL

Copies the bit string



Now I am a little bit confused about these function..

I do not know exactly if these funtion work in the same way like DWORD to real and real to DWORD conversion in FBD/STL.

I simply have 2 data blocks with real numbers and only want to address these values indirectly. Thats all.

Please see attached snapshot with my solution in DWORD.

I know that for copying I can use SFC20, but further I want to make another things with matrices and I need to know how to access real values indirectly...

Thank you a lot for your answers.

Georgio

Attachment: ScreenShot.jpg  (13 Downloads)



=== Edited by Georgio @ 3/16/2012 5:35 PM [GMT ] ===


=== Edited by Georgio @ 3/16/2012 5:32 PM [GMT ] ===



Top
  3/16/2012, 6:02 PM
Joined 1/28/2009
Last visit: 5/22/2013
Posts: 2863
Rating:
Rated: Excellent [4.1 out of 5 / rated 394 time(s)]. (394) 
Users with special expertise supervising conferences
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear  Georgio,

About the conversion from Real to DWORD (and vice versa):


Let me check your codes,I will update hereRnf:lblSmileyTooltip_
Best regards,
Hamid Hosseini



=== Edited by hdhosseini @ 3/16/2012 6:16 PM [GMT ] ===
// CODE OPTIMIZED


Human beings are members of a whole , In creation of one essence and soul
Sa'adi


Top
  3/16/2012, 6:24 PM
Joined 10/28/2008
Last visit: 3/21/2013
Posts: 54
Rating:
Rated: Excellent [4.67 out of 5 / rated 6 time(s)]. (6) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Dear hdhosseini

I know how conversion from real to dword in STL/FBD works blink

But as I wrote I am a little bit confused about these function in SCL now.. If it is working like TRUNC, DI_R....

From help:

REAL_TO_DWORD

Copies the bit string


DWORD_TO_REAL

Copies the bit string



Now I think I maybe solved my problem. I use REAL_TO_DWORD and DWORD_TO_REAL.
Now I have 2 DB with real numbers. I read 4 bytes like DWORD, convert it with and the real value and store with conversion to another DB. Please see attached file...

Problem is that I read and write DWORD, but in DBs I have real numbers..
I read DWORD, convert it to REAL, and than REAL number convert to DWORD and store to DB.
It works, but I think that it is not correct...

My code:






Thank you for your answers.

Best regards.

Georgio

Attachment: SCL.pdf  (14 Downloads)



=== Edited by Georgio @ 3/16/2012 6:30 PM [GMT ] ===


=== Edited by Georgio @ 3/16/2012 6:30 PM [GMT ] ===



Top
  3/16/2012, 8:28 PM
Joined 1/28/2009
Last visit: 5/22/2013
Posts: 2863
Rating:
Rated: Excellent [4.1 out of 5 / rated 394 time(s)]. (394) 
Users with special expertise supervising conferences
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Hello again,

I did not have your source codesad so I tried to
create situation similar to yours.I created 2
DBs identical with some real numbers as
cell elements(See the snapshots for my case):

Following codes working perfectly in my case as
I checked with PLCSIM.Rnf:lblSmileyTooltip_  think Why do not you use
assignment ":=" because both cells are real?


Best regards

Attachment: Forum_SCL_16_MARCH.zip  (13 Downloads)

Human beings are members of a whole , In creation of one essence and soul
Sa'adi



Top
12» Page 1 of 2 (13 items)
Actions