#avr | Logs for 2016-01-24

Back
[06:21:38] <phinxy> i want to flash my project on another computer. i could transfer the full project and install atmel studio but the problem is i would need to also transfer all external libraries and re-link them
[06:22:03] <phinxy> i could also just move the hex and the eep and flash with avrdude but i dont know the commands, can i grab them from atmel studio somehow?
[07:30:40] <x29a> phinxy: i think atmel studio uses some batchfiles to call avrdude, you could put some echos in there. or just try flashing "normally" with avrdude
[07:30:57] <x29a> do you suspect some offsets or special parameters?
[08:40:14] <phinxy> x29a nah is just didnt want to "learn" avrdude. i installed Atmel Studio and it went fine
[09:02:24] <cehteh> there is not that much to learn with avrdude
[09:12:27] <h4x0riz3d> avr doood
[10:34:28] <LeoNerd> GAHHH.. Ihate the SPI module on the 328 sometimes
[10:34:55] <LeoNerd> I *always* forget that really rare cornercase thing whereby you have to set the SS pin as a driven-high output before you enable the SPI module ,otherwise the hardware goes into slave mode
[10:42:57] <learath> ?
[11:10:20] <RikusW> LeoNerd: or enable pullup on that pin
[11:10:31] <RikusW> it is the case for all SPI modules
[11:10:35] <RikusW> not just 328
[11:11:16] <RikusW> iirc it only happens when SS is set as input and goes low, so enable pullup
[11:11:30] <RikusW> if its output it shouldn't matter afaik
[11:18:52] <LeoNerd> Well, yah any of the chips I suppose
[11:23:03] <LeoNerd> for(uint8_t i = 0; i < 512; i++)
[11:23:04] <LeoNerd> oopsie
[11:23:59] <cehteh> you need a uint9_t :D
[11:24:13] <LeoNerd> 10 surely.. because any uint9_t is going to be < 512
[11:24:39] <cehteh> gcc with -Werror should warn
[11:24:42] <cehteh> ah yes
[11:25:09] <cehteh> btw .. rarely used feature .. gcc/avrlibc implements nonstandard int24 types,
[11:25:21] <LeoNerd> ooooh nice
[11:25:26] <LeoNerd> Yes I've sometimes wanted those
[11:27:13] <cehteh> i havent used them, just noticed they are there, maybe sometimes the could be useful
[11:28:10] <cehteh> and it would be nice if gcc optimzes increment/decrement on biger (4-8byte) integers better than just calling a generic add function
[11:28:47] <h4x0riz3d> signed bool pls
[11:30:08] <cehteh> lol
[11:30:15] <cehteh> tribool
[11:31:03] <cehteh> well there are some higher level logic things where there are different states for a bool
[11:31:50] <h4x0riz3d> signed bool can be true, false, and -true
[11:31:55] <h4x0riz3d> >:)
[11:31:55] <cehteh> true, likely, unknown, unlikely, false .... and algebras over that
[11:32:59] <cehteh> https://en.wikipedia.org/wiki/Three-valued_logic or the simple case
[11:33:02] <phinxy> damn i loose half the accuracy of my tachometer because the hall sensor needs a negative magnetic field to do another trigger. that means slip every second magnet over. and it only triggers every other magnet :(
[11:33:32] <phinxy> anyone knows how this type of hall sensor is meant to be used =?
[11:34:04] <phinxy> flip* not slip
[11:34:54] <cehteh> just mount the magnet that the hall sensor se both poles
[11:35:10] <cehteh> then you get a spike when the magnet travels along
[11:35:42] <phinxy> you mean put the magnet on its side? that works but it wont be very balanced
[11:35:44] <cehteh> anyway .. from the start on i opposed using hall sensors :DDDD
[11:35:56] <cehteh> i dont know how you mounted it
[11:35:57] <phinxy> haha..
[11:36:33] <cehteh> you can also put a magnet close to the hall sensor .. static mounted
[11:36:49] <h4x0riz3d> initialize teh magnet
[11:36:57] <phinxy> yeah ive seen some interesting things you can do
[11:37:16] <phinxy> for example if you put a magnet behind the hall sensor it can measure Cogs on a cogwheel
[11:37:26] <cehteh> yes
[11:37:32] <phinxy> http://www.allegromicro.com/~/media/Images/Design/Hall-Effect-IC-Application-Guide/fig64.ashx?w=466&h=266&as=1&la=ja-JP
[11:38:22] <cehteh> so your magnets are mounted on the wheel (how many?) that only one pole passes along the sensor
[11:39:24] <cehteh> not mount a weaker magnet (or with some distance) relative to the hall sensor that it sees the other pole when idle, but when one of the wheel magnet passes by it overrides that static field
[11:39:36] <phinxy> i did 8 magnets but its effectively only 4 triggers per spin
[11:39:45] <phinxy> per spin.. you know what i mean
[11:39:49] <cehteh> rotation
[11:40:05] <cehteh> you should be able to get 8 triggers
[11:40:17] <phinxy> yes. if i check when it goes low
[11:40:39] <phinxy> according to the datasheet it goes high and stays high until a reverse field
[11:40:43] <cehteh> up to you how you sense the stuff
[11:41:12] <phinxy> you mean i could get more than 8 triggers?
[11:41:13] <cehteh> you can trigger on any edge, or reset the field with a static magnet
[11:41:29] <phinxy> theres no edge detection
[11:41:32] <cehteh> 16 triggers? :)
[11:41:55] <phinxy> hmm.. yeah maybe it could work without any code adjustment if i add a static magnet
[11:42:35] <cehteh> you prolly want that anyway to override any stray/weak magnetic field in the environment
[11:42:50] <cehteh> dunno how sensitive the thing is
[11:43:37] <phinxy> edge detection only applies to when the sensor is analog, or does it?
[11:43:54] <cehteh> no
[11:44:12] <cehteh> your sensor give a rising and a falling edge
[11:44:41] <phinxy> naaw
[11:44:46] <cehteh> depending on what magnetic pole it sees or?
[11:44:58] <phinxy> i wish you could link images from PDFs
[11:44:58] <cehteh> what then?
[11:45:08] <cehteh> just link the pdf :D
[11:45:35] <cehteh> anyway .. if you have one kind of edge then you have the other kind to
[11:45:50] <phinxy> http://i.imgur.com/pmdSf7m.png
[11:46:01] <cehteh> yes seen that
[11:46:21] <phinxy> you see the zero-point for the induction?
[11:46:30] <cehteh> yes
[11:46:56] <cehteh> well you only want to use one edge and statically offset the sensor with a magnet
[11:47:10] <cehteh> which edge you use is then irrelevent
[11:47:33] <cehteh> that will be the easiest and you get 8 signals per rotation
[11:47:41] <cehteh> that should be good enough
[11:48:47] <cehteh> btw if you dont place the magnets evenly on the rim (or whereever you place them) you could also detect the direction of travel .. in case you want to learn backwards driving on your bike :D
[11:49:26] <phinxy> thats clever
[11:49:58] <phinxy> but i guess you would have to travel a pretty constant speed for it to work
[11:55:17] <cehteh> nah i doubt you can accelerate/decelerate that much on 1/2 wheel rotation
[12:54:11] <LeoNerd> Is there anything really weird I should know about _delay_ms() ? Like.. how sometimes it doesn't actually wait the full time?
[12:54:20] <LeoNerd> I'm seeing a _delay_ms(1000) occasionally not actually wait at all
[12:54:53] <bedah> look at the source, luke!
[12:55:15] <bedah> gcc should output the assembler code
[13:46:24] <cehteh> LeoNerd: it should wait at least the specified time
[13:46:31] <cehteh> if not then you have a bug
[13:47:02] <cehteh> you have to set F_CPU correctly
[13:47:15] <cehteh> .. and delay is evil anyways :D
[13:51:18] <inkjetunito> why does it begin with an underscore again?
[13:54:49] <cehteh> because you shouldnt use it :D
[13:55:32] <cehteh> srsly ... leading underscore symbol names are 'reserved' for the implementation by the C standard
[13:55:58] <cehteh> aside from that there is nothing special
[13:56:36] <Lambda_Aurigae> it could be optimized out if your optimization settings are just right.
[13:57:12] <LeoNerd> It's a simple quick hack for debug purposes
[13:57:30] <LeoNerd> SD card switch is activated - wait 1000msec then try to initialise card
[13:57:39] <LeoNerd> only sometimes it doesn't wait, and does it almost instantly
[13:58:16] <cehteh> 1000ms ,, dunno when the counter overflows there, check the docs
[13:58:21] <Lambda_Aurigae> check the assembler output and make sure the delay loop is actually in there.
[13:58:26] <LeoNerd> It's unreliable, though
[13:58:33] <LeoNerd> Sometimes it waits, sometimes not
[13:58:41] <cehteh> then there is a problem in your code
[13:58:43] <LeoNerd> I can just hit the reset button a few times and watch it change
[13:59:19] <cehteh> _delay things are inline asm .. unless the whole call gets optimized out it will be there
[13:59:58] <cehteh> so you prolly dont call it at all under some circurcumstances
[14:00:13] <LeoNerd> My code is printf; delay; printf
[14:00:19] <LeoNerd> sometimes there's no delay in the serial output
[14:00:34] <cehteh> The maximal possible delay is 262.14 ms / F_CPU in MHz.
[14:00:40] <cehteh> ... says the doc btw
[14:00:41] <LeoNerd> hmmmmm
[14:00:51] <LeoNerd> Of _ms ?
[14:01:09] <cehteh> https://imgs.xkcd.com/comics/rtfm.png
[14:01:39] <cehteh> http://www.nongnu.org/avr-libc/user-manual/group__util__delay.html
[14:01:45] <cehteh> it has some fallback if longer
[14:02:07] <cehteh> still ... use a timer, not delay
[14:02:09] <phinxy> i use a delay function to wait 5ms for a relay switch to actually switch. is this okay?
[14:02:18] <cehteh> does your SD card stuff use any interrupts?
[14:02:31] <LeoNerd> Ohsure... if it was a real setup I would indeed use a timer
[14:02:42] <LeoNerd> I'm just hacking up a quick test now to check the hardware
[14:02:46] <cehteh> phinxy: depends, generally i would disagree :D
[14:02:56] <LeoNerd> when I have a hardware design I can order the PCB and continue to work on software
[14:04:54] * cehteh ranted yesterday that at 9600 baud one byte takes approx 1ms to transmit, just a random example, if you have some transmission running then you need to feed it each ms with a new byte
[14:05:22] <LeoNerd> yah
[14:05:30] <cehteh> maybe from interrupt, but anyway delay will affect that or be affected by that
[14:06:09] <cehteh> so depending on the program delay for 100µs to 1ms maybe ok, anything more needs to be carefully considered
[14:07:04] <cehteh> some programs certainly work with much larger delay calls ... still bad practice
[14:14:28] <bedah> AFAIK _delay_ms() is a makro, which only takes constants, not variables, and is translated by the gcc into some asm loops full of nops
[14:16:25] <cehteh> maybe, i never used it :D the delay_loops are at least inline asm, maybe macros
[14:17:35] <bedah> LeoNerd said "sometimes it doesn't actually wait the full time" - maybe there are some ISR active?
[14:18:02] <bedah> or he is playing with sleep modes or other stuff :)
[14:20:52] <cehteh> isr will only make th timespan longer
[14:59:19] <LeoNerd> Hrm. so I have a diode that comes in a SOT-23 package, across pins 1 and 3. What's the usual way to handle that in kicad?
[15:15:11] <LeoNerd> As in: do I create a custom schematic library part to fit a standard SOT-23 package, or do I create a custom footprint to fit the standard schematic library?
[15:17:28] <LeoNerd> Huh.. wrong channel
[15:19:14] <phinxy> LeoNerd, im curious, where can you ask that kind of questions?
[15:19:23] <LeoNerd> I asked in #kicad :)
[15:19:29] <LeoNerd> Ijust forgot this isn't there..
[15:20:01] <phinxy> oh is that the software EEVBlog did a review on
[15:20:55] <phinxy> yes it is.