#avr Logs

Aug 04 2017

#avr Calendar

12:26 AM day_ is now known as daey
12:42 AM Casper: WHOAHHH
12:42 AM Casper: ok that was a baaaad idea
12:43 AM Casper: don't do ntc calculation in the adc interrupt
12:44 AM Casper: at /128 prescaller... the avr can't keep up
12:45 AM Casper: the status printout on the serial port is supposed to take like 0.2 secs, it take 2 seconds...
12:49 AM polprog: genrally ISRs should be as light as possible
12:49 AM polprog: like setting some variable to be then processed in main
12:51 AM polprog: /128 prescaler, what's the main clock? just curious
01:00 AM Casper: 8M
01:01 AM Casper: but you won't like the math
01:01 AM Casper: it involve log()
01:09 AM Casper: ... now... printf claim that my float is not a number...
01:49 AM Emil: polprog: well
01:49 AM Emil: polprog: it depends
01:50 AM Emil: Casper: also there's your issue
01:50 AM Emil: using floats
01:50 AM Casper: float is enabled, and work
01:50 AM Emil: use s32 or s64 fixed point
01:51 AM Emil: polprog: anycase
01:52 AM Emil: polprog: odc keeping interrupts as short as possible might not be what you want always
01:53 AM Emil: because of the cost of entering one exists if your required latency is small you should actually do things inside the isr
01:55 AM Casper: Emil: is there any real issue with floats?
01:57 AM Emil: yes
01:57 AM Emil: speed
01:57 AM Emil: if you are just calxulating ntc
01:57 AM Emil: you dont need floats most of the time
01:59 AM Casper: never used fixed point... but I'm curious to figure out why it fail...
02:00 AM Emil: Casper: wat
02:00 AM Emil: fixed points are lyfe
02:02 AM Casper: . . . guess what is the real issue!
02:03 AM Casper: stupid gcc decided to treat my numbers at integer, so 1/3380 = 0
02:03 AM Casper: instead of 0.000295....
02:03 AM Emil: of course they are integers
02:03 AM Emil: duh
02:04 AM Emil: Anycsde
02:04 AM Emil: I remember seeing some fixed point types in gnu savannah or somewhere else
02:06 AM Casper: ah I get an almost sane temperature! 36°C ! .... supposed to be 25...
02:07 AM Emil: hmmmm
02:07 AM Emil: interestin
02:07 AM Emil: fixed point div is slower than float div
02:07 AM Casper: weird
02:07 AM Emil: https://ucexperiment.wordpress.com/2015/03/31/avr-gcc-fixed-point-vs-floating-point-comparison/
02:07 AM Emil: https://gcc.gnu.org/wiki/avr-gcc#Fixed-Point_Support
02:08 AM Casper: do you have some proper code example
02:08 AM Casper: ?
02:20 AM Casper: this... is a big issue... the ADC have precision issue
02:22 AM Casper: 508, should be 512
02:31 AM Casper: Anyone have toyed with ADC? how much off is the adc actually?
02:31 AM Casper: I'm getting 3-4 count off
02:32 AM Haohmaru: on what resolution? 1024?
02:32 AM Casper: yes
02:32 AM Haohmaru: and you think that's "much" off? ;P~
02:32 AM * Haohmaru gives Casper a big mug of cold reality
02:32 AM Casper: it make it useless for temperature sensing
02:34 AM Casper: I'm pretty sure that the other chips I used was basically off by less than 1 count
03:40 AM JanC is now known as Guest77859
03:40 AM JanC_ is now known as JanC
09:24 AM polprog: Casper: there are nice i2c/spi chips like ADC6320
09:24 AM polprog: Casper: ADC7320 *
09:25 AM polprog: caper: also, i got very nice results with LM335 connected to adc, 1024 counts give you .5 C accuracy at 5V
09:25 AM polprog: Casper: LM335 is analog, nota bene.
09:27 AM rue_more: Casper, LM35
09:28 AM rue_more: and LM75 if you wanna go digital
09:29 AM polprog: hmm
09:29 AM polprog: LM335 is 10mV/K and LM35 is 0+10mV/C, so in theory a good low niose amp could boost your resolution
09:29 AM polprog: in the latter sensor
09:30 AM rue_more: you could also put a sensor in an oscillator and measure it to 24-32 bits
09:30 AM polprog: yeah, you could hack around the the internal avr osc
09:30 AM rue_more: no
09:30 AM rue_more: external osc and measure the period
09:30 AM rue_more: temp dep osc
09:33 AM polprog: no meaning impossible or no meaning you meant something else?
09:33 AM polprog: im not sure about that internal osc
09:36 AM rue_more: what I'm talking about is an old adc technique where you convert your analog value to a duration of freq, and measure it using a counter, you can take a temperature sensor and make it PART of an oscillator, thus resulting in a temperature dependendt oscillator, if the frequency is low enough you can collect a LOT of counts aka 16 bits, 24 bits 32 bits or more
09:36 AM rue_more: gives you a lot of room to round out any noise
09:36 AM polprog: intresting
09:37 AM polprog: that's very cool
09:37 AM polprog: would that work if i used an ntc/ptc in an rc oscillator? am i thinking correctly here?
09:37 AM rue_more: yes
09:39 AM rue_more: you could even have the avr be the oscillaotr, using a digital pin, using a pin change interrupt and a overflow interrupt on a timer, there are gotchas to the design that I dont ahve3 the energy to spell out right now, use a 555
09:46 AM rue_more: summary: set pin to output, set low. on pinchange low (or if pin is low) set to input, no pullup, reset timer counter. on timer overflow, increment overflow counter. on pin change high save counter values, change pin to output, set low. repeat
09:47 AM rue_more: 1 ntc, one, say 10 ohm resistor, and one, say 0.47uF capacitor
09:48 AM rue_more: Pin----\/\/\/\----- Node r=10 ohms
09:49 AM rue_more: +5V (CLEAN) ------\/\/\/\/---- Node -------|(------ GND R=NTC C=0.47uF
10:14 AM Lambda_Aurigae: 555 or a 2-transistor oscillator...either way works wonders.
10:15 AM Lambda_Aurigae: you could also use the CTMU on some modern microcontrollers along with a cap and the temperature dependent resistor or analog temp sensor.
10:15 AM Lambda_Aurigae: the oscillator versions require very stable power supplies though...most do anyhow.
11:06 AM day_ is now known as daey
11:15 AM day_ is now known as daey
12:31 PM Casper: finally, it was multiple bugs
12:31 PM Casper: now I get like a 0.1°C precision @25°C
12:32 PM Casper: it look like the new gcc is more picky about integer and float and cast
12:34 PM * antto injects a denormal into Casper's floats
12:34 PM Casper: finally, with some tweaking and simplification, I safed a few bytes of ram, some in flash, and it still work
12:35 PM Casper: 5852 bytes once compiled
12:53 PM xentrac: --v^v^v^v--
12:57 PM Casper: 5876 bytes...did some more tune up... some 16 bits were unprotected from interrupt modification
12:57 PM Casper: https://paste.pound-python.org/show/tf6WnIVlkULRz2dX1s8k/ <=== if you see anything...
01:42 PM JanC_ is now known as JanC
07:24 PM Thrashbarg_ is now known as Thrashbarg
07:24 PM Casper: printf_P(PTSR("foo: %s"), foo ? PTSR("foo") : "bar"); <=== is that to be expected to work on avr? I get nothing...
07:52 PM cehteh: Guys when you program IoT things: https://vid.me/pASP3
08:05 PM Emil: :DD
08:06 PM Thrashbarg: haha
08:38 PM Casper: https://paste.pound-python.org/show/otLSRhWZ7wfE6eMmRayR/ <==== does anyone suggest anything to modify there for any reason? better coding, whatever..
09:16 PM enh: hi
09:20 PM Casper: o/