Posts

Showing posts from January, 2020

Component tester : Capacitor

The charge curve of a capacitor is Vc=Vcc*(1-exp(-t/RC)) The idea is to charge the capacitor up to ~ 70% and look how much time it took The formula is then inverted to  : C=   -t/R*(ln(1-ADC/4095) The problem is C can go from 1pF to 400 uF, that's a 400000000 factor So what we will do is charge up to 10% using the 20 k resistor and lookup how much time it took Depending on the result, we'll select the right resistance and do it again.  That initial sampling does not need to be accurate, it's just to select the right resistor. The idea is we aim at a charge time of ~ 200 ms so the errors are neglectable. For mid values and high values capacitor that works fine (C above ~200 pF or so) We poll the ADC with slow sampling period until we get over ~ 70% and compute the capacitance value from there. It does not need to be exactly 70% since we have the matching ADC value. The limit is here is the sampling period is a few us, which is fine if R*C is big comp...

Component tester with STM32 : Part 1 ADC, Resistor

Image
I was always  fascinated by the so call "transistor testers" that identify and report pin out, features of pretty much whatever you throw at it. They are based on Atmel 328p chip, the same as arduino nano. So why not do the same thing with a STM32/Bluepill ? The STM32 is faster, has a better ADC accuracy, more memory, can do float etc... and is not more expensive. Warning : I'm doing this for fun & to learn, it might contain error & plain misunderstanding So, i watched a couple of video on the general principle on how they work. This is not a "port" but a rewrite from ~ scratch. When something is weird, i check what the original one does for comparison. Measuring resistance So first thing first :  Resistance & Capacitance. These 2 will unlock the other ones. So how do we measure resistance ? What we do is a resistor divider with a know resistance value: Measure = Vcc*(RtoTest/(RtoTest+Rknown)) As far as the ADC goes, it means ADC=...

ESP32: TTGO T-Display + Jtag

Image
I bought a couple of these  TTGO T Display  modules on BangGood while they were on sales Perfect to do something more complicated than blink with arduino-cmake-stm32 and our jtag debugger Hook that to the jtag.... ah, IO14/TMS  is missing. Let's have a look at the datasheet  : Ok, IO14 is used to switch between VBUS / VBAT or something similar. Dont' care,  i dont intend to use the battery module on the board. So let's remove D6, that the diode on the left here : and put a dupont wire on the top/left pad. Open OCD now connects over Jtag.