Search the Community
Showing results for tags 'triggering'.
Hi, I have been struggling with this for quite a while and really need to get to a resolution. Using a USB-1608FS board, I am simply trying to reproduce programmatically what I've been able to do easily withTracerDAQ: initiate an ADC scan with AInScan() based on a rising edge trigger (from either the analog channel from the signal itself or the external digital trigger). As per the documentation, there are 2 trigger setup commands, ATrig() and SetTrigger() that somehow together should be able to accomplish this. From the manual: ATrig() Waits for a specified analog input channel to go above or below a specified value. ATrig continuously reads the specified channel and compares its value to trigValue. Depending on whether trigType is set to TrigAbove or TrigBelow, it waits for the first A/D sample that is above or below trigValue. The first sample that meets the trigger criteria is returned to dataValue. SetTrigger() Selects the trigger source and sets up its parameters. This trigger is used to initiate analog to digital conversions using the following Universal Library for .NET methods: AInScan(), if the ExTrigger option is selected. I've used the following in VB.Net and indeed it only triggers when the trigger is above 0, but not on the rising edge, so the signal is randomly moving around (I check the status in a timer in the standard way after AInScan). Note that there are no options for TrigPosEdge with ATrig, only TrigAbove or TrigBelow: Dim dataval As Short Dim threshold As Short = 32767 ULStat = DaqBoard.ATrig(0, MccDaq.TriggerType.TrigAbove, threshold, Range, dataval) ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, Rate, Range, MemHandle, Options) All attempts to use SetTrigger(), such as ULStat = DaqBoard.SetTrigger(MccDaq.TriggerType.TrigPosEdge, threshold, threshold) were also not having any impact on the trigger, and I've tried multiple combinations to no avail. If anyone could provide a simple example on how to do this most basic analog input, I would very much appreciate it (there are no examples in the example files provided). Thanks, Walid
Hi, I am trying to understand how to programmatically setup the triggers on the USB-1608FS board so that I can: 1. Read data on the rising edge with trigger level set to 0, similar to the screen shot in TracerDAQ shown below (and showing the trigger options) which gives a stable sine wave starting at 0 for a sine wave input. 2. Read data on the external trigger input from a digital signal (I'm assuming this should be more stable than 1) I know this can be done with this board and my signals are good because it works fine with TracerDaq. I'm using VB.net, there are no examples provided that do this (the trigger examples only work for a "signal above" level and therefore do not correctly trigger on the rising edge which is what I'm getting as well no matter what I set the trigger condition to), and the user's manual is a little confusing regarding how to use ATrig and SetTrigger in conjunction with AInScan (it suggests it only works with an external trigger, but I know it can work with a channel trigger). I've tried multiple combinations and only get triggers above 0 instead of rising edge triggers (and thus the sine wave just slides around the start trigger depending on when the signal was found to be above 0 rather than a positive edge). I know that the AInScan is armed and waiting for a trigger above 0 because it doesn't return a scan unless that is the case. Also pretriggering via ATrig apparently is not an option for this board. The code snippet for setting up triggering that loops is: ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.AiFunction) 'stop background scan for each trigger event Dim TrigVal As UShort = 32767 Count = 2000 ' total number of data points to collect ' per channel sampling rate ((samples per second) per channel) Rate = 10000 / ((HighChan - LowChan) + 1) 'Set up trigger ULStat = DaqBoard.ATrig(0, MccDaq.TriggerType.TrigAbove, TrigVal, Range, DataValue) ULStat = DaqBoard.SetTrigger(MccDaq.TriggerType.TrigPosEdge, TrigVal, TrigVal) Options = MccDaq.ScanOptions.Background 'Expect AInScan to now wait for trigger rising edge above 0 but instead get trigger at any value above 0 ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, Rate, Range, MemHandle, Options) If ULStat.Value <> MccDaq.ErrorInfo.ErrorCode.NoErrors Then Stop and I read it below with a timer (ADData always gives a shifted sine wave instead of one triggering on the rising edge): If Status = MccDaq.MccBoard.Running And UserTerm = 0 Then lblShowStat.Text = "Running" tmrCheckStatus.Start() ElseIf Status = MccDaq.MccBoard.Idle Or UserTerm = 1 Then lblShowStat.Text = "Idle" ULStat = DaqBoard.GetStatus(Status, CurCount, CurIndex, MccDaq.FunctionType.AiFunction) If ULStat.Value <> MccDaq.ErrorInfo.ErrorCode.NoErrors Then Stop lblShowCount.Text = CurCount.ToString("D") lblShowIndex.Text = CurIndex.ToString("D") If SwitchScan.Value = False Then tmrCheckStatus.Stop() End If If MemHandle = 0 Then Stop If ADResolution > 16 Then ULStat = MccDaq.MccService.WinBufToArray32(MemHandle, ADData32, FirstPoint, NumPoints) If ULStat.Value <> MccDaq.ErrorInfo.ErrorCode.NoErrors Then Stop For i = 0 To HighChan lblADData(i).Text = ADData32(i).ToString("D") Next i Else ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, NumPoints) If ULStat.Value <> MccDaq.ErrorInfo.ErrorCode.NoErrors Then Stop End If Any advice would be greatly appreciated--a very simple flowchart with the procedure for setting up the board for proper rising edge channel 0 triggering would suffice, and then how to do it with a digital external trigger signal with this board as well. Thanks, Walid
I build radar systems for a living, and I'm testing the Analog Digilent 2 as an A/D, timing control for other RF hardware, RF switch control, trigger source. Here's what I need to do: Write the software with python using the Waveforms SDK running on Windows 10. Acquire signals on 2 analog channels simultaneously. This must be triggered at a periodic rate on an input other than the two analog in channels. Generate a pulse width of p nanoseconds at an x kilohertz rate. This is a TTL signal. This pulse is used for RF pulse generation, but also as a trigger for the analog channels. All digital out signals must be synchronized. Capture n samples on both channels for a maximum of 256 triggers. Typically 128 or 256 is used -- a 2^n number of triggers is used for FFT processing. Capture to arrays (or lists in the case of python) must be real time. Rearrange the lists so that an FFT can be taken from the ith sample of each trigger event. So if I have 128 trigger events, and I capture 1024 samples on each event, then I take 128 values from index 0 of all trigger events and compute a complex FFT. Then I repeat for index 1, 2, … 1024. In radar terms, each sample relates to a range value. If sampling at 80 MSPS, each sample equates to 2 meters of range. So 1024 samples = 2048 meters of total range. The complex FFT computes the Doppler frequencies seen for each of those sample range points. Progress: A. I have successfully used the example SDK program named Digital_Duty.py to generate a x kHz pulse rate with p width in nanoseconds. I modified it to continue doing it until the program is terminated. The test values are 4 kHz pulse rate (trigger rate) and the pulse width is 300 nanoseconds. The output is on DIO Channel 1. The AD2 works great at this. B. I have successfully used the example SDK program named AnalogIn_Trgger.py to acquire signals. I modified this source to: digitize Channel 0 and Channel 1; trigger on an External Trigger, which is now the inputted by placing a jumper wire between DIO Channel 1 and Trigger 1 Channel; Continue to trigger for 128 times; Plot last set of data. C. I am using a 10 MHz and 20 MHz signal on Channel 0 and Channel 1, respectively. This is correctly plotted by the application. D. I was delighted to see the code was working...or so I thought. I added a time check to confirm 128 triggers were completed in the appropriate time. The time check came back as 0.156 seconds for 128 triggers of 1024 samples. The answer should have been (1/4000)*128 = 0.032 seconds. So my capture time was almost 5 times too long. I confirmed that even with two pulses the system cannot transfer fast enough. And even if I get down to 10 samples per trigger, there is little change in timing. I computed that the fast PRF (trigger event speed) = about 850 Hz. There is still some unexplained overhead time, but it is close to that number. So keeping under 850 Hz, the system is real time. Unfortunately, that equates to about 14 mph at usable radar frequencies. I need to get up to about 4000 Hz to be of use. See my attached Code written in python. I am using a Windows 10 Pro laptop running an i7 processor with 64 GB of RAM. I have the AD2 plugged into a spare USB port. 10 and 20 MHz signals feed the analog channels from a crystal oscillator as a test of the capture. I have available external waveform generators, oscopes, and spectrum analyzers. So given my test in D, does anyone know what I can do to improve performance? Is there something wrong in my code? Am I misunderstanding the capabilities of the AD2? If the system had a USB 3.0, I know it would be able to keep up. But given that is not available, what should I try if anything? Radar Data Capture With Internal Trigger.py