VisionBox .NET Library
Multi_Example.cs

C# example using the Strobe, Multiplexer, DigitalInput and CameraTrigger devices

1 
2 //This example uses the Strobe unit, the Multiplexer, DigitalInput and CameraTrigger.
3 //
4 //The code was tested using the VisionBox AGE-X2
5 //
6 //The Strobe unit is triggered with the digital input 4.
7 //The trigger signal and the resulting strobe pulse are copied to the camera trigger outputs.
8 //
9 //DigIn4 > Mux0 > Strobe0 > Mux1 > CamTrig1
10 // Mux0 > > CamTrig0
11 
12 using System;
13 using VIB_NET;
14 
15 namespace CSharp
16 {
17  class Multi_Example
18  {
19  public static void Multiplexer()
20  {
21  Console.Clear();
22 
23  try
24  {
25  // Create device objects with the 'using' statement so they get closed automatically:
26  using (VIB_NET.Multiplexer multiplexer = new VIB_NET.Multiplexer())
27  using (VIB_NET.TriggerGenerator triggerGenerator = new VIB_NET.TriggerGenerator())
28  using (VIB_NET.CameraTrigger cameraTrigger0 = new VIB_NET.CameraTrigger())
29  using (VIB_NET.CameraTrigger cameraTrigger1 = new VIB_NET.CameraTrigger())
30  using (VIB_NET.DigitalOutput digitalOutput = new VIB_NET.DigitalOutput())
31  using (VIB_NET.DigitalOutput digitalOutput = new VIB_NET.DigitalOutput())
32  using (VIB_NET.Strobe strobe = new VIB_NET.Strobe())
33  {
34  // open devices: TriggerGenerator, Multiplexer, DigitalOutput, 2x CameraTrigger and Strobe
35  multiplexer.Open();
36  triggerGenerator.Open();
37  digitalOutput.Open(0);
38  cameraTrigger0.Open(0);
39  cameraTrigger1.Open(1);
40  strobe.Open(0);
41 
42  // Signal configuration:
43  // DigIn4 -> multiplexer(0) -> cameraTrigger0
44  // -> Strobe
45  // -> StrobeOut0 -> multiplexer(1) -> cameraTrigger1
46 
47  //strobe (hardware trigger by edge, puls time 1ms with 1A)
48  Int32 minOffTime_us;
50  strobe.Init(true);
51  minOffTime_us = strobe.SetLimits(0, 24, 0, 1 * 1000, 0, 1000);
52  strobe.OnTime = 1 * 1000;
53  strobe.Validate = false;
54  strobe.Current = 1000;
55 
56  // you have to set the TriggerMode to hardware before you can configure the TriggerSource and TriggerSourceInvert
57  strobe.TriggerMode = VIB_NET.Strobe.eSTROBE_MODE.HARDWARE_EDGE;
58  res = strobe.TriggerMode;
59  strobe.TriggerSourceInvert = false;
60 
61  // Get number of outputs of the multiplexer
62  Console.WriteLine("\nNumber Of Multiplexer Outputs: " + multiplexer.NumberOfOutputs.ToString());
63  //>configure
64  //multiplexer
65  multiplexer.ConnectOutput(0, VIB_NET.Multiplexer.eMUX_SOURCE.DIG_IN4); // DigIn4 > Line0
66  multiplexer.ConnectOutput(1, VIB_NET.Multiplexer.eMUX_SOURCE.STROBE_0); // StrobeOut0 > Line1
67 
68  //camera trigger as push/pull
69  cameraTrigger0.Set(0, VIB_NET.CameraTrigger.eTRG_SOURCE.MUX_OUT0, false, true, true, false); // Line0 > CamTrig
70 
71  cameraTrigger1.Set(0, VIB_NET.CameraTrigger.eTRG_SOURCE.MUX_OUT1, false, true, true, false); // Line1 > CamTrig1
72 
73  strobe.TriggerSource = Strobe.eSTROBE_SOURCE.MUX_OUT0; // Line0 > Strobe
74 
75  // DigIn4 > Line0 > CamTrig
76  // > Strobe
77  // StrobeOut0 > Line1 > CamTrig1
78 
79 
80  digitalOutput.Output = 16;
81  System.Threading.Thread.Sleep(1000);
82  Console.WriteLine("\nPress enter to proceed...");
83  System.Console.ReadLine();
84  digitalOutput.Output = 0;
85 
91 
92  // Reset Digital Output
93  digitalOutput.SetBit(0, false);
94  digitalOutput.SetBit(1, false);
95 
96  // Read trigger generator version
97  Console.WriteLine("\nTrigger Generator Version: " + triggerGenerator.ConfigureGet("Version").ToString());
98 
99  // Configure trigger generator A to count on both edges of the input signal(TrigIn3 and TrigIn4) up to 10
100  triggerGenerator.ConfigureSet("CounterA=10,TrigIn3_Both CounterA_OFF=0 CounterA_ON=3 CounterA_Reset=Auto"); //TrigIn3(Mux3) > CounterA
101  triggerGenerator.ConfigureSet("CounterA_Start=On");
102 
103  // Connect trigger generator
104  // Gen A
105  triggerGenerator.ConfigureSet("TrigOut0_Mux=TrigIntern0 MuxIntern0=CounterA"); // CounterA > TrigIntern0 > TrigOut0_Mux
106 
107  // Connect multiplexer output 3 with digital input 0
108  multiplexer.ConnectOutput(3, VIB_NET.Multiplexer.eMUX_SOURCE.DIG_IN0); // DigIn0 > Mux3
109  // Connect trigger generator output 0 to multiplexer output 1
110  multiplexer.ConnectOutput(1, VIB_NET.Multiplexer.eMUX_SOURCE.TRIGGEN_OUT0); // TrigOut0_Mux > Mux1
111  //Connect camera 0 channel 0 to multiplexer output 1
112  cameraTrigger.Set(0, VIB_NET.CameraTrigger.eTRG_SOURCE.MUX_OUT1, false, true, false, false); // Mux1 > pCameraTrigger0
113 
114 
115  // Reset CounterA
116  triggerGenerator.ConfigureGet("CounterA,Reset");
117 
118  Console.WriteLine("\n\nTrigger Generator:\n\n0.\nInput State: " + triggerGenerator.ConfigureGet("TrigIn").ToString()); // 0
119  Console.WriteLine("\nCounter A State: " + triggerGenerator.ConfigureGet("CounterA").ToString()); // 0
120  digitalOutput.SetBit(0, true);
121  System.Threading.Thread.Sleep(100);
122  // Read trigger generator states
123  Console.WriteLine("\n\n1.\nInput State: " + triggerGenerator.ConfigureGet("TrigIn").ToString()); // 8(Mux3 active)
124  Console.WriteLine("\nCounter A State: " + triggerGenerator.ConfigureGet("CounterA").ToString()); // 1
125  digitalOutput.SetBit(0, false);
126  System.Threading.Thread.Sleep(100);
127  Console.WriteLine("\n\n2.\nInput State: " + triggerGenerator.ConfigureGet("TrigIn").ToString()); // 0
128  Console.WriteLine("\nCounter A State: " + triggerGenerator.ConfigureGet("CounterA").ToString()); // 2
129  digitalOutput.SetBit(0, true);
130  System.Threading.Thread.Sleep(100);
131  // Read trigger generator states
132  Console.WriteLine("\n\n3.\nInput State: " + triggerGenerator.ConfigureGet("TrigIn").ToString()); // 10(Mux1 und Mux3 active)
133  Console.WriteLine("\nCounter A State: " + triggerGenerator.ConfigureGet("CounterA").ToString()); // 3
134  digitalOutput.SetBit(0, false);
135  System.Threading.Thread.Sleep(100);
136  Console.WriteLine("\n\n4.\nInput State: " + triggerGenerator.ConfigureGet("TrigIn").ToString()); // 2(Mux1 active)
137  Console.WriteLine("\nCounter A State: " + triggerGenerator.ConfigureGet("CounterA").ToString()); // 4
138 
139 
140  // Switch off the multiplexer outputs 0...3
141  multiplexer.ConnectOutput(0, VIB_NET.Multiplexer.eMUX_SOURCE.OFF);
142  multiplexer.ConnectOutput(1, VIB_NET.Multiplexer.eMUX_SOURCE.OFF);
143  multiplexer.ConnectOutput(2, VIB_NET.Multiplexer.eMUX_SOURCE.OFF);
144  multiplexer.ConnectOutput(3, VIB_NET.Multiplexer.eMUX_SOURCE.OFF);
145  multiplexer.ConnectOutput(4, VIB_NET.Multiplexer.eMUX_SOURCE.OFF);
146 
147  // Turn off camera triggger 0 and 1
148  cameraTrigger0.Set(0, VIB_NET.CameraTrigger.eTRG_SOURCE.OFF, false, true, false, false);
149  cameraTrigger1.Set(0, VIB_NET.CameraTrigger.eTRG_SOURCE.OFF, false, true, false, false);
150 
151  // Turn Counter off
152  triggerGenerator.ConfigureSet("CounterA_Start=Off");
153 
154  // Reset digital outputs
155  digitalOutput.Output = 0;
156  } // Close all devices
157  }
158  catch (Exception e)
159  {
160  Console.WriteLine(e.Message);
161  }
162 
163  Console.WriteLine("\nPress enter to proceed...");
164  System.Console.ReadLine();
165  }
166  }
167 }
VIB_NET
All relevant classes and functions are residing in this namespace.
Definition: CameraLinkIn.cpp:6
VIB_NET::Multiplexer
This class controls the Multiplexer unit which connects signal sources and sinks with each other.
Definition: VIB_NET.h:978
VIB_NET::TriggerGenerator
This module controls the FPGA Trigger Unit.
Definition: VIB_NET.h:633
VIB_NET::CameraTrigger::eTRG_SOURCE
eTRG_SOURCE
Camera trigger source, used by Set() and SetAll()
Definition: VIB_NET.h:1183
VIB_NET::DigitalOutput
This class controls the optically isolated output signals.
Definition: VIB_NET.h:1074
VIB_NET::CameraTrigger
This class controls the digital camera trigger output.
Definition: VIB_NET.h:1177
VIB_NET::Multiplexer::eMUX_SOURCE
eMUX_SOURCE
Source signal definitions for the Multiplexer
Definition: VIB_NET.h:983
VIB_NET::Strobe
This class represents the LED Strobe Controller.
Definition: VIB_NET.h:658
VIB_NET::Strobe::eSTROBE_MODE
eSTROBE_MODE
Mode definitions for the strobe unit, used with TriggerMode
Definition: VIB_NET.h:662