#avr | Logs for 2013-11-15

Back
[01:46:10] <Gerritjan> Hey all
[03:43:51] <jerkey> hey
[03:44:18] <jerkey> i am now reading an atmega2560 with a DASA programmer (serial bitbang) and reading the flash is going to take about 14 hours
[03:47:47] <Xark> jerkey: Hmm, that seems somewhat sub-optimal. :)
[03:48:18] <jerkey> i have to back up my 3d printer's brain before i reprogram it arduino style.. just in case i need to go "back" to the original firmware.
[03:48:58] <jerkey> and when i read it with an arduino-as-ISP i only got 262106 bytes, and i think i need 262144 bytes. so i'm trying it another way.
[03:49:06] <jerkey> i wish i hadn't misplaced my usbtiny ISP
[04:41:08] <megal0maniac_afk> jerkey: That can't possibly be right. Are you using a usb to serial adapter?
[04:42:43] <theBear> i suspect he was exaggerating the time, also it's POSSIBLE (but like he says, best to be safe) that the code is a little smaller than the flash size, therefore hte file was smaller than 262,144
[04:44:05] <megal0maniac_afk> If he was using a usb to serial converter, it really can take hours :P
[04:44:40] <megal0maniac_afk> I wonder if the chip is bootloaded? Because bootloaders can read the flash back to you. Sans the bootloader itself, of course, but still
[04:52:53] <megal0maniac_afk> Can anyone else not access this? I get white screen http://www.ti.com/general/docs/lit/getliterature.tsp?genericPartNumber=pcf8574&fileType=pdf
[05:01:12] <theBear> which reminds me, yeah, he said he gonna do it arduino style, so it SOUNDS like he got a 3d printer controller programmed 'normally', and after a backup of the compiled code he gonna bootloaderise it and put his own stuff on there ?
[05:01:42] <theBear> i get offered a pdf, you want me to 'mirror' it for yer ?
[05:02:07] <megal0maniac_afk> Na, it's alright thanks. I'm just using the nxp one. Weird that it won't work though...
[05:02:16] <theBear> wtf ? how did i dload 1.3mb that fast ?
[05:02:34] <megal0maniac_afk> You're in 'MURICA!
[05:02:45] <theBear> errr, i am ?
[05:02:49] <megal0maniac_afk> Aren't you?
[05:03:01] <theBear> i sure hope not
[05:03:15] <megal0maniac_afk> Haha okay. I have been mislead
[05:03:21] <theBear> misled indeed :)
[05:03:41] <theBear> http://www.youtube.com/watch?v=zDCNJdeM9PE i think this guy comes from where i do
[05:04:26] <megal0maniac_afk> I like these. And I really like the top comment
[05:04:46] <megal0maniac_afk> Not so much the spammy nature of it, but it's cool nonetheless
[05:05:08] <theBear> heh indeed
[05:05:12] <theBear> and c+h DO rock my world
[05:05:29] <theBear> i remember the first vid they did, i'm impressed how well it translates, i was worried when they announced it
[07:46:05] <hackvana> This project is unbelievable: http://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollers
[07:46:17] <hackvana> I know the guy who did it. He designed the CNC mill we built
[12:39:43] <megal0maniac_afk> hackvana: That is pretty amazing :D
[14:28:03] <bangoo> hello
[14:29:34] <bangoo> i'm thinking of interfacing an attiny to an atmega. What would be the simplest method? UART?
[14:29:41] <OndraSter> UART or SPI
[14:29:55] <bangoo> the attiny would only need to send voltage data to the atmega when it polls it so i'm thinking 8+8 bits or 8+8+8
[14:31:00] <bangoo> the atmega also has another device on its spi bus so i'd have to probably change the spi bus speed in between if i'd use that, yes?
[14:31:02] <N1njAway> UART would take the least pins, but your ATTINY may not have a dedicated UART and/or SPI. Check the datasheets.
[14:31:14] <bangoo> yeah this is a 45. it has something called USI?
[14:32:59] <N1njAway> USI will do a stripped-down version of SPI, or I2C with a few caveats.
[14:33:14] <N1njAway> I2C might be your best option.
[14:33:22] <N1njAway> What is the reason for your offboard TINY?
[14:33:34] <N1njAway> We may be able to make better suggestions knowing the broad-stroke.
[14:34:13] <megal0maniac_afk> Thunder! Lightning! Do I stay on IRC or unplug all valuables? :)
[14:34:36] <bangoo> the tiny acts as a multi cell li-po battery cut-offer
[14:35:11] <megal0maniac_afk> zlog
[14:35:17] <bangoo> the mega in the circuit controls multiple devices so I was thinking offboarding this would be the best bet, in order to make things a bit more clear cut
[14:35:22] <RikusW> megal0maniac_afk: I usually unplug
[14:36:02] <bangoo> N1njAway: the mega has a mem card on spi, a parallel lcd, and a few other peripherals which require it to stream data to them
[14:36:05] <N1njAway> Just add UPS's to everything and you're good :)
[14:36:32] <bangoo> so i'd need the tiny to just send out a voltage number when i poll it with the mega, does this sound unreasonable?
[14:36:53] <N1njAway> bangoo: Seems sensible. I'd probably suggest looking at doing it with I2C/two-wire since the USI will easily do that, and provided you can afford the I2C pins on the Atmega. Then you can also avoid sharing the SPI, too :)
[14:36:58] <bangoo> the tiny itself does adc on the vin, and controls a mosfet which cuts off the main line when it drops too low
[14:37:05] <N1njAway> Yeah seems like a good plan :)
[14:37:23] <bangoo> The other thing is, I also have another i2c hooked on to the god damn mega =D
[14:37:50] <N1njAway> That or just let the ATMEGA monitor the same voltage via one of it's onboard ADC's. Buffer it through an op-mp before sending it over, then nothing the ATMEGA does could ever inadvertantly affect that signal :)
[14:38:15] <bangoo> yeah that's an option
[14:38:19] <N1njAway> i2c is easy to share since it's based on electronic chip address. Just make your TINY respond to something that isn't what your other chips are.
[14:38:38] <bangoo> I have never used i2c, this could be a good drill on that
[14:38:48] <bangoo> or well, not slaves
[14:38:49] <megal0maniac> I actually started with I2C today
[14:38:50] <N1njAway> If you are just needing to monitor a voltage and that's it, I would honestly just tie it to an Atmega ADC, use one pin, and call it good.
[14:38:57] <megal0maniac> It's a bit of a mission
[14:39:23] <N1njAway> That's quite a lot of overhead on the digital and software side just to read a voltage. If you were doing other multipurpose things I'd say it would be far more justified. :)
[14:39:34] <megal0maniac> Yeah, seems wasteful to dedicate an attiny to that task when you have a mega as well
[14:39:40] <bangoo> N1njAway: yeah, i need two pins on the mega though
[14:39:56] <bangoo> of which i'm trying to conserve pins, also mem space
[14:39:57] <N1njAway> megal0maniac: I prefer SPI over I2C - I2C has a lot more overhead with it getting started, and is especially difficult if you don't have a logic analyzer for debugging.
[14:40:25] <bangoo> because i need to write a thing which detects the lipo voltage and counts the cells, and then has hardcoded cutoffs for when to turn the mosfet off
[14:40:28] <megal0maniac> Luckily, I do have the LA
[14:40:34] <megal0maniac> Helps a lot
[14:40:45] <N1njAway> For battery management stuff, I'd advocate the Tiny being dedicated to the task. FAR less to go wrong, far simpler design.
[14:41:01] <N1njAway> megal0maniac: Which one?
[14:41:10] <bangoo> N1njAway: yeah, i guess you could say that?
[14:41:24] <bangoo> It measures the voltage, and cuts the rest of the circuit off when needed
[14:41:52] <N1njAway> bangoo: But again I would say don't even bother doing the digital comm if all you need is to read one single voltage value. Tie to an Atmega ADC pin and you're done.
[14:42:07] <N1njAway> (with optional op-amp for healthy paranoia and good design practivce!)
[14:42:17] <megal0maniac> N1njAway: Logic 8
[14:42:28] <bangoo> N1njAway: oh yeah I didn't get you at first =D
[14:42:49] <N1njAway> megal0maniac: Oooh excellent. Then you should do well with I2C since the Logic's have a very nice protocol decoder for I2C
[14:43:23] <N1njAway> megal0maniac: It just takes some fiddling since there's more registers to set up to get I2C active vs SPI. But nice to only have the two wires. Tradeoffs, tradeoffs.
[14:43:28] <N1njAway> megal0maniac: How did your test go?
[14:44:12] <bangoo> yeah, i'll just put the tiny controlling the fet, and deliver the voltage to the screen with just the mega adcing the vin
[14:44:24] <bangoo> thanks!
[14:46:06] <N1njAway> Sure. I always like to advocate a solution to the specific question asked, then provide alternative thoughts as to how to accomplish the boarder task at hand. :D
[14:46:46] <N1njAway> I can't stand it when I ask a specific question, and The Internet suddenly goes "Why would you want to do that? Do this instead!" without understanding of context. I asked the specific question for an answer. :)
[14:48:47] <N1njAway> Like one time I was searching for white toner cartridges for a very special application of printing on transparencies or black paper where such a thing might be important. Someone asked that question on a forum, and all the replies were along the line of "You're an idiot, you don't need to print white! You just don't print any there, and the paper is white!" assuming someone is always printing on
[14:48:47] <N1njAway> standard, white office paper. :)
[14:49:40] <N1njAway> Obviously if someone is asking for white toner, they probably have a good reason asking for it. :)
[14:49:46] <N1njAway> But anyhow...
[14:49:55] <N1njAway> bandoo: Let us know how it turns out!
[14:50:53] <bangoo> yeah soldering this thing up soon
[14:50:57] <megal0maniac> N1njAway: Pretty well, I think. Just too much parroting and not enough demonstation of understanding.
[14:51:15] <megal0maniac> And I've been using aery32. It has some nice libs for I2C
[14:52:12] <bangoo> hate these to220-5's for perfboard q_q
[14:52:52] <N1njAway> megal0maniac: Ahh that should help a lot, then. I generally always tend to roll my own at the register level because I'm a bare-metal masochist. (as opposed to a Full Metal Alchemist)
[14:53:28] <megal0maniac> Heh :P
[14:53:44] <megal0maniac> I want to move to atmega or xmega once I get it workince. Not sure which
[14:53:48] <megal0maniac> *working
[14:53:50] <N1njAway> bangoo: Just bend pins 2, 4 out in front to a new row and use 1, 3, 5 on the back row. Ideally slip some tiny heat-shrink over 2/4.
[14:54:04] <bangoo> that's what i'm doing :)
[14:54:11] <N1njAway> Perfect
[14:54:14] <bangoo> but it won't fit the raster have to bend one of the back row pins a bit also
[14:54:47] * N1njAway sticks a 208-QFP strategically in to bangoo's protoboard with some VERY clever pin mangling.
[14:55:20] <bangoo> 208? sure
[14:58:02] * carabia throws lga1156 into ninjas breadboard with very clever jumper wires
[14:58:42] * N1njAway bonds out dies to magnet-wire and puts them in carabia's
[14:59:06] <carabia> where's beaky
[14:59:17] <megal0maniac> He's PWMing an SMPS
[15:00:24] <megal0maniac> With an attiny, somewhere
[15:00:24] <carabia> arduinos don't come attiny flavored do they
[15:00:24] <carabia> so chances are it's an xmega rather than an attiny
[15:00:57] <N1njAway> He's pretty insistant about it being an ATTINY
[15:01:01] <N1njAway> He loves them.
[15:01:14] <N1njAway> I think they are stored in an anti-stat bag beneath his pillow at night.
[15:06:36] <carabia> It's one thing to ask a question to legitimately seek an answer or a new perspective on a matter than asking a butt ton of them and learn nothing
[15:07:07] <jerkey> i told him that a resistor divider would work fine, so he would just do it and get the hitpoints
[15:07:14] <carabia> But, he's a great lil beam of sunshine around
[15:07:24] <carabia> We really love him
[15:07:32] <megal0maniac> It's funny that I (am able to) answer many questions. I've learnt a lot from observation, yet I can basically do shit-all with a microcontroller :D
[15:07:48] <carabia> i love you too megal0maniac
[15:08:04] <megal0maniac> carabia: I even made a channel for people who love you
[15:08:09] <carabia> I know :)
[15:08:38] <megal0maniac> Nobody joined after waiting 3 days :(
[15:08:39] <megal0maniac> Not even you
[15:08:40] <carabia> i can't do jack shit when it comes to programming :(
[15:08:41] <jerkey> i am 87% through reading the flash of an atmega2560 with a dasa programmer. it has been 12 hours.
[15:09:00] <megal0maniac> theBear: Come look at this!
[15:09:08] <megal0maniac> He wasn't exaggerating
[15:09:10] <RikusW> jerkey: get a better programmer
[15:09:21] <jerkey> i had one and i lost it
[15:09:31] <megal0maniac> jerkey: RikusW will hook a brother up :P
[15:09:38] <megal0maniac> Where the hell is Tom?
[15:09:45] <carabia> where the hell is matt
[15:10:15] <carabia> jerkey: that's pretty cool. You should make a blog of something about it
[15:10:24] <carabia> of=or
[15:11:28] <megal0maniac> "Hour 4. Still programming
[15:11:31] <megal0maniac> "
[15:11:31] <megal0maniac> Reading. Whatever
[15:11:33] <megal0maniac> RikusW: Sell him something, quick! If you use DHL it might get there before his current one finishes :P
[15:11:49] <RikusW> lol
[15:11:50] <N1njAway> Yeah, we love beaky. :)
[15:12:16] <RikusW> he is a hopeless romantic when it comes to any tech... :-P
[15:12:41] <carabia> he is reading that one book... :)
[15:12:43] <N1njAway> I tend to be comically-lighthearted in a lot of my replies, but never hostile. I'll poke fun enough at myself as much as I may other people. :)
[15:13:42] <carabia> I told him not to take me seriously, as I hope he would never touch mains :(
[15:13:49] <N1njAway> This is a fairly pointless channel to actually troll in - it's pretty easy to spot someone asking legitimate technical questions who simply is inexperienced. :)
[15:13:51] <RikusW> We should ask beaky to build us an oil rig, since he is from UAE... :-D
[15:13:55] <carabia> no-one should actually take me seriously :D
[15:14:07] <N1njAway> carabia: Same!
[15:14:19] <carabia> ^5
[15:29:34] <megal0maniac> That's the questions on everyone's minds
[15:33:22] <N1njAway> Oh no, not that question again.
[15:33:37] <N1njAway> The programmer is in error - 256KB devices will read back 262,144
[15:34:25] <N1njAway> I just triple-checked this last night by dumping an ATMEGA2560 via ISP, and all 262,144 bytes are accounted for :)
[15:34:59] <N1njAway> 0x00000 thru 0x1FFFF
[15:40:14] <jerkey> 90% 45646.09s
[15:41:48] <jerkey> 45646.09/90*100/3600=14 hours
[15:42:42] <Duality> If I upload code, are the ports on the chip set to anything ?
[15:42:52] <Duality> or do they keep thier previous state ?
[15:45:13] <jerkey> When the chip is reset, all ports are set to input states i believe. I don't think that will change during programming, except for the MISO pin which is sending data from the chip to the programmer
[15:46:13] <N1njAway> jerkey: Input yes, though technically tri-stated, since inputs can have internal pull-ups applied in normal operation. :)
[15:46:53] <megal0maniac> I used the pull-up to drive a resistor once. Was chuffed with myself :P
[15:47:07] <megal0maniac> Probably shouldn't do that
[15:47:14] <megal0maniac> OMG
[15:47:23] <megal0maniac> *to drive an LED
[15:47:36] <N1njAway> I drive resistors all the time!
[15:47:46] <N1njAway> If you drive them hard enough, they start to emit light even!
[15:47:50] <N1njAway> LER's
[15:48:01] <N1njAway> Which inevitably become SER's
[15:48:42] <RikusW> megal0maniac: using a pullup like that will result in a dim led, but no damage
[15:48:52] <RikusW> its like 40k...
[15:49:43] <megal0maniac> Superbright white (just tried to spell that "wight") works alright. Reduces component count, too :)
[15:50:56] <N1njAway> RikusW: Just checked the datasheet, as I was curious. You are spot-on with that. Reset pull-up internally is 30-60K, I/O pull-ups are 20-50K
[15:51:30] <N1njAway> For some reason I was thinking they were a bit lower.
[15:53:06] <Duality> cool thanks for the clear answers all !
[15:53:31] <N1njAway> Duality: Hey, we try! Sometimes we're even useful. :)
[15:55:39] <Duality> any reason why I am unable to upload code when I got a lcd connected, but when I disconnect it, it wil upload ? it's not on any of the spi pins
[15:56:49] <Duality> and now it uploads perfectly,
[15:59:20] <Duality> does there need to be a pullup on the reset pin ?
[15:59:44] <N1njAway> No, the internal one is generally fine. For real paranoia you can add a 10K, but it's not necessary.
[16:00:16] <N1njAway> Duality: Is the LCD powered and such when attempting the upload?
[16:00:48] <N1njAway> Generally as long as the SPI bus pins aren't shared (without appopriate resistors added) there shouldn't be a conflict.
[16:03:25] <Duality> N1njAway: it is powered when i upload
[16:04:13] <megal0maniac> Woah. SPI is easy
[16:05:48] <megal0maniac> http://pastebin.com/Q77a7sYF
[16:06:50] <N1njAway> megal0maniac: Told you!
[16:07:12] <megal0maniac> And I only have I2C eeprom :/
[16:07:30] <megal0maniac> Although I imagine that once I figure out the set-up, it shouldn't be too difficult
[16:07:32] <N1njAway> megal0maniac: I2C done in the same register-twiddling manner will be probably 2-3x longer.
[16:07:55] <N1njAway> Just a few more things to set up and conditions to check.
[16:08:04] <megal0maniac> UART is much the same, correct?
[16:08:17] <megal0maniac> It's essentially SPI sans clock and enable
[16:08:26] <N1njAway> Yes, UART is about the same as the SPI. A bit more if you do interrupts.
[16:08:29] <megal0maniac> (i.e. async)
[16:08:56] <N1njAway> You have the baud rate divisor set register, and 3-4 config registers.
[16:09:50] <N1njAway> megal0maniac: Also, on your code, immediately after your while() statement there you can do "incomingData = SPDR;" so you can capture the byte that was potentially pushed in on the MISO pin.
[16:10:42] <megal0maniac> Ah, good to know :) Was actually wondering about that
[16:10:43] <N1njAway> In practice, you would also have a GPIO pin toggle in there that works as the CS/frame sync at the head and tail of your SPI transaction series of bytes.
[16:10:46] <Duality> can you do communication that way ?
[16:11:01] <megal0maniac> I know you need to write a byte to read a byte
[16:11:14] <N1njAway> megal0maniac: Remeber that in SPI, the master always drives the bus, so if you want to read something, you need to write something.
[16:11:17] <Duality> like between computer and chip ?
[16:11:56] <megal0maniac> Got it :)
[16:11:59] <N1njAway> megal0maniac: Generally you'll have something where you write out at least one byte before reading a response, then you cycle out a bunch of null writes.
[16:12:34] <N1njAway> megal0maniac: Because if you think about it, the end device doesn't know what to reply with until it generally has at LEAST a byte of data to know what to return. Unless it's only returning the same one-byte, over and over and over.
[16:13:07] <megal0maniac> Duality: You can, if you have a way for computer to do SPI
[16:13:20] <N1njAway> So usually you write at least a byte or two, then clock out a bunch of dummy bytes when you read the data fields back.
[16:13:30] <megal0maniac> UART is easier since you can just level shift an interface that already exists on a PC
[16:13:38] <Duality> megal0maniac: yea like a intermidiate chip, say your programmer (my case usbasp? )
[16:13:49] <N1njAway> It's actually quite a bit of fun when you are working at both ends of the chain, so you can build up your message protocols :)
[16:14:11] <megal0maniac> N1njAway: Why the CS/framing? Do you need to bit-bang /SS?
[16:14:20] <megal0maniac> I noticed it went low and just stayed low
[16:14:23] <N1njAway> Duality: Yeah, UART is probably the dirt simplest way to exchange data with a PC
[16:14:27] <N1njAway> megal0maniac: IMPORTANT ----
[16:14:54] <N1njAway> megal0maniac: If your AVR is functioning as the MASTER, you ABSOLUTELY MUST SET /SS AS AN OUTPUT PIN OR TIE HIGH
[16:15:10] <megal0maniac> I did :)
[16:15:25] <OndraSter> yes
[16:15:32] <OndraSter> there is nothing better than enabling SPI before doing that
[16:15:39] <OndraSter> and wondering why randomly the chip will stop booting :D
[16:16:06] <N1njAway> Even though /SS is driven under software control, /SS will function as an INPUT in SPI MASTER mode, and if left floating as an input, will randomly abort your SPI transactions.
[16:16:19] <OndraSter> (because you are trying to send some data on SPI which accidentaly fell into slave)
[16:17:12] <megal0maniac> http://i.imgur.com/w5GbYS9.png
[16:17:34] <N1njAway> megal0maniac: And the CS/SS/framing line is necessary for two reasons -- 1> it tells which slave device (assuming there is more than one) the transaction is active for and 2> it provides the framing data necessary to tell a slave "Hey, we are starting with byte 0 of a new transaction. Resync your state-machine."
[16:18:41] <megal0maniac> So /SS is just supposed to stay high?
[16:18:48] <megal0maniac> I mean low
[16:19:09] <N1njAway> Else in all but the most trivial transactions (single byte messages) it would be very difficult to tell the start of the message without higher-level mechanisms at work in the protocols.
[16:19:38] <OndraSter> you can use it as output just fine
[16:19:39] <N1njAway> What you call "ENABLE" should be low for the duration of the transaction.
[16:19:40] <OndraSter> but not as input
[16:20:01] <N1njAway> SS is fine as an output, but if it is set as an input it MUST remain high during a master transaction.
[16:20:08] <megal0maniac> I thought that /SS was essentially used for framing
[16:20:39] <megal0maniac> But clearly not. It just stays low
[16:34:49] <megal0maniac> Might be silly, I know, but before I hit the pillow (with my head, gently), am I doing something horribly wrong here or is it reasonable? http://pastebin.com/Q77a7sYF
[16:35:07] <megal0maniac> I prefer to double check with the small stuff. Prevent bad habits and whatnot
[16:38:29] <OndraSter> why the #define s
[16:38:34] <OndraSter> aren't they already #define d?
[16:38:40] <OndraSter> in the iom...h
[16:38:46] <OndraSter> which is automatically included
[16:40:28] <megal0maniac> Uuuuh. Yes. And included explicitly too
[16:40:35] <megal0maniac> I forget about that :)
[16:54:34] <megal0maniac> Well I added framing, but there's only 250nS between frame bit toggling and first clock pulse. Might be a little quick :P
[17:05:11] <N1njAway> mega: (sorry, had to step away)
[17:06:14] <N1njAway> mega: When in master mode /SS is entirely under software control when set as an output, so it can make a useful chip select line
[17:11:08] -card.freenode.net:#avr- [freenode-info] channel trolls and no channel staff around to help? please check with freenode support: http://freenode.net/faq.shtml#gettinghelp