#avr | Logs for 2014-11-14

Back
[05:11:54] <twnqx> reading LeoNerd's las lines... right, need some more leaded solder
[05:12:11] <twnqx> normally i use leadfree though...
[05:12:54] <LeoNerd> Mmm?
[05:13:25] <twnqx> i just looked into the channel, last line from ca. 13h ago :P
[05:13:54] <twnqx> if you get solder, just be very sure you get one with a flux core
[05:14:19] <twnqx> and for small DMS parts i personally like my 0.5mm thickness
[05:14:21] <twnqx> SMD*
[05:35:47] <LeoNerd> Yah; I found some 0.3mm fluxcore. And ordered a flux pen anyway
[05:53:55] <twnqx> yeah, i strongly advise you toget one for ICs
[05:54:22] <twnqx> i have 0.35 no flux solder... works good enough for caps and resistors
[13:04:10] <`Legend`> Hello, I need some help compiling my code in Atmel Studio 6.2
[13:04:48] <Jordan_U> `Legend`: OK. What problem are you having?
[13:05:02] <`Legend`> a big one.
[13:05:26] <`Legend`> I had some code contained in one .c file in version 4.5
[13:06:02] <`Legend`> then I distributed parts of the code to other .c files to make it more 'managable'
[13:06:26] <`Legend`> things like TWI bus handling
[13:06:59] <`Legend`> I also now have all function prototypes and declaration of variables in a header file.
[13:07:08] <`Legend`> I'm having issues getting the code to compile.
[13:08:13] <Jordan_U> `Legend`: OK. What issues?
[13:08:54] <`Legend`> can't get the code to compile without errors now....like 331 of them.
[13:09:40] <`Legend`> here is my understanding.
[13:10:25] <Jordan_U> `Legend`: We can't help without the error messages or the code. Try to give as much detail as possible when asking questions.
[13:10:31] <`Legend`> I still need to include pertinant libraries in the other .c files correct? eg. avr/io.h, stdlib.h etc...
[13:12:31] <Jordan_U> `Legend`: Only if they're not included in other .h files that you are including. But with a properly guarded header it shouldn't hurt to include them multiple times, even if it's redundant.
[13:13:31] <`Legend`> I was told its not good practice to put #include statements in a .h file....
[13:14:16] <`Legend`> http://pastebin.com/jkuMwKy0
[13:16:19] <`Legend`> http://pastebin.com/bfGfuJ96
[13:16:38] <`Legend`> those are the main .c and another .c that handles TWI interface on the AVR
[13:17:37] <Jordan_U> `Legend`: What error message are you getting when you try to compile?
[13:18:55] <`Legend`> http://pastebin.com/PARRDsuK
[13:19:01] <`Legend`> that is the header file.
[13:19:42] <`Legend`> a lot of 'multiple definition of variables'
[13:22:49] <`Legend`> http://snag.gy/AaCVu.jpg
[13:24:07] <`Legend`> picture of the first few errors
[13:28:47] <twnqx> oh god
[13:28:52] <twnqx> i should have never started this
[13:29:15] <`Legend`> is that what I should be saying?...
[13:29:42] <twnqx> no
[13:29:50] <twnqx> i am just building the first layer of my LED cube
[13:29:51] <`Legend`> whats your issue?
[13:29:56] <`Legend`> ah
[13:29:58] <twnqx> and i BADLY underestimated the effort.
[13:30:12] <`Legend`> soldering?
[13:30:21] <twnqx> yes
[13:30:47] <`Legend`> hmm
[13:30:54] <`Legend`> howmany leds?
[13:31:04] <twnqx> 8x8x8
[13:31:12] <`Legend`> max7219?
[13:31:28] <twnqx> integrated controller
[13:32:08] <`Legend`> so one controller to drive all leds?
[13:32:32] <twnqx> no, one controller in each LED :P
[13:33:28] <`Legend`> I'm doing a similar project but instead of a cube its a scrolling led message board...basically same principle
[13:33:53] <`Legend`> I have the board separated into 5 8*8 sections
[13:34:25] <twnqx> but you probably have a PCB to work with
[13:34:34] <`Legend`> each 8*8 section is driven by a max7219 led driver thats takes command from an avr
[13:34:47] <`Legend`> well the leds are mounted on a sheet of plywood
[13:35:55] <`Legend`> for some reason with your project I'd imagine mounting the leds on popcycle sticks or somthing like that....
[13:36:53] <`Legend`> Hey Jordan_U:
[13:36:54] <twnqx> currently the are head down in plywood
[13:36:56] <twnqx> to turn them int a grid
[13:37:15] <`Legend`> now you have to stack the grids correct?
[13:37:35] <twnqx> i am doing the first grid
[13:37:45] <twnqx> then i have to add wires for the power supply
[13:38:24] <twnqx> and once that is done i have to stack the grids, in my design by soldering them two 2mm copper
[13:38:31] <twnqx> 2x VCC, 2x GMD
[13:38:42] <twnqx> since the total current that thing can burn is 30A @ 5V...
[13:39:20] <`Legend`> are they 1W leds?
[13:39:28] <twnqx> 0.3
[13:39:36] <twnqx> or wait
[13:39:38] <`Legend`> hmm
[13:39:39] <twnqx> 50mA per LED
[13:39:41] <twnqx> no, 60
[13:39:53] <`Legend`> shouldn't need 30 amps
[13:40:11] <twnqx> 512*0.06
[13:40:12] <twnqx> 30.72
[13:40:33] <twnqx> no multiplexing :P
[13:41:01] <twnqx> and the worst
[13:41:06] <twnqx> each of them needs a bypass cap
[13:41:17] <twnqx> so i am soldering 0402s straight between the middle pins...
[13:41:29] <`Legend`> why not drive each grid with a max 7219?
[13:42:02] <`Legend`> I searched for multiple solutions when doing mine and I finally concluded that was best.
[13:42:16] <twnqx> multiplexing means never max brightness
[13:42:17] <`Legend`> one mcu and one max chip for each 8*8 grid.
[13:42:36] <twnqx> also, RGB, thus 3 each
[13:43:03] <`Legend`> I tested that...I ran an led at full voltage and the max7219 could still do it.
[13:43:52] <`Legend`> yes rgb is an added complication.
[13:43:59] <twnqx> well, i have my LEDs with integrated controller now
[13:44:09] <`Legend`> what is the cost/led?
[13:44:24] <twnqx> 16us cent
[13:44:34] <`Legend`> wow, from where?
[13:44:43] <twnqx> i was in shenzhen
[13:45:04] <`Legend`> convenient :P
[13:45:07] <twnqx> http://www.aliexpress.com/store/product/PL9823-F5-5mm-round-hat-RGB-LED-with-PD9823-chipset-inside-full-color-frosted/312912_1707244750.html
[13:45:12] <twnqx> if you want them otherwise
[13:45:54] <twnqx> which means i paid too much :P
[13:48:01] <twnqx> depending how this ends i might grab another 4k next trip and build a 16x16x16 cube :P
[13:48:18] <`Legend`> is this for your own use?
[13:48:30] <twnqx> yeah
[13:48:39] <`Legend`> good stuff.
[13:48:52] <`Legend`> you have much experience with Atmel Studio and C?
[13:48:59] <twnqx> C, yes
[13:49:03] <twnqx> atmel studio not at all
[13:49:09] <twnqx> i don't do windows if i can avoid it
[13:49:13] <`Legend`> I'm having a problem...
[13:49:25] <`Legend`> well if you know C well you may know what I need
[13:49:58] <`Legend`> Basically I had my code in one .c file.
[13:50:18] <`Legend`> I wanted to move parts of it to other .c files and also have all my variables declared in a .h file.
[13:50:43] <`Legend`> upon doing this I can't get it to compile without 331 errors
[13:50:58] <twnqx> you can't declare globals in a .h
[13:51:09] <twnqx> you will get "multiple definitions of ..." errors
[13:51:14] <`Legend`> ah...that could do it...
[13:51:20] <`Legend`> thats exactly what I tried to do.
[13:51:27] <twnqx> do the following
[13:51:35] <twnqx> put an "extern" keyword in fornt of each
[13:51:47] <twnqx> and in one single c file that includes this
[13:52:00] <twnqx> do
[13:52:03] <twnqx> #define extern
[13:52:08] <twnqx> #include <globals.h>
[13:52:10] <twnqx> #undef extern
[13:52:20] <twnqx> it's ugly, but works
[13:52:45] <`Legend`> would you also maybe recommend I just put the global definitions back in the .c file?
[13:53:18] <twnqx> then the code in the other C files can't use those
[13:53:37] <twnqx> which is probably not what you want
[13:53:48] <`Legend`> correct.
[13:53:49] <twnqx> (you should not use globals in the first place, but that's a different story)
[13:55:01] <`Legend`> so put extern infront of each global definition in the .h file?
[13:55:27] <twnqx> yes
[13:55:38] <`Legend`> I'm not sure I know what you mean by #define extern...
[13:55:49] <twnqx> heh
[13:56:05] <twnqx> extern tells the compiler that the space for the variable is reserved somewhere else
[13:56:06] <`Legend`> #define extern
[13:56:06] <`Legend`> #include <globals.h>
[13:56:06] <`Legend`> #undef extern
[13:56:17] <`Legend`> they go at the start of any .c file that uses them?
[13:56:18] <twnqx> but once you have to reserve it, or you will get unresolved symbol errors
[13:56:25] <twnqx> no, just exactly one
[13:56:51] <twnqx> that is where the real delcaration automagically happens, as the "extern" keyword will be replaced with nothing by the c preprocessor
[13:57:49] <twnqx> you could add a globals.c file to your project with just that
[13:58:02] <twnqx> which is what i normally do for cleanness sake
[13:58:24] <`Legend`> I was told by somone that I can't #include .c files...
[13:58:35] <twnqx> you ... can, syntactically
[13:58:41] <twnqx> but no, ignore that, and never do it.
[13:59:09] <twnqx> each .c file creates an object file when being compiled
[13:59:25] <twnqx> and in the end the linker's job is to but all the compiled object files together to form the binary
[14:02:02] <`Legend`> so when I needed a funtion to use a variable that wasn't declared inside of it I should have passed the variable to the function in the first place correct?
[14:02:45] <twnqx> as a genral rule of thumb, avoid globals - just not at any cost
[14:02:58] <`Legend`> I'm not sure I know how to avoid them..
[14:03:36] <`Legend`> when I have a funtion that needs to access a variable that isn't declared inside that function what do I do?
[14:03:53] <`Legend`> *function
[14:04:10] <twnqx> well, as you said.
[14:04:16] <twnqx> often i just pass them to the function
[14:04:26] <twnqx> especially if the function only reads from it
[14:05:01] <twnqx> you can use "static" globals that are only valid within the C file that contains them, if you have a group of functions using the same variabe
[14:06:29] <twnqx> it's hard for me to describe that as i do it always from a gut feeling, not hard rules
[14:07:06] <`Legend`> so in my .h file I also have some #define constants...
[14:07:15] <`Legend`> put extern in front of those aswell?
[14:07:35] <twnqx> no
[14:08:12] <`Legend`> moving sections of the code to other .c files is really making this 'convoluted'
[14:09:27] <twnqx> if that's the case your structure is likely... suboptimnal
[14:10:20] <twnqx> its supposed to cause the opposite :P
[14:10:28] <`Legend`> Basically I have a loop that handles input from a UART interrupt
[14:11:08] <`Legend`> and propes a realtime clock on through a two wire interface on an interrupt
[14:11:25] <`Legend`> *probes
[14:13:05] <`Legend`> when a hyperterminal is connected the main loop decides what to do based on key presses, like setting the clock or inputting a scrolling message etc.
[14:14:05] <`Legend`> this is a controller hub that connects 4 of those scrolling message boards I had mentioned earlier.
[14:14:49] <`Legend`> so what do I do about the #defined constants that have to be accessed globally?
[14:15:02] <twnqx> is there a particular reason you don't drive all of the MAX with just one controller?
[14:15:13] <twnqx> you keep them as globals
[14:15:22] <twnqx> OR
[14:15:27] <twnqx> each .c file should have its .h file
[14:15:41] <twnqx> move the #defines where they belong, structure wise
[14:15:43] <`Legend`> all of the max are driven by one mcu/board
[14:16:14] <`Legend`> one mcu per scrolling board.
[14:16:26] <twnqx> (also, consider to use enums instead of defines. they move all the problems from preprocessor to compiler, where they can be better handled.)
[14:16:29] <`Legend`> there are four scrolling boards that need to show different things
[14:16:59] <`Legend`> enums...
[14:21:09] <`Legend`> some of my defines need avr/io.h
[14:21:22] <twnqx> yeah, those can't be helped usualyl
[14:21:27] <`Legend`> for example: #define Channel_Sel_DDR DDRC // Channel Select on DDRC
[14:21:46] <`Legend`> #define Channel_Sel_DDR DDRC // Channel Select on DDRC
[14:22:07] <`Legend`> copy:paste didn't preserve the spaces there.
[14:22:32] <`Legend`> so would I put #include avr/io.h in the .h file?
[14:22:41] <twnqx> yes+
[14:47:52] <`Legend`> hey twnqx
[15:47:52] <twnqx> hey
[15:51:13] <twnqx> `Legend`: you wanted something?
[16:00:04] <hetii> Hi :)
[22:31:44] <hypermagic> hello my friends
[22:32:07] <hypermagic> Floppy Music | James Bond 007 Theme http://www.youtube.com/watch?v=jEzXjJN1RH0
[22:34:21] <Casper> yours or just one of the thousands on youtube?
[22:34:45] <hypermagic> not mine ;< but i have a few laying around too
[22:35:23] <hypermagic> hdd cd floppy, steppers, all of them can make noise
[22:35:40] <Casper> I wanted to do that one day, but then I realised that we disposed of all of the floppy we had
[22:36:22] <hypermagic> hehe
[22:36:43] <hypermagic> get it at some pc disassembly garage or junkyard
[22:36:54] <hypermagic> nobody needs them anymore
[22:42:44] <Casper> ... can you believe that one client was somewhat pissed off that the brand new computer he wanted to buy didn't came with one...
[22:43:29] <hypermagic> :)
[22:44:16] <Casper> actually, he decided to go elsewhere, because we couln't put one in...
[22:50:40] <hypermagic> Super Mario Theme for Stepper Motor http://www.youtube.com/watch?v=zlfsBlcH4ao
[22:54:51] <hypermagic> Portal's 'Still Alive' Played by Fiber Laser http://www.youtube.com/watch?v=C4OV2UofPFg < something new
[23:00:31] <hypermagic> harddrive plays music www.youtube.com/watch?v=MDTl9mk_ur8
[23:01:21] <hypermagic> attach a little metal plate vertically on the head to make it louder and give better low frequency
[23:08:23] <hypermagic> HDD Speaker(tune up) http://www.youtube.com/watch?v=bVoPrvjvSKs
[23:23:04] <hypermagic> Spray-on clothing http://www.youtube.com/watch?v=ScvdFeh1aOw ^^
[23:28:11] <jadew> that's pretty neat
[23:28:24] <hypermagic> nah finally closed all related videos, came from here: ToorCon 12: Ubertooth Zero, a preview (part 1 of 2) http://www.youtube.com/watch?v=m87gn7uOBGs
[23:28:57] <hypermagic> i'm not 100% convinced it is good for health, but it looks possible
[23:29:14] <hypermagic> (the spray on clothes)
[23:29:40] <jadew> yeah
[23:37:58] <hypermagic> they just spray cotton fibers with a dissolved plastic binder, then solvent evaporates