Author Topic: Mechanical rotary switch vs analog switch  (Read 925 times)

0 Members and 2 Guests are viewing this topic.

Offline DMartensTopic starter

  • Contributor
  • Posts: 26
  • Country: ph
Mechanical rotary switch vs analog switch
« on: July 27, 2024, 05:00:22 am »
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?
 

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1930
  • Country: au
Re: Mechanical rotary switch vs analog switch
« Reply #1 on: July 27, 2024, 05:14:38 am »
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?
Do 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



 
 
The following users thanked this post: DMartens

Offline DMartensTopic starter

  • Contributor
  • Posts: 26
  • Country: ph
Re: Mechanical rotary switch vs analog switch
« Reply #2 on: July 27, 2024, 05:35:35 am »
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.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4411
  • Country: nl
Re: Mechanical rotary switch vs analog switch
« Reply #3 on: July 27, 2024, 05:51:11 am »
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.

For 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.

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1930
  • Country: au
Re: Mechanical rotary switch vs analog switch
« Reply #4 on: July 27, 2024, 08:39:26 am »
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.

Selecting 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' ?
« Last Edit: July 27, 2024, 08:55:32 am by PCB.Wiz »
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 20767
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Mechanical rotary switch vs analog switch
« Reply #5 on: July 27, 2024, 10:57:34 am »
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?

I 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 the details of the circut and switch.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline DMartensTopic starter

  • Contributor
  • Posts: 26
  • Country: ph
Re: Mechanical rotary switch vs analog switch
« Reply #6 on: July 27, 2024, 12:07:42 pm »
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.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4411
  • Country: nl
Re: Mechanical rotary switch vs analog switch
« Reply #7 on: July 27, 2024, 07:27:59 pm »
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.

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19998
  • Country: gb
  • 0999
Re: Mechanical rotary switch vs analog switch
« Reply #8 on: July 28, 2024, 10:03:10 am »
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.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4411
  • Country: nl
Re: Mechanical rotary switch vs analog switch
« Reply #9 on: July 28, 2024, 10:36:29 am »
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.

The 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.

Quote
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.

I 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 a LCD2004 to display more information. Easy to do since there will be a MCU to control things.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf