Menu

Modbus RTU and SMC LECP6P linear actuator

Help
2015-04-28
2015-05-04
  • michael hompus

    michael hompus - 2015-04-28

    I am trying to connect with an SMC linear actuator controller but experience some difficulties.
    After changing the dcbstring := v+': baud=38400 parity=N data=8 stop=1'; in the SerialPort-unit I got comm working.

    Some further questions:
    Why are the tags’ values (TPLCTagNumber) doubles? The Modbus holding registers are 16bit wide (a word?). Anyway, how can I define tags on the HMI side to have the same length and structure as the corresponding variables at the device side. My device for instance uses two holding registers to store position (longint). If I would set TagType to longint, would that mean that ‘the system’ automatically requests and sends 4 bytes = 2 words=2 consecutive holding registers?

    What is the UpdateRate? I was thinking every so many miliseconds (I am using windows) the tags are refreshed, but even at 5000000 the messages still come by at a high rate. So, I think that Refresh (and/or) updateTime control something else than the rate at which variables are updated via ModBus??? Am I supposed to use a timer to control the update?

    My device uses a table of ‘records’ with a similar structure (speed, accel, decel, targetposition etc.) , so I was thinking of a sort of ‘variant record’ structure, consisting of an array of plc-registervalues one way and a list of the variables the other way. In that case, I could request the whole register array to be transferred in one go. How do I do that? Use a TPLCBlock and set its size to the length of the register array? I find some write functions that expect an array as parameter. Is that the way to go?

    Help will be appreciated!
    Michael

     
    • Fabio Luis Girardi

      I am trying to connect with an SMC linear actuator controller but experience
      some difficulties. After changing the dcbstring := v+': baud=38400 parity=N
      data=8 stop=1'; in the SerialPort-unit I got comm working.

      Your problem is related with windows. If you read the documentation of BuildComDCB (I don't remember the name of the function) of windows API, you will see that it can be used to check if a serial port exists in your system. In my tests, this function only works with serial ports <= COM9. If this is your case, try change the name of your serial port to a name less or equal than COM9.

      Some further questions:
      Why are the tags’ values (TPLCTagNumber) doubles? The Modbus holding
      registers are 16bit wide (a word?).

      Because it can be used to represent all numeric types.

      Anyway, how can I define tags on the HMI side to have the same length and
      structure as the corresponding variables at the device side.

      TPLCTagNumber.TagType = pttDefault.

      My device for instance uses two holding registers to store
      position (longint).

      TPLCTagNumber.TagType = pttInteger.

      If I would set TagType to longint, would that mean that
      ‘the system’ automatically requests and sends 4 bytes = 2 words=2
      consecutive holding registers?

      Yes.

      What is the UpdateRate?
      UpdateRate = RefreshTime = how much milliseconds the tag will be updated on your application.

      I was thinking every so many miliseconds (I am using
      windows) the tags are refreshed, but even at 5000000 the messages still come
      by at a high rate. So, I think that Refresh (and/or) updateTime control
      something else than the rate at which variables are updated via ModBus???

      No. UpdateRate does exactly what you thought. To get the expected behavior, set TModbusRTUProtocol.ReadSomethingAlways to false.

      Am I supposed to use a timer to control the update?

      No, set the expected update time on UpdateRate property of your tag and disable ReadSomethingAlways of your modbus driver. UpdateRate sets the property Interval of a Internal TTimer.

      My device uses a table of ‘records’ with a similar structure (speed, accel,
      decel, targetposition etc.) , so I was thinking of a sort of ‘variant
      record’ structure, consisting of an array of plc-registervalues one way and
      a list of the variables the other way. In that case, I could request the
      whole register array to be transferred in one go. How do I do that? Use a
      TPLCBlock and set its size to the length of the register array? I find some
      write functions that expect an array as parameter. Is that the way to go?

      Yes, TPLCBlock.TagType sets the type to entire register array. The TPLCStruct and TPLCStructItem does this job, but Modbus TagBuilder was not updated to use this tag. But you can set TPLCStruct and TPLCStructItem manually.

       
  • michael hompus

    michael hompus - 2015-05-04

    Thanks Fabio,
    I have a basic application running now! Next goal is to create the full fledged controller for an XY stud welding robot.

     

    Last edit: michael hompus 2015-05-12

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.