Author Topic: SCPI encabulator to keep the trigger time shifted inside display - Rigol DS1054  (Read 435 times)

0 Members and 1 Guest are viewing this topic.

Online RoGeorgeTopic starter

  • Super Contributor
  • ***
  • Posts: 6770
  • Country: ro
Usually we look at an oscilloscope trace at the part coming after the trigger point, not before.

The DS1054Z oscilloscope from Rigol likes to put the trigger moment in the middle of the screen  :-//, thus wasting the first half of the display with something not needed.

The trigger point can be shifted left/right manually, but any time base zoom is calculated relative to the center of the screen.  As an effect to this, unless the trigger point is in the center then any change in the time base will also move the position of the trigger point relative to the screen.  Often the trigger point will lend outside of the screen area.  :rant:

Would be nice to have the trigger point always fixed in the same position relative to the screen.

This is what this script does.  It reads the time base, then adjusts the trace position to always start from the place on the screen.  It does that at each 2 seconds.  If the time base of the oscilloscope is changed, then the trigger moment will be brought in the screen at the same position it was before.

The oscilloscope was connected by LAN.  Replace the IP address with the address of your instrument.  Tested with Kubuntu 20.04 LTS, Python 3, pyvisa and PySimpleGUI.  Should work the same for Windows, but I only tested in Kubuntu.

The program can be controlled by mouse or keyboard (the arrow keys, Enter and Escape), and it looks like this:



 8)



Dependencies to install:
Code: [Select]
pip install pyvisa-py
pip install pysimplegui
sudo apt-get install python3-tk

Python script to run:
Code: [Select]
import PySimpleGUI as sg
# docs at pysimplegui dot org
import pyvisa as visa


# connect to ds1054z
IP_address = '192.168.1.3'

try:
    rm = visa.ResourceManager()
    ds1054z = rm.open_resource('TCPIP::' + IP_address + '::INSTR')
    answer = ds1054z.query('*IDN?')
    answer = answer.replace(answer.split(',')[2], 'DS1Z_7654321_')

    # the SCPI commands list for DS1000Z can be found at
    # [url]https://beyondmeasure.rigoltech.com/acton/attachment/1579/f-0386/1/-/-/-/-/DS1000Z_Programming%20Guide_EN.pdf[/url]
except:
    answer = 'ERROR: Could not connect.'


# GUI
layout = [
    [sg.Frame(
        'Trigger point position in the oscillosope screen (divs from center)',
        [[sg.Slider((-6,6), key= '-DIVS-', enable_events=True, default_value=-5, orientation='h', expand_x= True)]],
        expand_x= True
    )],
    [sg.Button('Exit (Esc)', key= '-EXIT-', expand_x= True)],
    [sg.Text(answer, key= '-ANSWER-', expand_x= True)]
]

window = sg.Window('DS1000Z Trigger Mover', layout, finalize= True)

window.bind('<Escape>', '-ESCAPE-')
window.bind('<Up>', '-UARROW-')
window.bind('<Down>', '-DARROW-')
window.bind('<Left>', '-LARROW-')
window.bind('<Right>', '-RARROW-')


while True:
    event, values = window.Read(timeout= 2000)
    if event in (sg.WIN_CLOSED, '-EXIT-', '-ESCAPE-'):
        break

    # react to arrow keys
    if event in ('-UARROW-', '-RARROW-'):
        values['-DIVS-'] += 1
        window['-DIVS-'].update(values['-DIVS-'])

    if event in ('-DARROW-', '-LARROW-'):
        values['-DIVS-'] -= 1
        window['-DIVS-'].update(values['-DIVS-'])

    # find the current timebase and set the trigger display offset
    answer = ds1054z.query(':TIMebase:SCALe?')
    ds1054z.write(':TIMebase:OFFSet ' + str(-values['-DIVS-'] * float(answer)))

# bye
ds1054z.close()
rm.close()
window.Close()
 
The following users thanked this post: ivan747, ledtester


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf