Miniscope v2c

Very cheap low-speed dual channel PC/USB oscilloscope with STM32 (STM32F103C8T6) microcontroller.

Some low amplitude signals (300 mV p-p) recorded with miniscope v4:

miniscope v4 + v2c

Components should cost less than $10 total (with homemade PCB).

Schematic: miniscope_v2c_20120416.pdf

Single-sided Eagle PCB, 66mm x 36mm
miniscope v2c PCB (Eagle)
miniscope v2c PCB photo
Goldpin header and BOOT pushbutton are used to load firmware via UART.
miniscope v2c PCB photo
STM32F103C8T6: LQFP48 package
STM32F103C8T6

Eagle files

IDE

CDC class example - same path as with miniscope v2 - from STM was selected as a base project to speed-up USB device related programming. This example has project files for IAR, Keil, RIDE, HiTOP and TrueSTUDIO, so using one of these IDEs would be an advantage. Unfortunately I haven't found any of these appropriate. RIDE and HiTOP evaluation versions have restrictive licenses (valid support contract requirement after 7 days and no commercial usage respectively). IAR or Keil evaluation/lite version licenses have restrictions on output size and it wouldn't be a problem in a small project, but they have pretty big disk space requirements (~3 GB as I recall) and their installers don't allow much customization. Same goes with TrueSTUDIO.

As a result I've chosen CooCox toolchain - 115 MB download for IDE + gcc, ~800 MB disk space usage after installation, no license restrictions.

Firmware loading

PCB has no JTAG/SWD connector so firmware has to be uploaded with UART bootloader. To enter bootloader mode press and hold BOOT pushbutton while pressing RESET pushbutton. PC loader (STM "Flash Loader Demo") seems to work with no problems with USB-UART converter. MCU bootloader pins are 5V tolerant, so either 3.3V or 5V RS232-UART/USB-UART converter can be used.

RESET pushbutton can be removed - microcontroller will go into bootloader mode also if it would be powered on (USB would be connected) when BOOT is held down.

Since there is no USB 1k5 pull-up control USB need to be re-plugged to force re-enumeration after reset of new firmware loading.

Some basic project to test MCU and buzzer: stm32scopeTest.7z.

Tips on USB transfer speed

Use CDC example as a template. There are two BULK endpoints. For better transfer speed CDC example would require small modifications.

  1. Change VCOMPORT_IN_FRAME_INTERVAL to lower value. I'm not sure if value = 1 is suitable when transfer needs to be bidirectional, so I've used value = 2. It won't make much difference though.
  2. Increase USART_RX_DATA_SIZE. I've used 8192 bytes (2 x 4 kB), but I think that there would be no speed difference with values above 4096 B (maximum number of data would be transmitted in every or almost every frame).
  3. Modify Handle_USBAsynchXfer so it wouldn't transmit data unless half of the USART_Rx_Buffer would be full. Thus after each SOF maximum number of bytes would be sent. If there is a chance that buffer would be filled with low speed or not filled at all for some time then some kind of timeout would be needed here that would cause transmitting whatever is in buffer already - you may know this problem if you've used USB to UART converters before.

On a PC side make sure that application is constantly ready to accept new data. Make sure that thread that is reading data is working with higher priority than others. I've used libusb, so I've used combination of usb_submit_async/usb_reap_async to enqueue multiple read requests, each time requesting reading of 4096 B. I guess with WinUSB that could be made with overlapped I/O. Miniscope v2b/v2c dll interface library passes than data through FIFO to GUI application.

I wasn't interested in high PC to device speed, so I haven't any tips on reverse direction. Miniscope v2c (very similar to v2b) is streaming data to PC at maximum speed all the time. Transfers in reverse direction are insignificant (ID request, changing analog gain or analog coupling).

Firmware and miniscope v4 dll interface

Although windows driver (libusb-win32) is included in dll archive using Zadig is actually easier and it is only sensible option for 64-bit Win8/Win10:
Zadig on Windows 7
Important: make sure libusb-win32 is selected as driver in Zadig (WinUSB might be default).
Update from 2024.07.04: when installing on Win7 x64, Zadig 2.9 (current version) failed - Device Manager was showing that driver is not digitally signed. Going back to Zadig 2.5 (like on the picture above) solved this issue.

Follow-ups

PCB version with LM1117 3.3V regulator and few layout changes made with Pulsonix EDA software by Quang Duy: http://mritx.blogspot.com/2014/07/low-speed-dual-channel-pcusb.html.

Alternative hardware

Apparently ebay (and most likely any other shopping site of your choice) is flooded with very cheap ($5 including shipping) Maple-like minimalistic STM32F103C8T6 boards. While I haven't tested them they seem like good choice to run this firmware. Don't forget that USB-UART (or RS232-UART if you have RS232 in your PC) converter is required to load program to microcontroller.

STM32F103C8T6 board