#avr | Logs for 2013-10-07

Back
[02:16:53] <megal0maniac_afk> HKCMD: Yes
[02:17:21] <HKCMD> ok, thank you
[02:19:42] <megal0maniac_afk> It will program any device which supports ISP programming, and doesn't have more than 64KB flash. AVR, obviously
[02:24:16] <HKCMD> for programming, any limitation in the flash memory of the target ?
[02:25:16] <HKCMD> isit up to 64KB ?
[02:26:56] <megal0maniac_afk> Isn't that what I said?
[02:28:32] <HKCMD> ok
[02:29:41] <megal0maniac_afk> Yes, up to and including 64KB
[02:30:38] <HKCMD> ok, thank you
[03:35:14] <Tom_itx> HKCMD, you don't need an isp programmer for that chip. it has an onboard bootloader from atmel. you use FLIP or dfu programmer and a USB cable to program it
[03:35:49] <Tom_itx> if you use an ISP programmer on it, you will overwrite the bootloader more than likely
[03:36:01] <HKCMD> ok
[03:36:46] <Tom_itx> to enter programming mode, take the HWB pin low and then pull RESET low
[03:37:01] <Tom_itx> and FLIP should recognize it
[03:38:47] <Tom_itx> most USB chips come with the onboard bootloader
[04:18:14] <HKCMD> ok
[14:59:01] <MannImMond> \\
[16:47:54] <MarkX> hi
[16:48:36] <Casper> o/
[16:48:47] <MarkX> i have a basic program, all it does is tell me if a user button on my breakout board is pressed or not. it sends this message over usb
[16:49:17] * N1njaneer pushes MarkX's buttons
[16:49:25] <MarkX> ... lower
[16:50:24] <Casper> N1njaneer: I think he mean the power button on his powerbar on the floor...
[16:50:30] <MarkX> http://pastebin.com/fJcDdVT2
[16:50:37] <MarkX> here is the code
[16:50:39] <MarkX> very very basic
[16:51:12] <MarkX> the issue i'm having is, it appears that pinb is constantly changing
[16:51:17] <MarkX> even if i'm not touching the button
[16:51:33] <N1njaneer> What else is on PORTB?
[16:51:33] <Casper> is portb connected to anything else?
[16:51:42] <Casper> do you have pullup/down on each pins?
[16:51:48] <N1njaneer> You may want to mask off JUST the bit of interest your button is attached it.
[16:52:21] <N1njaneer> If the other PORTB pins are left floating and do not have the pull-up's enabled, waving your hand over it may be enough to change the values :)
[16:52:40] <MarkX> http://www.embeddedwirelesssolutions.com/schematics/ews_atmega32u4_breakout_board.png
[16:52:47] <MarkX> here is the schematic of the breakout board i'm using
[16:52:48] <N1njaneer> Also I assume you either have an external biasing resistor used with the button?
[16:53:06] <N1njaneer> Because I don't see anywhere you are setting the pull-up for the PORTB inputs
[16:53:24] <MarkX> do i need to pull up unused pins?
[16:54:16] <N1njaneer> Not necessarily, but it's a good idea to either tie them to ground on the traces OR turn on the pull-ups so the pins don't float. Oscillation like you are seeing is one problem, and as a side effect it can cause the device to consume more power, etc.
[16:54:34] <N1njaneer> Or set the unused pins to outputs, and zero them.
[16:55:33] <MarkX> hmm okay cool
[16:55:42] <N1njaneer> Which button are you referring to?
[16:55:52] <N1njaneer> Or tactile switch?
[16:56:23] <MarkX> its called a tactile switch
[16:56:25] <MarkX> on the schematic
[16:56:33] <N1njaneer> Which? There are two.
[16:56:35] <MarkX> one is for resetting the device
[16:56:40] <N1njaneer> S1 or S2?
[16:56:41] <MarkX> uhm
[16:56:53] <N1njaneer> PB7 input?
[16:57:03] <MarkX> s2
[16:57:06] <N1njaneer> For S2
[16:57:14] <Casper> MarkX: floating input will pick up ambiant electrical noise
[16:57:17] <Casper> and may oscillate
[16:57:32] <Casper> you want them set at a known state
[16:57:39] <N1njaneer> Okay, so it looks like the switch is pulling to ground. You need to enable the pull-up on PB7 pin in order to get a reliable result.
[16:57:46] <N1njaneer> Casper: That's what I mentioned above :)
[16:57:55] <MarkX> how do i enable pull ups
[16:58:13] <Casper> turning on the internal pullup is the safest way, as if you connect the pins to something you are sure to not cause a short
[16:58:14] <N1njaneer> PORTB = 0b10000000; (or 0x80) in your case
[16:58:40] <Casper> setting to output is another way, but be sure that you don't have any hard wired pin or pins that can cause issues
[16:58:51] <MarkX> aahh
[16:59:08] <Casper> also, your button also need a pullup or down, depending on your config
[16:59:14] <N1njaneer> Or use PORTB = PORTB | 0x80; if you want to affect JUST PB7
[16:59:22] <Casper> you can't just ground the pin and hope it will work :D
[16:59:22] <MarkX> so would PORTB get noise from (lets just say) PORTC as well?
[16:59:35] <Casper> also, consider debouncing your button
[17:00:01] <N1njaneer> MarkX: It will pick up noise from wherever power is present. Circuit board, traces, neighboring stuff on the die, etc.
[17:00:19] <MarkX> oh i see
[17:00:19] <N1njaneer> MarkX: An unbiased input left floating on a long trace like that is pretty much equivalent to a bad antenna :)
[17:00:28] <MarkX> heh
[17:02:02] <N1njaneer> MarkX: Basically you want to weakly pull the button up to VCC through 10-100K, so when the button is disconnected, the high-impedence input on the micro sees VCC through the 10-100K. When the button is pressed, it's practically zero ohms to GND, so the 10-100K bias practically disappears, and since it's such a high resistance there is very little current that sinks to GND via the resistor through
[17:02:02] <N1njaneer> the button.
[17:02:10] <Casper> an antenna is... a piece of wire :D
[17:03:53] <MarkX> hmm okay cool
[17:04:25] <N1njaneer> If it's a powered device it's generally not too bad and 10Ks will suffice, but if you are doing long-duration settings (for instance DIP switches, etc) on a battery-powered device, then you have to give some additional thought to using larger resistance so as to not load the battery. Using too small a resistance just burns unnecessary current in to hear. Using too large a resistance starts to
[17:04:25] <N1njaneer> negate the biasing effect. Make sense?
[17:04:50] <N1njaneer> +into heat
[17:05:11] <MarkX> yea it makes sense
[17:05:16] <MarkX> but is pulling up to VCC
[17:05:18] <MarkX> internal
[17:05:19] <MarkX> or external?
[17:05:56] <N1njaneer> But yes, getting back to your original question, set the pull-up resistor in the Atmel with PORTB = PORTB | 0x80; and then mask off PINB reads with (PINB & 0x80) so you are ONLY getting bit #7
[17:06:45] <MarkX> so just for my understanding
[17:06:49] <MarkX> if i set something as an input
[17:06:53] <N1njaneer> You can use internals for this scenario no problem. When you design PCBs, though, putting the resistor externally gives you better control over the value selected. I forget what the internal pull-ups are in the Atmel, I believe they are in the 4.7K-10K range
[17:07:33] <MarkX> using DDRB |= (0<<7);
[17:08:05] <MarkX> i then have to set PORTB |= 0x80
[17:08:06] <N1njaneer> Needs to be 1<<7
[17:08:13] <MarkX> so that it no longer floats
[17:08:14] <N1njaneer> 0 << 7 produces zero
[17:08:31] <MarkX> thats for portb though
[17:08:44] <MarkX> DDRB has to be 0<<7 to define it as an input
[17:08:45] <MarkX> doesnt it?
[17:09:11] <N1njaneer> DDRB &= ~(1 << 7);
[17:09:33] <N1njaneer> To set a zero you need to AND the contents with the inverted bitmask
[17:09:57] <N1njaneer> i.e. ABCDEFGH & 0b01111111 = 0BCDEFGH
[17:10:02] <MarkX> ah
[17:10:06] <MarkX> okay
[17:10:46] <N1njaneer> DDRB = DDRB & 0b01111111; // for clarity :)
[17:10:51] <MarkX> right
[17:10:57] <N1njaneer> That sets PB7 direction to zero
[17:11:06] <MarkX> okay cool
[17:11:11] <N1njaneer> PORTB = PORTB | 0b10000000; // for clarity :)
[17:11:12] <MarkX> making it an input
[17:11:28] <MarkX> then PORTB |= 0x80
[17:11:28] <N1njaneer> That turns on the pull-up on PB7
[17:11:37] <N1njaneer> That will do it, too.
[17:11:42] <MarkX> to make it biased?
[17:11:48] <MarkX> ah nice okay
[17:11:57] <N1njaneer> Or PORTB |= (1 << 7) like your initial example :)
[17:12:04] <N1njaneer> But yes, that will do it.
[17:12:24] <N1njaneer> Then I would do (PINB & 0x80) when you do your read and set.
[17:12:33] <N1njaneer> Also
[17:12:38] <N1njaneer> A subtle note --
[17:13:19] <N1njaneer> You may want to consider reading PINB only once -- use two variables, a newPINB and oldPINB. Set newPINB every time, then copy the value in to oldPINB.
[17:14:32] <MarkX> ....
[17:14:35] <MarkX> turns out it was my breadboard
[17:14:36] <MarkX> >_>
[17:14:50] <N1njaneer> If PINB transitions quickly or is metastable during the test, you can get two different reads of PINB in your if() and your setting of oldPINB. It's good practice to be aware of problems like that, as they fall in to race-condition/metastability problems which are generally VERY difficult to track down since they occur infrequently and are generallly not reproducable :)
[17:15:37] <MarkX> yea i think that is happening as well
[17:15:43] <MarkX> when i first made this program
[17:15:49] <MarkX> i was getting great results
[17:15:52] <N1njaneer> And as Caspter suggested you may want to debounce your inputs as well.
[17:15:54] <MarkX> and now everything is so unstable
[17:15:58] <N1njaneer> +Casper
[17:17:00] <N1njaneer> Rule of thumb I've always found -- if you see unstable and erratic results that border between working and non-working, always look for floating or unbiased inputs first and foremost. I can't count the number of times I've seen that happen in the course of debugging my own stuff, or helping others :)
[17:17:53] <MarkX> okay cool
[17:18:05] <MarkX> let me try the suggestions
[17:18:07] <MarkX> and see how it goes
[17:18:08] <N1njaneer> A very insidious one is with the SPI bus. If you are using SPI as master, you ABSOLUTELY have to either set SS to be an output, or you have to bias it to VCC as an input. If it's left floating as an input, it will cause the SPI bus to abort transfers randomly :)
[17:18:43] <N1njaneer> Give it a shot and let us know. I bet thouse couple things will fix it right up.
[18:30:55] <OndraSter> hehe once I was enabling SPI interrupt and SPI before setting the pin as input.. :)
[18:31:06] <OndraSter> and when I hooked up JTAG it would work because it would float up the SS line
[18:31:14] <OndraSter> if I disconnected JTAG it would miraclously stop working
[18:31:22] <OndraSter> took me maybe 30 minutes :D
[20:13:43] <Casper> OndraSter_: on my side, it was trying to use some ADC pins, but didn't disabled the jtag, it caused the pins to be mostly non-functional
[20:13:53] <Casper> but weirdly, it worked in digital
[20:13:57] <N1njaneer> That'll do it :)
[20:15:38] <Casper> I find atmel to be stupid from putting the jtag on the analog pins...
[20:15:54] <Fornaxian> it does tend to cause issues.
[20:15:59] <Casper> but then... probably thta it was the only pins left...
[20:16:13] <N1njaneer> Use DebugWire :)
[20:16:17] <Fornaxian> better than putting them on interrupt pins.
[21:04:27] <Vutral> hm
[21:39:43] <MarkX> N1njaneer: all that stuff you taught me today about bias and unbias. does that apply to inputs for ADC as well?
[21:40:37] <N1njaneer> With the ADC you are going to be feeding it a varying voltage level. The ADC really isn't going to do anything useful if it's disconnected :)
[21:41:12] <N1njaneer> If it's tied to, say, a potentiometer that's wired between AREF and GND, you'll always have a valid voltage going in to it.
[21:41:51] <MarkX> ah okay
[21:41:53] <MarkX> makes sense
[21:41:56] <MarkX> thanks again man
[21:41:59] <MarkX> really appreciate it
[21:42:16] <MarkX> also you should teach, your explanations are amazing
[21:42:19] <MarkX> same with Casper
[21:42:19] <MarkX> :D
[21:43:09] <N1njaneer> If you are bringing a signal in from the Big Scary Outside World, you generally want to run it through something like a rail-to-rail op-amp to buffer it before it gets in to the ADC's. Ideally you'd add something like a 100K-220K-ohm bias to ground on the INPUT to the op-amps, so if the input signal is physically disconnected, the op-amp would still see GND through the high-resistance bias, so
[21:43:09] <N1njaneer> the signal will go to "zero" when disconnected, etc.
[21:43:21] <N1njaneer> Thanks, I'm glad the explanations are clear :)
[21:44:08] <N1njaneer> (and beyond that diode clamping or tranzorbs or similar if you want to really help protect it from transients or other spikes, ESD, etc)
[22:19:29] <jadew> w|zzy, did you get the power on spikes issue on your power supply?
[22:19:52] <jadew> I might get one too and considering the options
[22:20:19] <w|zzy> Yes.. It only happens if you have had the psu on within the last 10-20mins..
[22:20:35] <w|zzy> Its not much.. it is enough to cause an led(directly connected, no resistor) to flash.
[22:20:36] <jadew> ah ha!
[22:20:38] <jadew> so it must be a cap
[22:20:42] <w|zzy> ya
[22:21:16] <jadew> interresting
[22:21:27] <jadew> looks super awesome for the price
[22:21:50] <w|zzy> Its been very very handy and cool
[22:22:05] <jadew> nice
[22:26:09] <w|zzy> There is supposedly a new "fault" haven't looked into it yet.. But its on the eevblog forum
[22:26:20] <w|zzy> Its built to a price and for that price its bloody good.
[22:26:33] <w|zzy> Also, at that price a lot more people are willing to buy it and rip it to shreds
[22:26:46] <jadew> yeah
[22:31:05] <Casper> jadew: did I told you for the record stuff?
[22:31:25] <jadew> Casper, no, did you try it out?
[22:31:54] <Casper> yes
[22:32:01] <jadew> can it record multiple channels?
[22:32:15] <Casper> it seems to simply be taking a thousand screenshot and keep them in memory
[22:32:36] <Casper> couln't find out how to save to usb beside saving them individually
[22:33:28] <jadew> I see, so it can do multiple channels recordings
[22:33:48] <jadew> was wondering about that, because my 1052E can't do it
[22:37:45] <Casper> btw
[22:37:58] <Casper> it can do math A+B A-B A*B and others
[22:38:19] <jadew> yeah, the 1052E can do that too
[22:41:57] * jadew doesn't know why there are so many haters for eevblog
[22:42:16] <jadew> I enjoy that show
[22:42:19] <w|zzy> Cause dave is a ranting aussie?
[22:44:13] <Casper> I don't understand too...
[22:44:24] <Casper> yes, he rant alot, but that's the show
[22:44:48] <jadew> not to mention that you get to learn about some really nice products
[22:45:14] <Casper> ya
[22:46:17] <Casper> and that rant about rigol that "screw up" their customers with the 70 vs 100MHz one... ok, it's annoying that they software limit, but why not? if it make it cheaper to produce...
[22:47:10] <jadew> I really don't mind software limits, they're begging to be broken :P
[22:47:54] <Casper> yeah, but even then... why not...
[22:48:19] <jadew> I do mind it however when manufacturers go out of their way to sell you junk for $$$
[22:48:34] <jadew> like data cables
[22:48:44] <Casper> ya
[22:48:47] <Casper> monster cable!
[22:51:00] <Casper> jadew: but... I need more channels :D
[22:51:13] <Casper> or current probes
[22:51:43] <jadew> heh
[22:51:57] <jadew> can't you make your own current probes?
[22:52:15] <Casper> possibly
[22:52:24] <Casper> being DC make it a bit more annoying
[22:54:11] <Casper> unless I make it with a shunt...
[22:55:12] <jadew> you can do it with an opamp fed from +x/-x
[22:55:35] <jadew> then you can handle AC
[22:55:39] <Casper> yeah...
[22:55:49] <Casper> might ends up making one or 2
[22:55:57] <Casper> or not :D
[22:56:14] <jadew> you'll need a pretty fast opamp tho, if you want to have the full bandwidth of the scope
[22:56:39] <Casper> yeah...
[22:56:50] <Casper> 300MHz opamp isn't enought
[22:57:03] <jadew> why not?
[22:57:19] <Casper> that's the gain*bandwidth product
[22:57:35] <Casper> probably want more than 3 of gain
[22:58:09] <jadew> isn't the gain vs bandwidth related to the slew rate?
[22:59:32] <jadew> http://www.analog.com/static/imported-files/data_sheets/AD8055_8056.pdf
[22:59:46] <jadew> this one has 1400V/uS slew rate
[23:00:14] <jadew> kinda hard to keep it stable but it might get the job done (you could give it a try with the signal analyzer :)
[23:00:15] <jadew> sorry
[23:00:18] <jadew> with the sig gen
[23:00:44] <jadew> costs about $3
[23:00:48] <jadew> maybe 4
[23:02:22] <Casper> now... what do I try next... flyback?
[23:02:55] <Casper> tried boost and buck... made fire (I tought those resistors was flameproof?)
[23:03:13] <jadew> heh
[23:03:18] <Casper> 19V into 47ohms 1/4W.... not an happy resistor
[23:03:32] <Casper> 7.7W :D
[23:03:38] * Xark has witnessed a few LIRs (light-emitting resistors). :)
[23:03:47] <Xark> LER* :)
[23:03:56] <Casper> arrggg... time to dress up and go outside
[23:04:12] <Casper> there is something that make noise beside the window... grrr... a box of something...
[23:07:13] <Casper> http://i.imgur.com/RPVb6k0.jpg lol
[23:07:34] <jadew> nice car
[23:08:32] <jadew> attiny25/45/85 doesn't have a 16bit timer :(
[23:10:02] <Casper> https://www.dropbox.com/s/zgcf8m8u40hhzzi/2013-09-21%2014.00.10.jpg
[23:11:03] <jadew> http://global3.memecdn.com/meanwhile-in-romania_o_236619.jpg
[23:28:30] <Casper> jadew: do you know why you shouln't use the mosfet body diodes in smps?
[23:29:41] <jadew> probably because they're weak?
[23:30:15] <Casper> rated 50A continuous
[23:30:21] <Casper> 200A pulsed
[23:30:32] <jadew> heh, then I don't know
[23:30:42] <Casper> maybe too slow?
[23:38:09] <jadew> you're trying to build a smps?
[23:38:19] <jadew> if so, make sure you're wearing protective glasses
[23:42:47] <N1njaneer> late to comment -- I've been extremely impressed with Rigol, mostly because I've demoed their products and found them quite nice for the price, and Rigol's US HQ is only 5 miles from here, so their engineers have been out here before. That and the entire Rigol US office are former Keithley guys - they know quality test and measurement equipment design. :)
[23:47:16] <GargantuaSauce> Casper: they generally have pretty high voltage drops
[23:47:26] <GargantuaSauce> like 3-5x as much as a schottky
[23:48:19] <jadew> N1njaneer, where do you live?
[23:48:54] <jadew> you sound like you're in the middle of it all :)