Author Topic: EthernetIPForMicro800 Writing Bool to PLC  (Read 2505 times)

aduhaime2003

  • Newbie
  • *
  • Posts: 36
    • View Profile
EthernetIPForMicro800 Writing Bool to PLC
« on: November 30, 2015, 09:06:36 AM »
I've run into a problem recently where I am trying to write parameters for a run of a system into the PLC. When I'm writing actual numerical values everything works fine but I have some values that are Booleans. This is what I'm writing currently (and where I'm stuck):

 For count As Integer = 0 To index
            SegmentNumber = SegmentSetpoints(index, 1) 'if the segments are read out of order then use the segment # field to indicate placement

            Label1.Text = "Segment " & count & " is being downloaded."
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].number", SegmentSetpoints(index, 1))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].next", SegmentSetpoints(index, 2))
           * EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].loop", CInt(Int(SegmentSetpoints(index, 3).Equals("true"))))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].durationSec", SegmentSetpoints(index, 4))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].startTempSP", SegmentSetpoints(index, 5))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].endTempSP", SegmentSetpoints(index, 6))
            *EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].ramp", CInt(Int(SegmentSetpoints(index, 7).Equals("true"))))
            *EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].soak", CInt(Int(SegmentSetpoints(index, 8).Equals("true"))))
            *EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].lastSegment", CInt(Int(SegmentSetpoints(index, 9).Equals("true"))))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].aquisitionInterval", SegmentSetpoints(index, 10))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].TCHHalarmLevel", SegmentSetpoints(index, 11))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].TCLHalarmLevel", SegmentSetpoints(index, 12))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].TCHLalarmLevel", SegmentSetpoints(index, 13))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].TCLLalarmLevel", SegmentSetpoints(index, 14))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].RoomHHalarmLevel", SegmentSetpoints(index, 15))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].RoomLHalarmLevel", SegmentSetpoints(index, 16))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].RoomHLalarmLevel", SegmentSetpoints(index, 17))
            EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].RoomLLalarmLevel", SegmentSetpoints(index, 18))

        Next
The asterisks are where my attempt is. I tried to convert the Boolean into an integer and write that but gives me an error: Object reference not set to an instance of an object.

Any advice for this would be great appreciated. 

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: EthernetIPForMicro800 Writing Bool to PLC
« Reply #1 on: November 30, 2015, 01:11:31 PM »
Try this for turning it into an integer

Code: [Select]
EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].loop", IIf(SegmentSetpoints(index, 3) = vbTrue, 1, 0))

aduhaime2003

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: EthernetIPForMicro800 Writing Bool to PLC
« Reply #2 on: November 30, 2015, 01:50:43 PM »
Thank you for answering so quickly. I used your suggestion and it caused a different kind of error, this time in the EthernetIPforCLX in the section where it writes to the DLL.

CIP Error - Unknown Code 255

Do you have any experience with this error since Visual Basic isn't very descriptive with what's going on?

Thanks again in advance for any help or advice 

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: EthernetIPForMicro800 Writing Bool to PLC
« Reply #3 on: November 30, 2015, 02:20:45 PM »
That's a bit over my head, but have you tried just sending a 1 or a 0?
Like this

Code: [Select]
EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].loop", 1)

or

EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].loop", 0)

That should be as simple as it gets.

Hope this helps.


aduhaime2003

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: EthernetIPForMicro800 Writing Bool to PLC
« Reply #4 on: November 30, 2015, 02:31:03 PM »
It seems like doing that would be easier in the long run. I'll see how I can change the boolean bits I have to binary. Thanks again for your help.

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: EthernetIPForMicro800 Writing Bool to PLC
« Reply #5 on: November 30, 2015, 02:36:23 PM »
But, does that work?

If it does then you could do something like this

Code: [Select]

dim intLoop as integer= IIf(SegmentSetpoints(index, 3) = vbTrue, 1, 0)
EthernetIPforMicro800Com1.Write("PROGRAMABLECONTROL.Segments[" & SegmentNumber & "].loop", intLoop)



aduhaime2003

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: EthernetIPForMicro800 Writing Bool to PLC
« Reply #6 on: November 30, 2015, 02:51:19 PM »
That actually works perfectly with the solution I had in mind. Tested the code and it works. Thanks A lot. I was stuck on this for a while now

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: EthernetIPForMicro800 Writing Bool to PLC
« Reply #7 on: November 30, 2015, 02:54:21 PM »
Great, Glad I could help.