1 Public Class IOScheduler_Example
2 ' Connect all outputs with the inputs Out 0 to In 0 and so on
3 Public Shared Sub IOScheduler()
6 Dim pVIBSystem As VIB_NET.VIBSystem = New VIB_NET.VIBSystem()
8 If pVIBSystem IsNot Nothing Then
11 'The signal flow inside the FPGA
12 ' TrigGen0[0] > Mux0[0] > IOScheduler0[0] > Mux0[1] > DigOut0[1]
13 ' IOScheduler0[1] > Mux0[2] > DigOut0[2]
15 ' > IOScheduler1[0] > Mux0[3] > DigOut0[3]
19 ' Open digital input device 0
20 '>Open Units(Multiplexer, 2x IOScheduler, DigOut, TriggerGen)
22 Dim pMultiplexer As VIB_NET.Multiplexer = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.MULTIPLEXER, 0), VIB_NET.Multiplexer)
23 'first both IOScheduler
24 Dim pIOScheduler_0 As VIB_NET.IOScheduler = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.IOSCHEDULER, 0), VIB_NET.IOScheduler)
25 Dim pIOScheduler_1 As VIB_NET.IOScheduler = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.IOSCHEDULER, 1), VIB_NET.IOScheduler)
27 Dim pDigitalOutput As VIB_NET.DigitalOutput = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.DIGITAL_OUTPUT, 0), VIB_NET.DigitalOutput)
29 Dim pTriggerGenerator As VIB_NET.TriggerGenerator = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.TRIGGER_GENERATOR, 0), VIB_NET.TriggerGenerator)
31 If ((pTriggerGenerator IsNot Nothing) _
32 And (pDigitalOutput IsNot Nothing) _
33 And (pMultiplexer IsNot Nothing) _
34 And (pIOScheduler_0 IsNot Nothing) _
35 And (pIOScheduler_1 IsNot Nothing)) Then
39 'TriggerGenerator to 100Hz
40 pTriggerGenerator.ConfigureSet("GenA_tLow=5ms GenA_tHigh=5ms")
41 pTriggerGenerator.ConfigureSet("TrigOut0_Mux=GenA")
44 pMultiplexer.ConnectOutput(0, VIB_NET.Multiplexer.eMUX_SOURCE.OFF) 'disconnect the 100Hz from the schedulers
45 pMultiplexer.ConnectOutput(1, VIB_NET.Multiplexer.eMUX_SOURCE.IOSCHEDULER_0_OUT0)
46 pMultiplexer.ConnectOutput(2, VIB_NET.Multiplexer.eMUX_SOURCE.IOSCHEDULER_0_OUT1)
47 pMultiplexer.ConnectOutput(3, VIB_NET.Multiplexer.eMUX_SOURCE.IOSCHEDULER_1_OUT0)
49 'MuxOutpus as source for the DigOut
50 pDigitalOutput.SetSource(0, VIB_NET.DigitalOutput.eOUT_SOURCE.MUX_OUT0, False) 'noInvert
51 pDigitalOutput.SetSource(1, VIB_NET.DigitalOutput.eOUT_SOURCE.MUX_OUT1, False) 'noInvert
52 pDigitalOutput.SetSource(2, VIB_NET.DigitalOutput.eOUT_SOURCE.MUX_OUT2, False) 'noInvert
53 pDigitalOutput.SetSource(3, VIB_NET.DigitalOutput.eOUT_SOURCE.MUX_OUT3, False) 'noInvert
55 'Prepare the IOScheduler
56 pIOScheduler_0.Reset() 'sets the default values
57 pIOScheduler_1.Reset()
58 pIOScheduler_1.SetOutputPulsTiming(8 * 1000, 2 * 1000) ' delay us, on us
61 pIOScheduler_0.Start()
62 pIOScheduler_1.Start()
65 Dim StartDelay As UInteger = 4
66 Dim StepMul As UInteger = 2
67 For i As UInteger = 0 To 4 Step 1
68 'we want to toggle the output
69 If (1 = (i Mod 2)) Then
70 pIOScheduler_0.PushValue(StartDelay + StepMul * i, 2)
72 pIOScheduler_0.PushValue(StartDelay + StepMul * i, 1)
74 'we want only edges so we set always 1
75 pIOScheduler_1.PushValue(StartDelay + StepMul * i, 1)
77 '> connect the 100Hz to the IOScheduler
78 pMultiplexer.ConnectOutput(0, VIB_NET.Multiplexer.eMUX_SOURCE.TRIGGEN_OUT0)
80 '> wait until all elements are outputted
81 Dim iFillLevel As UInteger = 0
83 iFillLevel = pIOScheduler_0.BufferFillLevel
84 Loop While iFillLevel > 0
86 'disconnect the 100Hz from the schedulers
87 pMultiplexer.ConnectOutput(0, VIB_NET.Multiplexer.eMUX_SOURCE.OFF)
89 Catch e As System.Exception
90 Console.WriteLine(e.Message)
92 ' Close the digital output
93 If (pDigitalOutput IsNot Nothing) Then
94 pVIBSystem.CloseDevice(pDigitalOutput)
95 pDigitalOutput = Nothing
97 ' Close the multiplexer
98 If (pMultiplexer IsNot Nothing) Then
99 pVIBSystem.CloseDevice(pMultiplexer)
100 pMultiplexer = Nothing
102 ' Close the IOScheduler_0
103 If (pIOScheduler_0 IsNot Nothing) Then
104 pVIBSystem.CloseDevice(pIOScheduler_0)
105 pIOScheduler_0 = Nothing
107 ' Close the IOScheduler_1
108 If (pIOScheduler_1 IsNot Nothing) Then
109 pVIBSystem.CloseDevice(pIOScheduler_1)
110 pIOScheduler_1 = Nothing
112 ' Close the trigger generator
113 If (pTriggerGenerator IsNot Nothing) Then
114 pVIBSystem.CloseDevice(pTriggerGenerator)
115 pTriggerGenerator = Nothing
119 Catch e As System.Exception
120 Console.WriteLine(e.Message)
126 Console.WriteLine(vbNewLine + "Press enter to proceed...")
127 System.Console.ReadLine()