š» HS402 3.0 ANDROID STM32 Oscilloscope PCB and assembling
This article describes how to build android oscilloscope HS402, includes a few ways to flash firmware with PC and Android.Ā
Electrical circuit
K1, K2 ā Solid-state (PhotoMOS) relayĀ for DC/AC choose;
R2, R3 ā voltage divider;
D1, D2 ā input protection (GND-0.3V; GND+0.3V);
U1, U3 ā input signal gain with different coefficient;
U2 ā virtual ground (3.3V/2 =Ā 1.65V);
šĀ SCH_HS402-WIFI_V3.0_210327.pdf
š SCH_HS402-WIFI_V3.1_220108.pdf
Components
Full list of components you can look in the .PDF document.
Ceramic capacitors C8 and C11 (47 uF)Ā could be rare and expensive, so it canĀ be replaced by 10uF 16V X5R/X7R.
šĀ HS402_Component_List_V3.1.pdf
Power supply options
Option #1 (simplest!) | Option #2 | Option #3 |
AP7343D | AMS1117-3.3 | TPS73733 (v3.0) orĀ RT9193-33GB (v3.1) |
Use onboard regulator of STM32 board (shortcut J1 jumper). | Separate regulator if supply voltageĀ 5V or more. | Allow 3.6V-5V input voltage.Ā Need Vref modification. |
Microcontroller
Both modules are pin-to-pin compatible development board, but STM32F411 is more powerful than STM32F401, but it twice as expensive.
MCU | STM32F401 | STM32F411 |
Sampling Rate | 2 KSa/s ā 1.4MSa/s | 2 KSa/s ā 1.6MSa/s |
Bandwidth | 0.7 MHz | 1 MHz |
Memory Buffer | 16K samples (2CH) 32K @ 3.8 MSa/s | 32K samples (2CH) 64K @ 4.2 MSa/s |
Trigger | Hardware ā checked after each complete scan, not centered, may loose samples | Hardware, real-time, position within first 500 samples |
Modules Supported in HScope | 280 KSa/s (1CH), 140KSa/s (2CH) | 280 KSa/sĀ (1CH), 140KSa/s (2CH) |
I strongly recommend don't solder module on the board, because if you want to takeĀ devboard comeback āĀ it'll be super-hard, so just use PBS connector:
BNC (RF connector)
Presented plastic white BNC connectors are really bad, if you can, replace it with more reliable.
Programmable Amplifier
MCP6S21 is rail-to-railĀ amplifier with SPI-programmable gain, that allows change voltage range by application.
Solid-state relay
AQY210 is a solid-state relay (PhotoMOS), that have internal LED (input), solar panel (convert light emitting into voltage) and transistor (output).
Voltage Regulator for Virtual Ground
Voltage regulatorĀ AMS1117-1.2 give a chance to get 1.65V (half of 3.3V) for virtual ground, what is require for take input signal polarity in both sides.
PCB
This is 3.0 version of the board. Now is available 3.1 newest and better version.
The Gerber files is available for download and order with PCB factories (current ver. is 3.1)
Ā Ā Ā ?Ā PCB_HS402-WIFI_V3.1_220108.zip
Assembling
Before assembling find minimum required components for the oscilloscopeĀ by the list and put in case.
You can use soldering iron, but the easies way is using hot air gun.Ā Before mounting you have to prepare PCB pads. If you have solder paste put it on pads manual or with help SMT-stencil, I don't have it, so I must coat pads by using soldering iron.
Don't forget to shortcut J1 jumper, if you use Option #1 power supply.
Then mount leftover THT components with soldering iron.
Settings
Visual inspection
After soldering thoroughly inspect soldering quality and components values.
Check input and output voltage
I use on-board voltage regulator 3.3V (Option #1).
Check input voltage ( GND and 5V) and output (GND and 3V3).
Flashing firmware
There are many ways to load firmware into microcontroller's flash-memory:
USB-TTL converter (Android/PC) | STLINK programmer(Android/PC) | USB DFU (Android/PC) |
USB-TTL converter
Android
The easiest way for you it's to use USB-TTL. IĀ use CH340, you can use: CP2102, FTDI232RL, PL2303HX) converter. CH340 Driver for Windows 10, 11 (must be installed manually):Ā
?Ā Download driver for CH340:Ā ch340_driver_win10.zip
Connect it toĀ STM32 board according to the wire diagram and then to android phone:
DownloadĀ and install STM32 Utils (from Play Store):
Check connection again and connect it to the phone:
Press both buttons NRST and BOOT0 and connect it to the phone, release first NRST and then BOOT0:
Open application and init chip. Press on blue cube, choose vendor Martinloren and select the last version of the HS402 oscilloscope firmware, press FLASH FW.
Wait for erasing data and writing chosen firmware, that's all.
PC
Also, you can use computer software STM32CubeProgrammer. Download it on official site (need registration), or in telegram.
After connection to the PC open Device Manager and check, that your converter is properly identificated (drivers properly installed).
Press both buttons NRST and BOOT0 and connect it to the phone, release first NRST and then BOOT0:
Open Cube Programmer, choose UART and select COM-port (in my case it's COM5, we have seen it before), press Connect. (If you do previous stepĀ wrong, you will see that, disconnect power andĀ press buttonsĀ again)
Download firmware binary file (available onĀ GitHub):
Press Open file and choose it.
Now we have opened binary file, press Download.Ā Wait about 20 seconds and that's all!
Programmer STLINK
PC
The easiest way for me is using programmer-debugger STLINK, connect it appropriate to table:
STLINK | GND | SWCLK | SWDIO | 3.3V |
STM32 | GND | CLK | DIO | 3V3 |
Check connection and connect it to the PC.
Android
By the way, you can use android application ZFlasher STM32.
USB (in DFU mode)
AnotherĀ simpleĀ way is using DFU (Device Firmware Update) mode.
Connect board to the PC (using USB cable), then press both buttons NRST and BOOT0,Ā release first NRST and then BOOT0 (within 0.5s) to enter load mode:
Choose USB connection and select USB1 port:
Press Connect:
Open Open file and select firmware file (see above where to get), press DownloadĀ and wait some time.
Android
By the way, you can use android application StmDfuUsb.
First connection
Download and install HScope app from Google Play.Ā The most convenient connection way is isĀ USB Type-CāUSB Type-C cable and Android phone with USB-C socket.
Virtual ground tune
Most likely, even if no signal on input you will see non-zero value, don't worry.
Just tune lineĀ to zero (must no input signal!) by rotation variable resistor.
Fronts tune
Connect first channel to rectangular waveform signal (use can use PWM output pin), if angle is no acute rotate trimmer capacitor (better use plastic/ceramic screwdriver).
The same tune do with second channel.
Calibration Zero Level
Shortcut ground and first channel input and do zero calibration.
Do the same with second channel.
Ready to use
Generally, the oscilloscope is ready to use, I want to test it on the generator based on comparator.
Test
I have got another STM32, let's generate PWM-signal and observe it with android oscilloscope.
PWM-signal (50% duty cycle)
10 Hz, 100 Hz
10 kHz, 100 kHz
200 kHz, 400 kHz
666 kHz, 1 MHz
Comparator-based relaxation oscillator
RC (Differentiator)
Previously generated signal connected to the input (yellow CH1), output on CH2 (green).
LC (Resonant circuit)
We can see the damped oscillations.
Level trigger (red line) is set, then battery (power supply) connected for a moment.
PWM generator
You also have got a PWM-signal generator with frequency and width regulation.
It can be used for tests or like voltage regulator, if transistor is connected.
Video
Conclusions
As you can see, assembling an HS402 oscilloscope is not difficult at all, but in any case the effort and time invested are considerable.
The most worth of this oscilloscope is possibility to get wireless data transmission to your phone, so you can observe electrical values remotely. To add this feature you need add ESP32 Wi-Fi microcontroller module, I will do this in next part.
Dr X 2 years ago #
Very good,.waiting for next part.
admin 2 years ago #
Next part is already available:Ā https://refcircuit.com/articles/16-hs402-wifi-android-oscilloscope-esp32-stm32.html
Hitesh 1 month ago #
What is maximum frequency it can measure accurately ?
admin 1 month ago #
I would say up to ~700 kHz, if we talk about rectangular signal.
See the PWM-signal (50% duty cycle) chapter for more details with tests 10 Hz to 1 MHz.
jose antonio 1 month ago #
Is there a way to know how to do ADC sampling I tried to do something similar but the signal is lost and it is distorted a lot, will you have any suggestion to replicate something similar of your project ?