Spark Logic

$10 O-Scope revisited

ahull

Over the last few days I’ve been playing with Ray’s STM32 Oscilloscope idea.

Image

Some preliminary results are available here..

https://github.com/pingumacpenguin/STM3 … ontruction

My take on the Scope Sketch is here..

https://github.com/pingumacpenguin/STM32-O-Scope

Its a fun little project and well worth building just for the entertainment value. Currently bandwidth is a little limited, but with a little extra effort it would be possible to make a fully functional 2MHz Scope for next to nothing. Ideal for probing i2c, audio and other low speed signals.

EDIT: We managed to squeeze the maximum speed out of the ADC, read further through the thread for details. The github code includes all of the enhancements made of the course of this thread.

Replies20

rexnanet Fri Mar 18, 2016 3:41 pm

mrburnette wrote:
Yes, this issue is simply an Arduino IDE issue in the way that libraries are searched … one can only have a single Time.h in the /Arduino/libraries directory. It sucks, really, but is just one of those abstract things that Arduino does.

I strongly recommend putting such code directly into the directory with the INO file(s) and encapsulate it. Hard disks are so large these days that the duplicated space is insignificant and the way the ArduinoIDE is evolving, having the Board Manager updating libraries has caused me a great deal of annoyance. Anyway, there are some environments such as Cypress PSoC development where libraries are always copied into the working folder – so the paradigm is not weird.

Ray

mrburnette Fri Mar 18, 2016 10:16 pm

rexnanet wrote:
<…>
To solve many of these issues we could create a zip/rar file with all the necessary libraries “in a working state” :) to make it easier to replicate the project.

That approach makes it more dificult to share libraries and their changes but makes compilation a lot easier.
<…>

rexnanet Wed Mar 23, 2016 2:20 pm

victor_pv wrote:Andy,

I worked some optimizations in the lcd library. It is still not the best it can, but much faster than before specially when it comes to drawing the captured data.
Download the zip attached and use that. It requires the latest SPI library from Roger’s repo.

Adafruit_ILI9341_STM.zip

rexnanet Wed Mar 23, 2016 3:00 pm

mrburnette wrote:The neatest part of this is that you are using Pix of the O’scope in operation to show capability and issues.

Job well done… this should be a required build for any serious tinkerer who does not have access to a scope. This would be a great PSoC 4200 project due to the “free” analog subsystem and analog mux + OpAmp. FYI, only $4 http://www.cypress.com/?rID=92146
( do not even consider 4100 )

Ray

rexnanet Wed Mar 23, 2016 5:03 pm

rexnanet wrote:
Latter I’ll test it on the board :)

ahull Wed Mar 23, 2016 11:16 pm

rexnanet wrote:rexnanet wrote:
Latter I’ll test it on the board :)

rexnanet Thu Mar 24, 2016 2:45 pm

ahull wrote:
Take care with the backlight, the pins on the STM32F103 may not be able to source the current needed to run the display at full brightness, you may (depending on your LCD board) need to add a transistor to drive the backlight.

ahull Thu Mar 24, 2016 4:41 pm

rexnanet wrote:ahull wrote:
No, the ADC on most boards is tied to the supply voltage, so in most cases you input signal *must* be between 0v and VCC (3.3V) otherwise you will damage the ADC.

rexnanet Sun Mar 27, 2016 8:45 pm

ahull wrote:
Dual channel should be relatively easy, but you will not get the full bandwith.

ahull Sun Mar 27, 2016 10:31 pm

You might find this interesting. https://www.tablix.org/~avian/blog/arch … oller_adc/

As to the stability of AnalogWrite, I am not aware of any instability, I suppose the best way to check for this would be to compare with a real oscilloscope.

ahull Mon Mar 28, 2016 12:55 pm

Once you have the kinks ironed out of your changes and you are happy with them, fire me a pull request on githib, and I can merge them if you want. :D

Based on the available analog bandwidth per Alvin’s Blog post I wonder if we can over clock the ADC (at the expense of resolution presumably), and get reliable results beyond the 1MHz stated STM Spec. It looks like an interesting experiment to try. Even 8 bit resolution at say 10MHz would be useful. The GD32F103 red pill boards might also be worth a bit of over clocking experimentation, their silicon should in theory be more amenable to being driven at higher frequencies.

RogerClark Mon Mar 28, 2016 8:32 pm

Andy

The GD32 boards seem to work fine at 120Mhz, but Ive not looked at whether the ADC works at that frequency.
But it is specced to 108Mhz ( but as you know, USB only works at 48,72,96 and 120Mhz because of limitations in the USB PLL clock divider)

ahull Mon Mar 28, 2016 9:03 pm

RogerClark wrote:Andy

The GD32 boards seem to work fine at 120Mhz, but Ive not looked at whether the ADC works at that frequency.
But it is specced to 108Mhz ( but as you know, USB only works at 48,72,96 and 120Mhz because of limitations in the USB PLL clock divider)

RogerClark Mon Mar 28, 2016 11:23 pm

HI Andy

I think someone may have already looked into clock switching, but I though it breaks the USB connection

You could of course force USB re-enumeration, but that would be a pain every time you wanted to transfer data

Unfortunately the STM32 only has 2 clock divider settings for the USB PLL, but the GD32 has 4 (2 bits) (this has been possible because STM have a reserved bit in the register next to the bit for the PLL divider, so GD were able to add 2 more PLL divider settings and yet keep backwards compatibility

ahull Tue Mar 29, 2016 12:53 am

RogerClark wrote:HI Andy

I think someone may have already looked into clock switching, but I though it breaks the USB connection

RogerClark Tue Mar 29, 2016 9:54 am

Hi Andy

I’m afraid I’ve not looked at the ADC clock at all.

Looking in the manual RM0008, there is a PLL divider for the ADC clock, but I don’t know where its setup in the core.

I took a quick look in the libmaple folder at adc.c, but I can only see the setup for the number of clock cycles per sample, rather than the master PLL divider for the ADC.

I suspect the ADC clock stuff is probably setup somewhere in the RCC code, but I’m not sure where.

If someone had time to play with it, I suppose you may be able to get a bit more performance at the expense of resolution, but I wonder how useful it would actually be, or whether you’d just end up with erroneous results.

rexnanet Tue Mar 29, 2016 10:09 am

ahull wrote:You might find this interesting. https://www.tablix.org/~avian/blog/arch … oller_adc/

As to the stability of AnalogWrite, I am not aware of any instability, I suppose the best way to check for this would be to compare with a real oscilloscope.

rexnanet Tue Mar 29, 2016 2:16 pm

rexnanet wrote:
With an overclocked ADC we must keep the 1.5clk on the sample time to allow a proper sampling of the signal.

RogerClark Tue Mar 29, 2016 9:21 pm

You could modify the SPI DMA transfer to be non blocking, and to generate an interrupt when the transfer is complete, as this would allow the core of the cpu to go off and do other stuff while the spi transfer was happening.

But I dont suppose there is much that the cpu could do while waiting for the spi transfer to finish?

Post a reply