Hi Guys,
I have a small programming problem that I was hoping someone could help me with. I am playing around with the FSUIPC SDK and VB and experimenting with the parallel port. Basically I have written a small program that is supposed to turn on LED's connected to the port when the Marker lights are activated in the sim. I have everything working (cool) apart from a small glitch. This is when I am over the Inner marker. It de-activates the light too early. It is fairly consistant when it happens, it seems to be at the same point when the light turns itself off, even though the sim light is still on. I am not really a programmer, so it is probably something stupid I am not doing right. The code fragment for the relevant routine is below. You will note that it is an expansion of the example in the SDK. The PortOut Call turns the appropriate pin on or off.
Private Sub Timer2_Timer()
Dim dwResult As Long
Dim omiInnermkr() As Byte
Dim omiMiddlemkr() As Byte
Dim omiOutermkr() As Byte
ReDim omiInnermkr(2)
ReDim omiMiddlemkr(2)
ReDim omiOutermkr(2)
' As an example of retrieving data, we will get the Marker status.
' If we wanted additional reads/writes at the same time, we could put them here
If FSUIPC_Read(&HBAC, 2, VarPtr(omiInnermkr(1)), dwResult) Then
' "Read" proceeded without any problems
If FSUIPC_Process(dwResult) Then
' "Process" proceeded without any problems
If omiInnermkr(1) Then
shpInner.FillColor = &HFFFFF
Call PortOut(888, 1)
Else
If omiInnermkr(1) = False Then
shpInner.FillColor = &H0&
' Call PortOut(888, 0)
End If
End If
Else
Label7.Caption = "Processing: " & ResultText(dwResult)
End If
Else
' Unable to "Read"
Label7.Caption = "Reading: " & ResultText(dwResult)
End If
If FSUIPC_Read(&HBAE, 2, VarPtr(omiMiddlemkr(0)), dwResult) Then
' "Read" proceeded without any problems
If FSUIPC_Process(dwResult) Then
' "Process" proceeded without any problems
If omiMiddlemkr(0) Then
shpMiddle.FillColor = &HFF00&
Call PortOut(888, 2)
Else
If omiMiddlemkr(0) = False Then
shpInner.FillColor = &H0&
Call PortOut(888, 0)
End If
End If
If omiMiddlemkr(0) Then
If omiInnermkr(1) Then
shpMiddle.FillColor = &H0&
Call PortOut(888, 1)
Else
If omiMiddlemkr(0) = False Then
shpInner.FillColor = &H0&
Call PortOut(888, 0)
End If
End If
End If
Else
' Unable to "Process"
Label7.Caption = "Processing: " & ResultText(dwResult)
End If
Else
' Unable to "Read"
Label7.Caption = "Reading: " & ResultText(dwResult)
End If
If FSUIPC_Read(&HBB0, 2, VarPtr(omiOutermkr(0)), dwResult) Then
' "Read" proceeded without any problems
If FSUIPC_Process(dwResult) Then
' "Process" proceeded without any problems
If omiOutermkr(0) Then
shpOuter.FillColor = &HFF00&
Call PortOut(888, 4)
Else
' Call PortOut(888, 0)
shpOuter.FillColor = &H0&
End If
Else
' Unable to "Process"
shpMiddle.FillColor = &H0&
End If
Else
' Unable to "Read"
Label7.Caption = "Reading: " & ResultText(dwResult)
End If
End Sub
Any help would be appreciated.
Thanks!
E :wink: