Menu

Accwessing items in a TPLCstruct

Help
2015-06-23
2016-02-02
  • michael hompus

    michael hompus - 2015-06-23

    I am trying to access items in a TPLCStruct as follows:

    myStr_Spd: TPLCStructItem; //which is an element of Mystruct:TPLCStruct, without a protocol driver attached
    temp:double;
    movespeed:integer=300;
    ....
    myStr_Spd.Value:=move_speed;
    temp:=myStr_spd.Value; // temp <> move_speed ??? This puzzles me

    The IDE Autocomplete suggests: myStr_Spd.SetValue(move_speed) but the compiler does not allow this (no Member SetValue). With an HMIEditBox, I can change the value, which I did for testing, but now I'd like to assign values to the tags via a procedure...

    So: Why can I assign a value, but get something else in return? What am I doing wrong?
    How should I assign a value to a PLCStructItem type tag? The items in the structure are not all of the same tagtype. Do I have to make a TArrayOfDouble, set the values for the elements, and then write the whole array to Mystruct?
    Is it correct that in "PLCBlock1.Write(cmd,2,3) \" the "3" refers to the element of the Block with index 3 where the writing of the dynamic array's contents begins?
    Michael

     

    Last edit: michael hompus 2015-06-29
  • Fabio Luis Girardi

    Sorry Michael by this delay. I'm starting up a climate control on last days.

    Well, I don't know what happens, I'll try build a example to study your case. If You have a example project, this will speed up my analisys.

     
    • michael hompus

      michael hompus - 2015-07-02

      Hi Fabio,
      In the meantime I solved my problem. After I decided to read and write the RAW-values on the structures (or tags if you wish), the outcomes are predictable. Before that I tried to work with the Values, which went wrong I think because the elements of the structure do not all have the same length.
      Question: If I do:
      Tag.Value:=something;
      myValue:=Tag.Value;
      I expect that myValue should equal 'something', which is the tag's Value in the PC. Changing the tag's value does not force an actual ModBus transfer (and is independent of AutoWrite On/Off). Correct?

      But if I want to read the actual value in the PLC I do:
      Tag.Value:=something;
      Tag.read;
      myValue:=Tag.Value;
      Here I expect to see myValue reflecting the old value (not necessarily the same as 'something') since Tag.Read is Synchronous, and the assignment depends on the scan. Correct?

      I did follow your suggestion to check the retries and it seems to work. So does synchronous mean that my program actually waits until a Write or Read to a tag has been completed (Modbus transfer and all)?

      PS I could use some climate control here now.... For a change we have 35 deg C outside, and no airco inside. It makes my thinking go slower!
      Regards,
      Michael

       
  • Christian Greif-Kettmann

    Hi,
    I am looking for a way to read and write values of a LOGO8 from Siemens using lazarus. This is why I found pascalscada. Till now however I did not have success. Is there a demo-project where I can see all the basic steps?

    Best Regards
    Christian

     
  • Fabio Luis Girardi

    I'll test if pascalscada Isotcp works with logo8.

    Currently it works with s7 200/1200/300/400 and might be works with 1500. Logo8 I never tested.

    I'll test this week. If this works, I'll post the example here.

     
  • Fabio Luis Girardi

    Your logo has a ethernet port available? If yes, can you check if port 102 TCP is open? (use a network scanner tool)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.