Parsing a lot of CV with lower sampling rate?

Thread Starter

chilloutdancer

Joined Jul 7, 2021
5
Guys, I'm rather new to electronics, so could you please give me some directions?
I basically have got an application and a hardware modular synth. I want to parse some Control Voltages (CV) to control my software with. Ideally, I would like to use a lot of CV, but I can't really see where the bottleneck is going to be.
Ideally, I'd like to have 64 simultaneous inputs or so. Would that be possible to achieve while having lower sampling rate? I target 60 fps, but could manage with 30 or even lower with some kind of interpolation. I could also tolerate latency, if it's going to be constant. The data may be fairly compressed if necessary, but I'd still want at least 8bit. With these constraints, would something close to what I want be possible?
I don't consider existing audio-cards/interfaces like Expert Sleepers since I need a more general solution for more inputs and don't need it to be so high-end.
 

ronsimpson

Joined Oct 7, 2019
1,630
Trying to understand.
You want to measure 64 voltages 60 times per second. =4000 samples/second
The measurements are 8 bits.
Using a PC?
What is the voltage range? 0 to 5 volts?

Here is a picture of a "data logger". This one is only good for 8 inputs. It can measure 50,000 samples/second. 16 bit measurements. Connects to the PC by USB.
1626095076772.png
Until I understand more I can't help choose a product.
1626095568696.png
 

Thread Starter

chilloutdancer

Joined Jul 7, 2021
5
@ronsimpson
Hi, thank you for your answer.
>You want to measure 64 voltages 60 times per second. =4000 samples/second
Let's say yes and consider it a target sampling rate.
>The measurements are 8 bits.
For simplicity let's say it's 8 bit or the data is at least aligned to 8 bit. I might experiment with compression/decompression later.
>Using a PC?
I've got an Arduino, Daisy and ready to get any kind of electronics if that would be the right way to go.
>What is the voltage range? 0 to 5 volts?
0 to 10.
>Here is a picture of a "data logger".
Idk, I've never used or seen such things. Looks okay, but I woudn't want to stack 8 of them anyway. The whole point is to get a lot of CV inputs, while compromising on the quality if necessary.

I'm not looking for a quick and easy solution, rather a solution that would allow me some flexibility and potential expansion. I'm ready to invest both time and money in this.
 

Irving

Joined Jan 30, 2016
2,308
As @ronsimpson said, 4000 samples/sec is easily doable, but an off-the-shelf 64 channel ADC is going to be quite expensive - a PCI card for the PC retails at around 900euro (770GBP, USD1100).

This USB device retails for USD161 and will give you 32 0 - 3v analog inputs. But its interface is a serial link over USB and limited to 115200baud (as far as I can tell - you need to ask vendor) so will give you around 20 frames/sec for 32 channels and two boards will be similar across 2 USB channels.
 

Irving

Joined Jan 30, 2016
2,308
@ronsimpson
Hi, thank you for your answer.
>You want to measure 64 voltages 60 times per second. =4000 samples/second
Let's say yes and consider it a target sampling rate.
>The measurements are 8 bits.
For simplicity let's say it's 8 bit or the data is at least aligned to 8 bit. I might experiment with compression/decompression later.
>Using a PC?
I've got an Arduino, Daisy and ready to get any kind of electronics if that would be the right way to go.
>What is the voltage range? 0 to 5 volts?
0 to 10.
>Here is a picture of a "data logger".
Idk, I've never used or seen such things. Looks okay, but I woudn't want to stack 8 of them anyway. The whole point is to get a lot of CV inputs, while compromising on the quality if necessary.

I'm not looking for a quick and easy solution, rather a solution that would allow me some flexibility and potential expansion. I'm ready to invest both time and money in this.
OK, if you have time & money to invest then I'd suggest a custom build based on an STM32 microcontroller. A single device will give you 32 channels at 16bit. As its a 3v device you'll need 32 channels of signal conditioning to map 10v to 3v; that's easily done. Then duplicate for 64 channels.

You won't do this with an Arduino or a Daisy (my son uses one of those), you simply don't have the IO ports or bandwidth.

Are you bringing the samples back to a PC or what?~ What's your intended outcome? The STM32 are to the Arduino as a F1 car is to a family saloon. There is shed-loads of power there if you wanted to do local processing.
 

ronsimpson

Joined Oct 7, 2019
1,630
I've got an Arduino, Daisy
max Here is a link to a ADC that can read 8 or 16 voltages at a time. 300,000 readings/second. It is just one of many parts like this. I can see having 4 or more talking to a Arduino. I think you need a computer with a SD card to store the data on.

ADCs come in 8bit, 10 bit 12 bit .... 16 bit etc. The more bits the slower in general.
Number of inputs start out 1,2,4,8,12,16 ..... and you can run many at the same time.

The input range is not what you want but with two resistor ahead of each channel you can read 0 to 10V.

I might use a Raspberry Pi for the job. Much faster part. I would use a Pi2,3 or 4 but a Pi 0 would do the job.

Arduino might work. You can add EERPOM storage or flash storage.

What Arduino do you have? Many have 6 analog inputs. How fast can you read all 6 inputs? There is a way to get 8x inputs on each. 8x6=.
 

Irving

Joined Jan 30, 2016
2,308
Whilst an Arduino can theoretically do 15k adc reads a sec, it can't do much else after that. It definitely couldn't handle 4000 samples/sec and transmit to a PC over USB. I've had too many projects where I've had to move off an Arduino to something faster. A Pi in an option though it's reliance on Linux and support for all the other hardware onboard may or may not be helpful depending on what else the TS wants to do with the data.

I've tended to go for microcontrollers with FreeRTOS for anything fast and time deterministic as its so much easier to track what's going on without the operating system getting in the way. On a recent project I used a 2 core MCU, 1 core to handle the data acquisition and the other to post process and transmit it. This made it very easy to sort out any timing v processing issues.

@chilloutdancer how fast do your control voltages vary? I think it's important to ensure you're covering all the bases, and not limiting yourself going forward.

Looking at specs of commercial synth modules they suggest CV inputs from 90sec/cycle to over 1000cycles/sec (or 2k samples/sec, nyquist rate).

My son tells me it depends on what you're using the CV for but he would expect to slew the whole 10octave range for a glissando in < 1sec with each note distinct. That's using 24 semitones/octave (for eastern music apparently, who knew?). So that's around 500 samples/sec nyquist.

The other issue I feel is important is quantisation noise. If you need 8 bits output then you should be sampling to 10 bits at least, preferably 12.
 

Thread Starter

chilloutdancer

Joined Jul 7, 2021
5
@Irving
Thank you.
> OK, if you have time & money to invest then I'd suggest a custom build based on an STM32 microcontroller.
I'll probably go this route.
> Are you bringing the samples back to a PC or what?
Yeah, I intend to use it with my own software, I'm not set up on any particular data layout or streaming protocol at the moment, but I guess, ideally I would receive a batch of compressed data from different inputs every 1s/30 or 1s/60 interval, pass in to CPU, decompress to different variables and use it further or something similar.

> how fast do your control voltages vary? I think it's important to ensure you're covering all the bases, and not limiting yourself going forward.
My software is limited to 30/60 fps and the modulation is probably going to be rather low-frequency, definitely not 1khz. It's up to experimentation really.

What STM32 would you recommend? I'll probably take a few different ones out of curiosity, but still. And maybe anything else I might need?

And thanks for your detailed answer. I'm starting to think it's more doable than I thought.
 

ronsimpson

Joined Oct 7, 2019
1,630
I do not know the Arduino system but I have done this before.
Scripting & interpreters are slow compared to compilers. Python, Arduino just seem slow to me.
Many languages have a command (get analog voltage) which starts the ADC working and then waits for the results. ADCs are slow. If you get down to how the hard ware works you will see this is not how fast Analog to Digital should be done. I like writing my own (get analog voltage). After getting the data from the ADC, start the next conversion, then store the data and what ever you need to do to the data, while the ADC is doing its job. By the time you get back likely the ADC is almost done. This is much like the (write to EEPROM) that comes with most software. Doing one write and then waiting for the write to happen is a waste of time. It is too easy to have a ADC delay and a EEPROM delay in your fast loop.

On the other side, if the language you are using can only do 1000 to 10,000 instructions/second then the hardware will seem fast. lol If you write the fast loop in machine language the hardware will seem slow.
 

Irving

Joined Jan 30, 2016
2,308
On an Arduino you usually can't go much faster than the C code, it translates pretty well. I've done pretty much the same as you before too. Just an 8Mhz clock is a killer. The STM32 has the advantage that the ADC can autonomously convert and dump results into memory using DMA and an end-conversion interrupt so there isn't any waiting or reading of peripheral as such. Using external ADC on SPI or I2C can be slow too as in general the SPI/I2C interface is essentially software driven and being serial takes shed loads of pulses to send the peripheral address and then read the result back in... again the STMs DMA interface is king here.

Having said that, the STM32 chips in their 178/208 pin LQFP package at 200+MHz are not for the uninitiated to design with.

The MAXIM 11131 16-channel, 12-bit ADC can handle ~30k samples/sec on a 10MHz SPI bus, so 4 ADC read sequentially would give ~7.5ks/sec - this is the problem with SPI, but taking it to the 40MHz the ADC is capable of is beyond most MCU. Assuming you wanted to process each set of 64 samples as a frame, with a 2-core processor, one core would be responsible for acquisition into pair of 64-word 16-bit memory buffers, then the other core processes the 'current' buffer every 125uS, that's about 10Mbit/sec so forget serial USB via the programming port. I do it for my 5MBps dual-channel CAN interface over wifi (2-core ESP32, core 1 acquisition, core 2 does the wifi). So that would be my alternate choice.

edit: corrected maxim part #.
 
Last edited:

Yaakov

Joined Jan 27, 2019
3,737
Just a note so your discussion of this won't be confusing to others later: the term you want is sampling not "parsing".

Sampling refers to capturing a discrete value of a continuous analog signal while parsing is syntactic analysis of a sentence or string.
 

Irving

Joined Jan 30, 2016
2,308
Another added thought. The ESP32 can do 40MHz SPI and DMA too so it might be an easier contender using 4 MAXIM 11131 ADC. I've not used the fast SPI/DMA myself, but it might be worth looking in to... The ESP32 modules are cheap and robust and can be programmed on the Arduino IDE, though I'm using Visual Micro for the advanced debugging.
 
Last edited:

ronsimpson

Joined Oct 7, 2019
1,630
"I know nothing" Here is what looks like a serious Arduino.
The Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU. It is the first Arduino board based on a 32-bit ARM core microcontroller. It has 54 digital input/output pins (of which 12 can be used as PWM outputs), 12 analog inputs, 4 UARTs (hardware serial ports), a 84 MHz clock, an USB OTG capable connection, 2 DAC (digital to analog), 2 TWI, a power jack, an SPI header, a JTAG header, a reset button and an erase button.
1626215730524.png
Down deep in the data sheet it looks like the ADC will run 12 bit at 1,000,000/second.
 
Last edited:

Irving

Joined Jan 30, 2016
2,308
Yes, the Due is a better "Arduino". Its quite expensive at 39gbp compared to the esp32 at 8gbp and lacks the Wi-Fi onboard. it only has one SPI channel limited to 3 external devices without additional hardware but does support DMA on that (but not on the internal ADC). Another downside of the Due is the lack of low-level Peripheral support, it's the same software stack as the Uno.

An even better Arduino is the Pro Portenta H7 but that's 74gbp. .
 

ronsimpson

Joined Oct 7, 2019
1,630
My thought; if your are good at Arduino then try to stay with in that. Learning different is hard. (maybe not when young)
I can make a 8 bit little computer dance because I know how and have the right tools. I would probably struggle with a 32 bit ARM because I don't know it and do not have tools. (experience)
I really don't care and do not have a horse in this race. I just was thinking about how far Arduino can go. I heard there was a 32bit ARM version.
 

Irving

Joined Jan 30, 2016
2,308
My thought; if your are good at Arduino then try to stay with in that. Learning different is hard. (maybe not when young)
I can make a 8 bit little computer dance because I know how and have the right tools. I would probably struggle with a 32 bit ARM because I don't know it and do not have tools. (experience)
I really don't care and do not have a horse in this race. I just was thinking about how far Arduino can go. I heard there was a 32bit ARM version.
I don't disagree with the sentiment. I too used to use an Arduino for most projects, now I use an ESP32 as it covers all the bases better and yet I've used STM32 for other projects because even the ESP32 couldn't cope.

I've seen too many projects spend too much time & money trying to make something work which simply couldn't be done. Its not hard to run the numbers and get a feel if this is clearly doable, marginal but worth an experiment or two, or not worth considering.

And if you've not written code for a real-time pipelined environment, massaging the hardware, it probably makes little difference what the platform is, there still a learning curve.
 
Top