Mechanical rotary switch vs analog switch - Page 1
Forum section: electronics / projects

author: DMartens
author_rank: Contributor
timestamp: July 27, 2024, 05:00:22 am
content: I have a frequency counter design which uses a rotary switch to select between 1/10/100 second gate time and a rotary switch to select between Period/Frequency function. Since I am looking to add a micro-controller as a digital read-out, I was thinking of also replacing the rotary switches by analog switches and e.g. a menu system to select function/range since these are all low-current digital signals and frequencies of less than 20 MHz.Any advantages / disadvantages?

author: PCB.Wiz
author_rank: Super Contributor
timestamp: July 27, 2024, 05:14:38 am
content: Quote from: DMartens on July 27, 2024, 05:00:22 amDo any of the switch lines carry signals ?If they are only selecting gate times and period/frequency, then you should be fine.If you are adding a MCU, you could look at auto ranging, or even a reciprocal counter design.That measures both cycles and time ( sysclks for a whole number of cycles) then uses division to give Frequency = Cycles / Time

author: DMartens
author_rank: Contributor
timestamp: July 27, 2024, 05:35:35 am
content: For the frequency range, they would be switching in/out a different capacitor ... for the gate time, they would select between the outputs of 2 or 3 decade counters.The auto-ranging etc. are indeed the kinds of things I was thinking of adding ... "great minds think alike" ...Also wondering how the "on" resistance would influence things.

author: pcprogrammer
author_rank: Super Contributor
timestamp: July 27, 2024, 05:51:11 am
content: Quote from: DMartens on July 27, 2024, 05:35:35 amFor this you can probably use a digital multiplexer like for instance a 74153.But for better advice you might want to add the schematic of the device your are looking to modify.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: July 27, 2024, 08:39:26 am
content: Quote from: DMartens on July 27, 2024, 05:35:35 amSelecting GATE signals could be done with either an analog switch or a digital MUX.Or, you could generate the gate using the MCU timers.If you have the MCU, you can also use a simple external gated binary counter to prescale a higher Fin to a more modest rate the MCU can count itself.If you have reciprocal maths working, that counter becomes a simple multiplier.If you want to measure pulse widths, the hardware gets a bit more complex.Something like input AC or DC coupling, is a natural for a mechanical switch, and tougher for an analog switch.My PM6672 reciprocal counter has a knob for nominal gate time, and a knob for input slicing level when DC coupled. which becomes gain when AC coupled.How much of this already exists in 'working hardware' ?

author: tggzzz
author_rank: Super Contributor
timestamp: July 27, 2024, 10:57:34 am
content: Quote from: DMartens on July 27, 2024, 05:00:22 amI doubt the digital signals are only 20MHz. The period might be >50ns, but the maximum frequency is determined by the transition time. FFI:https://entertaininghacks.wordpress.com/2018/05/08/digital-signal-integrity-and-bandwidth-signals-risetime-is-important-period-is-irrelevant/Apart from that, analogue switches will have voltage limits, a non-zero and non-linear resistance, plus some capacitance. Whether that is relevant depends on thedetailsof the circut and switch.

author: DMartens
author_rank: Contributor
timestamp: July 27, 2024, 12:07:42 pm
content: The design is from Elektor Electronics - June 1995 (attached) and based around the MAX038 which I have found several (original ones) of in my dad's stash.He has no interest in electronics anymore and I don't want to just throw them out so I thought of using them and "upgrading" the design with an MCU etc.As a learning exercise. I know many will say "why bother with an old chip", "why not use a DDS" etc. but I have the MAX038 so I want to use them.Was thinking of replacing the rotary switches S2b (Function) and S1a (Range) with analog switches (hence the question).S2a (driving A0 and A1 of the MAX038 to select the wave form) can be driven directly from output pins of the MCU.S1b can probably be eliminated as the Freq Counter signal will be measured by the MCU.Not sure if I will include the Sweep/FM/Intern functionality selected through S3. If I do, is an analog switch suitable?For the read-out, the ICM7224 with be replaced by an MCU driving an 8 digit 7-segment display controlled from an Max7219 via I2.I think 4 digits for freq is enough and the remaining can show "F" or "T" and maybe "S/T/B" for square/triangle/block etc.

author: pcprogrammer
author_rank: Super Contributor
timestamp: July 27, 2024, 07:27:59 pm
content: For playing with the MAX038 there are many options and you can deviate from the given schematic to optimize for using with a MCU.To control the frequency you can use a multiplying DAC with the reference output as input and still keep the FM input by using an opamp to mix the voltages. The same applies for the pulse width adjustment.The tricky bit is the selection of the capacitors on the oscillator. Using an analog multiplexer like a 4051 might work bandwidth wise, but the on resistance might be a problem. This is something you can easily test of course by building a simple test setup. Just try and see what happens.The output mode select is simple to do with direct MCU GPIO connections, like you wrote yourself.Looks like a fun project for sure.

author: Zero999
author_rank: Super Contributor
timestamp: July 28, 2024, 10:03:10 am
content: That's both a frequency counter and signal generator?Which switch(es)? All of them? Most of them carry analogue signals.If think it'll work, but why? I think it would be easier to start from scratch and use a synthesiser IC, if you're going to use a microcontroller.

author: pcprogrammer
author_rank: Super Contributor
timestamp: July 28, 2024, 10:36:29 am
content: Quote from: Zero999 on July 28, 2024, 10:03:10 amThe OP explained that he has a couple left over from his dad's hobby time and he wants to use at least one of them in a project.QuoteI think this is a good idea and certainly as a learning exercise fun to do.Instead of driving an eight digit 7 segment display, I would look into using a LCD type like aLCD2004to display more information. Easy to do since there will be a MCU to control things.