#avr | Logs for 2014-01-21

Back
[01:01:33] <rigid> grreat, atmel doesn't provide the full datasheet for the ATtiny11 anymore :-/
[01:04:00] <rigid> i wonder who makes such stupid decisions, don't they know that the file is cached all over the web anyway? grr...
[01:05:20] <Casper> o.O
[01:05:28] <Casper> the few hundred pages?
[01:06:07] <rigid> yep... the one I found at digikey (that contained the electrical characteristics) has 89
[01:06:28] <rigid> the one provided by atmel has 15
[01:06:29] <Casper> checking
[01:07:28] <rigid> i suppose they remove it since the device is depreciated and they wanna force people to buy newer ones
[01:08:04] <Casper> o.O they DID removed the datasheet o.O
[01:08:25] <Casper> weird
[01:08:26] <rigid> if that's true it's kinda retarded if they think people go "let's throw away the old stock and buy another model"
[01:08:43] <Casper> they might have screwed up when they converted their site a while ago
[01:08:52] <rigid> i doubt it
[01:09:21] <rigid> well, maybe.
[01:09:50] <rigid> but then they screwed up big time since the product page is missing all sorts of stuff
[04:17:17] <rigid> can I save more power, in theory, when doing PWM with a tiny than using the timer interrupt and going to idle mode?
[04:17:42] <rigid> i suppose the timer won't run when I power-down...
[05:15:36] <sabesto> could anyone remind me where the DFU firmware is located?
[05:16:06] <sabesto> i forgot where, i only remember looking for a long time before finding it
[11:36:41] <zmo> .. avrdude bug reported.
[11:40:25] <kline> for the m328p, the datasheet says that for timer0 in CTC mode, TIMER0_COMPA_vect is called on TCNT0 = TOP, and TIMER0_OVF_vect on passing MAX
[11:41:17] <kline> does this mean that OVF will only happen on "missing" (setting a compare value below TCNT0) a compare or when the compare is the same as MAX?
[12:10:17] <antto> which timer is 16bit?
[12:10:40] <Tom_itx> varies
[12:10:46] <Tom_itx> read the data sheet
[12:11:31] <antto> can't find it :/
[12:11:40] <antto> ..within the datasheet
[12:12:03] <Tom_itx> i'm confident it is there
[12:12:23] <antto> at the very top it says that it has 2 8bit and 4 16bit timers
[12:12:46] <Tom_itx> what part?
[12:13:17] <antto> atmega2561
[12:14:52] <Tom_itx> 1 3 4 and 5
[12:15:11] * Tom_itx hits antto with a clue bat
[12:15:40] <Tom_itx> 17. 16-bit Timer/Counter (Timer/Counter 1, 3, 4, and 5)
[12:16:17] <Tom_itx> 0 and 2 are 8 bit
[12:17:18] <antto> i see
[12:34:55] <rigid> zmo: did you report the bug to the mailinglist? or is there an issue tracker?
[12:35:08] <zmo> both
[12:35:13] <zmo> on the savannah issue tracker
[12:35:19] <zmo> which copies to the avrdude dev ml
[12:35:21] <rigid> zmo: ah, nice
[12:35:40] <zmo> though sadly I did not compile avrude with debug symbols
[12:35:43] <rigid> since "High Voltage Serial Programming only possible with STK500 FW Version 2.x but not with 1.x" is also a bug I'd report
[12:35:47] <zmo> and rebooting fixed it
[12:35:56] <rigid> but i'm too lazy for a mailing list :-/
[12:36:10] <zmo> it looks like it was a libusb bug or a kernel driver
[12:37:11] <rigid> ah... upstream bugs are the best ones :)
[13:21:25] <antto> can't figure out how to make timer3 throw an interrupt when it reaches 6667
[13:22:07] <antto> i've set the prescaler to /1, OCR3A to 6667..
[13:23:45] <antto> actually, i'm no longer even sure if my math is correct
[13:27:57] <inkjetunito> hey, how are those circuits called that keep the mcu from starting before the power supply has stabilized?
[13:29:46] <Tom_itx> relays
[13:30:28] <Tom_itx> do they still even use those?
[13:31:33] <kastein> um... relays? how quaint
[13:32:05] <Tom_itx> no, i had one on an old 68hc11 once
[13:32:26] <kastein> I think you probably want a reset watchdog, something like a dallas semiconductor ds1233 if I had to guess
[13:32:39] <kastein> http://datasheets.maximintegrated.com/en/ds/DS1233.pdf
[13:32:40] <inkjetunito> kastein: that's what i'm looking for. thanks!
[13:33:14] <Tom_itx> brownout detection circuit
[13:34:00] <Fleck> antto: sure you have 16bit timer?
[13:34:06] <moemoe> why not use the internal bod?
[13:34:39] <Tom_itx> and startup delay fuses
[13:37:54] <antto> Fleck i don't know
[13:38:09] <antto> Fleck the datasheet covers a few chips besides mine
[13:38:39] <Fleck> antto: :) well how do you count to 6667 then?
[13:38:48] <Tom_itx> they're all in the family, they should share the peripherals
[13:38:54] <Fleck> where do you store that value, is that register 8 or 16bit?
[13:39:11] <antto> in "OCR3A"
[13:40:05] <Fleck> which chip?
[13:40:14] <antto> atmega2561
[13:40:51] <Fleck> yep - OCR3A is 16bit reg
[13:40:52] <Tom_itx> <Tom_itx> 17. 16-bit Timer/Counter (Timer/Counter 1, 3, 4, and 5)
[13:40:52] <Tom_itx> <Tom_itx> 0 and 2 are 8 bit
[13:40:56] <antto> i'm trying to make an interrupt fire ~2400 times per second, given that my cpu runs at 16MHz
[13:41:34] <antto> so 16M/6667 ~= 2400
[13:42:23] <Tom_itx> how many clocks of that are overhead?
[13:42:46] <antto> what do you mean?
[13:43:17] <Tom_itx> it's gotta stop and compare if it's there yet
[13:43:20] <Tom_itx> that takes cycles
[13:43:55] <antto> no idea
[13:43:57] <Fleck> not a big deal - he can tweak value
[13:44:38] <antto> i currently have timer0 set to fire 1000 times per second, and i'm doing some stuff there
[13:44:51] <Tom_itx> timer0 is 8 bit
[13:45:15] <antto> but 1000 is not frequent enough for the thing, and i want to move that code into a more frequent timer
[13:45:25] <antto> i still need timer0 to be running at 1000 for other stuff
[13:45:33] <antto> yeah
[13:45:46] <antto> timer0 is configured with prescaler /64 and "250"
[13:46:46] <antto> so i want to try a faster timer, 2000 or more
[13:46:54] <DanFrederiksen> hmm, have any of you tried using a laser to solder with solder paste?
[13:47:47] <antto> but i just can't get my head around these codes, it doesn't run for some reason
[13:48:04] <antto> and i'm not sure what i'm doing tbh ;]
[13:48:34] <kastein> DanFrederiksen: nah, but I'm curious, why?
[13:48:38] <kastein> it's an interesting idea
[13:55:03] <Tom_itx> rather expensive soldering iron
[14:08:54] <Fleck> antto: I have atmega2560, can try to write simple code
[14:09:07] <Fleck> for start - you can share yours
[14:20:32] <Tom_itx> yeah i've got one too
[14:25:26] <ambro718> what's the most efficient way to do addition and increment for ring buffers when the size is not a power of two?
[14:27:56] <ambro718> stuff like this: uint8_t add (uint8_t a, uint8_t b) { return (b >= SIZE - a) ? (a - (SIZE - b)) : (a + b); }
[14:28:12] <ambro718> uint8_t inc (uint8_t a) { return (a == SIZE - 1) ? 0 : (a + 1); }
[14:28:33] <ambro718> but with optimal worst case efficiency in assembly
[14:32:45] <ambro718> damn my hard drive just crashed, had to reboot :(
[14:32:58] <ambro718> that makes me wonder in the thing can have its firmware updated
[14:53:01] <vectory> ambro718: that doesnt make sense, when you can aswell use assembly
[14:53:29] <vectory> oh, now i get what SIZE means
[14:53:37] <vectory> nvm
[14:53:47] <ambro718> if it's not a power of two you need to handle overflow
[14:53:52] <ambro718> can't just AND it
[14:53:55] <vectory> ambro718: did you test x*x vs square(x) ?
[14:54:18] <ambro718> not yet. But thanks for the remainder, might have forgotten about it otherwise ;)
[14:56:37] <ambro718> Well I remember from my studies that computing the square is asymptotically equally complex to multiplication..
[14:57:16] <ambro718> It was a cryptography course I think.
[14:59:35] * ambro718 stop his habit of clicking Help->About in random apps when thinking stuff, since his IRC client tends to crash when you do that
[15:00:33] <ambro718> moving windows around still works ;) Except in Windows where Aero Shake messes it up, lol
[15:19:01] <Duality> ambro718: when I open a irc client in windows, I get a blue screen
[15:19:27] <ambro718> yeah that's pretty cool!
[15:20:47] <ambro718> unless you have a blue IRC client ;)
[15:27:26] <Duality> ambro718: no the one that kills everything. in linux if something goes wrong your trown into a terminal/console to fix it. and normaly I can :)
[15:28:14] <ambro718> unless your hard drive crashes, then everything just gets more and more frozen, heh
[15:29:02] <ambro718> I hate how the kernel is lacking some kind of smart hard disk recovery. Like for disconnected and reconnected USB disk.
[15:29:15] <ambro718> (if you're running root fs on USB disk)
[15:43:15] <ambro718> It's funny when you design a data structure and find out years later that it has an actual name, lol. http://www.codeproject.com/Articles/3479/The-Bip-Buffer-The-Circular-Buffer-with-a-Twist
[15:43:25] <ambro718> That's my implementation from a few years ago: https://code.google.com/p/badvpn/source/browse/trunk/structure/ChunkBuffer2.h
[15:43:43] <ambro718> same goes for design patterns
[15:46:29] <ambro718> ^^ not exactly the same probably but works in very much the same way, by prematurely wrapping the circular buffer if there's not enough space left for a contiguous chunk of data
[16:12:32] <johnwalkr> running atmega8 at 8Mhz. want to have a moving average or some kind of average of 2 analogue signals
[16:15:02] <johnwalkr> reading them each at about 50Hz over i2c. right now reading is done at time of i2c query but i wish to have averages over about 0.04s or 0.05 ready to send over i2c
[16:15:06] <johnwalkr> any ideas
[16:15:29] <johnwalkr> obviouslly don’t want to read thousands of values and average them
[16:20:17] <ambro718> johnwalkr: Have you considered an exponential moving average?
[16:20:39] <johnwalkr> no i haven’t
[16:21:03] <johnwalkr> to be honest i posted the question before considering anything
[16:21:15] <ambro718> basically: state = smoothing * state + (1 - smoothing) * this_reading;
[16:21:41] <johnwalkr> you know sometimes answers are off the top of people’s heads.in the meantime i’’m reading
[16:21:44] <johnwalkr> ooh
[16:21:50] <johnwalkr> sounds siple
[16:22:13] <ambro718> you can either do it in floats or fixed points. Floats are generally too slow for interrupts.
[16:22:30] <antto> Fleck there ain't much code.. but imma paste it
[16:22:37] <ambro718> With fixed point you'll need more bits for the "state" than your readings actually need. About twice as much is good.
[16:22:48] <johnwalkr> ok
[16:22:53] <johnwalkr> 2 readings
[16:23:01] <ambro718> what do you mean?
[16:23:22] <johnwalkr> i need to keep track of 2 analog inputs
[16:23:31] <ambro718> well that is irrelevant
[16:23:44] <ambro718> I mean, how much bits is each reading?
[16:23:47] <ambro718> probably 10 or 8
[16:23:47] <johnwalkr> oh
[16:23:50] <johnwalkr> 10
[16:24:51] <antto> Fleck http://pastebin.com/Njv0Qb8n
[16:25:12] <ambro718> so then it would be wise to, for example, have a 32-bit 'state' variable, with a scaling factor of 2^-16
[16:25:31] <ambro718> johnwalkr: if you're considering fixed point, read this http://en.wikipedia.org/wiki/Binary_scaling
[16:25:41] <johnwalkr> will do
[16:25:55] <johnwalkr> leave me with that and i might have more Qs tomorrow
[16:26:05] <johnwalkr> it’s super late now, bedtime
[16:26:12] <johnwalkr> thank you!
[16:26:34] <ambro718> see you :)
[16:32:57] <ambro718> For anyone interested in theoretical stuff, it turns out there's an online moving averags algorithm (for arbitrary weights) with O(sqrt(n*logn)) time complexity per input value.
[16:33:11] <ambro718> http://cs.stackexchange.com/questions/10612/weighted-sum-of-last-n-numbers <-- my question, someone solved it, and I even implemented the solution
[16:34:02] <ambro718> but it only gets better then summing everything at every input when you're doing the moving average with length above thousands :D
[16:39:55] <johnwalkr> thanks ambro718
[16:40:10] <ambro718> you DON'T want to implement that ^^ lol
[16:49:01] <johnwalkr> ok
[16:49:09] <johnwalkr> gave good insight though :)
[16:51:05] <Fleck> antto: well - first thing - port is not set as output!
[16:51:32] <PoppaVic> whew! beware input in yer outputter!
[16:52:23] <antto> O_o
[16:52:28] <antto> what port?
[16:54:39] <Fleck> well, OCR3A ? you need to toggle that port? or just use interrupt?
[16:55:11] <antto> uhm, i don't even understand ;]
[16:55:36] <antto> i copied that code more or less from timer2
[16:58:09] <Fleck> well, compare match needs to be sent out of avr to external device?
[16:58:27] <antto> my poor understanding of this is.. that the timer increments (F_CPU/1) times per second and each time compares its value with the target value which is set in ocr3a.. and if it matches - it fires the interrupt
[16:58:32] <antto> and that reapeats forever
[16:59:05] <Fleck> ohh ok, so no external device
[16:59:17] <antto> nah, i want to do some stuff when the interrupt fires
[16:59:17] <Fleck> well you do not enable interrupts in your code
[16:59:27] <antto> uhm
[16:59:34] <antto> i thought i do.. in main()
[16:59:48] <antto> my other timer (timer0) works
[16:59:54] <Fleck> no main() in your paste
[17:00:17] <Fleck> I don't have extra senses :D
[17:00:20] <antto> sei(), right?
[17:00:31] <Fleck> TIMSK
[17:00:43] <antto> oh
[17:01:12] <Fleck> also sei() is needed!
[17:01:35] <antto> yeah, i know that
[17:01:51] <antto> but i'm not that familiar with this timsk
[17:03:20] <antto> doesn't the OCIE3A line do that?
[17:03:27] <Fleck> also check interrupt vectors on page 105
[17:04:34] <Fleck> ohh, yes, missed that one!
[17:04:59] <antto> x_x
[17:05:06] <antto> i feel totally lost
[17:05:10] <ambro718> if you ever look as the assembly, remember that the numbers there are one less then in the datasheet
[17:05:18] <ambro718> *vector numbers
[17:05:52] <Fleck> antto: alo, in normal wave gen mode no counter clear is done
[17:06:12] <jadew> http://www.eevblog.com/forum/microcontrollers/chinese-atmega88-clone/
[17:06:18] <antto> wave gen mode?!
[17:06:28] <Fleck> WGM bits
[17:06:48] <antto> does this output some voltage or something?!
[17:07:09] <Fleck> :)
[17:07:28] <antto> f*ck.. what am i even doing
[17:07:44] <antto> i need to be doing something at a fixed frequency
[17:08:26] <antto> i'll be generating a sort of clock on some pin, which is rather low-speed
[17:08:41] <antto> the max freq of that clock is about 240Hz
[17:09:19] <Fleck> so you need output pin? :D
[17:09:23] <antto> before now, i was doing it from timer0 (which happens 1000 times per second) but i want to move that chunk of code to a more dense timer
[17:10:39] <antto> the output pin is PORTD, PIND
[17:11:18] <antto> all of that is sorted long ago, i just want to move it to a more dense timer (while i still need to keep timer0 at 1000Hz for a few other purposes)
[17:11:57] <antto> but i didn't know that this timer generates waveform O_o
[17:13:11] <Fleck> OC3A/B/C - OC3A os PortE Pin 3
[17:13:16] <Fleck> s/os/is
[17:14:44] <antto> what does this mean?
[17:14:51] <antto> what happens on portE pin3?
[17:16:31] <Fleck> PE3: AIN1/OC3A (Analog Comparator Negative Input or Output Compare and PWM Output A for Timer/Counter3)
[17:16:32] <Fleck> :D
[17:23:01] <antto> it appears that pin (luckily) isn't used for anything else
[17:25:12] <antto> from the little i understand, i think i should be using this CTC mode
[17:25:22] <Fleck> http://paste.opensuse.org/44001173 << on pinb5: http://im9.eu/picture/do2541
[17:25:39] <antto> when the timer reaches 6667, it should fire the interrupt and start over again from 0
[17:26:14] <Fleck> I used Timer1
[17:26:47] <Fleck> 2400Hz
[17:26:56] <Fleck> ~
[17:27:17] <antto> what does this code do exactly?
[17:27:27] <Fleck> ;)
[17:27:52] <antto> generate a 2400Hz pulse on some pin?
[17:28:06] <Fleck> yes, check 2nd url
[17:28:17] <Fleck> that what comes out of PortB Pin5
[17:28:23] <antto> but that's not what i want
[17:28:45] <antto> i want to execute a chunk of code 2400 times per second
[17:28:49] <Fleck> sure
[17:29:14] <Fleck> now, set output mode and add vector function, enable interrupts - done
[17:29:39] <antto> in this chunk of code, i am manipulating the output of pinD on portD, and i don't want to be doing anything else on other pins besides what this chunk of code is doing
[17:29:54] <Fleck> COMnA1 and COMnA0
[17:30:39] <Fleck> 0 0 Normal port operation, OCnA/OCnB/OCnC disconnected (so there will be no pulse on pin)
[17:31:07] <Fleck> I enabled output to pin because it's easier to debug this way! :)
[17:32:25] <antto> i don't debug anything, nor have tools for it ;]
[17:32:39] <antto> just doing things in very tiny steps..
[17:33:04] <PoppaVic> debuggingisforwimps.Write it, sell it. Done.
[17:33:57] <antto> so, in TCCR3A, the top 2 bits shall be zero then
[17:34:29] <antto> i think they have always been zero
[17:38:02] <antto> and this WGM thing has 4 bits
[17:38:39] <antto> i need just WGMn2 set for CTC mode
[17:38:48] <antto> right?
[17:40:14] <Fleck> right
[17:40:47] <Fleck> about TCCR3A too
[17:41:49] <Valen> flashing LED is all the debug tools i need
[17:44:03] <antto> got 40 LEDs, but it ain't blinking
[17:44:34] <Valen> well theres ya prablem
[17:44:41] <Valen> oscilloscope helps with timer issues ;->
[17:45:07] <antto> the issue is in my dumb code ;]
[17:45:20] <antto> oscilloscope costs a kidney
[17:45:38] <Fleck> ;p
[17:45:45] <Fleck> logic analyzer = 8$
[17:45:54] <Valen> eh you can get cheapish ones off the ebays
[17:50:42] <antto> http://pastebin.com/QCrTWNf9
[18:06:16] <myself> even an old single-trace analog scope is better than nothing, you can get a cheap one on craigslist for $100
[18:06:31] <Fleck> myself: right! :)
[18:06:55] <myself> or see if your local hackerspace has one you can use for a few hours :)
[18:07:15] <Fleck> no such thing here :/
[18:08:49] <Valen> where are you?
[18:10:43] <Fleck> https://www.google.com/maps/preview#!data=!1m4!1m3!1d19373!2d21.5940751!3d57.3914251
[18:10:48] <Fleck> there! :D
[18:11:08] <Valen> ebay then
[18:11:37] <Fleck> yep
[18:14:15] <myself> better: http://detroit.craigslist.org/wyn/ele/4296888413.html
[18:14:20] <myself> if I didn't already have one I'd go get that one
[18:15:49] <Fleck> go where?
[18:20:00] <antto> craigslist?
[18:20:04] <antto> 100 bucks?
[18:20:23] <antto> you realize by the time this thing gets to here it's gonna turn to 500 bucks? ;]
[18:20:24] <PoppaVic> stolen sillyscopes are bestest!
[18:20:30] <antto> shipping plus import taxes
[18:21:53] <Fleck> antto: are you in EU too?
[18:21:58] <antto> yup
[18:22:02] <antto> BG
[18:22:13] <Fleck> ohh, cool! :)
[18:22:30] <Fleck> btw antto, you can't use COMPA vector in CTC mode afaik
[18:22:37] <antto> i don't think i need a scope to tell that the code in my interrupt ain't getting called
[18:22:58] <antto> hm?!
[18:23:11] <antto> what then?
[18:23:35] <antto> how do i get a chunk of code get executed at a regular interval?
[18:23:37] <Tom_itx> talk nicer toit
[18:24:14] <Tom_itx> set up a subsumption architechure
[18:25:23] <Fleck> never mind antto, you can!
[18:26:08] <antto> :/
[18:26:18] <antto> what am i doing wrong then?
[18:48:30] <Fleck> I have no clue antto, looks good to me
[18:48:36] <Fleck> where are you coding?
[18:48:49] <Fleck> I mean - what compiler?
[19:01:10] <antto> Fleck avrgcc / windows
[19:13:14] <antto> what's that OCFnA flag about?
[19:16:02] <Fleck> read OCIEnA description
[19:17:09] <antto> that's where i saw it
[19:32:43] <antto> as far as i understand, i don't need that if i'll be using interrupt
[19:55:41] <Fleck> Ill update atmelstudio :D
[19:55:53] <Fleck> I can't find whats wrong antto
[19:58:58] <antto> nor me
[20:03:16] <antto> i give up for today
[20:03:22] <antto> ph*ck it
[20:05:01] <Fleck> :)
[20:05:19] <Fleck> I'll try on updated atmel studio
[20:20:22] <Fleck> nope, update did not help, so I must be missing something!
[21:46:39] <rigid> does anyone know some nifty trick to get a random seed on a tiny11 on powerup?
[21:47:32] <rigid> like shuffling the initial contents of the RAM or some timer stuff? something that is roughly indeterministic?
[22:22:10] <Tom_itx> rigid, read a random adc input value
[22:23:54] <rigid> Tom_itx: yeah, that'd be nice but the tiny11 doesn't have an adc... only an analog comparator
[22:24:37] <rigid> i also thought about sampling digital noise from a diode, but without external hardware it would be nicer... and actually I only need a pseudo random seed
[22:25:39] <rigid> i don't even care for even distribution, but i want different states on each powerup. And since the tiny11 only allows 512 instructions, i'm a bit limited
[22:34:04] <tzanger> rigid: I'm not aware of a way to do that. osccal won't be random
[22:35:08] <rigid> hm, i hoped there might be some dirty trickery
[22:35:29] <rigid> Tom_itx: tzanger: thanks anyway, maybe someone in here has an idea
[22:35:31] <tzanger> yeah that is actually a very good question
[22:35:40] <rigid> s/in here/else/
[22:35:53] <tzanger> I was thinking that maybe the timer value might be random or something
[22:35:58] <tzanger> but I think it's all reset very nicely
[22:36:12] <tzanger> you can try checksumming RAM... you might get lucky
[22:36:26] <tzanger> but I don't know that you can be guaranteed it will be random
[22:37:13] <rigid> i'm going to do some experiments soon... in theory even a random 0/1 bit should be a good seed to create a pseudorandom seed for a prng
[22:37:54] <rigid> tzanger: well, i don't do cryptography. i'm just choosing colors for an RGB necklace for my gf :) it shouldn't always show the same color
[22:38:12] <rigid> so real randomness is not needed
[22:40:22] <tzanger> I'd just run through RAM, summing it and using that
[22:44:29] <rigid> yep, that'd be my first try
[22:47:57] <Tom_itx> so don't use a random number, just make the selection so high it seems random
[22:48:35] <Tom_itx> skip x the first time, skip y the next
[22:51:40] <tzanger> but x and y are still going to be the same value
[22:52:11] <tzanger> although I guess you could set up a timer and a busy loop and rely on it taking +/- a few clock cycles to get to the ISR to interrupt the busy loop
[22:54:56] <CeruleanSky> could you count how many cycles the powerbutton was pressed and use that as a seed?
[22:56:12] <CeruleanSky> assuming you use a small pressbutton and not a switch
[22:56:17] <CeruleanSky> sliding switch
[22:56:51] <Tom_itx> all i'm saying is if you make the number of selections high enough it will seem random on something like that