Author Topic: 3 position sw.  (Read 1494 times)

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
3 position sw.
« on: May 01, 2015, 01:00:23 PM »
When I start my HMI , the switch always shows Center position , if the bit for right or left is true it still shows the Center position ,   Micrologix 1400 ,  I have to click it to show the correct position

Darrell

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: 3 position sw.
« Reply #1 on: May 01, 2015, 01:37:50 PM »
Do you have anything in the properties PLCAddressValueLeft and PLCAddressValueRight? If there is nothing in those properties, it will not sync up with the PLC.

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: 3 position sw.
« Reply #2 on: May 01, 2015, 05:05:39 PM »
Yes I do , the bit is true , and it doesn't sync up
Darrell

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: 3 position sw.
« Reply #3 on: May 01, 2015, 06:31:30 PM »
Open SelectorSwitch3Pos.vb and add this code to the PLC Related Properties region:

    Private m_ValueLeft As Boolean
    Public Property ValueLeft As Boolean
        Get
            Return (Value = 0)
        End Get
        Set(value As Boolean)
            If m_ValueLeft <> value Then
                If value Then
                    Me.Value = 0
                ElseIf Not m_ValueRight Then
                    Me.Value = 1
                End If
                m_ValueLeft = value
            End If
        End Set
    End Property

    Private m_ValueRight As Boolean
    Public Property ValueRight As Boolean
        Get
            Return (Value = 2)
        End Get
        Set(value As Boolean)
            If m_ValueRight <> value Then
                If value Then
                    Me.Value = 2
                ElseIf Not m_ValueLeft Then
                    Me.Value = 1
                End If
                m_ValueRight = value
            End If
        End Set
    End Property

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: 3 position sw.
« Reply #4 on: May 02, 2015, 10:59:57 AM »
Now works , thanks Archie

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: 3 position sw.
« Reply #5 on: May 03, 2015, 10:04:16 PM »
What I noticed today was when I load my HMI the switch will sync , but if I happen to click the switch to another position it will not re-sync

I'm using this one as an indicator , to tell me which one is on , Hand/Off/Auto switch for example

Darrell