#avr | Logs for 2013-11-23

Back
[04:26:30] <beaky> hello
[04:26:45] <beaky> what are some common mistakes people do when using ATmega328p
[04:27:03] <beaky> e.g. not connecting decoupling caps or LC filters, not enabling pullup resistors, not powering down devices, etc.
[04:31:48] <w|zzy> beaky: using the arduino framework.
[04:35:07] <beaky> whats a bitwise trick to 'assign' to a set of bits
[04:35:18] <beaky> atm I do one step to and the bits, then a second step to or the bits
[04:35:50] <beaky> im sure i can do it in one line with xor
[04:36:05] <abcminiuser> Not unless you want to flip them rather than set/clear
[04:36:17] <abcminiuser> Can do it with one C line, but it's still the same instructions
[04:37:58] <beaky> ah
[04:38:03] <beaky> ok how od i do it in one c line
[04:38:45] <beaky> register = register & mask | bits?
[04:41:22] <beaky> amirite?
[04:41:23] <beaky> :D
[04:41:29] <beaky> yay i am a bitwise hacker
[04:44:44] <abcminiuser> Jupp
[04:47:13] <ambro718> beaky: probably best to use parantheses with those bitwise ops, not all people know the grouping rules (including me ;)
[04:47:32] <w|zzy> rum abcminiuser ?
[04:48:25] <abcminiuser> All good now
[04:49:33] <ambro718> beaky: if you ever work with more advanced uC's, you'll find registers such as FOO_SBAR and FOO_CBAR for atomically setting and clearing the bits of FOO_BAR
[04:51:58] <ambro718> for example in AT91 you can enable a pin by PIO_SODR=1<<pin. Unlike on some AVRs where some ports are not accessible using the sbi and cbi instructions.
[04:58:56] <specing> ambro718: frisms? :D
[05:00:50] <ambro718> specing: no, arduino due (well, a chinese clone)
[05:01:06] <ambro718> just got my printer running with it (and ported my firmware to it)
[05:02:11] <ambro718> omg that thing has a 210MHz cpu
[05:02:36] <ambro718> ah it's an external ram thing
[05:03:23] <ambro718> I like my SRAM better :)
[05:09:09] <ambro718> looks like this lol, http://www.pasteall.org/pic/show.php?id=62980
[05:10:15] <ambro718> and stupid wires are picking up interference from the stepperss, hence the capacitors on the board to filter the ADC readings a bit
[05:10:18] <specing> spaghetti mess
[05:10:21] <specing> *slurp*
[05:13:57] <beaky> hello
[05:14:02] <beaky> why is my avr adc readings off by 40mV
[05:14:31] <ambro718> what's your vcc (or aref if you use that)?
[05:14:38] <beaky> my vcc is +5.10V
[05:14:49] <beaky> (using vcc as aref)
[05:15:07] <ambro718> you use 10-bit mode right?
[05:15:14] <beaky> yw
[05:15:15] <beaky> yes
[05:15:19] <beaky> is there more resolution?
[05:15:27] <ambro718> how do you know it's off?
[05:15:32] <carabia> there is 256 bits
[05:15:35] <carabia> best for PWM
[05:15:44] <beaky> i use meter and it says its 40mV higher than what my avr is reading
[05:16:04] <carabia> ah
[05:16:04] <ambro718> beaky: if you connect the adc pin to gnd, what is the reading?
[05:16:06] <carabia> use meter
[05:16:25] <carabia> if you connect the adc pin to mains what does it read?
[05:16:37] <beaky> 0
[05:16:37] <carabia> aref to mains also
[05:16:46] <OndraSter> :D
[05:16:55] <carabia> and remember grounds
[05:17:03] <ambro718> beaky: and to vcc?
[05:17:44] <beaky> it says +5V
[05:17:50] <beaky> 1023
[05:18:02] <ambro718> but you said your vcc is 5.10V
[05:18:16] <ambro718> so your adc-->voltage equation is wrong
[05:19:18] <beaky> oh
[05:19:37] <beaky> also my pwm is not woring
[05:19:49] <beaky> i am using PD5 (OC0A) of my ATmega328p
[05:19:59] <specing> ambro718: that 210 (actually 192) MHz thingie runs Gentoo just fine :)
[05:20:15] <ambro718> yeah right ;)
[05:21:16] <ambro718> until you need to compile glibc heh
[05:21:32] <specing> ambro718: compiles are done in qemu-arm on a ivy i5 :)
[05:21:42] <specing> in an LXC virtual machine
[05:21:51] <ambro718> and that is faster?
[05:22:14] <specing> apart from that it actually works (64MB ram, remember?)
[05:22:44] <specing> ambro718: qemu-arm with distcc is *very* fast
[05:22:49] <ambro718> well when I was running Gentoo on a Marvell something 500MHz (TS-7800), compiling on qemu was barely faster than on the board
[05:23:33] <ambro718> ah yes, I remember I used distcc, but not with qemu. It did speed up but there's lots of other things that have to run on the board (dep calculations, make...)
[05:24:01] <ambro718> oh and c preprocessor
[05:24:30] <ambro718> just Amdahl's law in action ;)
[05:24:35] <specing> I just emerge binpkgs
[05:25:02] <specing> Or even just rsync the VM onto the board
[05:32:44] <OndraSter> why do you need qemu-arm when you can just get distcc and gcc-arm on your normal x64 machine?
[05:45:44] <specing> OndraSter: because python (among others) don't wanna crosscompile
[05:53:09] <OndraSter> that'S weird
[05:53:44] <ambro718> OndraSter: he runs the build process in a qemu-arm *and* uses distcc to run compilers on x64 machines
[05:54:03] <ambro718> because his qemu-arm is faster than his board (for running the build process itself)
[05:54:08] <OndraSter> ah
[05:54:39] <ambro718> Once upon a time I managed to cross-compile an entire stage3. The overlay is very out of date now, though, https://code.google.com/p/ambro-cross-overlay/wiki/Instructions
[05:55:03] <ambro718> that included Python cross-compilation
[05:59:12] <ambro718> so does Atmel not distribute a pre-built ARM toolchain, like it does for AVR?
[06:00:33] <OndraSter> don't they?
[06:00:48] <ambro718> I can't find it as a download.
[06:04:17] <specing> ambro718: yeah it is a lot of work to get it rolling; and my time > computer's time
[06:05:10] <ambro718> luckily I didn't waste *too* much time to figure it out. USE="-fortran -openmp" crossdev -s4 --genv 'EXTRA_ECONF="--disable-libstdcxx-time"' armv7m-softfloat-eabi
[06:05:36] <ambro718> and download and link ASF right, that wasn't hard to figure out
[06:06:04] <ambro718> unfortunately most people don't use Gentoo so I can't just tell everyone who wants to compile my stuff to use crossdev
[06:06:27] <specing> you can tell them to use Gentoo :)
[06:06:34] <ambro718> yeah lol
[06:29:14] <beaky> is a SMPS a good use of an ATmega328p
[06:29:31] <twnqx> no
[06:31:29] <beaky> why
[06:33:31] <twnqx> mainly, voltage range
[06:33:52] <twnqx> you need a power supply for the avr which can't be the smps itself...
[06:36:00] <ambro718> why not?
[06:40:27] <beaky> you can bootstrap the power
[06:40:29] <beaky> using a zener
[06:42:48] <specing> beaky: then do it and stop asking questions to which you already believe to have an answer
[06:43:36] <beaky> i tried it and smoked my avr
[06:44:01] <specing> AND DONT CRY ABOUT RUINING AVRS WITH YOUR STUPID METHODS
[06:44:22] <specing> SHUT UP AND GET OUT
[06:44:25] <specing> !!!
[06:44:57] <beaky> i am getting good results, 20mV ripple
[06:45:49] <beaky> i trust my avr for mission critical apps like power supply :D
[06:45:59] <beaky> i love my avr :D
[07:07:53] <ambro718> beaky: when it's complete will you make it open source? I've always wondered how PSUs work ;)
[07:08:14] <beaky> yes iw il github it and blog it
[07:09:35] <ambro718> where's your blog?
[07:09:35] <beaky> i dont have one yet :(
[07:09:35] <ambro718> okay ;)
[07:09:42] <beaky> but i took everything i know from some appnotes
[07:10:01] <beaky> atmel has some smps appnote using atxmega
[07:10:08] <beaky> microchip has a bunch using pics
[07:10:57] <specing> ambro718: there is an appnote for SMPSs by atmel and I've also made one for highschool (75V ripple though)
[07:11:28] <ambro718> lol 75V :D
[07:11:46] <specing> yea, exactly my feeling
[07:21:25] <twnqx> bah, crap efficiency with dropping 230V to 5V with a zener
[07:21:32] <twnqx> even for a few mA
[07:41:41] <beaky> it will drop for the first few miliseconds, then switch to the output supply :D
[10:45:38] <kdehl> How do I know what capacitance to use for what crystal frequency?
[10:46:53] <kdehl> I Never mind, found something.
[10:46:55] <kdehl> -I
[11:05:14] <kdehl> So... I can't just connect a crystal and two capacitors to a 8088 or a 6502, I need some clock generating curcuit in between?
[11:05:30] <kdehl> Like one can do to an AVR.
[11:12:14] <kdehl> Or a crystal oscillator.
[11:38:10] <jerkey> beaky read about the 34063 chip and the TL494C chip, and this http://www.futurlec.com/Linear/LM2575HVT-5pr.shtml
[16:54:48] <N2TOH> What are the odds of getting an AVR chip to work as an I2C master with a 1039Hz clock?
[17:00:43] <Casper> why wouln't it work?
[17:01:07] <N2TOH> i2c runs @ 100KHz/400KHz no?
[17:02:26] <N2TOH> I'm looking to boot up an ATmega644P with a Linear tech LTC6904 programmable clock in place of the crystal oscillator. the 6904 "boots up" @ 1039Hz"
[17:03:18] <N2TOH> I then need to change the output of the 6904, whit the AVR part running on a 1039Hz system clock. I plan on setting it to 16MHz
[17:04:29] <N2TOH> the end goal is to have a firmware configurable system clock speed.
[17:54:08] <Tom_itx> N2TOH, you would need to change the fuse settings for external oscillator and that wouldn't be compatible with a crystal input to it
[17:54:17] <Tom_itx> or external clock
[17:54:41] <N2TOH> eh?
[17:55:00] <Tom_itx> you change the avr clock source to external clock
[17:55:06] <Tom_itx> not crystal
[17:55:36] <N2TOH> I can change the fuse settings for an external clock. my concern is that the external clock starts off at 1039Hz
[17:55:38] <Tom_itx> then tie the input to the clock in
[17:55:45] <Tom_itx> so?
[17:55:57] <Tom_itx> i guess you can try it and see
[17:56:05] <Tom_itx> pretty damn slow
[17:56:43] <N2TOH> my concern is will I be able to tell the i2c device to change it's output frequency when the AVR part is using a 1039Hz clock
[17:57:19] <Tom_itx> what clock speed does the i2c need?
[17:57:55] <Tom_itx> you would have to check the ckdiv fuses and see if you can get what you need
[17:58:02] <N2TOH> I can check again, but I am under the impression it's around 100KHz
[17:58:07] <Tom_itx> and the i2c sck source
[17:58:29] <N2TOH> aha!
[17:58:30] <Tom_itx> and see if it has a divider as well... i can't remember
[17:58:43] <N2TOH> I should just give it a try
[17:59:02] <N2TOH> will be awesome when I can specify the clock speed with the 6904
[17:59:43] <Tom_itx> chicken & egg thing?
[17:59:51] <N2TOH> so I can just include the desired speed in the sketch
[18:00:01] <N2TOH> not if I use the SPI version the 6903
[18:00:04] <Tom_itx> arduino?
[18:00:20] <N2TOH> AVR/ arduino same thing
[18:00:26] <Tom_itx> not so much
[18:00:35] <Tom_itx> i know what i put in an AVR
[18:00:45] <Tom_itx> you don't know what they put in the arduino libs
[18:00:50] <N2TOH> you can wipe the bootloader out of an Arduino
[18:00:59] <Tom_itx> i would recomend that
[18:01:03] <N2TOH> LOL yeah
[18:01:16] <Tom_itx> then you are welcome to stay and chat :)
[18:01:21] <N2TOH> :)
[18:01:35] * N2TOH should I pour another beer with my meal?