Author Topic: Trigger signal in software like an oscilloscope  (Read 1704 times)

0 Members and 1 Guest are viewing this topic.

Offline bushjavierTopic starter

  • Newbie
  • Posts: 9
  • Country: co
Trigger signal in software like an oscilloscope
« on: November 28, 2018, 05:55:00 pm »
Hi

I am working on a C software running on a BeagleBone Black to capture data from a USB DAQ. The data acquisition is working ok, I am sampling at 1M samples per second for x amount of seconds, so right now i have all the samples in a array in memory. In my requirements i need to split that signal in cycles using a trigger level in volts exactly like an oscilloscope, the problem is my algorithm is having problems when the signal is noisy is not detecting correctly the index in the array where i need to "trigger". My background is in software so I do not have any experience in signal processing.


The algorithm try to detect the rising edge of the signal when the samples go above the trigger level, also for more robustness i am getting like 10 samples in a sliding window and doing a linear regression of the points in the whole window so if the slope is positive I am on a rising edge, if the slope is negative I discard the index. After some testing my naive approach is having problems with the noise, so I need a better way to trigger the signal i appreciate if someone could help me with some ideas or code (java, matlab, c, c++, pseudocode, does not matter) to trigger and split my signal correctly, attach is an example how the signal looks like.

Thanks!
 

Offline _Wim_

  • Super Contributor
  • ***
  • Posts: 1582
  • Country: be
Re: Trigger signal in software like an oscilloscope
« Reply #1 on: November 28, 2018, 06:48:23 pm »
What is exactly your problem, are you also triggering on the negative edge around the trigger level?

If yes, you could add some hysteresis, where you first remember the sample where the trigger level was crossed, but only consider it as a rising edge if in the next "n" samples a level is reached equal to the trigger level + hysteresis.
 

Offline bushjavierTopic starter

  • Newbie
  • Posts: 9
  • Country: co
Re: Trigger signal in software like an oscilloscope
« Reply #2 on: November 30, 2018, 05:35:56 pm »
 _Wim_ I am triggering only on the rising edge of the signal, you think that with only adding some hysteresis when the trigger level was crossed is sufficient to have a robust rising edge triggering in my software?
 

Offline DaJMasta

  • Super Contributor
  • ***
  • Posts: 2421
  • Country: us
    • medpants.com
Re: Trigger signal in software like an oscilloscope
« Reply #3 on: November 30, 2018, 05:46:24 pm »
Well a precision hardware edge trigger is typically a fast comparator and a threshold voltage, so I think it is likely to be effective.  For hysteresis you have all sorts of options in software, but two easy options would be to trigger at a level and then check the next few samples to see if they stay over/under the trigger level (for rising or falling), and if you get one that isn't, you just restart the check at the next point past the trigger level.  You could also have a primary trigger level and a secondary one, so that only when you pass the secondary trigger does the first one get counted as a trigger point.  You could, of course, do a bunch of data processing on the raw values before feeding them into either, but software triggers can effectively have arbitrarily complex evaluations so long as the system can keep up with the number of waveforms needed per second.
 

Offline _Wim_

  • Super Contributor
  • ***
  • Posts: 1582
  • Country: be
Re: Trigger signal in software like an oscilloscope
« Reply #4 on: November 30, 2018, 08:48:42 pm »
_Wim_ I am triggering only on the rising edge of the signal, you think that with only adding some hysteresis when the trigger level was crossed is sufficient to have a robust rising edge triggering in my software?

Hi bushjavier, want I meant was what exactly is your problem currently with the noise signal. Do you have too much jitter when triggering, or is it triggering both on rising and falling edges. The hysteresis will not help for the jitter (for that it is probably better to low pass the signal first by making a moving average and then set your trigger of the result of the moving average).
 

Offline fsr

  • Regular Contributor
  • *
  • Posts: 169
  • Country: ar
Re: Trigger signal in software like an oscilloscope
« Reply #5 on: November 30, 2018, 11:08:03 pm »
In oscilloscopes you can choose the trigger level, and also rising or falling edge, to use a low-pass filter, you can AC-couple the trigger signal, you can hold-off the trigger, and probably other options as well. Check some oscilloscope manuals, some of Dave's videos on oscilloscopes, and that's probably going to help a lot.
In software you could do something like using the average value of the last n samples for your trigger. That should kill random noise. Don't know if that's common practice, but should work.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf