Author Topic: Questions about reading and writing with strings and using com2 for scale input?  (Read 5163 times)

Stevenlee

  • Newbie
  • *
  • Posts: 6
    • View Profile
First, thanks for making this software it is awesome!

Secondly, I'm wondering if the advancedHmi software allows reading and writing to the slc 500's st:14 files?

Third, I have scale data(ASCII string) coming in on com2 and want it convert it to an integer for storage in the Plc. Any idea how that can be done?

Any help would be great, thanks.

Jesse

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
if you don't want to use code
1.) grab whatever driver you want for the slc and drop onto form
2.) Define parameters of that driver in the properties window ( IP address, etc.)
3.) drop a basic label onto the form and in its properties make sure that driver is the comm component
4.) if you want to read string ST14 in the PLCAddressvalue propertie enter ST14:0
5.) if you want to write to it set PLCaddressKeypad value to ST14:0 that will bring up a keypad whent the label is clicked(you can use keyboard to type words into it) that will send whatever you type to that address

If you want to use code to read and write at certain events use a textbox

Code: [Select]
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

'To read from PLC
dim plcString1 as String
plcString1 = EthernetIPforPLCSLCMicroCom1.Read("ST14:0")
TextBox1.Text = plcString1

''''''  OR ''''''''
 
'To write to PLC
plcString1 = TextBox1.Text
EthernetIPforPLCSLCMicroCom1.Write("ST14:0", plcString1)

End Sub


And for the ASCII, what are you trying to do? Decode the ASCII to and integer?

Stevenlee

  • Newbie
  • *
  • Posts: 6
    • View Profile
I'm trying to use the serialport1 component from the toolbox. However, under its properties I cannot find out how to assign com2 to that component.

Also, I've tried typing the st14:0 file in the plcaddressvalue field and it doesn't work. I could be wrong but it only seems capable of dealing with integers not strings.

Yes, I want the computer running the hmi software to communicate to the Plc through com1 and use com2  to receive ASCII text from a scale. The program then needs to take the ASCII number convert it into a integer and place it into an n7 file.

I don't have any experience using VB, it's new to me. I have done programing before mostly old school basic and assembly. I'm trying to fing a book on VB to help me out.

Stevenlee

  • Newbie
  • *
  • Posts: 6
    • View Profile
Ok, so with df1comm1 and serialport1 together in the lower box and the basiclable selected, when I try and change the commcomponent property I'm only given none and df1comm1 as options.

Stevenlee

  • Newbie
  • *
  • Posts: 6
    • View Profile
After putting st14:0 in PLCAddressValue and running the code the basiclable alternates between saying "basiclable" and "object reference not set to an instance of an object."

Stevenlee

  • Newbie
  • *
  • Posts: 6
    • View Profile
Code: [Select]
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

'To read from PLC
dim plcString1 as String
plcString1 = EthernetIPforPLCSLCMicroCom1.Read("ST14:0")
TextBox1.Text = plcString1

''''''  OR ''''''''
 
'To write to PLC
plcString1 = TextBox1.Text
EthernetIPforPLCSLCMicroCom1.Write("ST14:0", plcString1)

End Sub


Thank you for this code. I shifted gears for a little bit to learn more about Visual Basic. After figuring out how to get the scale's RS-232 text into my code I can now get it into the plc!