#avr Logs

Jun 29 2019

#avr Calendar

12:08 AM phinxy: Help! The ADC output is completely random on the 4.. 5 highest bits.
12:12 AM phinxy: There is no filter anywhere can that be the reason?
12:40 AM phinxy: The recommended AREF and AVC filters did not make a difference
01:36 AM phinxy: The multimeter is picking up something funny on all the ADC pins, its a high frequency voltage flicker
01:37 AM phinxy: Most ADC pins are 0.2V but ADC0 is 0.8
02:19 AM Maya-sama is now known as Miyu
02:27 AM phinxy: I must conclude the ADC conversion is broken inside the chip
02:58 AM phinxy: If this stuff were not fun I'd be angry with spending two days to compile the entire AVR toolchain just to end up using another chip family
03:57 AM Kliment: ColdKeyboard: What qtouch features do you need? Just touch detection or do you need the fancy shit?
03:58 AM Kliment: phinxy: Is your analog supply decoupling ok?
04:04 AM Kliment: ColdKeyboard: Pretty sure the attiny4 does not support qtouch because that requires a working adc - the attiny5 shares a datasheet and has an ADC
04:08 AM Kliment: ColdKeyboard: You can still detect touch events without the qtouch library
04:11 AM Kliment: ColdKeyboard: Yep, just checked the manual, qtouch has a attiny10 specific library, it doesn't support almost anything
04:11 AM Kliment: ColdKeyboard: no support whatsoever on the smaller devices
04:17 AM Kliment: ColdKeyboard: Generally the PTC and qtouch is a scam from my pov - huge code size cost, shit performance, and it's basically a hack of the ADC that can be implemented without using a horribly painful to integrate huge closed source lib
04:18 AM Kliment: My implementation is a handful of lines of code. If all you care about is binary touch detection and you don't need the wake-from-sleep-on-touch there is an even simpler implementation that works on anything
04:20 AM Kliment: If you want a single button on the attiny5, use https://github.com/cpldcpu/TinyTouchLib (I extended it to multiple buttons, my version is at https://github.com/kliment/catws/blob/master/firmware/main.c)
04:21 AM Kliment: If you want to run on the attiny4, with no ADC, there is a way to do that, have a look at the block starting here https://github.com/kliment/catws/blob/master/firmware/main.c#L110
04:23 AM Kliment: (this is derived from Mitch Altman's Ardusynth, https://github.com/maltman23/ArduTouch/blob/master/Arduino/libraries/ArduTouch/System.cpp#L436)
04:24 AM Kliment: Mitch's implementation does not even need an ADC - it just uses a normal GPIO, but it requires conductive contact to the user
06:00 AM phinxy: Kliment: with analog supply decoupling, do you mean AVCC 10uH series + 100nF to ground? I added 100nF decoupling caps all over the place. The noise is so extreme it cant be anything other than it being broke. All bits are totally random. Then when I put the 6 other ADC pins to inputs the noise become predictable with a repeating patterns....
06:44 AM Kliment: phinxy: oh uhm, this is crazy but is your adc clock enabled?
06:45 AM Kliment: phinxy: because I've seen this kind of randomness with adc unclocked
06:45 AM Kliment: phinxy: but I agree with you your next step should be swap out the part
06:56 AM Kliment: phinxy: also check if you've set your ADC to differential mode and your reference is floating
07:43 AM phinxy: Kliment: Can the clock be disabled? I
07:44 AM phinxy: There are prescaler options, tried a few of them
07:44 AM Kliment: phinxy: what part is this?
07:44 AM phinxy: atmega644
07:45 AM Kliment: PRR bit 0 disables ADC clock
07:47 AM Kliment: And ADCSRA bit 7 (ADEN) needs to be 1 for ADC to work
07:48 AM Kliment: I don't know if the ADC clocking gets messed up when the debugger is attached
07:48 AM Kliment: never tried that
07:49 AM phinxy: I disabled the debug fuse and put -O2 back on
07:49 AM Kliment: Can you swap out the part to eliminate the possibility it's physically damaged?
07:50 AM phinxy: Not without ordering a new part, no.
07:50 AM Kliment: Okay, and I suspect you've tried running a minimal code example
07:51 AM phinxy: The last thing I tried was to have the ADC interrupt increase an integer and print that out on portb
07:51 AM phinxy: that worked as expected, looked good in the digital analyzer
07:52 AM Kliment: Okay, what's your ADC config?
07:52 AM Kliment: (ADCSRA, ADCSRB, ADMUX)
07:52 AM phinxy: http://termbin.com/j8x4
07:54 AM Kliment: phinxy: Is this meant to be a differential measurement?
07:55 AM phinxy: Yes
07:55 AM Kliment: Okay, can you try single ended?
07:56 AM phinxy: I might try that, maybe the gain stage is broken
07:56 AM Kliment: gain stage is not used in your configuration
07:56 AM Kliment: it's at 1x
07:57 AM cehteh: more likely your code / circuit
07:57 AM Kliment: cehteh: that's what we're trying to eliminate
07:57 AM phinxy: Kliment: MUX0 and MUX3 is what I used before starting messing about
07:57 AM phinxy: Thats 10x
07:57 AM phinxy: unless I misinterpret the datasheet endian
07:57 AM Kliment: No, you're correct
07:58 AM cehteh: did you add a rc filter on the inputs? what ipedance has your input?
07:58 AM cehteh: what kind of signal do you expect there? already somewhat noisy/switching?
07:58 AM phinxy: the inputs only have decoupling caps
07:58 AM Kliment: cehteh: the issue is bit pattern entirely unrelated to input
07:59 AM cehteh: yes
07:59 AM phinxy: very linear from a thermistor with a constant current through it
07:59 AM phinxy: I have a circuit i can show:
07:59 AM cehteh: iirc you cant just use decouplig caps (or they need to be large)
08:00 AM phinxy: cehteh: But noise on all bits , plausible to you?
08:00 AM Kliment: noise on all bits is likely with large gain values
08:00 AM cehteh: missing ground, something floating, decoupling caps .. progamming error
08:01 AM cehteh: too much unflitered noise
08:02 AM cehteh: and whats the input signal anyway
08:02 AM Kliment: cehteh: voltage across a voltage divider
08:02 AM cehteh: what R's ?
08:02 AM phinxy: ah, the circuit was lost, i fumbled with the browser. 620mV on the one pin and 320-800mV on the other. The math checks out, should give -512 +512
08:03 AM phinxy: The 620mV comes from TL431 2.5V reference total R 2Kohm
08:03 AM cehteh: note that avr's are not mesurement amplifiers, their input impedance is soemwhat low
08:04 AM cehteh: did you scoped the input?
08:04 AM cehteh: maybe there is noise, anyway add some RC filter at least
08:04 AM Kliment: My next step would be to try single-ended measurement on each one
08:05 AM cehteh: and its prolly better to mux asap and do the measurement a bit later, let the voltage stabilize
08:05 AM cehteh: schematic would be favorable
08:05 AM phinxy: cehteh: What do you mean, is not MUX just a set-up thing.
08:06 AM cehteh: ah i thought you mux differnt inouts round robin
08:06 AM cehteh: when its only stup then ok
08:06 AM Kliment: cehteh: it's just a single differential config
08:07 AM cehteh: likely some error then :D
08:08 AM Kliment: phinxy: you can also set your mux to all-ones (input source gnd) and check that that reads zero
08:09 AM Kliment: phinxy: then set to 11110 and check that that reads around half your range
08:09 AM phinxy: Youre not talking about measuring the offset?
08:10 AM Kliment: phinxy: no, this is just to verify the ADC works
08:10 AM Kliment: phinxy: 11111 grounds the input, 11110 connects it to 1.1V bandgap reference
08:11 AM phinxy: What register is that?
08:11 AM Kliment: phinxy: admux
08:11 AM Kliment: last 5 bits
08:11 AM phinxy: Oh, I see
08:13 AM Kliment: so set those, make it write the ADCH val on PORTB in the interrupt, and see if it looks right
08:13 AM Kliment: if it does not, no sense messing with the inputs
08:24 AM phinxy: What voltage should be on the pins with all MUX's to 1?
08:24 AM phinxy: (grounded)
08:27 AM Kliment: phinxy: they're disconnected
08:27 AM phinxy: floating?
08:27 AM Kliment: phinxy: yes
08:28 AM Kliment: phinxy: but you're not interested in that - you're interested in the ADC conversion output
08:41 AM phinxy: 0x01001110 with MUX4..1 (1.1V)
08:48 AM phinxy: I'm getting ready to go to bed. MUX4..MUX1 is set for a 1.1V. With VREFS 1.1 all portb bits were 0 with re-occurring jitter. VREFS at VCC is a stable 0x00011100 reading.
08:49 AM phinxy: Ill have to continue tomorrow with RC filters and scan 0-5V to a single end read
03:23 PM [1]MrMobius is now known as MrMobius
07:07 PM davor_ is now known as davor
11:19 PM day__ is now known as day