#avr | Logs for 2013-03-03

Back
[08:06:26] <megal0maniac> gcc-avr or avrlibc?
[08:12:44] <megal0maniac> Or both?..
[08:22:39] <Horologium> megal0maniac, well, they are kinda useless each alone.
[08:31:11] <OndraSter_> megal0maniac, you need avr-gcc to make any use of avrlibc :)
[08:31:14] <OndraSter_> not vice-versa
[08:40:56] <Horologium> yes..it is possible to build C apps for avr without avr-libc but you will be reinventing the wheel for a lot of it.
[08:42:21] <Malinuss> Horologium, sure many of the avr-libc are nice, but often I find it much easier to just manipulate the registers myself. Seriously, there are sometimes functions that just changes one register ;P
[08:42:51] <Horologium> true.
[08:47:57] <Malinuss> INTERRUPT and IO are the two most important ones from libc... eeprom+sleep+math+pgmspace.h are nice too though. everything else - meh
[08:48:35] <Malinuss> actually that made me realise that I have no idea how pgmscape works, haha
[08:48:50] <abcminiuser__> And my printer bootloader is done
[08:48:56] <abcminiuser__> Jaevla corner cases
[08:49:41] <abcminiuser__> xoriath, I don't :P
[08:51:52] <OndraSter> congrats for the printer BL :P
[08:51:54] <OndraSter> now do scanner BL!
[08:52:06] <abcminiuser__> OCR on a MEGA? :P
[08:52:12] <OndraSter> xmega!
[08:52:35] <OndraSter> you are allowed to use black strip for logic 1 and nothing for logic 0 :)
[08:54:58] <Malinuss> abcminiuser__, what is a "printer bootlader" ? a bootlader for a avr chip with usb that would be recongnized as a printer? eh
[08:55:41] <xoriath> Malinuss: jupp
[08:55:55] <xoriath> reprogram using lpr or notepad etc
[08:56:22] <Malinuss> xoriath, what is lpr?
[08:56:33] <xoriath> cups command line
[08:57:10] <abcminiuser__> Malinuss, It's *amazing*
[08:57:19] <abcminiuser__> You just "print" HEX files to it
[08:57:44] <abcminiuser__> https://github.com/abcminiuser/lufa/tree/master/Bootloaders/Printer
[08:57:53] <xoriath> http://www.youtube.com/watch?v=fTQvnhNVgxQ
[08:58:20] <Malinuss> abcminiuser__, oh, which printer are you using? How did you connect the avr chip to the rest, did you reverse engineer a whole printer?
[08:58:43] <abcminiuser__> It pretends to be a USB text only printer
[08:59:33] <Malinuss> abcminiuser__, oh so for now it's "only" a bootloader. The links won't really help me understand since I know jack about USB protocol
[09:00:00] <abcminiuser__> I tell the computer BEEP BEEP I AM A PRINTER BEEP
[09:00:18] <abcminiuser__> Windows goes "Yo dawg, you're a printer, imma gonna install my drivers for you"
[09:00:26] <abcminiuser__> User says "PRINT THIS"
[09:00:35] <abcminiuser__> Windows streams the raw text file to my "printer"
[09:00:47] <abcminiuser__> Printer bootloader goes BEEP BEEP PROGRAMMING BEEP
[09:00:50] <abcminiuser__> Done.
[09:02:12] <Malinuss> abcminiuser__, yeah I get that part ;P.... I'm just wondering why you don't just send the data from the file you want to print, like you would do with a normal printer, instead of programming the uC with the file.
[09:02:46] <abcminiuser__> One good thing about living alone, no one is here to judge me while I have coffee and Irish cream
[09:03:10] <abcminiuser__> Malinuss, you do, you program the AVR with the bootloader
[09:03:23] <abcminiuser__> Then you can reprogram the AVR via the bootloader by "printing" new firmware to it from then on
[09:03:23] <xoriath> abcminiuser__: is that an invitation?
[09:03:38] <abcminiuser__> xoriath, sure if you want to drive in this crap
[09:04:25] <xoriath> it's not bad weather, only a bit more...
[09:04:36] <Horologium> abcminiuser__, you posting the project somewhere with downloads?
[09:04:47] <Horologium> nevermind.
[09:04:49] <Horologium> just saw it.
[09:05:23] <xoriath> I need an hour ish
[09:07:04] <Malinuss> abcminiuser__, but I mean, if the file you want to print is bigger then the flash, then it wouldn't work?
[09:07:24] <abcminiuser__> It doesn't buffer and process, it's got an in-place HEX parser
[09:07:39] <abcminiuser__> So as long as the contents of the HEX data fits into FLASH you're fine
[09:08:06] <abcminiuser__> The HEX contents is read and processed a byte at a time, so you don't need RAM to store it all
[09:08:48] <Malinuss> abcminiuser__, yeah, but if you wanted to make a actual printer out of that bootlader, you had to change it, so it would just stream the data, instead of programming the uC?
[09:09:57] <Horologium> one would think that one could convert it without too much issue...it's just the enumeration and comms that's the USB issue...the rest would be stripped and converted to printer.
[09:10:23] <Horologium> for printing, you would want to be able to buffer the entire job most likely, unless it was a text only line by line printer.
[09:11:18] <Malinuss> Horologium, but isn't it OS defined, how the OS streams the data to the printer?
[09:11:42] <abcminiuser__> Well yes you could also do something else with the data
[09:11:42] <abcminiuser__> Hell you can be a Poscript printer too, but good luck interpreting that
[09:11:42] <abcminiuser__> Plain text data is easy however, and you could for example stream it over a USART or something instead of being a bootloader
[09:14:59] <Malinuss> abcminiuser__, yeah but you still need some USB stacks running on the uC, that tells the OS that it's a printer, or am I missing something?
[09:15:10] <abcminiuser__> Yes you do
[09:19:09] <Malinuss> abcminiuser__, and in which "format", does the OS send the data to the uC, when you press "print"
[09:19:44] <abcminiuser__> Plain text stream of whatever you print
[09:19:50] <abcminiuser__> No headers or anything
[09:20:03] <abcminiuser__> Since I'm forcing it into a super legacy text only mode
[09:20:07] <Malinuss> what if you print a picture? or PDF
[09:20:20] <abcminiuser__> The printer driver will reject it and the print will fail
[09:20:33] <abcminiuser__> If I enumerated as a PostScript printer I'd see PostScript data instead
[09:20:44] <abcminiuser__> Which supports graphics but it's super, super hard to process
[09:20:57] <Malinuss> well it would be a slow printer then ;P
[09:21:03] <Malinuss> but how do they solve that in actual printers?
[09:21:31] <abcminiuser__> They interpret PostScript commands
[09:21:44] <Malinuss> it can't be THAT slow, printers have printed pretty fast the last 15 years... and then the uC's were slower, no?
[09:22:18] <abcminiuser__> Well cheap printers have their own printer drivers that do the rendering and send the dumb printer a pre-rendered stream of data
[09:22:30] <abcminiuser__> Shifting all the grunt work to the PC
[09:26:20] <Malinuss> abcminiuser__, so in the end, it just stream something like the "color" of each "pixel" it has to print.. cool thanks.. I didn't know it would be possible for drivers to do that much work
[09:26:38] <abcminiuser__> Well if you're a printer driver you can do whatever the hell you want
[09:26:46] <abcminiuser__> But yes that's what the cheap printers do
[09:26:58] <abcminiuser__> More expensive ones interpret the PostScript in the printer
[09:27:35] <Tom_itx> moin
[09:28:37] <Malinuss> thanks again
[09:31:16] <Malinuss> abcminiuser__, one quicky now I have your attention. Does progmem in short work like this: you define some flash space with y adress and with x value, then in the runtime, you can point at the x adress in the flash (even though it's somewhere else then the "stream") and get the value?
[09:32:07] <abcminiuser__> Y address in flash, but yes
[09:32:31] <abcminiuser__> When you tag a variable with PROGMEM it is linked into the application binary in FLASH space, and not RAM
[09:32:41] <abcminiuser__> Then you use the special PROGMEM functions to read it out
[09:33:23] <Malinuss> abcminiuser__, yeah I confused myself there with using y first, haha... but yeah, anywhere I could get a better understanding which asm commands are used to jump somewhere else in the flash? Or will I just have to read the datasheet asm commands and at the progmem.h source?
[09:33:28] <Tom_itx> abcminiuser__, when you do that does it make a copy in ram when used or use it from flash directly?
[09:33:39] <Tom_itx> is it any slower?
[09:34:33] <abcminiuser__> Tom_itx, no, it loads it directly from FLASH via the LPM (Load Program Word) ASM instruction - no buffering, which is kinda the point
[09:35:03] <abcminiuser__> If it wasn't for PROGMEM, the data would still be stored in FLASH (it has to exist somewhere) but it would be automatically copied to a RAM buffer on startup
[09:35:20] <abcminiuser__> Using PROGMEM suppresses the auto copy to RAM, so you then have to load it directly from FLASH instead
[09:35:25] <abcminiuser__> It's a tiny bit slower
[09:35:50] <abcminiuser__> Malinuss, there's a ASM manual for AVRs somewhere with all the jump instructions
[09:36:00] <abcminiuser__> RJMP, JMP, CALL, etc
[11:27:01] <Malinuss> abcminiuser__, what does the ALU do if it "reads" "invalid"/"not known" command? Jump to 0x00?
[11:31:30] <gatchi> hmm
[11:31:35] <gatchi> how did it even compile in the first place?
[11:36:04] <Malinuss> gatchi, this is a theoretical question. but let's just say you compiled it for a other chip, that does have that said asm instuction, that the one you upload to doesn't
[11:39:12] <BJFreeman> mirco code looks for the op code if not there will increment one address and look for op code
[11:39:54] <BJFreeman> if an opcode is found then will try to execute based on Op code if fault will increment based on the Op code
[11:42:02] <Malinuss> BJFreeman, so it will just go to the next adress?
[11:47:47] <Tom_itx> just like the mailman
[11:59:19] <einball> there's no better friend than my mailman!
[12:20:31] <abcminiuser__> Malinuss, we use partrial address decoding
[12:20:41] <abcminiuser__> So it's essentially a random result
[12:21:55] * abcminiuser__ is moving to friends place back later
[13:07:50] <creep> h
[13:33:21] <megal0maniac> That printer thing sounds very cool
[13:33:23] <Steffanx> i
[13:39:53] <slidercrank> megal0maniac, what thing?
[13:40:37] <megal0maniac> slidercrank: Read up. abcminiuser's printer bootloader
[13:40:51] <Tom_itx> it's the shizzle
[13:41:51] <megal0maniac> Tom_itx: A friend of mine is struggling with some I2C stuff. I told him to ask here, and to use your log as a reference for his project :P
[13:42:00] <slidercrank> megal0maniac, http://www.masswerk.at/google60/ you may like it:)
[13:42:45] <slidercrank> that thing sounds great:)
[13:43:36] <megal0maniac> Tom_itx: so now your log shall become a university reference
[13:44:01] <megal0maniac> slidercrank: very cool. I haven't watched Mad Men, so the reference is lost on me. But I'll show my boss
[13:46:34] <megal0maniac> Is working with SPI as difficult as it sounds?
[13:46:51] <Tom_itx> no
[13:47:08] <Steffanx> Its as easy as uart megal0maniac :)
[13:47:18] <megal0maniac> (Assuming it's hardware SPI and not USI)
[13:49:08] <megal0maniac> Steffanx: I'll give this a shot, but could you say that MISO and MOSI are equivalent to RX/TX, the CS determines which direction the data is travelling, and CLOCK is due to it being synchronous as opposed to regular async serial over uart?
[13:49:18] <megal0maniac> What have I missed?
[13:49:50] <Steffanx> "the CS determines which direction the data is travelling" dont think that is right
[13:50:06] <Steffanx> As SPI really is master-slave
[13:50:27] <megal0maniac> But it is bi-directional, no?
[13:50:43] <Steffanx> So the master clocks data in and the slave clocks data out using the clock from the master
[13:51:00] <Steffanx> Not sure if I use the right terms, but .. :)
[13:51:04] <slidercrank> megal0maniac, it can be bi-directional
[13:51:28] <slidercrank> megal0maniac, but not all devices support sending data to the master
[13:52:08] <slidercrank> so I have an LCD display which can only receive data in the SPI mode but not send back
[13:54:42] <megal0maniac> So the clock determines whether the master or slave is in send mode?
[13:54:53] <megal0maniac> (Assuming bi-directional communication)
[13:56:34] <Tom_itx> megal0maniac, which log?
[13:56:43] <megal0maniac> "zlog"
[13:56:57] <Tom_itx> oh
[13:57:26] <megal0maniac> As proof that he didn't go "Hey, I'll give you $5 if you can make this code work" kind of thing
[13:57:55] <Tom_itx> not for 5
[13:57:58] <Tom_itx> maybe 10
[13:58:04] <megal0maniac> Depends on the code :)
[13:59:21] <megal0maniac> He has to write to I2C eeprom, then read it back. On a Renesas chip, but the code is in C, so should be pretty similar. Apparently he can read, and he can write, but if he reads straight after writing, it hangs
[14:02:14] <Tom_itx> there's i2c example for a rtc on my site
[14:02:21] <Tom_itx> not mine but i've used it
[14:02:54] <Tom_itx> http://tom-itx.dyndns.org:81/~webpage/avr/i2c/
[14:05:28] <megal0maniac> Thanks, I'll send the link his way. Renesas is horrible
[14:18:24] <megal0maniac_afk> :detach
[14:18:32] <megal0maniac_afk> :/ Whoops
[14:19:14] <OndraSter_> heh
[14:19:15] <OndraSter_> vi?
[14:25:41] <megal0maniac_afk> OndraSter_: screen :)
[14:26:27] <megal0maniac> I run irssi within a screen, so I don't have to keep the ssh session running for irssi to be open
[14:27:51] <specing> Bouncers ftw
[14:28:25] <megal0maniac> Bouncers?
[14:29:58] <specing> yes, bouncers
[14:30:03] <specing> like ZNC
[14:30:07] <specing> I run it on my router
[14:30:15] <specing> and connect to it with irssi
[14:39:16] <yunta_> + for bouncers, slightly more convenient than running client in screen
[14:41:05] <OndraSter_> I am running hexchat in RDP :D
[14:45:52] <Malinuss> wut is RDP?
[14:45:53] <Steffanx> You are amazing OndraSter_
[14:58:05] <OndraSter_> Malinuss, remote desktop
[15:03:09] <Malinuss> OndraSter_, you wut the wut?
[15:03:58] <OndraSter_> replying to the wut
[15:08:44] <Malinuss> OndraSter_, wut=
[15:10:57] <OndraSter_> ..
[15:14:08] <Horologium> http://dangerousprototypes.com/2013/03/03/ftdi-announces-eve-embedded-video-engine-chip/
[15:25:28] <BJFreeman> commin in late on SPI. three pins for bidirectional comm. SCK MOSI MISO
[15:26:26] <BJFreeman> the master uses the MOSI the slave connects to MISO the master supplied the SCK
[15:26:55] <Horologium> and if you have more than one slave then you have to have chip select lines for each one.
[15:27:14] <BJFreeman> yup
[15:29:10] <BJFreeman> Malinuss not sure what happens with the OP code is not in the microcode
[16:31:47] <creep> ingenious? :) http://shaddack.twibright.com/projects/machining_MagneticDoorLock/
[16:36:17] <creep> http://www.eeweb.com/blog/circuit_projects/old-cd-player-used-as-door-lock
[17:32:12] <vsync_> was thinking of building a test bench for my motors, just a simple one that provides info for current, voltage and rpm
[17:32:52] <vsync_> currently i have no rpm meter, and i'm sick of always measuring volts and amps with multimeter
[17:33:09] <vsync_> so that i won't burn my motors
[17:33:16] <creep> you can have a freq meter by sensing current
[17:33:38] <creep> the frequency will depend on number of commutations/rotation though
[17:33:48] <vsync_> yes, not going to do it like that
[17:33:57] <vsync_> going to just use an optic sensor for rpm
[17:34:01] <creep> an opto-encoder wheel?
[17:34:17] <vsync_> yes
[17:34:19] <creep> and an opto gate from some junk printer
[17:34:42] <creep> or a magnetic stuff
[17:34:51] <vsync_> well i gotta order some stuff aswell, from maybe digikey or the like, so i'll just check if there's some cheapo optogates
[17:35:03] <vsync_> should be plenty
[17:35:10] <creep> why not use some juk?
[17:35:24] <vsync_> have none available that would suit it
[17:35:32] <vsync_> i'm a poor guy you see
[17:35:46] <creep> a thrown out printer has opto gates
[17:35:47] <vsync_> can't even afford junk ;(
[17:35:51] <creep> thaht should be free
[17:36:07] <vsync_> yeah but really can't be arsed to go hunting for broken printers
[17:36:09] <vsync_> eh?
[17:36:15] <creep> then a cd-rom drive?
[17:36:26] <vsync_> none either :) really, have nothing
[17:36:44] <creep> bad for you if you don't even have a broken old cd
[17:37:06] <vsync_> nope, i have only one drive and i sort of need that
[17:37:20] <creep> are you in the middle of the desert or what?
[17:37:28] <vsync_> i'm in the middle of a suburb!
[17:37:31] <vsync_> that's even worse
[17:38:00] <vsync_> i also have to get a display, now how poor is that ;D
[17:39:46] <creep> matrix 0.1 ?
[17:40:39] <vsync_> something like that yes
[17:45:12] <creep> exit-the-matrix
[17:47:48] <vsync_> acs756 would look like a good transducer for measuring the current
[17:48:01] <vsync_> and doesn't even cost that much
[17:49:10] <creep> vsync_<< dead pc fan?
[17:49:47] <vsync_> have really no junk lying around here
[17:50:03] <vsync_> i recently moved
[17:50:33] <vsync_> i have to start building stuff again so i can collect a junk stash
[17:50:49] <creep> well the cheapest you can do is use an opamp to measure current from the dc motor then
[17:51:01] <creep> commutation will have glitches
[17:52:13] <creep> ti will give free samples from opamps, and atmel -> microcontrollers
[17:52:26] <vsync_> well, my poor i didn't mean broke :D
[17:52:29] <vsync_> by*
[17:52:54] <vsync_> and i can't really use shunts
[17:52:59] <vsync_> i'm talking tens of amps
[17:53:03] <vsync_> around
[17:53:05] <vsync_> 5-50 amps
[17:53:19] <creep> that should be fine using a precision opamp
[17:53:32] <creep> a piece of copper wire can be resistor
[17:53:51] <vsync_> yeah but i don't really fancy using shunts with high currents
[17:54:04] <vsync_> brb
[17:54:16] <creep> opamp can amplify 100V/mV
[17:59:02] <vsync_> might go higher than 50A's in the future, but for now it should suffice... think acs756 goes up to 100 amps, that oughta do
[17:59:26] <creep> supercharged wheelchair?
[18:00:04] <creep> measuring high DC currents is via hall sensors btw.
[18:00:22] <creep> honeywell has them
[18:00:59] <vsync_> yep, the allegro one is a hall sensor
[18:01:17] <vsync_> and isn't that expensive, around $6 at digikey
[18:01:22] <creep> i'd go brushless.
[18:01:45] <vsync_> no wheelchairs :)
[18:01:54] <creep> no sparking, and 95%+ efficiency compared to 50-60%
[18:03:38] <vsync_> i am using brushless motors
[18:05:00] <creep> then lol @ measuring rpm
[18:05:04] <creep> hahaha
[18:05:15] <vsync_> ...
[18:05:52] <creep> connect the requency meter to any of 2 phases.
[18:06:15] <vsync_> yes but thing is i also have to measure brushed motors too
[18:06:31] <creep> throw them out ;/
[18:06:34] <vsync_> so i can't do it simply like that
[18:06:59] <vsync_> i can't, cause i'd have to spend too much on replacing those with brushless ones
[18:07:09] <creep> definitely
[18:07:20] <creep> but brushless ones do not need replacement
[18:07:29] <creep> bearings used to wear
[18:07:55] <vsync_> they still wear
[18:09:36] <vsync_> and especially the quality of insulation on my china coils, don't know really how long that'll last, since they do heat up somewhat
[18:10:33] <creep> deburr, pot into epoxy, rewind,
[18:10:45] <creep> winding can also be potted in epoxy
[18:10:54] <creep> that will work underwater
[18:11:33] <vsync_> you really do like to tinker don't you? :D
[18:11:43] <creep> i used to rewind stuff yes
[18:11:48] <vsync_> for a $10 china motor, you want to start rewinding coils?:D
[18:12:26] <creep> i did this with BLDC from scrapyard
[18:12:35] <vsync_> if you dip the winding into epoxy
[18:12:54] <vsync_> if the lacquer starts coming off
[18:12:56] <vsync_> it will
[18:13:02] <vsync_> in the inside
[18:13:10] <creep> it will not.
[18:13:12] <creep> ;>
[18:13:17] <vsync_> tell me about it?
[18:13:35] <creep> i use a 10k NTC in the winding, and set 70C temp limit for the controller
[18:14:12] <creep> i might as well prefer using an SI diode, or transistor
[18:14:33] <vsync_> yeah if you put an ntc in there
[18:16:16] <creep> motors can be killed by constant overloading, because the coating will burn from the windings, and wire may even melt
[18:16:24] <vsync_> yep
[18:16:45] <vsync_> and the quality of the lacquer on these is really unknown, so don't know how much it'll last
[18:16:55] <vsync_> but i'm not trying to burn them on purpose
[18:16:56] <creep> they are good for about 180C
[18:16:59] <vsync_> and that's why i need my test bench
[18:17:15] <vsync_> to get a ballpark figure
[18:17:23] <creep> the "magnet wires" i don-t know, may take 95C maybe
[18:17:35] <vsync_> those are only estimates
[18:17:49] <creep> i use the double insulated copper that takes 180C
[18:18:03] <vsync_> yeah, but i'm not going to start rewinding lol
[18:18:24] <vsync_> maybe if i'd get a lil chinese slave
[18:18:28] <vsync_> that'd be a job for him
[18:18:33] <creep> then the burrs can cut the windings or short them
[18:18:57] <creep> nothing to do with that, if they are crap, you get what you pay for
[18:19:11] <vsync_> yes
[18:26:41] <vsync_> so, gonna use an optogate, and prolly the allegro hall chip, and voltage will be easy with a voltage divider straight into adc
[18:27:59] <Tom_itx> that hall chip needs an op amp doesn't it?
[18:29:28] <vsync_> haven't checked the datasheet
[18:29:30] <vsync_> let's see
[18:30:25] <Tom_itx> i dunno which one i had
[18:31:20] <vsync_> why
[18:33:57] <vsync_> don't think this chip actually needs an op amp
[18:40:06] <balrog-k1n> hi, i have a 16-bit memory register that i load into r24/r25, increment using adiw and the write back to memory. someone told me that i'd need a cli/sei before/after this operation. why is that? assuming that interrupts don't use r24/r25 is there anything else that they can corrupt?
[18:40:31] <balrog-k1n> oh wait... i just realised
[18:40:45] <balrog-k1n> the interrupt reads the same memory location
[18:46:28] <BJfreeman> this is the one I use for voltage sensing. http://www.mouser.com/ProductDetail/Honeywell/CSLW6B40M/?qs=SFC1ZZvMyCG7C3xNrx5ktw%3d%3d
[20:54:20] <dirty_d> i have an atmega8l here on an R/C ESC
[20:54:38] <dirty_d> reset isnt connected to anything, that means the reset lock fuse is programmed right?
[20:54:47] <dirty_d> and you can reprogram it without a HV programmer?
[23:35:17] <tzanger> hm
[23:35:49] <tzanger> with a 16MHz clock and a 1024 prescaler, an 8-bit counter should have a tick every 64us
[23:37:07] <tzanger> if I'd like a 1ms ISR, 1/.064 is 15.625
[23:37:37] <tzanger> timer overflow causes the interrupt, so 256-15.625 is 240.375
[23:38:09] <tzanger> so I load TCNT0 with 240, which gives me 15*64us or 960us interrupts
[23:38:24] <tzanger> is my math right so far?
[23:38:57] <tzanger> er no 241, that gives 960us, since it interrupts whent he timer hits zero, not max
[23:40:03] <tzanger> so 960us interrupts, they're 40us fast. Every 100 ticks I'll be 4ms ahead of where I want to be
[23:41:07] <tzanger> so if I simply don't set my ms flag every 25 ticks, I should have an average "one_ms" flag time of 1ms
[23:41:27] <tzanger> it's a pulse skip method but the average will be right
[23:51:32] <Xark> tzanger: Hmm, if you instead divide 16Mhz clock by 128 (instead of 1024), then you get 125,000 overflows per second which divides evenly into 1000. However, that is probably a bit too much overhead (without using 16-bit timer)