EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: mr_jj on April 30, 2024, 09:47:14 am

Title: Beginner Oscilloscope that can be controlled via Python
Post by: mr_jj on April 30, 2024, 09:47:14 am
There are several brands of oscilloscope for around $1000 that are great for beginners. I'm looking for one that has an API that allows control via python. I'm looking to do things like getting the raw data, triggering, changing ranges/time scales and so on.
I've done this on a Lecroy in the past but for my current application, I just need a basic oscilloscope that is scriptable.
Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: coromonadalix on April 30, 2024, 10:12:27 am
i would  immediately go with Siglent  models,  because of their hack .. cough cough   and mostly all their scpi commands are documented, we did some automation with a scope and generator, the IT guy was drooling,  it was so easy

we do it by ethernet cable, each item has its own ip adress, the software check for their presence  and start after a keyboard press

over 80 freqencies are "outputted" and checked and stored as csv files ... we check some specially crafted frequency filter pcb's....

no drivers are needed,  you have python stuff here,  lxi tools here     just do some search,   you can find many examples on the web
Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: Aldo22 on April 30, 2024, 10:17:59 am
There are several brands of oscilloscope for around $1000 that are great for beginners. I'm looking for one that has an API that allows control via python. I'm looking to do things like getting the raw data, triggering, changing ranges/time scales and so on.
I've done this on a Lecroy in the past but for my current application, I just need a basic oscilloscope that is scriptable.

I think if the scope has SCPI, you can control it via pyvisa, for example.
Even my $130 Hantek can do that, although not very fast, but it was enough for a bode plot script (https://www.eevblog.com/forum/testgear/new-hantek-dso2x1x-models/msg5338418/#msg5338418).
Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: tggzzz on April 30, 2024, 10:21:13 am
Have a look at the Digilent Analog Discovery. That has an API, so presumably it can be controlled by Python etc. I believe JavaScript is used internally, and is available for you to extend the basic functionality - e.g. spectrum analyser, etc etc

You also have an AWG and digital i/o, so you can synthesise your own test instrument.

Overall I like the underlying hardware, within its clearly stated limits.

You can download the GUI and play with it, to see what it can do.
Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: BennoG on April 30, 2024, 02:19:53 pm
you can also have a look at picoscope, they range from $100 to $16000 and can all be read out by python.
Only problem is you can not use the application and python at the same time.
With the SDK you can read the data faster out of the device than in the application.

I have done this in the SDK and let it stream continually at 5M Samples/sec for over a week. (I did only save the parts of interest, because the HD would be full in no time)
This was where a specific problem was only seen rarely and impossible to make a trigger for it, so the software I wrote tested realtime for the problem and saved the data from 5 seconds before it and 5 seconds afterwards (50M samples per channel)

Added Note: check specifications for SDK on the type of scope you want to use, there are a lot of differences between the $150 scopes and de $600 and up scopes.

Benno
Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: Faranight on April 30, 2024, 07:51:33 pm
I would definitely suggest you go with one with a LAN port. If you're gonna buy more instruments in the future, you're eventually going to run out of USB ports on your PC.
I have about 8 devices in my home lab, and they're all wired via a switch to my laptop, and I an use SCPI to control pretty much all of them. None of that USB cable replugging.

Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: tautech on April 30, 2024, 07:53:14 pm
There are several brands of oscilloscope for around $1000 that are great for beginners. I'm looking for one that has an API that allows control via python. I'm looking to do things like getting the raw data, triggering, changing ranges/time scales and so on.
I've done this on a Lecroy in the past but for my current application, I just need a basic oscilloscope that is scriptable.
Please share for best advice.
Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: pdenisowski on May 01, 2024, 05:31:39 am
I think if the scope has SCPI, you can control it via pyvisa, for example.

This.  As long as the scope implements SCPI, you should be able to control it using PyVISA.  Frankly, these days I would expect even a hobbyist level oscilloscope to implement SCPI.

Note that some vendors (like R&S) also provide their own Python modules and/or PyCharm plug-ins to make it easier to write scripts for their instruments, so this may be something you want to look into as well. 

https://www.youtube.com/watch?v=DsibuH51IVw (https://www.youtube.com/watch?v=DsibuH51IVw)
Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: Doctorandus_P on May 01, 2024, 07:35:14 am
Any decent scope probably supports SCPI. Even my old Rigol 1052DS has it.
And of course, Every decent scope supports SCPI, if you make SCPI support part of the definition of a decent scope.  8)

Support is so common that they don't even bother to print it on the front panel for 10+ years.

But if you want to control your scope via SCPI, you can make extra good use of a 12 bit ADC in your scope. As long as you're viewing the LCD of the scope, 12-bit resolution is of limited use because it just does not fit on the display (but you can zoom, and use it for on screen measurements) (Except maybe with Rigol, which tend to do on screen measurements based on screen pixels instead of measurement data  |O
Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: paulca on May 01, 2024, 10:04:26 am
Alternatives....

Arduino Uno.  30 seconds.  Run the IDE.  Select the osciliscope script, flash it, run it, hook up your signal (<5V) to the analog pin.  The IDE will produce your waveform.
Raspberry PI with an ADC module scope can be directly implimented in Python.

Moving out of amateur DIY.  Almost all "pro" gear of any kind, be it scope, gen, PSU can be found with a basic UART console connection (Serial terminal port).  Even the basic TENMA PSU have this.  More modern equipment will usually just have "Serial over USB" and not even a serial port.

Yes, it's slightly more faff using a serial link or USB link and if not careful opens you up to using junk desktop software written by embedded developers, which never goes well.

It just opens up a lot more devices to your automated lab.  If you add some middleware into that, like MQTT, Kafka or MQueue you can even open it up to non-electronics bench equipment.
Title: Re: Beginner Oscilloscope that can be controlled via Python
Post by: pdenisowski on May 01, 2024, 11:09:05 am
Moving out of amateur DIY.  Almost all "pro" gear of any kind, be it scope, gen, PSU can be found with a basic UART console connection (Serial terminal port).  Even the basic TENMA PSU have this.  More modern equipment will usually just have "Serial over USB" and not even a serial port.

Perhaps I’m misunderstanding, but I think R&S counts as a “pro” manufacturer, and almost nothing we make has a UART console for remote control.