Analog mux settling time on Attiny24/44/84

Go To Last Post
32 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm considering using the analog mux  and  analog compare to sample multiple inputs.

 

I see that the interrupt must be disabled when changing the analog mux  input, but I can't find how long I must wait before enabling it again.

 

In other words, how fast can I switch the mux inputs while using the analog comparator?

 

 

 

 

This topic has a solution.
Last Edited: Mon. Nov 18, 2019 - 07:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When using the ADC you must consider the input impedance on each channel relative to the S/H capacitance.  For the analog compare I'd guess you'd do the same thing but use the pin input capacitance instead.

Letting the smoke out since 1978

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can easily calculate the RC due to the input capacitance and the output impedance of the circuits driving the mux inputs--it will be quite low.

 

But what's the input mux series resistance, the capacitance on it's output, and the comparator input capacitance?

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It might not matter so much...the real question is how soon after you switch the mux will you start (or want to start) monitoring the output of the comparator?

 

For example, if you were not going to look at the comparator output for 100us after switching the mux, then any switching transients at the input will have long been settled out. 

 

The ADC is different, since it performs a "hold"  ...once the conversion starts, the signal voltage is locked in, so the changeover & settling is critical before beginning the conversion.  The comparator does not have this limitation, it's output will track whatever  change is coming in at the signal pin.

 

According to the datasheet any comparator delays are less than 1us, so it is blazing fast compared to the ADC. You could probably use 10us and have tons of margin...but you certainly won't be changing channels every 10us, that's 100,000 channels/sec!  

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Tue. Nov 5, 2019 - 04:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

davethomaspilot wrote:
I see that the interrupt must be disabled when changing the analog mux  input,
Really? Where does it say that?

 

EDIT: I've downloaded the datasheet and can see nothing about interrupts needing to be disabled. It does say that for AC it should be "switched off" during a mux changed and for ADC it says the first reading after a mux change should be discarded - but I don't see any mention of interrupts in that?

Last Edited: Tue. Nov 5, 2019 - 09:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the real question is how soon after you switch the mux will you start (or want to start) monitoring the output of the c

omparator?

Well, yes.  That is the question.  Or stated a different way, how long must I wait after switching mux inputs? 

 

 

How fast can I compare 2 inputs, or maybe 4 inputs if it's fast enough.  

 

 

 

 

I see that the interrupt must be disabled when changing the analog mux  input,   ...  

I see that the interrupt must be disabled when changing the analog mux  input,

Really? Where does it say that?

 

Clawson, you are it's when you change ACD (Analog Comparator Disable)  or ACIS0, or ACIS1 (Analog Ccomparator Mode).

 

 

 

Last Edited: Tue. Nov 5, 2019 - 12:27 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

 You could probably use 10us and have tons of margin..

Well, I'd hope.  10 usec is a very long time (80 cycles) in my application.   If I had to wait 10 usec after switching ADMUX, I'd a discrete transistor for each input instead to drive logic levels into the ATTiny.

 

I understand the difference between the analog comparator and ADC and that the ADC takes a much longer time because it does an successive approximation.  The question is how fast can I can ADMUX inputs.

but you certainly won't be changing channels every 10us, that's 100,000 channels/sec!  

Why not? 

 

The processor is monitoring the output of  a pre-amplified , band pass filtered, and envelope shaped IR signal.  The IR carrier frequency is 2 Mhz (no, not 38Khz).

 

I have control of the filter and envelope time constant.  Currently it's Q is designed so that the output fully transition after 10 carrier cycles and the signal.  The decay time is similar.

 

A PNP transistor and bias resistors can be employed that fully saturate this signal to a logic level.  But, possibly I could eliminate the need for these devices by using the ATTiny's analog comparator.    

 

But, can I switch fast enough between multiple channels to detect each of 2 (or maybe 4) inputs.  

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe it's useful to see the input signal waveform.

 

In the plot below, the red signal is the pre-amplified IR signal.  The blue signal is after the bandpass and envelope detector.

 

The carrier will either be present or not each time slot.  (A time slot is 10, 2 Mhz  periods)

 

In this run, the IR signal amplitude was adjusted so the output of the envelope detector saturates.  So, with an IR signal this large, a comparator would not be needed.  

 

But, if a comparator is used, the signal could be much smaller and there could still be reliable detection.

 

There are 24 instances of this circuit spread across N pcbs.   In a lower carrier frequency implementation, N is 12--each ATTiny handles two IR receivers.  But, the equivalent of the comparator function is in the IC used.

 

I need to have a processor handle at least 2 channels--maybe 4 (but other contraints may prohibit 4).

 

Thanks!

 

 

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

 

 

According to the datasheet any comparator delays are less than 1us

 

 

Can you help me find this in the datasheet?  

 

I found this:

 

Bit 5 – ACO: Analog Comparator Output
The output of the Analog Comparator is synchronized and then directly connected to ACO. The
synchronization introduces a delay of 1 - 2 clock cycles.

 

So, for example, could I write MUX4:0, wait 2 clock cycles, read ACO from the ACSR, change mux4:0 to pick another input, wait 2 clock cycles, read ACO again?  Or, must I wait more than 2 clock cycles, not for the synchronization delay, but for the mux output to settle?

 

(Assuming the input is being driven from near zero impedance source relative to 1 usec time constant).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Can you help me find this in the datasheet?  

see the electrical characteristics section, comparater  subsection.

  It's actually much faster in some cases than 1us...I rounded up since I thought 1us was still an extremely fast response.  

If your AVR is busy doing many things, needing to switch & process the comparator every 80 instructions might be somewhat extreme (without careful planning).  The AVR video generator guys are good at that kindo stuff.

 

Seems like constantly switching channel may lead to false transients (in addition to measuring the actual signal)...that's another consideration if you are in an extreme hurry.

 

When the comparator goes high, what will you do with the info?  time stamp it? If they are happening every  few us that's a lot of stuff  you have to put somewhere & do something with (before the next 80 instructions are up).

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Wed. Nov 6, 2019 - 12:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The processor has nothing else to do during it's active timeslots. 

 

There's a synchronization signal that triggers an interrupt to start timing to the processor's slots.  It only needs to indicate if any of the channels it is monitoring do NOT detect carrier by asserting an open collector signal low.   

A separate processor monitor's the signal shared across all 24 signal.  It identifies a "beam interrupt" bus and takes appropriate action.

 

So, it really is about how fast I can switch the analog mux reliably.

 

Thanks!

Last Edited: Wed. Nov 6, 2019 - 01:50 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

eems like constantly switching channel may lead to false transients (in addition to measuring the actual signal)...that's another consideration if you are in an extreme hurry.

False transients?   

 

The signals themselves won't have "false transients".  The low pass filtering and integration means it takes several cycles for the signal to transition from a zero volts to something above the comparator threshold.  The inputs will be sampled when the signal is known to be high, if (and only if) the IR signal was detected during that time slot.  The ATTiny's counter is used to determine the correct sampling time from a synchronization input.

 

So, the only transients that I haven't already designed around are are on the output of the analog mux.   

 

If I can really switch in a microsecond, I should be "good to go".

 

Thanks again!

Last Edited: Wed. Nov 6, 2019 - 01:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

False transients?   

By that, I mean the switching of the mux may cause noise  injection (mux switching often causes a small charge to be coupled in muxes)...so doing it a often  might increase the amount of charge "noise". Also as it switches from A to B, maybe it is open circuit for a dozen nano seconds...all kinds of things can be happening that we don't know about.  Not sure if their posted times include any such effect.

 

     There are a number of different capacitances quoted in the data sheets. These relate to the source and drain capacitance both when the switch is on and when the switch is off. Where capacitance is the key specification, the lower the capacitance, the better. Charge injection, QINJ, is a measure of the glitch impulse transferred from the digital input to the analog output during switching. The lower the charge injection, the better. Charge injection is caused by stray capacitance associated with the transistors that make up the switch. As a result, the capacitance of the switch and the charge injection are linked; thus, when the capacitance of the switch is low, generally the charge injection is also minimized.

 

Be sure to evaluate this factor if your design has any high-impedance nodes in the signal path. Charge injection is often a cause of pops and clicks in audio circuits that incorporate analog switches.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I’d like to find

 

 There are a number of different capacitances quoted in the data sheets. These relate to the source and drain capacitance both when the switch is on and when the switch is off. 

I can't find those capacitance values in the ATTiny 24/44/84

 

I am familiar with charge injection related issues when using analog switches—I designed some switched capacitor filters in the 80’s (yup, about 40 years ago).

 

When used for high speed switching of an analog mux, a device with matching capacitane is driven by an inverted version of the gate signal. This effectively cancels most of the charge injection. 

 

But, the mux on the ATTiny probably wasn't designed that carefully.  That's why I originally asked about its settling time.

 

The injected charge won't impact the input side of the mux in ny application--it's low impedance.  In other words, the capacitance on the input is orders of magnitude greater than any conceivable Cgs or Cgd on the analog switches.  

 

But, that charge will likely be enough to move the output of the mux significantly  How long it takes that node to equalize to the input voltage will be a time constant that's the resistance of the switch multiplied by the output capacitance, including whatever the mux drives.  That's the analog mux settling time.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So the DS does not say what the mux settling time is, so I would think doing some simple testing would have told you if it is acceptable or not, rather then posting and waiting for two days for answers from other users of AVR's.  In case you did not know, this is not an official MC support line, but simple users of AVR's helping each other support forum.  We have no inside info, or a source for same here.  Detailed spec quiestions as yours should be asked directly to MC support.

Have you posted your question to MC support? 

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've gotten lots of help on this forum over the years.  It's my go to place.  Usually, much faster and better answers than what I got from Atmel technical support.  

 

With any luck, a forum member may have actually used the device for something similar.

 

And , it's not like I'm waiting for two days for answer...  There are many things going on in parallel in design of this system.  

 

I'm not sure what a simple experiment involve.  I guess I could cobble up some resistor dividers with decap for two input voltages, and see how fast I can switch between them and still get believable results.  But, that's one device, one temperature. 

 

there also alternatives in the system design.  If ADMUX settling turns out to be an issue, I could add devices.  The first pass pcb design will include footprints for these "contigency" parts. 

 

I could also slow things down if necessary. 

 

I thought I could also ask an user's forum for any insight, Sorry if I asked something inappropriate.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

This looks an interesting project.

 

Did you reject the purely analogue implementation for any reason ?

 

i found these hex comparators at £2.77 each.

Texas Inst LMV7231SQ

Analog Comparators Hex Window Comparator with 1.5% Precision and 400mV Reference 24-WQFN -40 to 125

https://www.mouser.co.uk/ProductDetail/Texas-Instruments/LMV7231SQ-NOPB?qs=sGAEpiMZZMuayl%2FEk2kXcXQP6b1HBn6mbGJWzVDNhMQ%3D

4 of these and a big "Master" micro controller should do it. of course, you probably already have a "Master" micro controller.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I have done similar projects using the AC and ultra sound transducers (25kHz) but not anything as fast as your project, so never worried about mux setting time, just switched channels and waited for signal cross over event.   Let us know what you find out, I'm sure someone else will want to know some day.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 Thanks for the replies!

 

 

 Did you reject the purely analogue implementation for any reason ?

 

At this point, nothing is rejected.   

 

But, there are 24 channels that need monitoring.  Each processor will monitor 2 channels (possibly 4, but that gets kind of ugly), so we'd probably need 12 packages (pairs of channels are physically spaced apart). 

 

That's a pretty significant impact.

 

At this stage, we're not sure if the comparator stage is actually needed.  We'll need to get the 1st pass pcbs back to measure the magnitude of the carrier after the IR pre-amp with the actual photo diodes and emitters, emitter to detector spacing, and optics.   

 

Gain through the pre-amp and post filter stages can also be increased to eliminate the need for a comparator (if the Signal/noise is adequate).

 

The Attiny (or something similar) is a given, since it's what is used on a design that uses Vishay 6056 IR detectors (56 Khz).  So, if there's a good chance that ATtiny comparator can do the job, the pcb layout will get the signals to the appropriate pins on it to enable use of the onboard comparator.  That might eliminate a lot of devices!

 

I was thinking of using something like an LM393 if we really needed an extra comparator stages, but I'll look at the LMV7231SQ.

 

Thanks again!

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will report back what I find out.  At this point, I'll just make sure the signals go to where they must on the ATTiny so the comparator can be used. 

 

When the pcbs come back, I can much more easily test to see if the mux settling time is an important consideration.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 

 

At the risc of hearsay, some of our PIC brothers have 4,6, 8 channel high speed comparators

 

http://ww1.microchip.com/downloads/en/DeviceDoc/40001819B.pdf

 

 

 

also some AVR cousins (tiny1614) come with three

http://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny1614-DataSheet-DS40001995B.pdf

 

section 29:

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Nov 7, 2019 - 01:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow!  That's I'm really glad I posted about the project on this forum.   Thank you!

 

I'd looked at an ATtiny selection guides, but in those summaries there was not a column for # of comparators.

 

At first glance,the tiny1614 is better for this application.  Not only can I avoid having to switch the mux quickly, but I can use a reference voltage on a pin rather than just an internal reference (on the ATTIny24, you have to use an internal reference on the comparator if you want to use the output of the mux on the other comparator input).  That would allow a greater dynamic range, since I can split the 5V rails for the reference instead of having to use 1.4 volts.

 

I programmed a PIC many years ago, but Idon't know what it would take to switch over at this point.  At least, the equivalent of my Atmel ICE and new tools installed on my workstations.    But, I think the ATTiny1614 will work well!

 

Thanks! 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Here is the complete list:  attiny1614, attiny1616, attiny1617, attiny3216, attiny3217

 

Funny, these "tinys" have 16K or 32K of flash...the MEGA48 has 4K...shows progress of last decade (if that's progress).

 

 tiny & mega---what a farce!

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Nov 7, 2019 - 05:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
 tiny & mega---what a farce!
Do they have "MUL"? The distinction between "tiny" and "mega" core CPU used to be the presence/absence of MUL - nothing to do with the flash size.

 

EDIT: OK so they do have MUL. So that's a bit odd then!

Last Edited: Thu. Nov 7, 2019 - 05:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've never used UPDI.  Seems nice!

 

This may belong in a different thread, but

 

Based on this:

 

https://microchipdeveloper.com/atmelice:updi

 

I think I can use my Atmel ICE without any modification?

 

I use a tag-connect so I don't need so much space on the PCB for a connector footprint.  That required me to wire a simple "Patch" pcb, since the pin-out from the tag-connect cable did't match what I needed for ATTing ISP and debugWire.

 

It looks like UPDI just requires 3 pins.  If I get those signals to the correct pins on the ICE AVR connector, can I just use a 3 (probably 4) pin header on the target pcb?  The tag-connect footprint is nice and small, but it is it bit more of hassle to keep the pins in place while programming.

 

Thanks!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

davethomaspilot wrote:
 it is it bit more of hassle to keep the pins in place while programming.

you know they do clips to hold it in place?

 

Or you could make yourself a jig ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
these "tinys" have 16K or 32K of flash...the MEGA48 has 4K

LOL - that's the trouble with a historic naming convention !

 

Kind of like the NXP (originally Philips) "LPC" parts;  where that originally meant "Low Pin Count" - but they now come in huge pin-count packages!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I have a couple of the clips.

 

They work fine, but it is not very easy to get the clip on the pins, at least compared to putting a socket on  the .100 pitch header.

 

Worse,  in this application the pcbs are taped to a metal strip using Scotch VRB.  I had to cut the guide pins to make them short enough so the pogo pins would actually make contact on .062" board.  Until I did this, I had to untape the pcb every time I wanted a new program.  And that VRB tapes holds very well!

 

Still it works ok--I just hold the tag-connect while I program.  But when space isn't critical, I still use the regular ISP header.   But, UPDI makes it not so much of a board space penalty.

 

Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


You can also use castlleated  connections along the edge of the board....I saw a clip connector somewhere for that purpose...then it takes almost no room on the PCB  (but watch for any extra $$ charges to fab them) 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

So, my two questions are:

 

  1. Can I use my Atmel ICE "as is" to program and  using debug UPDI?
  2. Any reason I need more than 3 pins on the pcb if I'm willing to "cross wire" as needed?

 

Thanks!

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

1) yes

2) no

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks!