#avr | Logs for 2015-09-19

Back
[00:18:31] <FrankD> 16 gauge IS butter
[00:19:37] <JoeLlama> 16 gauge what FrankD?
[00:20:04] <FrankD> Casper said his new 18V cordless jigsaw was mean because it cut 16 gauge 'metal sheet'
[00:20:17] <FrankD> im assuming he means steel or aluminum and not something exotic
[00:20:19] <FrankD> :P
[00:23:32] <Casper> yeah steel
[00:24:18] <Casper> but a 15" cut took like 10-15 seconds... hard to tell because it cut too fast and had to stop because the vice that hold the sheet was getting in the way...
[00:24:47] <Casper> my electric skill one would have took easy 5 minutes to cut it
[02:12:50] <gorroth> anyone here using the RPi for SPI comms with an AVR? i'm wondering how i choose a ~SS pin via the spidev.h header/kernel device
[02:13:25] <gorroth> looks like the RPi can use both the CE0 or CE1 pins as ~SS, but i don't see how to choose in the spidev.h header, unless i need to load GPIO and pull it low myself
[02:23:03] <gorroth> oooooooooooooooooooh
[02:23:09] <gorroth> there is /dev/spidev0.0 and spidev0.1
[02:23:19] <gorroth> i think that selects ce0 or ce1 for me when i'm writing
[02:23:36] <gorroth> s/is/are/
[05:24:26] <ambro718> Hi. Is it possible to force gcc to perform a certain computation between two register writes, and not move it outside if it feels like? My code looks like this: REGISTER=1; compute_some_stuff(); REGISTER=0; I want to make sure the computation actually happens in between to ensure a minimum time delay between the register writes.
[05:29:13] <ambro718> I'm thinking about something like this: REGISTER=1; int result = (int volatile)calc((int volatile)input); REGISTER=0;
[05:29:43] <ambro718> but not sure if it's enough, maybe it's not and I would need to do it via volatile variables not just casting to volatile
[05:31:15] <Jartza> yeah, declare the variables to volatile
[05:31:18] <Jartza> casting is not enough
[05:31:50] <ambro718> yes I'll do that
[16:19:47] <Kobboi> just for my information, how long does it typically take to flip a pin value (low>high or high>low)? can it not be in effect after execution of the relevant instruction?
[16:20:01] <Emil_> Kobboi: ?
[16:20:06] <Emil_> One cycle
[16:20:48] <Emil_> if the instruction is PORTX=somechar then it takes exactly one cycle
[16:21:02] <Emil_> Of course, it can happen sooner in the cycle
[16:21:17] <Emil_> but it's a hard minimum
[16:21:54] <Emil_> Flipping the bit is also just one cycle, avr has its own instruction for that
[16:22:02] <Kobboi> ok
[16:22:11] <Emil_> Almost everything is one cycle in avr
[16:22:14] <Emil_> some are 2
[16:22:36] <Kobboi> i guess it makes sense that it happens before the instruction cycle is over
[16:22:49] <Kobboi> kinda by definition of instruction
[16:24:16] <Kobboi> but suppose i would increase the frequency... cycles become shorter, but the physics of moving charges does not. is it conceivable to reach a situation where the physics still allows the CPU to function but the external pins cannot be flipped fast enough?
[16:24:29] <Kobboi> (again, hypothetical "learning" question)
[16:27:28] <Emil_> Nope
[16:27:40] <Emil_> The cpu will cease to function long before you no longer can flip bits
[16:27:51] <Emil_> because memory is not fast enough
[16:28:01] <Emil_> Also you'll burn the chip :D
[16:28:02] <Emil_> ":D"
[16:28:05] <Kobboi> lol
[16:28:07] <Kobboi> ":D"
[16:28:33] <Kobboi> good point on the memory
[16:29:32] <Kobboi> so i guess it makes sense that this data is not in the datasheet
[16:30:06] <Kobboi> too bad, i was interested to know some ballpark figure
[16:32:11] <Emil_> Kobboi: tell me me more?
[16:34:19] <Kobboi> i don't know :) i'm just a beginner :) when i want to communicate with an external device there are certain setup and hold times i need to take into account. i was just wondering whether on the "transmit" side, the microcontroller, there are also limitations
[16:34:37] <Kobboi> but i guess the answer is that those are hidden by the concept of microcontroller instructions
[16:34:43] <Kobboi> that guarantee state
[16:39:12] <Jartza> sure there are limits
[16:39:46] <Jartza> have you seen that the gigahertz race has sort of ended in last few years
[16:40:14] <Jartza> now we just add cores or use other means to make processors faster
[16:40:37] <Jartza> it starts to boil into the fact that moving electrons is slow
[16:40:50] <Jartza> moving light would be faster
[16:41:17] <Emil_> Mostly it boils down to inefficiency
[16:41:34] <Emil_> and the fact that we don't have the materials to handle that high switching speeds
[16:41:36] <Jartza> that too
[16:41:54] <Jartza> too much lost as heat
[16:42:21] <Jartza> anyway, in mcu world those are rarely an issue
[16:42:41] <Jartza> as we're usually talking megahertz instead giga
[16:47:31] <Jartza> also moore's law has reached "saturation point"
[16:48:57] <Kobboi> but isn't all of this "internal" to the chip? my question was in the (incorrect?) assumption that the external pins and how they are implemented would be somewhat "slower"
[16:51:07] <Jartza> I don't really understand the question, what is "external pin"?
[16:55:51] <Emil_> Jartza: just a pin
[16:55:57] <Emil_> outside of the microcontroller
[16:56:13] <Emil_> Kobboi: also if you have enough stray capacitance that can fuck you up
[16:56:36] <Jartza> pin outside microcontroller makes no sense :)
[16:56:42] <Jartza> it's called wire
[16:56:45] <Jartza> :D
[16:58:41] <Kobboi> then why is it called a pinout
[16:59:10] <Emil_> Because Jartza is playing with out
[16:59:10] <Kobboi> i really tought the numbered things were called pins
[16:59:11] <Emil_> you*
[16:59:15] <Emil_> they are pins
[16:59:22] <Emil_> No need to call them extern or anything
[17:00:12] <Jartza> yes, they are pins.
[17:01:22] <Jartza> if you mean "external" as "outside the core of a chip", then pin is basically just metal pin wired to the core
[17:01:45] <Jartza> but still very much part of the chip
[17:02:37] <Jartza> of course there is miniscule delay while electrons travel through the wire, if you mean that?
[17:02:39] <Kobboi> i guess what i meant was that of all things that represent a 0 and a 1 in a microcontroller, i thought that maybe there was a difference in properties between the internal 0/1s and the things that are meant to become pins
[17:03:01] <Jartza> ahh well okay
[17:03:09] <Emil_> Miniscule
[17:03:11] <Kobboi> pins can be input, can be output
[17:03:12] <Emil_> Marginal
[17:03:20] <Emil_> really, really small
[17:03:23] <Kobboi> stuff like that makes them more complex than just a regular thing in the ALU or something
[17:03:31] <Emil_> ah
[17:03:32] <Emil_> nope
[17:04:06] <Kobboi> sorry for also still having to understand my own question
[17:04:46] <Kobboi> i guess only a marginal, really really small fraction of people that buy arduinos wonder about it :/
[17:05:07] <Jartza> it's good to wonder
[17:05:14] <Jartza> and good to ask questions
[17:05:19] <Jartza> too few people do that
[17:05:46] <Jartza> I just also have problem trying to understand the question :)
[17:06:02] <Emil_> Kobboi: it's super fucking awesome that you think about those questions
[17:06:27] <Jartza> I think what you mean is like pin switching speed compared to cpu speed or something like that?
[17:06:33] <Kobboi> yes
[17:06:41] <Jartza> ahh
[17:08:23] <Jartza> basically in microcontroller world, you don't have to worry about it
[17:08:50] <Jartza> there is of course some switching delay, but again as Emil_ said, marginal :)
[17:10:38] <Kobboi> is there any impact of what i connect to the pin?
[17:10:50] <Jartza> of course
[17:11:16] <Kobboi> then i don't understand :)
[17:11:31] <Kobboi> suppose i have a pin connected to another pin of an external device
[17:11:36] <Jartza> and when extending the question to "bus" like i2c and spi, there are several factors that affect the bus speed
[17:11:37] <Kobboi> i want to set it to 1
[17:11:48] <Kobboi> but after the instruction, i'm not sure it actually IS ?
[17:11:54] <Jartza> it is
[17:12:26] <Roklobsta> well that can depend...
[17:12:31] <Jartza> yes
[17:12:49] <Roklobsta> the system might think it is, but if it's open drain or collector and pulled down.
[17:13:19] <Roklobsta> Kobboi: Most I/O have a facility for you to set a pin but also read back what it's actual state is on the physical pin.
[17:13:22] <Jartza> there's then electrical issues like the capacitance and in the case of bus, maybe some pull-up resistors, filters, etc.
[17:13:47] <Jartza> sometimes the electrical rise-time of the signal can be slow
[17:14:24] <Roklobsta> the actual state might be controlled by external factors
[17:14:30] <Jartza> yes
[17:14:55] <Jartza> or the potential :)
[17:15:03] <Roklobsta> if you tie a pin directly to ground or VCC there is no amount of code that can change the pin state.
[17:15:04] <Kobboi> so the setting of a 1, is just configuring the hardware to make it so that in normal conditions you would read a 1
[17:15:36] <Roklobsta> yes
[17:15:47] <Jartza> yeah
[17:15:49] <Kobboi> when i reread that it sounds so stupid
[17:15:50] <Roklobsta> you next to make sure the external conditions allow it
[17:16:03] <Kobboi> like "of course that's what it means"
[17:16:07] <Kobboi> "duh"
[17:16:22] <Jartza> no, it's a good question
[17:16:38] <Jartza> now that we understand what you mean :)
[17:17:23] <Kobboi> :)
[17:17:31] <Jartza> unfortunately for the external conditions there is no specific answer, it depends on multiple things
[17:19:05] <Jartza> and even more unfortunate is, that electronically, what gets out from pin is analog :)
[17:19:28] <Emil_> Well
[17:19:28] <Jartza> and there's no 0 or 1 state in analog :)
[17:19:37] <Emil_> it doesn't really matter that is is analog
[17:19:45] <Emil_> It's fuzzy logic with fixed thresholds :D
[17:20:16] <Jartza> it's good to understand it's analog
[17:20:20] <Emil_> True
[17:21:22] <Kobboi> another thing i always fail to understand
[17:21:39] <Jartza> I once had hard time talking to i2c unless I dropped the speed to ridiculously slow
[17:21:40] <Kobboi> is statements like "... can deliver X amount of current..."
[17:22:08] <Kobboi> and what will happen when I arrange for conditions that disagree with that
[17:22:26] <Jartza> well, I found out that in my box of resistors labelled 4k7 I had accidentally put 47k resistors too :)
[17:22:48] <Jartza> and in this circuit they ended up in my breadboard as i2c pull-ups
[17:22:49] <Kobboi> will it break/burn for Y > X ?
[17:22:49] <Emil_> The chip will or will not break
[17:22:52] <Kobboi> will I only get X?
[17:23:09] <Emil_> the probability of breaking will usually drastically increase as you go over more than what is allowed
[17:23:21] <Kobboi> suppose I attach 3 LEDs in parallell
[17:23:23] <Jartza> looking at that i2c bus with scope was fun
[17:23:39] <Jartza> more like a rollercoaster than digital signal
[17:23:42] <Kobboi> will they burn only a little bit? or will they pull more current from the MCU so it will start to fail
[17:24:05] <Emil_> Resistance will drop (albeit marginally)
[17:24:36] <Emil_> Also leds are physically that you can't put them in parallel without a current resistor for each and every single one of them
[17:25:27] <Emil_> if you just have a single current limiting resistor and after that three leds one will be lit much more than the others (usually)
[17:26:21] <Emil_> and if you your desired current times 3 is higher than what the leds can stand then all of them will probably break
[17:26:31] <Emil_> desired current per each led
[17:26:33] <Emil_> that is
[17:27:14] <Kobboi> i think my question is about voltage sources, current sources and there level of "perfection" and deviation from ideal models
[17:27:17] <Kobboi> but i'm not sure :)
[17:27:36] <Emil_> You don't think through before you ask, which at the moment is fine because I don't mind :D
[17:27:40] <Emil_> anycase
[17:28:04] <Kobboi> i'm asking because i'm having trouble getting my mind around it
[17:28:06] <Emil_> Am I right that you have three leds that you'd like to light from one pin?
[17:28:16] <Emil_> And that one pin is a microcontroller pin
[17:28:19] <Kobboi> no, i might have the wrong example
[17:28:30] <Kobboi> suppose i short a pin to ground that
[17:28:42] <Kobboi> or no
[17:28:44] <Kobboi> a 1 ohm resistor
[17:28:51] <Emil_> A microcontroller vcc pin to ground?
[17:29:06] <Kobboi> no
[17:29:13] <Kobboi> a digital output
[17:29:26] <Emil_> Sorry by that I mean a pin that has vcc on it
[17:29:29] <Kobboi> yes
[17:29:52] <Kobboi> well a pin whose hardware is configured to in normal cases put vcc on tit ;)
[17:29:54] <Kobboi> -t
[17:30:41] <Emil_> without current limiting resistors your chip will probably die
[17:30:47] <Kobboi> what are the reasons to say that a pin can only deliver X amount of current
[17:30:53] <Emil_> Heat
[17:31:04] <Emil_> that is, internal resistance
[17:31:13] <Kobboi> it's not like a tap that you can not open further then
[17:31:19] <Kobboi> because that does not break
[17:31:24] <Kobboi> it just won't give you more
[17:31:33] <Emil_> Yes it will if you try to ask for a bazillion pressure
[17:32:02] <Emil_> or
[17:32:02] <Emil_> rather
[17:32:03] <Kobboi> are there situations in electronics where the statement "...can only deliver X amount of current... "only implies "I cannot give you more, and don't even bother trying"
[17:32:14] <Kobboi> or is it always "if you ask me for more, i will break"
[17:32:42] <Emil_> Suppose you have a pipe
[17:32:57] <Emil_> and that pipe is somewhat smooth on the inside
[17:39:24] <Kobboi> Emil_: hm?
[17:41:00] <Emil_> Kobboi: if you open a valve to it
[17:41:23] <Emil_> and you don't restrict the amount of water that will pass through it
[17:41:34] <Emil_> the water will rip and break the pipe
[17:41:58] <Emil_> Kobboi: sure there are current sources :D
[17:42:14] <Emil_> but voltage sources are "more natural" per se
[17:50:28] <Jartza> well
[17:50:36] <Jartza> you can do the same with copper pipe :)
[17:50:45] <Jartza> just regular copper water pipe
[17:51:19] <Jartza> push water through it so that it's speed rises above 3m/s and the copper will eat itself out
[17:51:58] <Jartza> tiny copper particles will transfer to water and then the water becomes abrasive and more copper particles will transfer to water...
[17:52:37] <Jartza> it's called erosion :)
[17:56:36] <Kobboi> i'm off to bed, thanks a lot for the feedback guys
[17:57:39] <Kobboi> if you have any literature that addresses questions like this (i.e. more than your average typical textbook i guess?), recommendations welcome