HS402 DIY Oscilloscope

HS402 Oscilloscope series are quite good DIY oscilloscopes designed for higher performance respect the HS10X series while keeping the best ratio performance/cost/ease to build.

Power consumption is also one of the lowest in the market (~40mA). They can be used only with HScope app for Android (since version 2.2.7).

HScope is in continuous development thanks to the suggestions from the users and the contributions of the supporters, and aim to become one of the best affordable high-tech diagnostic tool. 

Consider to support this project with a donation!

please indicate in the notes the purpose of donation

Intro

A 2 Channel oscilloscope based on STM32F4x1 Black Pill development board. It provide long memory buffer and high real-time transfer speed.

Technical Specifications

Channels1 or 2
Input RangeCan be built with one of the following variants:
Single range bypolar (ie. ±5V) | PRO (multiple ranges, selectable on app interface)

PRO input ranges
±16V, ±8V, ±4V, ±1.6V, ±500mV
Sampling RateSTM32F401
2 KSa/s – 1.4MSa/s
2.8MSa/s, 3.8 MSa/s not linear rates
STM32F411
2 KSa/s – 1.6MSa/s
3.2MSa/s, 4.2 MSa/s not linear rates
ADC Resolution8-12 Bits (8 bit @ max rate, 10bit @ 100KSa/s, 11bit @ 25KSa/s)
Input NoiseSchematic Option 1
0.4% MAX @ 1.4MSa/s
0.12% MAX @ 140KSa/s (in real-time, 2 Channels, 10 bit)
<0.01% @ 50KSa/s (in real-time, 2 Channels)
Cross-channel noise: 0.05%
Schematic Option 2 (REF2033)
0.17% MAX @ 1.4MSa/s
0.13% MAX @ 800KSa/s
0.09% MAX @ 400KSa/s (10 bit)
0.05% MAX @ 200KSa/s
<0.06% @ 160KSa/s (real-time, 2 Channel, 11 bit)
<0.05% @ 50KSa/s (in real-time, 2 Channels)
Cross-channel noise: 0.25%
BandwidthSTM32F401
700 KHz
STM32F411
1MHz
Input Impedance1 Mohm (1.010 kOhm)
Memory BufferSTM32F401
16K samples (half when use 2 channels together)
32K @ 3.8 MSa/s
STM32F411
32K samples (half when use 2 channels together)
64K @ 4.2 MSa/s
TriggerSTM32F401
Hardware – checked after each complete scan, not centered, may loose samples
STM32F411
Hardware, real-time, position within first 500 samples
HW Options Supported– AC/DC Coupling Module
– PWM Output Generator
– Input Buttons Module to control basic oscilloscope functions (eg. Start/Stop, sampling rate,..)
Modules Supported in HScopeAutomotive Module up to*:
STM32F401
280 KSa/s single channel, 140KSa/s with 2 channels
STM32F411
320 KSa/s single channel, 160KSa/s with 2 channels
Audio Module
PWM Generator: supported up to 1 MHz, duty cycle 1-99%
OS VersionAndroid 7+ (Android 4.4 supported but Automotive Module cannot reach more than 100KSa/s for 1 channel and 50KSa/s for 2 channels)

*performances dependent from Android hardware and OS version. Check required OS Version. Suggested CPU 2.1GHz+

Schematics & Built

Notes

  • Other STM32 development boards can be used, the important is that the main crystal is 25MHz
  • On the schematic are indicated 2 hardware options. One exclude the other.


Flash the Firmware

The firmware flashing is made with the app STM32 Utils with an OTG adapter connected to the phone and an USB-TLL adapter connected to the OTG adapter. After connecting the phone to the STM32 Black Pill board like in picture, the red led light up.

By pressing the buttons on the Black Pill as in picture, the board enter into the STM boot loader and it is ready to be flashed. On the App:
1) Go to Init Chipset and check that the app read the chipset


2) Go to the Blue Box icon and in the list under vendor Martinloren select HS402 Oscilloscope, select the chipset from the variants (STM32F411 or STM32F401), then FLASH FW.

3) After flashing disconnect the USB-TTL cable from the STM32 board and connect the STM32 to the phone through the OTG cable. Open HScope, the app should show you the signal from Channel 1.

Connection

First Setup / Calibration

When the oscilloscope is connected go in HScope Settings, General - Hardware. Here:

  • Set the Model to HS402 and Input Type to PRO. When you do this change also the option Hardware AC/DC Coupling will be enabled automatically.
  • Disconnect and reconnect the oscilloscope to get the new configurations.

You can also Enable the input buttons if you have installed the corresponding I2C module.

Offset Calibration

  • (required just for Hardware Option 1) Connect Channel 1 probe to its GND.
  • (required just for Hardware Option 1) Rotate the precision variable resistor (R9) until the software show a DC voltage quite near to 0. This trimmer requires a lot of turns. Make sure with a multimeter that its value is around 1Kohm before proceed with the fine tuning.
  • For each channel do the Calib Zero Lvl procedure in the Settings -> Calibration.

Frequency Calibration

  • Enable the PWM signal using the PWM module (red square icon in the right menu, then open the module). HS402 will generate a square wave on pin B15 (1kHz initially).
  • Connect the probe to pin B15. Use an high rate, i.e. 450KSa/s and turn the variable capacitor until the rising part of the square wave reproduce a good square. Do this for each channel.

Now the device is calibrated in frequency response.

Multiplier Calibration

For this calibration you need an accurate voltage source, for example 3.3V or 5V from a voltage stabilizer. 5V from USB port is not accurate and should never be used for this calibration. Batteries also should not be used. At least you can use LM7805 or this kind of linear voltage regulators.

  • For each channel do the Calib Multiplier procedure in the Settings -> Calibration.

HW Debugging

Here the tests you can perform in case of issues:

  • Check that PGND is approximately around 1.65V respect GND. In Option 1 the R9 trimmer requires a lot of turns to get the offset near the 0. With a multimeter you can test it reach around 1Kohm and then fine tune the zero level with HScope. A3 and A5 pins (analog inputs) also should be at the same voltage with no input signal is applied.
  • With a multimeter check that there are no shortcuts among the pins B3, B4, B5, B6 (these are connected to the PGA (U1, U3) which are very small and are easy to get shortcuts between the pins).
  • Check that voltage change on C4 and C5 when on HScope you enable/disable AC/DC option on the channels. To check that the AC/DC coupling works just apply a battery to the input. When DC is selected you should read the voltage of the battery, when AC is selected you should read 0V.

Hardware options & Modules

Schematic Option 2

This option provide a stable reference voltage to the STM32 ADC, by installing the part indicated in the Schematic as Option 2. It requires also a modification on the STM32 board in order to bring the Vref pin from the STM32 to one of the pins of the development board (PA2). One component should be removed (the inductor) and a jumper should be created to PA2 according the picture under. PA2 is inactive and used just to provide the Vref signal.

Option 2 just show a greater cross-channel noise respect Option 1: 0.25% vs 0.05%.

Note: after this modification the STM32 board will work only if 3.3V is applied to PA2 (now Vref)!

Hardware Buttons Module

By connecting the PCF8574 I2C module it is possible to have 8 hardware buttons to control the oscilloscope. These are the pin that should be connected to the STM32: GND, VCC (5V), SDA, SCL, INT. Buttons are triggered by connecting the P0-P7 pins to GND.

Button functions

  • P0: Start / Stop
  • P1: Rate up
  • P2: Rate down
  • P3: Fit waveform to screen
  • P4-P7: (not assigned yet)

PWM Module

HS402 can generate PWM output. A MOS driver like the MOSFET IRF520 Module Board can be used to control loads. Here the schematic of connections. A video about how to use the HScope PWM module is here. The IRF520 has been tested at 1KHz PWM frequency and showed low pass characteristics so it is not suggested to use an higher frequency.

Arbitrary Input Range

You can design the input ranges for each channel according your needs. For example it is possible to have the maximum voltage to ±5V or to ±50V. Channel input ranges can be also different (for example a channel has max voltage ±16V and the other channel ±5V).

  1. Calculate R2/R3 (or R6/R7) resistors values according the required range. Pay attention the sum of these 2 resistor should be around 1Mohm.
    a) R2 + R3 = 1Mohm
    b) ±Range = 1.65 * (R2 + R3) / R3

    Example: Range = 1.65 * (910k + 100k) / 100k = ±16.66V
  2. Do the multiplier calibration of the channel. After the software will show the voltage ranges according the hardware.

Warning: do not exceed 50V input range since the input is not isulated from GND and from the phone, leading to a possible electrocution.

Built by Users

Built by Matt (2020, 3D case files available here)

Built by Sebastian (2020)

Built by Denis (2020)

Built by Mikael (2020)

Built by Jim, PCB v.1.7 (2020)

Built by Mikael (2-Channels version – 2020)

Built by Andrew B (2020)

Built by Ramon (2020)

Additional Resources