#avr | Logs for 2016-03-11

Back
[02:56:35] <julius> linux was complaining that /media/system was corrupt?
[02:57:04] <julius> you can comment that out in /etc/fstab and mount manually if needed
[02:57:39] <julius> reinstalling win8 will also kill grub in the mbr
[03:48:41] <nikomo> Anyone know why the sleep modes aren't listed in the docs for avr/sleep.h? http://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html
[05:03:59] <Jartza> nikomo: I found the OLD version mirrored here http://www.ele.uva.es/~jesus/perifericos/avr-libc-user-manual-1.4.5/group__avr__sleep.html
[05:04:23] <Jartza> so they used to be listed. no idea why they disappeared, maybe report a but?
[05:04:24] <Jartza> bug
[05:04:25] <Jartza> even
[05:05:13] <Jartza> but, has anyone tried avr-libc 2.0 with gcc 5 yet?
[05:05:52] <Jartza> ahh
[05:05:52] <Jartza> https://savannah.nongnu.org/bugs/?45795
[05:05:57] <Jartza> nikomo: ^^
[05:06:38] <nikomo> Jartza: :P at least the bug's filed. also, I'll check what version my avr-libc package is, I know my avr-gcc is 5.something
[05:06:50] <Jartza> oh really
[05:07:00] <Jartza> well then I guess you must have 2.0 avr-libc
[05:07:02] <nikomo> avr-gcc -v, gcc 5.3.0
[05:07:21] <Jartza> because main point for 2.0 release was gcc 5 compatibility :)
[05:08:04] <Jartza> I prefer the atmel "official" packages though
[05:08:08] <Jartza> so I'm still with 4.8.1 :)
[05:08:09] <nikomo> avr-libc: Version : 1.8.1-4
[05:09:09] <nikomo> https://www.archlinux.org/packages/community/any/avr-libc/ says 2.0.0, I haven't updated in a bit, sec
[05:09:57] <Jartza> yea
[05:09:58] <nikomo> Jartza: yup, 2.0.0 is available on arch, I'm gonna update now
[05:10:10] <Jartza> latest is not always greatest ;)
[05:10:18] <Jartza> anyhow. I'm off to lunch
[05:10:20] <Jartza> laters
[05:10:38] <nikomo> I ride the bleeding edge so far, you'd think I'm emo
[07:39:22] <julius> is a 100ohm resistor between a avr pin and a mosfet really enough to keep the avr safe from overcurrent?
[07:39:50] <julius> dont know the gate resistance, but assuming its just the 100ohm that would be 5v/100ohm = 50ma
[07:40:11] <julius> 50ma seems a lot...wasnt a avr supposed todo like 20ma overall?
[07:46:13] <LeoNerd> gate on a MOSFET is usually best considered as isolated
[07:46:25] <LeoNerd> So that resistor really isn't going to be doing anything useful
[07:48:09] <Lambda_Aurigae> just limiting inrush current.
[07:48:22] <Lambda_Aurigae> the gate on a mosfet is effectively a capacitor for such things.
[07:49:28] <LeoNerd> Mm.. true
[07:49:37] <Lambda_Aurigae> I usually use something like a uln2803 or something for driving mosfets from microcontrollers.
[07:49:52] <LeoNerd> I suppose if it's a big power one that might be significant
[07:50:10] <julius> and isolated means what?
[07:50:18] <Lambda_Aurigae> so that 50mA current inrush is going to be really fast.
[07:50:29] <julius> yes, probably ns
[07:50:41] <LeoNerd> Gate resistance is usually measured in tens or hundreds of Mohm, at least
[07:51:04] <LeoNerd> So adding 100ohm to that is insignificant, in the DC case. Though also capacitance to consider
[07:51:10] <Lambda_Aurigae> by isolated, it means the thing won't draw much current through the gate continuously.
[07:51:18] <julius> ah ok
[07:52:02] <Lambda_Aurigae> if you are PWMing that thing you might look at a BJT or uln2803 to drive it.
[07:54:13] <julius> i was thinking about using a logic level mosfet like the irlb3813pbf
[07:54:20] <julius> and skipping the driver
[07:54:55] <Lambda_Aurigae> just make sure your inrush current doesn't screw with the avr.
[07:55:35] <julius> as leonerd said gate resistance is like 10mohm+
[07:55:49] <julius> how can a mosfet draw significant current at all with that?
[07:56:08] <Lambda_Aurigae> 100 to 200 ohm resistor on the gate is a necessity but that will slow down the switching speed...not necessarily bad enough at your frequencies though.
[07:56:20] <Lambda_Aurigae> the gate resistance, yes
[07:56:47] <Lambda_Aurigae> but the turn on inrush is charging a capacitor effectively, which has little to do with the gate resistance.
[07:57:25] <julius> so i still should add the 100ohm for the avr, hoping that it can handle 50ma for 20ns or something
[07:57:26] <LeoNerd> julius: think of the gate as a capacitor and resistor in series, with the other end attached to some point between the source and drain
[07:57:53] <julius> in series would mean that the resistor keeps the current down?
[07:57:54] <Lambda_Aurigae> julius, yes. and have a spare AVR handy just in case.
[07:57:55] <LeoNerd> In the DC case, only that resistor matters; it's a huge many-Mohm thing. But, in addition while switching (i.e. in the AC case) that capacitor has to charge or discharge
[07:57:56] <LeoNerd> er.. parallel
[07:58:01] * LeoNerd typing too fast ;)
[07:58:11] <julius> ah, now i get it
[07:58:18] <julius> its AC because if goes on/off
[07:58:21] <LeoNerd> Yup
[07:58:50] <LeoNerd> So putting a small resistor in there as well means you limit that inrush current. It makes switching times a little slower, but gives you the benefit of a smoother switch current.. doesn't cause such a peak
[07:59:11] <LeoNerd> It's nicer on the PSU and whatever's driving the gate - maybe directly from the AVR itself
[07:59:14] <julius> i only need <30khz
[07:59:24] <LeoNerd> Yah; so you don't need superfast switching.. so a resistor is good
[07:59:28] <LeoNerd> Keeps EMI down too
[08:04:16] <julius> how long can you heat up a mosfet in a to220 package with ~250C?
[08:05:34] <Lambda_Aurigae> depends on the mosfet.
[08:05:41] <Lambda_Aurigae> what are the tolerance specs?
[08:06:37] <julius> dont know
[08:06:47] <Lambda_Aurigae> look it up.
[08:06:50] <julius> but i guess i killed one while attaching a too big wire
[08:07:03] <julius> it can work up to 175C
[08:07:10] <julius> junction temperature
[08:07:32] <julius> so soldering with 250 for a few seconds should be fine? or should i go lower?
[08:07:41] <Lambda_Aurigae> a few seconds?
[08:07:49] <Lambda_Aurigae> not if the junction temp gets that high.
[08:08:08] <Lambda_Aurigae> heatsink clips for the win.
[08:08:25] <Jartza> allo
[08:08:25] <julius> ok, so soldering faster
[08:08:29] <julius> hi
[08:08:48] <Lambda_Aurigae> or, an alligator clip on the lead between mosfet and soldering point.
[08:08:53] <Lambda_Aurigae> morning Jartza
[08:09:43] <Jartza> good time of the day to you too :)
[08:10:02] <julius> you mean the alligator on the plate where the heatsink will go on?
[08:10:36] <Lambda_Aurigae> well, heatsink on the chip will help too.
[08:11:14] <Lambda_Aurigae> but on a to-220 there should be a short length that is wider than the pin that goes through the board.
[08:11:31] <julius> yes
[08:11:55] <Lambda_Aurigae> that's where you heatsink it while soldering.
[08:12:10] <Lambda_Aurigae> to keep the heat from flowing up the lead to the chip.
[08:12:48] <julius> i get it
[08:15:51] <julius> thanks for the quick info
[08:16:01] <julius> i really have to buy you a bear or something
[08:16:55] <theBear> nah you don't, i'm good
[08:19:33] <liwakura> i've got an question
[08:20:20] <liwakura> i discovered that linux tty's also use CRLF instead of LF only
[08:21:08] <liwakura> could it be that standart eol for serial consoles is CRLF, even when its a LF only machine?
[08:21:17] <liwakura> *standard
[08:21:44] <Lambda_Aurigae> standard....hmmm...there is such a thing?
[08:21:58] <liwakura> im so confused right now, when i make a shell transscript with "script file.txt" and xxd the file, its mixed LF and CRLF
[08:23:05] <liwakura> ( im programming an serial tty on an arduino, and i need to know that to implement it properly )
[08:23:58] <Lambda_Aurigae> I've never had a problem with LF only on linux.
[08:24:20] <liwakura> when its on files, okay
[08:24:47] <liwakura> but when you communicate to an linux machine via uart, you get CRLF's i guess
[08:24:57] <Lambda_Aurigae> never seen that myself.
[08:25:32] <Lambda_Aurigae> when I send a \n I get a \n at the other end.
[08:25:34] <liwakura> Lambda_Aurigae: need steps to reproduce?
[08:25:38] <cehteh> liwakura: crlf is common in telnet like things, think about old teletype terminals where it originates from
[08:26:05] <cehteh> but nothing defines it as 'linux uses' that ... its just the implementation
[08:26:17] <liwakura> but i also get it in my terminal emulator..
[08:26:32] <Lambda_Aurigae> if you are getting it then something must be sending it.
[08:26:49] <cehteh> the ugly thing is when you *send* date typed from keyboard you hit 'return' then you only get cr
[08:27:18] <cehteh> but when the µC replies it likely has to send crlf
[08:27:34] <liwakura> cehteh: thats what i observed
[08:27:42] <liwakura> the thing it, the roles will be reversed soon
[08:27:43] <cehteh> i use 'screen' which only sends the cr
[08:27:53] <liwakura> same
[08:28:10] <cehteh> moreover .. its pita when you echo back everything which got send
[08:28:32] <cehteh> rx and tx have the same baudrate .. but tx has more bytes to send
[08:28:53] <liwakura> argh
[08:29:07] <cehteh> been there :) .. i had my fun already
[08:29:11] <liwakura> the thing is, im about to stick an keyboard and a display to the avr
[08:29:23] <liwakura> and but an agetty process to my /dev/ttyUSB0
[08:29:45] <liwakura> and i have no idea how to implement that properly regarding eol's
[08:29:48] <cehteh> just make sure you have some pauses in the serial transfer before buffer overrun
[08:29:57] <cehteh> and/or implement flow control
[08:30:04] <Lambda_Aurigae> just send a \n
[08:30:09] <cehteh> i havent done that yet, but its on my todo list
[08:30:36] <cehteh> yes or configure your terminal only using \n .. but i'd like to stay with the defaults
[08:30:53] <liwakura> i guessed \n only was the default
[08:31:05] <Lambda_Aurigae> hell, hook up two serial ports together and talk between them on one computer and see what works and what doesn't on your particular implementation.
[08:31:17] <cehteh> anyway for line editing/cursor positioning i need to send quite more bytes than i receive already
[08:31:33] <liwakura> cehteh: the echo back was just for testing
[08:31:59] <cehteh> i have a commandline interface for configuring things
[08:32:08] <liwakura> neat
[08:32:17] <cehteh> but things get ugly when one copy pastes a lot text into that
[08:32:49] <julius> liwakura, dont know if its relevant, but the bluetooth android app that i use as a serial console wants \r\n or it wont show the data
[08:32:55] <julius> the data is send by a avr
[08:32:59] <cehteh> i'll add a heuristic for that later, no need to echo shitloads of text back when one pastes a lot stuff into it
[08:33:24] <liwakura> julius: thanks, do you know what the app appends when writing?
[08:33:42] <julius> yes, one second
[08:34:05] <Lambda_Aurigae> yanno,,,my old vt102 terminal has the option to do \n or \r\n
[08:34:29] <cehteh> just ignore \r and fine
[08:34:37] <liwakura> ... you have an vt102, Lambda_Aurigae? like a real one?
[08:34:41] <cehteh> then it wirks with \n and \r\n
[08:34:43] <Lambda_Aurigae> yeah.
[08:34:56] <Lambda_Aurigae> it has a problem with the power supply right now.
[08:35:04] <Lambda_Aurigae> I've been too lazy/busy to futz with it.
[08:35:04] <julius> liwakura, \r\n for example: if you send the avr abc it will receive first a, then b, then c, then \r, then \n
[08:35:24] <liwakura> so \r\n in both directions...
[08:35:41] <julius> the avr sees first the \r and then the \n, but yes
[08:36:15] <liwakura> i think i'll make an implied \r if the avr sees an \n first and actually handle those two differently
[08:36:41] <julius> liwakura, http://paste.pound-python.org/show/kxorwiITAqYf5l71dAkW/ in USART_RX_vect you can see how i "read" the data from my mobile and turn on a led
[08:36:51] <cehteh> you need to configure on the avr if it should send \r\n (likely yes, thats the usual default)
[08:37:11] <cehteh> and when receiving you just trop \r on the floor
[08:37:14] <cehteh> drop
[08:37:30] <cehteh> then everything worlks well in most cases
[08:37:35] <liwakura> hm
[08:38:06] <liwakura> julius: i see, you also go via the "drop \r" method
[08:38:16] <cehteh> i bet there are some esoteric options where you can use \r only or \n\r .. but i wont care (\n\r will work already)
[08:39:02] <Lambda_Aurigae> I use the \r when using terminals....just means carriage return or move cursor all the way to the left on this line...good for retyping over the last line on the screen as an updating scroll line or something.
[08:39:30] <liwakura> yeah, also know that trick from old dos ages
[08:39:35] <cehteh> Lambda_Aurigae: yes sure as control sequence in the other direction
[08:40:03] <Lambda_Aurigae> \r was used on teletypes to "erase" or XXXX over a line of data sent by accident.
[08:40:46] <liwakura> Lambda_Aurigae: the \r\n split is because of typewriter machines
[08:40:53] <Lambda_Aurigae> yup.
[08:41:14] <Lambda_Aurigae> you needed both to go to the start of the next line.
[08:41:38] <liwakura> im just a bit pissed because its inconsistent on my shell
[08:41:53] <cehteh> works for me :D
[08:42:10] <Lambda_Aurigae> you could send lots of data with \r\n at the end of each line then at the end just send a bunch of \n\n\n\n\n to feed the paper out without wasting time moving the printing head back to the \r position.
[08:42:24] <cehteh> wasnt there \f for that
[08:42:30] <Lambda_Aurigae> formfeed, yea
[08:42:31] <cehteh> formfeed
[08:42:47] <julius> theBear, you get one too
[08:42:59] <Lambda_Aurigae> for continuous roll feed machines some didn't have a true formfeed.
[08:43:10] <cehteh> lol
[08:43:12] <Lambda_Aurigae> that was added,,,,later.
[08:43:13] <cehteh> roll feed :D
[08:43:25] <Lambda_Aurigae> hey, I've worked with roll feed machines.
[08:43:56] <Lambda_Aurigae> my first duty assignment in the military, we used asr-700 and ksr-700 teletypes that printed on thermal roll paper.
[08:44:18] <cehteh> yeah reminds me about an accident at a host .. one employee accidentally dumped the whole database on such a roll feed high performance pinwriter at weekend, no one was there to stop it
[08:44:40] <cehteh> you know this high performance pinwriters with multiple printig heads
[08:44:44] <Lambda_Aurigae> hooked to a dual processor mini computer TI-980b
[08:45:09] <Lambda_Aurigae> have heard of but never seen one in person cehteh
[08:45:40] <liwakura> god traveling with the DB has gotten such a hassle in the last decade http://www.dieselcrew.ch/web/aktuell/dw/20150317-ice-dfb.jpg
[08:45:48] <Lambda_Aurigae> I like the high speed ibm printers that used a metal ribbon with all the characters on it and 132 hammers
[08:46:12] <theBear> wtf irc ? we auto-loading links in non-foreground channels now ?
[08:46:30] <liwakura> theBear: its client-specific
[08:46:44] <theBear> or maybe punishing me for dropping something on f1
[08:47:11] <theBear> liwakura, of course, i was using an affectionate term for my long-time client/window-where-the-important-stuff-happens :)
[08:47:59] <theBear> and thanks to bumping "the good old help key, that EVERYONE uses regularly" ultimately discovered my buddy is still as always was
[08:48:33] <theBear> i honestly didn't even think about using f1 intentionally for the first 15+ years of using computers where it was by-default/fixed as help-key
[08:49:06] <theBear> and when i have tried recently, i only discovered that xfce doesn't have a lotta documentation fleshed out, but hey, fortunately it all works pretty ok mostly :)
[10:49:00] <Jartza> I don't know anyone who thinks f1 is really helpful :)
[10:49:50] <LeoNerd> f1?
[10:50:00] <Lambda_Aurigae> I use it sometimes.
[10:50:14] <Jartza> me too. it turns down the keyboard brightness :D
[10:50:16] <Lambda_Aurigae> when playing KSP
[10:50:28] <LeoNerd> Sun Type 5 keyboards have a dedicated 'Help' key
[10:52:10] <Jartza> some keyboard from distant past had red "AIDS" button in it.
[10:52:13] <Jartza> I can't remember what
[10:52:32] <Jartza> might have been some kind of vt100 terminal
[10:53:19] <LeoNerd> The BBC micro had red function keys
[10:53:29] <LeoNerd> And they were labeled f0 to f9 too.. none of this 1 to 10 or 12 nonsense
[10:53:39] <LeoNerd> The 0 even had a nice strike through it
[10:53:47] <LeoNerd> *nostalgic sigh*
[10:53:49] <Lambda_Aurigae> commodore had multi-function keys....4 of them.
[10:54:01] <Jartza> yea
[10:54:07] <Jartza> f1, f3, f5 and f7
[10:54:12] <LeoNerd> http://chrisacorns.computinghistory.org.uk/Pics/BBCB3M.jpg look at those.. lovely
[10:54:13] <Jartza> without modifiers
[11:17:43] <Evidlo> Jartza: So that modulation scheme ended up not working on my radio. It worked fine on a breadboard, but when I used the radio i would get ringing on every edge
[11:18:22] <Jartza> mmkay
[11:18:30] <Jartza> did you try slower speeds?
[11:18:57] <Evidlo> Yes. I think it was the square edge that caused it
[11:19:02] <Jartza> might be
[11:19:10] <Jartza> that could be softened a bit though
[11:19:26] <Jartza> or maybe it just needs some filtering
[11:19:38] <Evidlo> Yea, I'm not really filtering it at all. I'm just decoupling it with a 1uF cap
[11:20:22] <Jartza> it might work better with comparator
[11:21:23] <Evidlo> What do you mean
[11:21:31] <Evidlo> the problem is in transmission
[11:25:02] <Jartza> do you have oscilloscope pic or something about the rining?
[11:25:06] <Jartza> ringing
[11:26:35] <Evidlo> I do not, but I can get one in a few hours
[11:26:54] <Jartza> mmkay
[11:27:57] <lorenzo> anyone with a mcp9808 around?
[11:28:01] <lorenzo> or similar Microchip sensor
[11:28:32] <lorenzo> I'm writing some code for mcp9804 but it's probably portable to the entire product line too :/
[11:42:34] <Jartza> lorenzo: nope, but doesn't look too hard
[11:43:27] <Jartza> looks nice sensor, though
[11:43:33] <Jartza> might be suitable for my needs too
[11:44:48] <lorenzo> Jartza: yeah, I've just sampled mcp9808 too
[11:45:14] <lorenzo> looks like the only difference between the two (besides from accuracy) is the product ID in one of the registers.. so it should work
[11:45:24] <lorenzo> https://github.com/lcafaro/avr-mcp9804
[12:30:29] <Evidlo> Jartza: do you know if data -> audio needs to be rebiased at 0V after decoupling?
[12:30:55] <Evidlo> or rather data -> mic in
[13:00:38] <Jartza> Evidlo: you mean "audio out"?
[13:01:12] <Evidlo> Jartza: No im talking about transmitting
[13:01:19] <Evidlo> the sending side
[13:03:07] <Jartza> isn't that audio out? :)
[13:03:23] <Jartza> no, just feed it through cap and it'll be fine
[13:04:29] <Evidlo> Jartza: But what about the voltage level? Isn't the voltage from a mic way smaller than 5V?
[13:05:53] <Jartza> hmm
[13:07:56] <Jartza> true
[13:08:58] <Jartza> Evidlo: just a sec
[13:11:44] <julius> got a 12v computer fan here, says 0.05a on it. does this mean that the resistance is 100omh? just attaching it between +12v and the collector of a 547b seems to work
[13:12:00] <julius> 547 can withstand 200ma iirc
[13:12:51] <julius> the resistors for the 547 are calculated for working as a switch
[13:13:25] <Jartza> Evidlo: https://i.imgur.com/6s6f10D.png
[13:13:37] <Jartza> that's the circuit I've used
[13:15:48] <Evidlo> Jartza: yeah I did something similar, but I still got awful ringing on the receiving end
[13:16:38] <Jartza> maybe that's receiver problem?
[13:17:52] <Jartza> Evidlo: did you try just driving the signal in receiver through series resistor?
[13:23:58] <Evidlo> No. I haven't yet. I don't think that will fix the ringing issue though
[13:24:39] <Jartza> depends what the ringing looks like
[13:56:15] <Evidlo> OK. So I think I get it now. The built in LPF is too sharp, and this causes the edge to ring
[13:56:33] <Lambda_Aurigae> take a file to it.
[15:01:17] <julius> with a 200ohm resistor my atmega32 would have to provide 25ma for ~20-100ns under electrical characterisitcs in the datasheet it says maximum current per pin: 40ma. so 25 is probably a safe value?
[15:02:35] <cehteh> at what frequency?
[15:03:19] <cehteh> for very short times you can exceed the 40mA a lot (pwm)
[15:03:57] <cehteh> its then more about duty cycle and how much current goes on average
[15:04:49] <julius> its a mosfet, does duty cycle matter?
[15:05:03] <julius> doesnt it just need current to switch on?
[15:05:49] <julius> 25khz
[15:08:42] <cehteh> yes but with 25khz it means it switches on/off 25000 times a second
[15:08:52] <julius> ah yes
[15:09:06] <julius> im gonna order drivers
[15:09:15] <cehteh> heh
[15:09:40] <julius> but how do you calculate the amperage over time?
[15:10:02] <cehteh> dunno, likely not simple
[15:10:24] <cehteh> with a square wave its just the duty cycle
[15:10:52] <cehteh> but you carge a cap, that means the voltage rises and current decreases
[15:10:56] <julius> lets assume that, 50% duty cycle means?
[15:11:23] <cehteh> i really dont know the exact calculations there
[15:11:42] <julius> would be interresting
[15:11:50] <cehteh> but i am pretty sure that you can exceed the 40mA a lot when you do PWM
[15:12:04] <cehteh> see datasheet, 40mA is under DC characteristics
[15:12:47] <cehteh> i dont know how much, but my gut feeling is that 5-10times the current are possibly ok
[15:13:08] <cehteh> if you find anything on that topic tell me :)
[15:17:01] <julius> i got the 40ma from absolute maximum characteristics
[15:17:58] <cehteh> https://www.mikrocontroller.net/topic/114657
[15:21:55] <julius> oh, the avr also acts as a 25ohm resistor on exit
[15:21:58] <julius> on pin i mean
[15:23:15] <julius> i read some posts from the first responder (benedict) he seems to know what hes doing, he wrote a lcd driver for some pollin display
[15:24:20] <julius> thing is even with the 23ma that is currently drawn (assuming 225ohm resistance) a led on another pin stops blinking and does not resume blinking even after i disconnect the mosfet
[15:30:04] * theBear is in no condition for this, thus wanders off confusedly
[15:35:27] <cehteh> julius: do you have a small ceramic cap very close to VCC?
[15:35:35] <cehteh> 100nF at least
[15:37:33] * cehteh ordered shitloads of 100nF caps and adds them everywhere :D
[15:38:41] <cehteh> https://pbs.twimg.com/media/CdOGmipWEAAA-Ak.jpg:large .. really everywhere, lm317 driving leds there :D
[15:40:44] <julius> would that keep my led blinking because of a little buffer?
[15:44:05] <grafi_> Is it a common way to handle interrupts by setting a flag in the interrupt handler/vector, and then check the flag in the main while loop and do the routines there?
[15:44:34] <LeoNerd> That's very common, yup
[15:44:36] <LeoNerd> I do that all the time
[15:44:39] <julius> yes
[15:44:47] <LeoNerd> Where "a flag" is "set the runnable state on a tasklet", that my main loop works on
[15:45:02] <LeoNerd> Most of my ISRs are just some variant on { task_schedule(TID_FOO); }
[15:48:21] <grafi_> Ok, is it bad practice to do the routines directly from the handler/vector?
[15:48:43] <PoppaVic> side-effects
[15:50:11] <grafi_> Like I may overlaod the interrupt handler if the routine takes to many cycles?
[15:50:58] <julius> yes
[15:51:08] <julius> get out of there as fast as possible
[15:54:48] <grafi_> Ok, I see. I need to read an ADC value at a 50 Hz interval, not sure which solution to go for
[15:57:53] <grafi_> Both works since 50 Hz is pretty slow, but unsing the main while loop for reading is best practice/most professional?
[15:58:04] <grafi_> using*
[15:59:57] <PoppaVic> I think you are confusing yourself
[16:02:06] <grafi_> Maybe?
[16:02:10] <PoppaVic> Primarily, there are like "3 times" - 1) the main program loop; 2) an "event"; 3) critical code that should not be interrupted.
[16:02:26] <PoppaVic> #3 should be small and rare and short;
[16:02:41] <PoppaVic> #2 can happen more often, it's still short because..
[16:02:54] <PoppaVic> #1 This is where we want to handle almost everything
[16:04:16] <PoppaVic> In theory, (and I am sure a lot of examples and apps over the years), a lot of code could be tossed into #2 because they felt it was the same as #3
[16:05:23] <PoppaVic> thing is, the smaller, tighter and slower the target/project/client, the less leeway you have for delays and interrupting the main task
[16:06:30] <PoppaVic> so, this is why a lot of folks will loop and check flags in that main loop.
[16:09:42] <grafi_> I think I understand, thanks for the explanation! The project is only a small demonstration of how to read an ADC value using interrupt, and I want to follow best practices since it's going to be reviewed
[16:10:09] <PoppaVic> do it both ways, demonstrate the difference.
[16:10:58] <grafi_> Good idea
[16:11:23] <PoppaVic> iirc, the adc likes to waste time, so the difference would be of interest to folks.
[16:11:54] <PoppaVic> (something like the ADC wants so many samples before it's happy?) idk.
[16:16:17] <Lambda_Aurigae> well, you should always sample once and throw it away before relying on the input.
[16:16:30] <Lambda_Aurigae> at least, once after reset/poweron
[16:17:08] <PoppaVic> Lambda_Aurigae: I was trying to remember more about it.. Like they take so many clocks? IT was something like eeprom and flash write wait-around. I forgot wtf I read or where
[16:17:31] <Lambda_Aurigae> well, it does take some time to do an analog sample too.
[16:18:01] <Lambda_Aurigae> you can either start it and let an interrupt capture it or start and loop until it finishes.
[16:18:06] <Lambda_Aurigae> loop and test
[16:21:20] <PoppaVic> yeah, and that was something like I recall, hence the idea of writing it both ways.
[16:21:31] <Lambda_Aurigae> I believe an ADC conversion actually can vary in the time it takes to complete depending on the input voltage.
[16:22:40] <Lambda_Aurigae> I could be wrong on that but,,,
[16:34:38] <Jartza> avr adc always gives result in same amount of clock cycles
[16:34:49] <Jartza> iirc, in attiny85 it's 13 clock cycles to sample adc
[16:34:55] <Jartza> except the first read, which is 25 clocks
[16:35:26] <Jartza> and people always say "forget the first reading from adc" but that's not entirely true
[16:35:30] <Lambda_Aurigae> ok..then it's another ADC that is variable.
[16:35:52] <Jartza> only when you _switch_ to internal reference voltage, it takes 1ms for the adc to give correct results
[16:39:29] <Jartza> also, when changing inputs, you have to be careful when you change it
[16:39:45] <Jartza> because you might get one sample from the previous input even after changing it
[16:40:07] <Jartza> I think that's behind the "always sample once and discard" -rule :)
[17:01:40] <julius> could it be that you calculate the maximal switching frequency of a mosfet like this: 1/(t rise + t fall) ?
[17:57:22] <julius> ping
[17:57:52] <Lambda_Aurigae> pong
[17:58:06] <julius> :)
[17:58:32] <julius> looks like the rest died...wanna split their shit 50/50?
[17:58:54] <Lambda_Aurigae> I got enough shit of my on.
[17:58:59] <Lambda_Aurigae> own
[18:07:47] <liwakura> what?
[18:19:04] <Jartza> darn
[18:19:12] <Jartza> why doesn't anyone make 4-pin MCUs? :)
[18:19:30] <Lambda_Aurigae> kind of useless.
[18:19:34] <Lambda_Aurigae> 2 i/o pins?
[18:19:40] <Jartza> yes :D
[18:19:58] <Lambda_Aurigae> 6-pin is the smallest I've seen.
[18:20:01] <Lambda_Aurigae> so, cut 2 off.
[18:20:05] <Jartza> heh
[18:20:07] <Jartza> naa
[18:20:16] <Jartza> I have those 6-pin MCUs
[18:20:23] <Jartza> I run VGA out of them
[18:20:25] <Jartza> 8 colors
[18:27:03] <cehteh> consider the ibutton a 1 pin mcu :D
[18:28:15] <Lambda_Aurigae> there's at least 2 there.
[18:29:06] <PoppaVic> does the ibutton get an iphone?
[18:29:41] <Lambda_Aurigae> icrap
[18:29:51] <PoppaVic> me two
[18:31:09] <Jartza> well
[18:31:10] <Jartza> https://www.youtube.com/watch?v=qucJMObCUpI
[18:31:12] <Jartza> this is attiny5
[18:31:27] <Jartza> yes. sot23-6 chip. 32 bytes of ram, 512 bytes flash (256 instructions)
[18:31:38] <Jartza> 12MHz external osc :)
[18:34:10] <cehteh> no internal osc?
[18:34:21] <Lambda_Aurigae> it's not stable enough for vga
[18:34:21] <cehteh> ah your thing ok
[18:34:25] <cehteh> yes i know
[18:34:35] <cehteh> but would save a pin
[19:29:17] <julius> with a computer power supply, can i use the 5v line for the transistor base and the 12v line on the collector to switch a 12v component?
[19:29:30] <julius> they both got the same ground, right?
[19:29:43] <Lambda_Aurigae> correcct.
[20:29:43] <Evidlo> Jartza: Here is the input and output. You can see how bad the ringing is http://imgur.com/a/MG9FM
[20:47:48] <Casper> julius: common ground yes, and yes you can. However, there is a small precaution that you may need to take: 5V line often need a minimum load to stay in regulation, so a 5 ohms 10W resistor may be needed if you have issues with the 12V line
[20:50:42] <Valen> if this is a PC power supply I have used a 20W bulb on the 5V line
[21:08:44] <Valen> 12v bulb that is
[21:08:58] <Valen> so it was pulling less but still enough to get the 12 somewhere near right
[21:09:09] <Valen> that said though 12v supplies from china are so damn cheap these days
[22:52:20] <Casper> might need to get one soon
[22:52:40] <Casper> I plan to install 75W of led strip in the kitchen