I’am trying to interface Meadow and Wiegand Reader. I seem to only get 33 bits out of 34 bits. Is the meadow interrupt fast enough to handle wiegand speed.If so ,what could I be doing wrong.Here is my test code.
Imports System
Imports System.Threading
Imports Meadow
Imports Meadow.Devices
Imports Meadow.Hardware
Imports Meadow.Foundation
Imports Meadow.Foundation.Leds
Public Class MeadowApp
'Change F7MicroV2 to F7Micro for V1.x boards'
Inherits App(Of F7Micro, MeadowApp)
Private pin_d0 As IDigitalInterruptPort
Private pin_d1 As IDigitalInterruptPort
Private _lastWiegand As UInt64 = 0
Private _bitCount As UInt64 = 0
Public Sub New()
MyBase.New
Console.WriteLine("Hello VB.NET!")
Initialize()
Main_Prog()
End Sub
Private Sub Initialize()
Console.WriteLine("Initialize hardware...")
_lastWiegand = 0
_bitCount = 0
pin_d0 = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeFalling, ResistorMode.InternalPullUp)
pin_d1 = Device.CreateDigitalInputPort(Device.Pins.D01, InterruptMode.EdgeFalling, ResistorMode.InternalPullUp)
AddHandler pin_d0.Changed, AddressOf ReadD0
AddHandler pin_d1.Changed, AddressOf ReadD1
End Sub
Private Sub ReadD0()
_bitCount += 1 'Increament bit count for Interrupt connected to D00
_lastWiegand = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() ' Keep track Of last wiegand bit received
End Sub
Private Sub ReadD1()
_bitCount += 1 'Increment bit count for Interrupt connected to D01
_lastWiegand = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() 'Keep track Of last wiegand bit received
End Sub
Private Sub Main_Prog()
Dim sysTick As UInt64 = 0
While True
sysTick = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
If ((sysTick - _lastWiegand) > 25 And _bitCount > 0) Then 'Print and reset bitcount at end of read perios
Console.WriteLine("BITCOUNT : " + _bitCount.ToString())
_bitCount = 0
End If
Thread.Sleep(50)
End While
End Sub
End Class