Square Waveform Voltage and Frequency detection

panic mode

Joined Oct 10, 2011
4,985
If you say so!! Not every electronic tech or production line service person is skilled in whatever language that is. Nor would they be able to adjust it or diagnose any problem.
how do you think he or production service team would feel about troubleshooting hardware solution like peak detectors, sample and hold or whatever? why do you think they would be more skilled or successful in such situation?

since TS is struggling with circuit design, that is the part i tried to simplify for him. i sure hope he can make up for that with some programming, or he may be looking for a different job. ;)

i am just trying to offer something semi-concrete and let TS decide what works for him. for example he asked for help with this circuit and so far nobody offered anything about it - how it works, how to size the parts to fit his criterias etc.
1760038330884.png

here is an example that shows both positive and negative peak detectors - it is two slightly different circuits:
1760038455111.png

one can replace resistors by mosfets. resistors are there to discharge capacitors and without them peak value will have less ripple. then MCU can pulse the mosfets to reset the circuit after measurement is done.

things to watch for - OpAmps need to be sufficiently fast enough (some of the circuit google returned show the old 741...).
negative peak detector should have buffered output. above circuit shows that as inverting amplifier (so output is magnitude). if needed this can be turned into plain voltage follower - as long as one knows how to measure negative voltages using MCU. also whatever OpAmps are used, they need to be powered correctly. this means (depending on choice of OpAmp) one should consider supply voltages that exceed peaks... preferably by 2V or so... so split supply is needed like +20V/Gnd/-5V or +20V/Gnd/-10V

Something like this:
1760041010081.png
 

panic mode

Joined Oct 10, 2011
4,985
U5 is wired almost like a buffer - it only has additional diode. so the output follows the input voltage - until voltage at inverting input matches it. this is good because characteristic of diode is not critical, output will overcome 0.6V or so to get C charged to same voltage that is at the input. but because of diode this only works as long as input voltage does not drop. so with help of U5 diode becomes ideal diode with Vf=0V

Same happens in case of U6 and D2 but the polarity is reversed. without resistor to bleed capacitor, voltage will stay as is for long time (there will always be some leakage etc.). So you want to choose C of suitable type to minimize that leakage (use ceramic).
OpAmps are common in packs of 2 or 4 so i would also add buffer to the output of positive peak detector. this will minimize any drain on capacitor by external circuits (voltage divider).
 

ronsimpson

Joined Oct 7, 2019
4,694
Years ago I made a PCB with a small micro, 2x16 LCD display, 6 buttons, a bread board area and a place for a wall-wort power supply. (USB now days)
The micro had a hand full of IO lines and 8 ADC inputs connecting to the bread board area.
These fit into a plastic box from digikey.

I don't program well but I do BASIC. The pic-micros have a BASIC compiler (pic-basic pro) and there are several other BASIC compiler and interpreters. Another reason for using pic BASIC is that there are IO commands that simplify things. There is a command (Analog in) or PRINT LCD. Most of the IO work is done for you.


Today I might use a PiZero 2W board. The first board is a WiFi computer board. It has Pi 40 pin connector that you can plug a bread board into. It runs on a USB power supply. There are versions if the Pi0 that do not have WiFi but in a factory, it is good to have test boards connected to the network. The Pi boards allow you to use your PC over the network to reprogram the little board. (can drive a monitor, keyboard, mouse) Has Ubuntu or Android. I have NodeRed and Python on it.

1760044491698.png
The "hat" board adds IR, buttons, audio, more USBs and ethernet. I wanted the buttons and ethernet.
1760045111033.png
 

MisterBill2

Joined Jan 23, 2018
27,530
Those are indeed pretty modules and I am sure they can run all sorts of wonderful code and do amazing things. And certainly creating al of that code requires not only a good understanding of what the application needs to do, and how the pieces need to be configured to run the code to do those functions. AND all of that code must be written on a computer and loaded into the module. And if some part does not work as needed it is difficult to see how it is going wrong, because there is no place to probe the code with a meter.
THAT is my point: there are, in most places, more folks with electrical understanding than there are folks who can produce code that runs reliably.
 
Top