Author Topic: sending data to PLC over modbus  (Read 1106 times)

jgmdesigns

  • Newbie
  • *
  • Posts: 15
    • View Profile
sending data to PLC over modbus
« on: January 10, 2022, 10:07:23 PM »
Hello again,
  With a lot of head scratching I am slowly getting this going.  My next point on my list is being able to send numeric data to a holding register in teh PLC.  I would like to use a text entry box, but that seems like the wrong item to use.

What would I use to enter an integer and when I click a send button, or press enter, it will send the integer to teh plc over ModbusTCP?

Also, I have added a data source thinking that would help, but nope...how do I delete it?

Jim

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: sending data to PLC over modbus
« Reply #1 on: January 11, 2022, 08:17:17 AM »
Many of the controls have a property named PLCAddressKeypad. If you put a valid address in that property, then clicking the control during run time will pop up a keypad.

Another way to write a value is to use the BasicButton and set OutputType to WriteValue. Use the ValueToWrite property to set which value to write. This may seems to be of little use, but it comes into play in cases such as having 3 buttons for Manual-Off-Auto. Each state always having a fixed value.

jgmdesigns

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sending data to PLC over modbus
« Reply #2 on: January 11, 2022, 08:57:32 AM »
Thanks for the reply.  I did see that feature of the keypad, which it appears that I will have to use.  I'll be ordering the PDF explaining all the abilities of the Basic Label as it seems to be the workhorse, but I wot know until I buy the book today.

Dumb question time....
Can I create my own control and attach it to the ModbusTCP engine for use in AdvancedHMI?

I have also in another thread asked about a user manual for all these things as well.

Jim

jgmdesigns

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sending data to PLC over modbus
« Reply #3 on: January 11, 2022, 09:02:55 AM »
Just thought of one more item I need to accomplish as well...

I need to read  register in teh PLC.  THats easy peasy.  But I need to write this same number I received back into the PLC into another register for comparison.  Reason for this is for the PLC to detect that the software has shutdown.

Can AHMI accomplish this?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: sending data to PLC over modbus
« Reply #4 on: January 11, 2022, 02:45:16 PM »
You can create your own controls. There are some examples the Additional Components section of this forum. The key to understanding how AdvancedHMI works is knowing the controls have 2 layers. The first layer is purely Windows application functionality which has no connection the drivers. The 2nd layer inherits that control and adds the code that links it to the communication driver. If you look at the PLCAddress* properties, you will notice the text after PLCAddress most often matches an existing property. The layer 2 automatically recognizes this and takes the value from the PLC and puts it into the corresponding property.

The ComBridge is a component that reads from one register and writes the value to another

dmroeder

  • Administrator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: sending data to PLC over modbus
« Reply #5 on: January 11, 2022, 08:30:44 PM »
If the goal is for the PLC to know that the software isn't running, then I would just have a timer in your AHMI project that writes the PC clock milliseconds to a DINT register in the PLC.  Just check that the value is changing.  I don't think there is a need to complicate things by having to read something first, then write it back to the PLC.
« Last Edit: January 11, 2022, 08:42:43 PM by dmroeder »

jgmdesigns

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: sending data to PLC over modbus
« Reply #6 on: January 12, 2022, 02:41:18 PM »
Thanks for the idea @dmroeder.

For teh purposes of learning, I would like to stick with my idea first.  I code in C for microcontrollers, and AHMI looks to be using C++ which I am not very good with.  But I will look at your idea once I have things in order on my end.

@Archie,
Where would I find ComBridge?  My apologies for ll the questions, but doing things this way is rather new to me.

JIm