public void PlayWaveform() { try { #if false moduleAOU.triggerIOconfig(SD_TriggerDirections.AOU_TRG_OUT); int PXIMask = 1 << ctrlParameter.SyncTriggerOut; var t = moduleAOU.AWGqueueMarkerConfig(nAWG, 3, PXIMask, 1, 0, 1, 18, 0); Log("1.4 AWG Sync Output set"); #endif moduleAOU.AWGstop(nAWG); var t = moduleAOU.AWGstart(nAWG); Log("AWG Playing. " + t.ToString()); } catch (Exception ex) { Log(ex.Message); throw ex; } }
public HW_STATUS_RETURNS ScanControlInitialize(double x_amp, double y_amp, double[] Xarray_vol, double[] Yarray_vol, int[] Xarray_index, int[] Yarray_index, double delay, int recording_rate) { int status; // Channel 1 for y scan and channel 2 for x scan //Create an instance of the AOU module SD_AOU moduleAOU = new SD_AOU(); string ModuleName = "M3201A"; int nChassis = 1; int nSlot = 7; if ((status = moduleAOU.open(ModuleName, nChassis, nSlot)) < 0) { Console.WriteLine("Error openning the Module 'M3201A', make sure the slot and chassis are correct. Aborting..."); Console.ReadKey(); return(HW_STATUS_RETURNS.HW_SUCCESS); } // Config amplitude and setup AWG in channels 1 and 2, moduleAOU.channelAmplitude(1, y_amp); moduleAOU.channelWaveShape(1, SD_Waveshapes.AOU_AWG); moduleAOU.channelAmplitude(2, x_amp); moduleAOU.channelWaveShape(2, SD_Waveshapes.AOU_AWG); moduleAOU.waveformFlush(); // Convert array into list xpoints = new List <double>(); ypoints = new List <double>(); xindex = new List <int>(); yindex = new List <int>(); xpoints.Clear(); ypoints.Clear(); xindex.Clear(); yindex.Clear(); xpoints = Xarray_vol.ToList(); ypoints = Yarray_vol.ToList(); xindex = Xarray_index.ToList(); yindex = Yarray_index.ToList(); // Set external trigger as input moduleAOU.triggerIOdirection(SD_TriggerDirections.AOU_TRG_IN); // Config trigger as external trigger and rising edge moduleAOU.AWGtriggerExternalConfig(1, SD_TriggerExternalSources.TRIGGER_EXTERN, SD_TriggerBehaviors.TRIGGER_RISE); moduleAOU.AWGtriggerExternalConfig(2, SD_TriggerExternalSources.TRIGGER_EXTERN, SD_TriggerBehaviors.TRIGGER_RISE); // flush both channels status = moduleAOU.AWGflush(1); status = moduleAOU.AWGflush(2); int WFinModuleCount = 0; /// load waveform for channel 2 (X) for (int ix = 0; ix < xpoints.Count; ix++) { // with 16 reps when generate wave form, AWG generates the desired scan pattern, not sure why // var tmpWaveform_X = new SD_Wave(SD_WaveformTypes.WAVE_ANALOG, new double[] { xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix], xpoints[ix] }); var tmpWaveform_X = new SD_Wave(SD_WaveformTypes.WAVE_ANALOG, new double[] { xpoints[ix], xpoints[ix] }); status = moduleAOU.waveformLoad(tmpWaveform_X, WFinModuleCount, 1); // padding option 1 is used to maintain ending voltage after each WaveForm if (status < 0) { Console.WriteLine("Error while loading " + ix + " point from x array"); } WFinModuleCount++; } // queue x channel, for x, WFinModuleCount is the same as ix for (int ix = 0; ix < xindex.Count; ix++) { // loop x array status = moduleAOU.AWGqueueWaveform(2, xindex[ix], SD_TriggerModes.EXTTRIG, 0, 1, 4);// AWG, waveform#, trigger, delay, cycle,prescaler if (status < 0) { Console.WriteLine("Error while queuing " + ix + " point from x array"); } } /// load waveform for channel 1 (Y) for (int iy = 0; iy < ypoints.Count; iy++) { // var tmpWaveform_Y = new SD_Wave(SD_WaveformTypes.WAVE_ANALOG, new double[] { ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy], ypoints[iy] }); var tmpWaveform_Y = new SD_Wave(SD_WaveformTypes.WAVE_ANALOG, new double[] { ypoints[iy], ypoints[iy] }); status = moduleAOU.waveformLoad(tmpWaveform_Y, WFinModuleCount, 1); // padding option 1 is used to maintain ending voltage after each WaveForm if (status < 0) { Console.WriteLine("Error while loading " + iy + " point from y array, error code " + status); } WFinModuleCount++; } // queue waveform for channel 1 for (int iy = 0; iy < yindex.Count; iy++) { // use external trigger and cycles for Y channel status = moduleAOU.AWGqueueWaveform(1, yindex[iy] + xpoints.Count, SD_TriggerModes.EXTTRIG_CYCLE, 0, xindex.Count, 4);// AWG, waveform#, trigger, delay, cycle,prescaler if (status < 0) { Console.WriteLine("Error while queuing " + iy + " point from y array, error code " + status); } } // y protection waveform runs only once var protWaveform_Y = new SD_Wave(SD_WaveformTypes.WAVE_ANALOG, new double[] { -0.99, -0.99 }); status = moduleAOU.waveformLoad(protWaveform_Y, WFinModuleCount, 1); // use pos xpoints.Count + ypoints.Count at waveform pool, can be shared by both x and y if (status < 0) { Console.WriteLine("Error while loading protection point from y array, error code " + status); } status = moduleAOU.AWGqueueWaveform(1, xpoints.Count + ypoints.Count, SD_TriggerModes.EXTTRIG, 0, 2, 4095);// AWG, waveform#, trigger, delay, cycle, prescaler if (status < 0) { Console.WriteLine("Error while queuing protection point from y array, error code " + status); } // Configure X channel to cyclic mode, Y to single shot moduleAOU.AWGqueueConfig(1, 0); moduleAOU.AWGqueueConfig(2, 1); Console.WriteLine("Scanning in traditional way with " + Xarray_index.Count() + " by " + Yarray_index.Count() + " beam positions."); // Start both channel and wait for triggers moduleAOU.AWGstart(1); moduleAOU.AWGstart(2); // after AWGstart(2), AWGisRunning(2) = 1, AWGnWFplaying(2) = 0, same for channel 1, there might be 1 px offset Console.WriteLine("Now running on x and y " + moduleAOU.AWGnWFplaying(1) + "----" + moduleAOU.AWGnWFplaying(2)); #region previous scheme to jump on Y channel // determine how long to pause after each jump based on frame rate /*int pause_ms = 1; * double frametime = 1000 / (double)recording_rate; * if (frametime > 1) * { * pause_ms = (int)Math.Ceiling(frametime); * } * int ncycle = 0; * Console.WriteLine("Now on Y channel " + moduleAOU.AWGnWFplaying(1) + " Now on X channel: " + moduleAOU.AWGnWFplaying(2) + "_" + moduleAOU.AWGisRunning(2)); * while (moduleAOU.AWGnWFplaying(2) == 0) // x channel may not be at zero when no trigger come, replace with AWGisRunning * { * // Empty loop wait for trigger to come * } * * // Now cycle start * Console.WriteLine("Now on Y channel " + moduleAOU.AWGnWFplaying(1) + " Now on X channel " + moduleAOU.AWGnWFplaying(2)); * ncycle++; // ncycle=1, currently working on cycle 1 * * * * while (ncycle < yindex.Count()) * { * if(moduleAOU.AWGnWFplaying(2)==xindex.Count()-1) * { * ncycle++; * moduleAOU.AWGtrigger(1); * Console.WriteLine("Jump to cycle " + ncycle + " now on Y channel: " + moduleAOU.AWGnWFplaying(1) + " now on X channel : " + moduleAOU.AWGnWFplaying(2)); * System.Threading.Thread.Sleep(pause_ms * 2); * } * } * moduleAOU.AWGtrigger(1); // trigger y to protection position and stop x scan * Console.WriteLine("Now on Y channel " + moduleAOU.AWGnWFplaying(1)); * moduleAOU.AWGstop(2); * System.Threading.Thread.Sleep(5000); // sleep 5 secs with beam in protection position for user to block beam and stop acquisition */ #endregion while (moduleAOU.AWGnWFplaying(1) != xpoints.Count + ypoints.Count) { } Console.WriteLine("Acquisition finished, stop camera now"); moduleAOU.AWGstop(2); moduleAOU.AWGstop(1); return(HW_STATUS_RETURNS.HW_SUCCESS); }
static void Main(string[] args) { int status; //Create an instance of the AOU module SD_AOU moduleAOU = new SD_AOU(); //Open a physical AOU-H0002 module on Slot 4 if ((status = moduleAOU.open("SD-PXE-AOU-H0002", 0, 3)) < 0) { Console.WriteLine("Error openning the Module 'SD-PXE-AOU-H0002', make sure the slot and chassis are correct. Aborting the Demo..."); Console.ReadKey(); return; } // Config amplitude and setup AWG in channels 0 and 1 moduleAOU.channelAmplitude(0, 1.2); // 1.2 Volts Peak moduleAOU.channelWaveShape(0, SD_Waveshapes.AOU_AWG); moduleAOU.channelAmplitude(1, 1.2); // 1.2 Volts Peak moduleAOU.channelWaveShape(1, SD_Waveshapes.AOU_AWG); Console.WriteLine("Press any key to run the AWG on channel 0 (infinite cycles of a Triangular with prescaler 2)..."); Console.ReadKey(); // Load, queue and run the Triangular.csv waveform on channel 0 if (moduleAOU.AWG(0, "Triangular.csv", SD_TriggerModes.AUTOTRIG, 0, 0, 2) < 0) { Console.WriteLine("Error loading the waveform file 'Triangular.csv', make sure the path is correct. Aborting the Demo..."); Console.ReadKey(); moduleAOU.close(); return; } Console.WriteLine("Press any key to run the AWG on channel 1 (2 cycles of a Triangular with prescaler 5)..."); Console.ReadKey(); // Load, queue and run the Triangular.csv waveform on channel 1 if (moduleAOU.AWG(1, "Triangular.csv", SD_TriggerModes.AUTOTRIG, 0, 2, 5) < 0) { Console.WriteLine("Error loading the waveform file 'Triangular.csv', make sure the path is correct. Aborting the Demo..."); Console.ReadKey(); moduleAOU.close(); return; } Console.WriteLine("Press any key to stop the AWGs 0 and 1..."); Console.ReadKey(); //Stop simultaneously the AWGs of channels 0 and 1. moduleAOU.AWGstopMultiple(3); Console.WriteLine("Press any key to run the AWG on channel 0 and 1..."); Console.WriteLine("(Channel 0: 1 cycle Triangular with prescaler 4 -- Channel 1: 3 cycles Triangular with prescaler 3)"); Console.ReadKey(); // Load, queue and run the triangular.csv waveform on channel 0 if (moduleAOU.AWG(0, "Triangular.csv", SD_TriggerModes.AUTOTRIG, 0, 1, 4) < 0) { Console.WriteLine("Error loading the waveform file 'Triangular.csv', make sure the path is correct. Aborting the Demo..."); Console.ReadKey(); moduleAOU.close(); return; } // Load, queue and run the triangular.csv waveform on channel 1 if (moduleAOU.AWG(1, "Triangular.csv", SD_TriggerModes.AUTOTRIG, 0, 3, 3) < 0) { Console.WriteLine("Error loading the waveform file 'Triangular.csv', make sure the path is correct. Aborting the Demo..."); Console.ReadKey(); moduleAOU.close(); return; } Console.WriteLine("Press any key to run the AWG on channel 0 with a long handmade RAW triangular waveform..."); Console.ReadKey(); double data = 0; int nPoints = 1000000; double inc = 0.1; short[] waveformData = new short[nPoints]; for (int i = 0; i < nPoints; i++) { waveformData[i] = (short)(data * 32767.0); data = data + inc; if (data > 1) { data = 2 - data; inc = -0.1; } else if (data < -1) { data = -2 - data; inc = 0.1; } } if (moduleAOU.waveformLoad(SD_WaveformTypes.WAVE_ANALOG, waveformData, 0) < 0) { Console.WriteLine("Error loading the waveform, make sure its data and type are correct. Aborting the Demo..."); Console.ReadKey(); moduleAOU.close(); return; } if (moduleAOU.AWGqueueWaveform(0, 0, 0, 0, 0, 0) < 0) { Console.WriteLine("Error queueing loaded waveform, make sure queue parameters are correct. Aborting the Demo..."); Console.ReadKey(); moduleAOU.close(); return; } if (moduleAOU.AWGstart(0) < 0) { Console.WriteLine("Error running AWG. Aborting the Demo..."); Console.ReadKey(); moduleAOU.close(); return; } Console.WriteLine("Press any key to quit the demo..."); Console.ReadKey(); moduleAOU.close(); }
private void buttonTestWaveformTrigger_Click(object sender, EventArgs e) { clearConsole(); // Create a waveform object in PC RAM from waveform file SD_Wave wave1 = new SD_Wave("..\\..\\..\\..\\..\\..\\..\\Waveforms\\Triangular.csv"); SD_Wave wave2 = new SD_Wave("..\\..\\..\\..\\..\\..\\..\\Waveforms\\Gaussian.csv"); if (wave1.getStatus() < 0 || wave2.getStatus() < 0) { printToConsole("Error opening waveform File"); return; } int nWave1 = 0; int nWave2 = 1; // Erase all waveforms from module memory and load waveforms waveId1 and waveId2 in position nWave1 and nWave2 moduleAOU.waveformFlush(); moduleAOU.waveformLoad(wave1, nWave1); moduleAOU.waveformLoad(wave2, nWave2); // Turn off nChannel moduleAOU.channelWaveShape(nChannel, SD_Waveshapes.AOU_OFF); // Switch off angle modulation and Amplitude modulation moduleAOU.modulationAngleConfig(nChannel, SD_ModulationTypes.AOU_MOD_OFF, 0); moduleAOU.modulationAmplitudeConfig(nChannel, SD_ModulationTypes.AOU_MOD_OFF, 0); // Config amplitude and setup AWG in nChannel moduleAOU.channelAmplitude(nChannel, 1.2); // 1.2 Volts Peak moduleAOU.channelWaveShape(nChannel, SD_Waveshapes.AOU_AWG); // Set external trigger as input moduleAOU.triggerIOdirection(SD_TriggerDirections.AOU_TRG_IN); // Config trigger as external trigger and rising edge moduleAOU.AWGtriggerExternalConfig(nChannel, SD_TriggerExternalSources.TRIGGER_EXTERN, SD_TriggerBehaivors.TRIGGER_RISE); // Flush channel waveform queue moduleAOU.AWGflush(nChannel); // Queue waveform nWave1 with VI/HVI trigger and delay of 50ns from the trigger moduleAOU.AWGqueueWaveform(nChannel, nWave1, SD_TriggerModes.VIHVITRIG, 50, 1, 0); // Queue waveform nWave1 with external trigger and delay of 100ns from the trigger moduleAOU.AWGqueueWaveform(nChannel, nWave1, SD_TriggerModes.EXTTRIG, 100, 1, 0); // Queue waveforms nWave1 and nWave2 with differents trigger and delay of 200ns from the trigger and between them moduleAOU.AWGqueueWaveform(nChannel, nWave2, SD_TriggerModes.EXTTRIG, 200, 1, 0); moduleAOU.AWGqueueWaveform(nChannel, nWave1, SD_TriggerModes.AUTOTRIG, 280, 1, 0); printToConsole("External trigger configurated.\nModule configuration successfull, Press CONTINUE to start the AWG"); runPause(); moduleAOU.AWGstart(nChannel); printToConsole("AWG started. Waiting for the triggers. Press CONTINUE to send a VI/HVI trigger."); runPause(); moduleAOU.AWGtrigger(nChannel); printToConsole("Waiting for two external triggers. Press CONTINUE to stop the AWG."); runPause(); moduleAOU.AWGstop(nChannel); printToConsole("AWG Stopped. Test Finished."); }
private void buttonPlay_Click(object sender, EventArgs e) { // Start the AWG to reproduce the waveforms in the queue module.AWGstart((int)comboBoxChannel.SelectedIndex); }
public HW_STATUS_RETURNS ScanControlInitialize(double x_amp, double y_amp, double[] Xarray_vol, double[] Yarray_vol, int[] Xarray_index, int[] Yarray_index, double delay) { int status; // Channel 1 for y scan and channel 2 for x scan //Create an instance of the AOU module SD_AOU moduleAOU = new SD_AOU(); string ModuleName = "M3201A"; int nChassis = 1; int nSlot = 3; if ((status = moduleAOU.open(ModuleName, nChassis, nSlot)) < 0) { Console.WriteLine("Error openning the Module 'M3201A', make sure the slot and chassis are correct. Aborting..."); Console.ReadKey(); return(HW_STATUS_RETURNS.HW_SUCCESS); } // Config amplitude and setup AWG in channels 1 and 2, moduleAOU.channelAmplitude(1, y_amp); moduleAOU.channelWaveShape(1, SD_Waveshapes.AOU_AWG); moduleAOU.channelAmplitude(2, x_amp); moduleAOU.channelWaveShape(2, SD_Waveshapes.AOU_AWG); moduleAOU.waveformFlush(); // Convert array into list xpoints = new List <double>(); ypoints = new List <double>(); xindex = new List <int>(); yindex = new List <int>(); xpoints.Clear(); ypoints.Clear(); xindex.Clear(); yindex.Clear(); xpoints = Xarray_vol.ToList(); ypoints = Yarray_vol.ToList(); xindex = Xarray_index.ToList(); yindex = Yarray_index.ToList(); // Set external trigger as input moduleAOU.triggerIOdirection(SD_TriggerDirections.AOU_TRG_IN); // Config trigger as external trigger and rising edge moduleAOU.AWGtriggerExternalConfig(1, SD_TriggerExternalSources.TRIGGER_EXTERN, SD_TriggerBehaviors.TRIGGER_RISE); moduleAOU.AWGtriggerExternalConfig(2, SD_TriggerExternalSources.TRIGGER_EXTERN, SD_TriggerBehaviors.TRIGGER_RISE); // flush both channels status = moduleAOU.AWGflush(1); status = moduleAOU.AWGflush(2); int WFinModuleCount; // load waveform for channel 2 (X) for (WFinModuleCount = 0; WFinModuleCount < xpoints.Count; WFinModuleCount++) { // with 16 reps when generate wave form, AWG generates the desired scan pattern, not sure why var tmpWaveform_X = new SD_Wave(SD_WaveformTypes.WAVE_ANALOG, new double[] { xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount] }); // WaveForm has to contain even number of points to activate padding option 1 status = moduleAOU.waveformLoad(tmpWaveform_X, WFinModuleCount, 1); // padding option 1 is used to maintain ending voltage after each WaveForm if (status < 0) { Console.WriteLine("Error while loading " + WFinModuleCount + " point from x array"); } } for (WFinModuleCount = 0; WFinModuleCount < xindex.Count; WFinModuleCount++) { status = moduleAOU.AWGqueueWaveform(2, xindex[WFinModuleCount], SD_TriggerModes.EXTTRIG, 0, 1, 0);// AWG, waveform#, trigger, delay, cycle,prescaler if (status < 0) { Console.WriteLine("Error while queuing " + WFinModuleCount + " point from x array"); } /*if (WFinModuleCount > 1023) * { * Console.WriteLine(xindex[WFinModuleCount] + " Status: " + status + "\n"); * }*/ } // load waveform for channel 1 (Y) for (WFinModuleCount = 0; WFinModuleCount < ypoints.Count; WFinModuleCount++) { var tmpWaveform_Y = new SD_Wave(SD_WaveformTypes.WAVE_ANALOG, new double[] { ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount] }); // WaveForm has to contain even number of points to activate padding option 1 status = moduleAOU.waveformLoad(tmpWaveform_Y, WFinModuleCount, 1); // padding option 1 is used to maintain ending voltage after each WaveForm if (status < 0) { Console.WriteLine("Error while loading " + WFinModuleCount + " point from y array, error code " + status); } } // queue waveform for channel 1 for (WFinModuleCount = 0; WFinModuleCount < yindex.Count; WFinModuleCount++) { status = moduleAOU.AWGqueueWaveform(1, yindex[WFinModuleCount], SD_TriggerModes.EXTTRIG, 0, 1, 0);// AWG, waveform#, trigger, delay, cycle,prescaler if (status < 0) { Console.WriteLine("Error while queuing " + WFinModuleCount + " point from y array, error code " + status); } } // Configure queue to only one shot moduleAOU.AWGqueueConfig(1, 0); moduleAOU.AWGqueueConfig(2, 0); // Start both channel and wait for triggers moduleAOU.AWGstart(1); moduleAOU.AWGstart(2); /*while (moduleAOU.AWGisRunning(1)==1) * { * Console.WriteLine(moduleAOU.AWGnWFplaying(1)); * Thread.Sleep(10); * }*/ return(HW_STATUS_RETURNS.HW_SUCCESS); }
public HW_STATUS_RETURNS ScanControlInitialize(double x_amp, double y_amp, double[] Xarray_vol, double[] Yarray_vol, int[] Xarray_index, int[] Yarray_index, double delay, int recording_rate) { int status; string sent; // Channel 1 for y scan and channel 2 for x scan //Create an instance of the AOU module SD_AOU moduleAOU = new SD_AOU(); string ModuleName = "M3201A"; int nChassis = 1; int nSlot = 3; if ((status = moduleAOU.open(ModuleName, nChassis, nSlot)) < 0) { Console.WriteLine("Error openning the Module 'M3201A', make sure the slot and chassis are correct. Aborting..."); Console.ReadKey(); return(HW_STATUS_RETURNS.HW_SUCCESS); } // Config amplitude and setup AWG in channels 1 and 2, moduleAOU.channelAmplitude(1, y_amp); moduleAOU.channelWaveShape(1, SD_Waveshapes.AOU_AWG); moduleAOU.channelAmplitude(2, x_amp); moduleAOU.channelWaveShape(2, SD_Waveshapes.AOU_AWG); moduleAOU.waveformFlush(); // Convert array into list xpoints = new List <double>(); ypoints = new List <double>(); xindex = new List <int>(); yindex = new List <int>(); xpoints.Clear(); ypoints.Clear(); xindex.Clear(); yindex.Clear(); xpoints = Xarray_vol.ToList(); ypoints = Yarray_vol.ToList(); xindex = Xarray_index.ToList(); yindex = Yarray_index.ToList(); // Set external trigger as input moduleAOU.triggerIOdirection(SD_TriggerDirections.AOU_TRG_IN); // Config trigger as external trigger and rising edge //moduleAOU.AWGtriggerExternalConfig(1, SD_TriggerExternalSources.TRIGGER_PXI, SD_TriggerBehaviors.TRIGGER_RISE); moduleAOU.AWGtriggerExternalConfig(2, SD_TriggerExternalSources.TRIGGER_EXTERN, SD_TriggerBehaviors.TRIGGER_RISE); // flush both channels status = moduleAOU.AWGflush(1); status = moduleAOU.AWGflush(2); int WFinModuleCount; // load waveform for channel 2 (X) for (WFinModuleCount = 0; WFinModuleCount < xpoints.Count; WFinModuleCount++) { // with 16 reps when generate wave form, AWG generates the desired scan pattern, not sure why var tmpWaveform_X = new SD_Wave(SD_WaveformTypes.WAVE_ANALOG, new double[] { xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount], xpoints[WFinModuleCount] }); // WaveForm has to contain even number of points to activate padding option 1 status = moduleAOU.waveformLoad(tmpWaveform_X, WFinModuleCount, 1); // padding option 1 is used to maintain ending voltage after each WaveForm if (status < 0) { Console.WriteLine("Error while loading " + WFinModuleCount + " point from x array"); } } for (WFinModuleCount = 0; WFinModuleCount < xindex.Count; WFinModuleCount++) { status = moduleAOU.AWGqueueWaveform(2, xindex[WFinModuleCount], SD_TriggerModes.EXTTRIG, 0, 1, 0);// AWG, waveform#, trigger, delay, cycle,prescaler if (status < 0) { Console.WriteLine("Error while queuing " + WFinModuleCount + " point from x array"); } /*if (WFinModuleCount > 1023) * { * Console.WriteLine(xindex[WFinModuleCount] + " Status: " + status + "\n"); * }*/ } // load waveform for channel 1 (Y) for (WFinModuleCount = 0; WFinModuleCount < ypoints.Count; WFinModuleCount++) { var tmpWaveform_Y = new SD_Wave(SD_WaveformTypes.WAVE_ANALOG, new double[] { ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount], ypoints[WFinModuleCount] }); // WaveForm has to contain even number of points to activate padding option 1 status = moduleAOU.waveformLoad(tmpWaveform_Y, WFinModuleCount, 1); // padding option 1 is used to maintain ending voltage after each WaveForm if (status < 0) { Console.WriteLine("Error while loading " + WFinModuleCount + " point from y array, error code " + status); } } // queue waveform for channel 1 for (WFinModuleCount = 0; WFinModuleCount < yindex.Count; WFinModuleCount++) { // use software trigger for Y channel status = moduleAOU.AWGqueueWaveform(1, yindex[WFinModuleCount], SD_TriggerModes.SWHVITRIG, 0, 1, 0);// AWG, waveform#, trigger, delay, cycle,prescaler if (status < 0) { Console.WriteLine("Error while queuing " + WFinModuleCount + " point from y array, error code " + status); } } // Configure X channel to cyclic mode moduleAOU.AWGqueueConfig(1, 0); moduleAOU.AWGqueueConfig(2, 1); // Start both channel, x channel wait for external trigger, send software trigger to y channel moduleAOU.AWGstart(1); moduleAOU.AWGstart(2); moduleAOU.AWGtrigger(1); // trigger Y channel to protection value // determine how long to pause after each jump based on frame rate int pause_ms = 1; double frametime = 1000 / (double)recording_rate; if (frametime > 1) { pause_ms = (int)Math.Ceiling(frametime); } int ncycle = 0; Console.WriteLine("Now on Y channel " + moduleAOU.AWGnWFplaying(1)); while (moduleAOU.AWGnWFplaying(2) == 0) // x channel may not be at zero when no trigger come, replace with AWGisRunning { // Empty loop wait for trigger to come } // Now cycle start moduleAOU.AWGtrigger(1); // trigger Y channel to first value Console.WriteLine("Now on Y channel " + moduleAOU.AWGnWFplaying(1)); ncycle++; // ncycle=1, currently working on cycle 1 while ((ncycle < yindex.Count - 2) && Convert.ToBoolean(moduleAOU.AWGisRunning(2))) { while (moduleAOU.AWGnWFplaying(2) != ypoints.Count - 2) { // empty loop wait for x channel to play last waveform } ncycle++; moduleAOU.AWGtrigger(1); Console.WriteLine("Jump to cycle " + ncycle + " now on Y channel: " + moduleAOU.AWGnWFplaying(1) + " now on X channel : " + moduleAOU.AWGnWFplaying(2)); System.Threading.Thread.Sleep(pause_ms * 2); while (moduleAOU.AWGnWFplaying(2) != 0) { // empty loop wait for x channel to play first waveform } ncycle++; moduleAOU.AWGtrigger(1); Console.WriteLine("Jump to cycle " + ncycle + " now on Y channel: " + moduleAOU.AWGnWFplaying(1) + " now on X channel : " + moduleAOU.AWGnWFplaying(2)); System.Threading.Thread.Sleep(pause_ms * 2); } // after all cycles finished, sleep for 5 sec before stop AWG System.Threading.Thread.Sleep(5000); moduleAOU.AWGstop(1); moduleAOU.AWGstop(2); Console.Write("Both channel closed"); return(HW_STATUS_RETURNS.HW_SUCCESS); }