Hi
I use netduino plus
Which I/O pins are compatible for multi threading.
I have a problem with multithreading.
Code:
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus
Module Module1
Dim button As New InputPort(Pins.ONBOARD_SW1, False, Port.ResistorMode.Disabled)
Dim Sensor As New InputPort(Pins.GPIO_PIN_D0, False, Port.ResistorMode.Disabled)
Dim Motor As New OutputPort(Pins.GPIO_PIN_D1, False)
Dim StepMotor As New OutputPort(Pins.GPIO_PIN_D2, False)
Dim tMotor As New Thread(AddressOf RotateMotor)
Dim tStepMotor As New Thread(AddressOf RotateStepMotor)
Sub Main()
' write your code here
tMotor.Start()
tStepMotor.Start()
Do
Loop
End Sub
Sub RotateMotor()
If button.Read = True Then
Do
Motor.Write(True)
Thread.Sleep(1)
Motor.Write(False)
Thread.Sleep(63)
Loop Until buton.Read = False
End If
End Sub
Sub RotateStepMotor()
If Sensor.Read = True Then
Do
StepMotor.Write(True)
Thread.Sleep(20)
StepMotor.Write(False)
Thread.Sleep(20)
Loop Until Sensor.Read = False
End If
End Sub
End Module
[color=rgb(0,0,0);]If sensor is active then all is OK.[/color]
[color=rgb(0,0,0);]If button is active then all is OK.[/color]
[color=rgb(0,0,0);] [/color]
[color=rgb(0,0,0);]If button and sensor are active then everything is not OK.[/color]
[color=rgb(0,0,0);] [/color]
The output signal of Motor is the same as the output signal of Stepmotor.
What is wrong?
Thanks