#avr Logs

Jun 16 2020

#avr Calendar

09:28 AM specing_ is now known as specing
09:40 AM PublicWiFi is now known as MaccasWiFi
09:40 AM giantmidget: Hey lads
09:40 AM giantmidget: Having an issue with I2C implementation on the STM32 platform
09:41 AM giantmidget: Basically I2C1 works as expected, no issue. However when I attempt to send on I2C2 I get a couple clock pulses and then it hangs, even though I've specified a timeout
09:42 AM giantmidget: Any ideas as to what may be causing this?
09:50 AM MaccasWiFi is now known as PublicWiFi
10:27 AM polprog: giantmidget: hmm, are you sure you arent missing a register read somewhere?
01:12 PM markasoftware: cehteh: I need Avcc to not change by more than 1mV/us even when the main supply voltage drops by up to half a volt. Using a small inductor cannot give such characteristics, but an RC with 30uF and 100 ohms can.
01:14 PM markasoftware: What is the minimum pulse width to trigger a pin change interrupt?
01:22 PM nohit: hi JanC
02:02 PM giantmidget: Anyone know what logic family I2C uses?
02:02 PM giantmidget: Or what are the voltage thresholds?
02:03 PM cehteh: markasoftware: watf are you trying to do?
02:03 PM cehteh: AVCC is *NOT* your reference
02:05 PM cehteh: its only a pin routed out from the analog circruity on the board to enable noise filtering, but it must not be much different from VCC and any switching you do on the other pins that are connected to the analog stuff *will* affect noise there
02:05 PM cehteh: you use AREF as voltage reference stabilize/filter that
02:29 PM markasoftware: cehteh: ah, i guess i can do that, just keeping aref near but not quite at avcc
02:30 PM cehteh: why do you need that?
02:30 PM cehteh: wtf do you try to do?
02:31 PM cehteh: usually you have aref at some sweet spotv well below your VCC
02:31 PM cehteh: then you can divide vcc into the desired range, done
02:32 PM cehteh: you may even use the internal 1.1v bandgap, just a 100nF cap on AREF then the ADC is only 10 bits that should be good enough
02:32 PM markasoftware: for an RC low pass filter, inevitably it will be less than vcc
02:32 PM cehteh: add some RC filter to the ADC input, do proper oversampling and you are fine
02:33 PM cehteh: there is no current drawn
02:33 PM cehteh: ADC input not AVCC
02:33 PM cehteh: AVCC must be AVV just filtered
02:33 PM cehteh: avcc draws current, rc filters are prohibited there
02:34 PM cehteh: adc inputs draws close to no current (charging a few pF cap)
02:35 PM cehteh: add some software calibration to compensate for the inaccuracies and tolerances of the components and you get decent results
02:35 PM cehteh: when you need a high impedance input then you add an instrumentation amplifier in front
02:36 PM markasoftware: yeah, I think I got it, I will be able to use aref appropriately
02:36 PM markasoftware: and probably just put low esr caps on avcc
02:36 PM cehteh: but any sampling needs filtering about 1/2 of the sampling frequency else you measure shit
02:36 PM markasoftware: i am measuring dc
02:36 PM cehteh: ceramic 100nF
02:37 PM cehteh: thats low esr .. when you want to mage it good then you add the inductor, iirc datasheet says 10µH .. pretty small one
02:37 PM cehteh: arduino and most cheap devel boards leave the inductor out
02:38 PM cehteh: when you do oversampling a little noise (around 1LSB) is actually not that bad and improves accuracy
02:39 PM LeoNerd: I've never found the AVR ADC good enough to actually bother using the inductor
02:39 PM LeoNerd: It's only 10 bit
02:39 PM LeoNerd: For instrumentation I often put an ADS1115 or some other chip around
02:41 PM cehteh: i usuall do 64x oversampling rolling average that gives a 16bit result from 10bit adc and is very simple to implement
02:41 PM LeoNerd: Eh.. yeah but then the other thing is the ADC isn't very -fast- to let you do that
02:41 PM cehteh: if course you dont get 16bit precision but some bits more than 10 is possible
02:42 PM cehteh: well depends on what you want to do
02:42 PM LeoNerd: It's fine for a battery meter or reading analog chains on buttons, stuff like that
02:42 PM markasoftware: i think the 0-series and 1-series can do 150 ksps
02:42 PM cehteh: yeah
02:42 PM LeoNerd: I just don't use it for /precision/ stuff, so a bit of noise on the AVCC line doesn't matter
02:43 PM LeoNerd: Yeah the newer chips can be faster, and support oversampling directly in hardware, but none of those have a separate AVCC pin either
02:43 PM cehteh: i use it for battery meter, but on lipo voltage curves 10bit are already not suficient
02:43 PM LeoNerd: Ah..
02:43 PM LeoNerd: Yeah though I suppose sample rate isn't as much of an issue there
02:43 PM markasoftware: so if i put an rc filter on aref but not avcc, that means the aref could be slightyl higher than vcc for a few milliseconds, is that a problem?
02:44 PM markasoftware: if i don't do measurement during that time
02:44 PM cehteh: markasoftware: ony your ADC *input*
02:44 PM cehteh: please read the datasheet
02:44 PM cehteh: and what do you really want to do?
02:45 PM cehteh: VCC as analog reference has only one use case .. thats when you want to read a potentiometer thats clamped between vcc and gnd
02:45 PM cehteh: for anything else you want an external more stable reference or the internal 1.1v reference
02:45 PM cehteh: wher the external reference should be sufficiently below VCC
02:46 PM markasoftware: part of what i am doing is measuring unknown resistances
02:46 PM markasoftware: so yes
02:46 PM cehteh: markasoftware: i dont know why you try to make it different than its suppsoed to be
02:46 PM cehteh: kindof fucking it up for no gain
02:47 PM cehteh: how unknown are your resistances? could they be below lets say 100 ohms?
02:47 PM markasoftware: i am measuring the unknown resistances. Sometimes the unknown resistance changes very rapidly (microseconds scale) and i have some comparators and op amps set up to detect this. If vcc spikes or droops then the resistance-change detector will fire for no reason.
02:48 PM cehteh: then put some measurement amp in front
02:48 PM cehteh: the adc cant handle that anyway
02:48 PM markasoftware: i am using the adc to measure the steady-state resistance, when it is not changing.
02:49 PM cehteh: avr adc are not so precise or fast and moreover they need pretty low input impedeance (10KOhm or less)
02:49 PM cehteh: thats not a property you want from an measurment device
02:49 PM twnqx: can always drop in an opamp with gain .1 or so to solve that :P
02:50 PM cehteh: yeah
02:50 PM cehteh: better balanced instrumentation amplifier with low noise
02:50 PM twnqx: that's... uh
02:50 PM twnqx: pointless if you sample with an avr afterwards
02:51 PM cehteh: but in what ballpark are the resistances you are measure
02:51 PM markasoftware: ~500 ohms te 36k
02:51 PM cehteh: yeah its only 10 bit and slow
02:51 PM cehteh: do for measuring 500 ohms you want a rather low voltage already else some considerably current flows
02:52 PM twnqx: i'd say
02:52 PM cehteh: at 5V that would be 10mA ... from a reference voltage source, thats pretty much
02:52 PM cehteh: you want a much smaller measurment voltage anyway
02:52 PM twnqx: 1. you will want an opamp to get the input impedance in the mohm range
02:53 PM cehteh: +1
02:53 PM twnqx: 2. you need a second (known) resistor to build a voltage divider anyway, no?
02:53 PM twnqx: i mean, to convert the resistance to voltage
02:53 PM cehteh: likely, other ways should be possible but thats the usual way
02:54 PM markasoftware: it's a really long story
02:54 PM cehteh: wheatstone bridge
02:54 PM twnqx: and if you go the opamp route, you likely indeed want an instrumentation amplifier
02:54 PM cehteh: what resolutiin/precision do you need anyway?
02:55 PM cehteh: logarithmic?
02:55 PM cehteh: because 500 to 36000 is a lots of range for 10 bits
02:55 PM markasoftware: yeah, the thing is i actually need to measure conductance
02:56 PM markasoftware: so i want a constant resolution in terms of conductance
02:56 PM cehteh: isnt that often done with AC?
02:56 PM * cehteh dont know
02:56 PM markasoftware: so what i'm doing is keeping a constant voltage (2V) over the unknown resistance, then measuring the current
02:56 PM markasoftware: with a sense resistor
02:56 PM markasoftware: but the constant voltage isn't actually 2V
02:56 PM markasoftware: it's just 2/3rds of the supply voltage, which just happens to be 3V (CR2 battery cell)
02:57 PM cehteh: well then make a constant voltage (or constant current whatever)
02:57 PM cehteh: you can use the VREF as output as well *but* very little current is allowed on that, needs to read datasheet for that
02:58 PM cehteh: or do some differential meaurment VREF VCC and your DUT
02:59 PM cehteh: CR2 is only 3V
03:00 PM cehteh: mhm
03:07 PM cehteh: methinks other way around, provide a constant current and then measure voltage
03:32 PM markasoftware: that's for a constant resolution over resistance
03:32 PM markasoftware: i.e, 100uA @ 100 ohms = 10mV, then 100uA @ 200 ohms = 20mV
03:33 PM markasoftware: I believe ohmmeters usually use a current source for this reason
03:35 PM markasoftware: but 100uA @ 1 siemen = 100uV, and 100uA @ 2 siemen = 50uV, at 3 siemen = 33uV, etc -- it's not linear
03:35 PM markasoftware: because current / conductance = voltage
03:35 PM markasoftware: however, voltage * conductance = current, so if you hold voltage constant and measure current, it is linear with regards to conductance
11:26 PM day_ is now known as day