Looping sensors

sandhu

Member
Join Date
Dec 2002
Posts
4
Hi all,
I have got a problem here. I am currently working on a program. In this programi am using 4 input pins from the PLC to attach to 4 different sensors. In the programme below I am able to detect only one sensor. I am unable to detect the other 3 sensors. In the coding below the instring1 is detect the sensor at pin 9. How do i modify the programme so that it can detect 3 more sensors? I keep getting errors whenever i loop them. Do I have to read in a "DM"? Can anybody help?
"
Private Sub tmrReadInput_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrReadInput.Tick
Dim instring1 As String

tmrReadInput.Enabled = False
' Always wrap up working with Comm Ports in exception handlers.

Try
' Enable the timer.
Me.tmrReadCommPortMain.Enabled = True
instring1 = "RD" + " " + "9" & Chr(13)
' Write an user specified Command to the Port.
m_CommPort.Write(Encoding.ASCII.GetBytes(instring1))
' Sleep long enough for the modem to respond and the timer to fire.
System.Threading.Thread.Sleep(200)
Application.DoEvents()

Catch ex As Exception
' Warn the user.
MessageBox.Show("Unable to communicate with PLC")
Finally
' Disable the timer.
Me.tmrReadCommPortMain.Enabled = False

Me.tmrReadInput.Enabled = True

End Try

End Sub
"
I am using the below code to generate the output detected by the input.
"
Private Sub WriteMessageMain(ByVal message As String, ByVal linefeed As Boolean)
Dim buffer As Integer

buffer = InStr(message, "0")
If buffer <> 0 Then
TextBox1.Text = "Vacant"
End If

buffer = InStr(message, "1")
If buffer <> 0 Then
TextBox1.Text = "Occupied"
End If

End Sub
"

Thanx
Sandhya
 

Similar Topics

Hi, I am new to ladder logic. I have completed a code in the Xinje PLC XC3-32RT-E for one of the machines I am developing. Currently the program...
Replies
30
Views
977
Hello, I am programming a ladder routine that finds a part on a conveyor that has a given part number. I am having no problem finding the part and...
Replies
1
Views
1,906
I've got several ListBoxes that I want to perform the same function on. From my searches, you can accomplish this in VBA by using a FOR loop, but...
Replies
4
Views
2,882
Hello everyone, I am new to ladder logic and am currently working on a small project where I might need some help. So I am modifying the sequence...
Replies
9
Views
2,412
Hello, This is my very first post here - I'm working on a small brewery project with multiple solenoid valves. The instructions follow a set of...
Replies
2
Views
1,747
Back
Top Bottom