siglentRust - software for controlling Siglent devices, written in Rust - Page 1
Forum section: electronics / testgear

author: TopQuark
author_rank: Frequent Contributor
timestamp: November 02, 2022, 05:31:09 pm
content: No, this is not a thread about metallic rust found in early Siglent devices, but rather software for controlling Siglent devices, written in Rust.https://github.com/TopQuark12/siglentRustI have been playing with data processing for scope waveform captures, and have been quite unhappy with the speed of Python. I want to try things like externally controlled bode plotting, implementing fast DSA spectrum analysis etc. and the slowness of Python is getting into my way.My current job happens to involve writing embedded software in Rust, so I thought I'd practice my Rust coding skills with this project. For the uninitiated, Rust is a compiled programming language with strong emphasis on memory safety, making it harder to have memory fk ups in the program, yet it compiles into code that runs practically just as fast as C/C++.I have made some comparisons between Python and Rust doing the same thing, capturing a waveform and plotting it into PNG. Note that both code aren't very optimised, it is just written with best effort to my limited ability.20Mpts 2GSa/s 12-bitPython: 17.703sRust: 5.865s200Mpts 2GSa/s 12-bitPython: 236.24sRust: 56.083sSo Rust is around 3-4 times faster, which matters if you are impatient like me I guess.Not sure how far I'll develop this, and the code is very crude at its current state. But I thought I'd document the existence of the work, both as a bit of an academic curiosity, and so people can at least use the code as an example (or counter-example) in their own scripting setups.

author: TopQuark
author_rank: Frequent Contributor
timestamp: November 02, 2022, 06:46:06 pm
content: Pulled out my 8 bit SDS2000x plus and did some testing, fixed some bugs.On the SDS2000x plus, here are some benchmarks with the rust code:2Mpts 2GSa/s 8-bit 0.884 sec20Mpts 2GSa/s 8-bit 3.769 sec200Mpts 2GSa/s 8-bit 36.608 sec

author: pope
author_rank: Frequent Contributor
timestamp: November 02, 2022, 09:28:25 pm
content: Nice.So this means that it could possibly work on 8-bit scopes like the 1104x-e for example?

author: tautech
author_rank: Super Contributor
timestamp: November 02, 2022, 09:48:35 pm
content: Quote from: pope on November 02, 2022, 09:28:25 pmThere are several preexisting SW packages that work with Siglent devices:https://int.siglent.com/download/drivers/And an amount of free SW:https://int.siglent.com/download/softwares/Then for instruments with a webserver and SCPI command panel the programming guides can be found here:https://int.siglent.com/download/documents/

author: TopQuark
author_rank: Frequent Contributor
timestamp: November 03, 2022, 04:33:46 am
content: Quote from: pope on November 02, 2022, 09:28:25 pmYes, more likely than not it should work, unless Siglent bungles up their SCPI implementation in the 1104x-e. I spent quite some time debugging my code yesterday, only to discover my 8-bit sds2504x plus self reports it has 127 LSB per vertical division. Upgraded its firmware and now it reports 30 LSB per div, and the math now works fine. So give it a shot, make sure you have the latest FW, and report back any success or otherwise.Quote from: tautech on November 02, 2022, 09:48:35 pmDon't get me bloody started on Siglent's remote programming resources, or this will become a rant post. Their VISA implementation causes the scope to hang and report junk data half of the time, the only reliable way to talk to the device is through sockets.And look at this example python code from Siglent's own programming manual.Code:convert_data = []if BIT > 8:for i in range(0, int(len(recv_all) / 2)):data_16bit = recv_all[2 * i + 1] * 256 + recv_all[2 * i]data = data_16bit >> (16-BIT)convert_data.append(data)else:convert_data = recv_allvolt_value = []for data in convert_data:if data > pow(2,BIT-1)-1:#12bit-2047,8bit-127data = data - pow(2,BIT)else:passvolt_value.append(data)del recv,recv_all,convert_datagc.collect()especially these two linesQuoteLook, my favourite programming language is solder, and I self identify as an EE, not a programmer. But this is beyond hopeless- Calculating 2 to the power of bit depth for every single data point (there are literally hundreds of millions of data points) , TWICE per loop, instead of calculating it once outside of the loop. And it is Python, so not like there's a compiler to optimise that bit of code away. WHY?- The person that wrote this piece of gem has likely slept through programming 101 class and never heard of 2's complement. Why else would someone in their right mind write this instead of just casting the one or two u8 into signed integers?