PSLab Desktop App has a feature of oscilloscope. Modern day oscilloscopes found in laboratories support a lot of advanced features and addition of trigger controls in oscilloscope was one such attempt in adding an advanced feature in the oscilloscope. As the current implementation of trigger is not robust enough, this feature would help in better stabilisation of waveforms.
Captured waveforms often face the problem of distortion and trigger helps to solve this problem. Trigger in oscilloscope is an essential feature for signal characterisation. as it synchronises the horizontal sweep of the oscilloscope to the proper point of the signal. The trigger control enables users to stabilise repetitive waveforms as well as capture single-shot waveforms. By repeatedly displaying similar portion of the input signal, the trigger makes repetitive waveform look static. In order to visualise how an oscilloscope looks with or without a trigger see the following figures below.
Fig 1: (a) Without trigger (b) With trigger
The Fig:1(a) is the actual waveform received by the oscilloscope and it can be easily noticed that interpreting it is confusing due to the overlapping of multiple waveforms together. So, in Fig:1(b) the trigger control stabilises the waveforms and captures just one waveform.
In general the commonly used trigger modes in laboratory oscilloscopes are:-
- Auto – This trigger mode allows the oscilloscope to acquire a waveform even when it does not detect a trigger condition. If no trigger condition occurs while the oscilloscope waits for a specific period (as determined by the time-base setting), it will force itself to trigger.
- Normal – The Normal mode allows the oscilloscope to acquire a waveform only when it is triggered. If no trigger occurs, the oscilloscope will not acquire a new waveform, and the previous waveform, if any, will remain on the display.
- Single – The Single mode allows the oscilloscope to acquire one waveform each time you press the RUN button, and the trigger condition is detected.
- Scan – The Scan mode continuously sweeps waveform from left to right.
Implementing Trigger function in PSLab
PSLab has a built in basic functionality of trigger control in the configure_trigger method in sciencelab.py. The method gets called when trigger is enabled in the GUI. The trigger is activated when the incoming wave reaches a certain voltage threshold and the PSLab also provides an option of either selecting the rising or falling edge for trigger. Trigger is especially useful in experiments handling waves like sine waves, square wave etc. where trigger helps to get a clear picture.
In order to initiate trigger in the PSLab desktop app, the configure_trigger method in sciencelab.py is called. The configure_trigger method takes some parameters for input but they are optional. If values are not specified the default values are assumed.
def configure_trigger(self, chan, name, voltage, resolution=10, **kwargs): prescaler = kwargs.get('prescaler', 0) try: self.H.__sendByte__(CP.ADC) self.H.__sendByte__(CP.CONFIGURE_TRIGGER) self.H.__sendByte__( (prescaler << 4) | (1 << chan)) if resolution == 12: level = self.analogInputSources[name].voltToCode12(voltage) level = np.clip(level, 0, 4095) else: level = self.analogInputSources[name].voltToCode10(voltage) level = np.clip(level, 0, 1023) if level > (2 ** resolution - 1): level = (2 ** resolution - 1) elif level < 0: level = 0 self.H.__sendInt__(int(level)) # Trigger self.H.__get_ack__() except Exception as ex: self.raiseException(ex, "Communication Error , Function : " + inspect.currentframe().f_code.co_name)
The method takes the following parameters in the method call
- chan – Channel . 0, 1,2,3. corresponding to the channels being recorded by the capture routine(not the analog inputs).
- name – The name of the channel. ‘CH1’… ‘V+’.
- voltage – The voltage level that should trigger the capture sequence(in Volts).
The similar feature will also be used in oscilloscope in the Android app with the code corresponding to this method in ScienceLab written in Java.
Additional Resources
- Read more about Trigger here – http://www.radio-electronics.com/info/t_and_m/oscilloscope/oscilloscope-trigger.php
- Learn more about trigger modes in oscilloscopes – https://www.picotech.com/library/oscilloscopes/advanced-digital-triggers
- PSLab Python repository to know the underlying code – https://github.com/fossasia/pslab-python