#avr | Logs for 2016-12-19

Back
[01:15:10] <rue_house> nono
[01:16:59] <rue_house> https://www.aliexpress.com/item/Mist-Coolant-Lubrication-Spray-System-For-8mm-Air-Pipe-CNC-Lathe-Milling-Drill/32583019577.html?spm=2114.01010208.3.17.l8gXAw&ws_ab_test=searchweb0_0,searchweb201602_3_10065_10068_10084_10083_10080_10082_10081_10060_10061_10062_10056_10055_10037_10054_10059_10032_10099_10078_10079_10077_427_10103_10073_10102_10096_10052_10050_10051-10050,searchweb201603_2&btsid=c04b4b73-53f1-471a-a927-2a6d6dacbabb
[01:17:04] <rue_house> Coops
[01:17:19] <rue_house> https://www.aliexpress.com/item/Mist-Coolant-Lubrication-Spray-System-For-8mm-Air-Pipe-CNC-Lathe-Milling-Drill/32583019577.html
[01:17:22] <rue_house> Casper,
[01:17:24] <rue_house> ^^
[01:17:39] <rue_house> thats prolly what you want
[01:18:42] <Casper> rue_house: too long for the shipping, need it this week
[01:18:48] <Casper> in fact, tomorrow
[01:19:31] <rue_house> ah, your screwed
[01:21:29] <Casper> yup
[01:21:51] <Casper> see, I want to make like 10x10x5' of packed snow
[01:21:57] <Casper> for this week end
[01:22:21] <Casper> that also mean I have to put it in place, and ideally ice it in place to make the best slide ever!
[01:23:49] <Casper> my only hope is that the hydroponic garden store thing have some
[01:24:20] <Casper> also, I may have a tiny issue with the garden hose that might want to... freeze...
[01:34:03] <rue_house> not if water is flowing
[01:34:26] <rue_house> use a small hose, keep the velocity high, insulate it
[01:39:17] <Casper> 1/2 hose is all I have, no insulation on hand
[04:27:21] <Jartza> Emil: looks you're right, remembered wrong, they added that in attiny 25
[08:14:17] <Emil> Dies anyone have a good makefile, I wrote myself https://emil.fi/jako/makefile for just C programminh but it took great pains to complete and I'm having issues extending it to provide functionality to avrs.
[08:14:39] <Emil> Makefiles are unnecessarily hard
[08:16:05] <Emil> I know I need to add a separate linker at least
[08:42:26] <Lambda_Aurigae> just a min Emil
[08:42:41] <Lambda_Aurigae> I was just testing one from some demo stuff I had laying around...and I'm at work.
[08:43:02] <Lambda_Aurigae> https://sites.google.com/site/emrirc/avrstuff
[08:43:17] <Lambda_Aurigae> there are a couple of example files there...same thing in both.
[08:43:31] <Lambda_Aurigae> the makefile in the adc section is pretty generic.
[08:51:21] <carabia> www
[08:53:59] <Lambda_Aurigae> if you say so.
[09:01:24] <Vikinger> ill have a look later
[09:01:26] <Vikinger> also
[09:03:57] <Vikinger> i found a good project about the random generatign thing
[09:05:01] <Vikinger> uint8_t randSeed = eeprom_read_byte ((uint8_t*)1); ++randSeed; eeprom_write_byte ((uint8_t*)1, randSeed); srand (randSeed);
[09:05:15] <Vikinger> using eeprom
[09:22:58] <rue_house> you might also get away with seeding it with a value of an ADC channel
[09:23:14] <rue_house> esp if you have a floating pin
[09:23:38] <rue_house> the m328 has two adc-only pins
[09:23:56] <LeoNerd> The 328PB fixes that, by the way :)
[09:24:07] <LeoNerd> Adds PORTE, puts two digital pins on those ADC6/ADC7
[09:24:26] <rue_house> cool I was dissapointed when I found out they weren't part of io
[09:26:37] <rue_house> there is something about using a transsistor junction to generate white noise, not sure how that goes
[09:39:05] <Vikinger> im using attiny13 and all pins are busy
[09:39:46] <rue_house> you just need to get a seed on startup, are all the pins pulled high and or low during startup?
[09:40:03] <Vikinger> depends
[09:40:15] <Vikinger> im using charlieplexing to drive leds
[09:40:23] <rue_house> ooo perfect
[09:40:25] <Vikinger> i think can use it at startup
[09:40:39] <rue_house> they all start as inputs, do grab an adc channel value
[09:40:42] <LeoNerd> If you're looking for a random seed, another thing you can do is time correlations between a timer channel and the WDT
[09:40:55] <LeoNerd> Because the WDT is its own separate RC oscillator, so it won't be in lockstep with the main timer
[09:40:56] <rue_house> ah
[09:41:20] <rue_house> I like that better
[09:41:37] <LeoNerd> A lot easier on a chip that has WDT prewarning interrupts
[09:41:40] <rue_house> do you have to setup a wdt overflow to count it?
[09:41:52] <Vikinger> ill check that
[09:41:57] <LeoNerd> Use the prewarning interrupt, capture the value of the fast timer, ack the WDT
[09:42:13] <rue_house> I think there is a flag that tells you the boot was because of wdt
[09:42:27] <LeoNerd> Yes; on non-prewarning capable chips that's the approach you use
[09:42:31] <LeoNerd> A bit more annoying, but that's possible too
[09:42:40] <rue_house> you could look for it on startup and disable the wdt if it was a wdt startup
[09:42:43] <LeoNerd> WDT reset does reset a lot of the peripherals though
[09:42:49] <LeoNerd> So you have to reconfigure everything again
[09:42:49] <rue_house> oh :/
[09:43:04] <LeoNerd> That's why the prewarning interrupt version is a lot nicer, because that doesn't
[09:43:10] <rue_house> not alot of room on a t13 either
[09:43:41] <rue_house> dosn't a prewarning defeat the purpose of a wdt?
[09:43:58] <LeoNerd> It's only a prewarning; you still get the real timeout after it
[09:44:05] <LeoNerd> if you don't ack it
[09:44:36] <rue_house> yea, but if the processor is locked up on someting that the prewarning gets around, the point of a watchdog is defeated
[09:44:48] <LeoNerd> Wellsure; depends how you write the code
[09:44:57] <rue_house> badly if your using a wdt
[09:45:26] <rue_house> in 1 year I had a PIC lock up on me hardware wise about 8+ times
[09:45:40] <rue_house> in 16 years I'v never had an avr hardware wise lock up
[09:46:24] <rue_house> (pics are hypersensitive to power quality)
[09:46:28] <LeoNerd> Mmm
[09:46:55] <LeoNerd> Yah I don't think I've ever had an AVR lock up to the point that #RESET doesn't bring it back
[09:47:26] <rue_house> no I'm talking about a spike or dip in power on a battery powered robot
[09:47:47] <rue_house> if you fire a low spike or two at a pic, it'll usually freeze up
[09:48:37] <rue_house> iirc, an avr, may halt around the 2.8V mark, but will usually resume if the spike isn't below about 1.8
[09:48:50] <rue_house> otherwise, it resets
[09:48:57] <LeoNerd> Depends on BOR fuses
[09:49:06] <rue_house> which it ought if the power is supposed to be 5V
[09:49:53] <rue_house> that said, a PIC can take momentary vcc of 12V and still work :)
[09:50:06] <rue_house> "History of 'OOPS...'"
[09:52:35] <rue_house> I had a dream I was in a high-class place and they were annoyed at me when I tried to pour myself a drink...
[10:13:23] <Jartza> I give 12V to my avr daily
[10:13:30] <Jartza> it's called high voltage programming :)
[10:14:56] <LeoNerd> 12V on the RESET pin is exceptional, and allowed
[10:44:11] <Jartza> what AVR doesn't like, is negative voltage
[10:45:05] <Emil> LeoNerd: it's probably because of a 12V zener existing there and it not sinking current usually
[10:45:54] <Emil> 12V is not nearly enough to kill the junctions
[14:32:46] <Lambda_Aurigae> rue_house, the transistor junction white noise thing is basically an untuned AM radio.
[14:34:27] <Lambda_Aurigae> Emil, but -12V would do nasty things.
[14:43:28] <Emil> Lambda_Aurigae: yeah
[14:51:15] <tpw_rules> so one common pattern in my code is uint8_t x = read_byte(); uint8_t y = read_byte(); uint16_t num = (x << 8) | y. the compiler compiles as this: http://pastie.org/10984150 where x is r28, y is r24, and num is alarm_ctr. is there a way to convince it to just do sts alarm_ctr+1, x; sts alarm_ctr, y and save the extra garbage? using a + instead of | does not help
[14:52:36] <tpw_rules> i'm not sure how to best combine two 8 bit values into a 16 bit value
[14:54:20] <Lambda_Aurigae> you could force them into specific registers...but that can get hairy sometimes.
[14:54:43] <Lambda_Aurigae> some registers combine into 16bit pairs.
[14:54:44] <tpw_rules> i was hoping something less gnarly
[14:55:03] <Lambda_Aurigae> if you were doing assembly then it's simple enough as you don't have the C overhead killing your register assignments.
[14:55:04] <tpw_rules> like it's a value in memory that's later read by an isr. it's just all the shifting and registers are useless when it could just do sts
[14:55:20] <tpw_rules> like there's no reason it can't sts r24 and r28. it's an optimization issue, methinks
[14:55:27] <sebus> as Lambda_Aurigae said, tpw_rules look at x, y and z registers (r26..r31 iirc)
[14:55:58] <tpw_rules> i think you guys are misunderstanding. i don't need them as 16 bits in a register. i need them as 16 bits in memory
[14:56:40] <Lambda_Aurigae> then create memory location reservation
[14:56:43] <Lambda_Aurigae> and write directly.
[14:56:49] <tpw_rules> in that asm snippet the first four instructions are useless
[14:57:03] <tpw_rules> they don't do anything of value. not sure why they're there?
[14:57:07] <tpw_rules> Lambda_Aurigae: like using pointers?
[14:57:23] <Lambda_Aurigae> well, you use malloc to reserve the memory location...its return is a pointer.
[14:57:28] <tpw_rules> what?
[14:57:31] <Lambda_Aurigae> then you use the pointer to the memory location to write it out.
[14:57:38] <tpw_rules> i don't need malloc. these are static values
[14:58:08] <Lambda_Aurigae> then how do you intend to tell the compiler not to overwrite your memory locations?
[14:58:42] <Lambda_Aurigae> you could create one variable of 16 bits then use a pointer to the variable and do it that way I suppose.
[14:58:51] <tpw_rules> that seems to be working but it's ugly
[14:59:07] <Lambda_Aurigae> so write it in assembly and make it pretty
[14:59:52] <tpw_rules> well of course. but my question is if i'm doing something wrong to not trigger an optimization
[15:00:56] <sebus> <tpw_rules> like it's a value in memory that's later read by an isr. it's just all the shifting and registers are useless when it could just do sts
[15:01:17] <sebus> if you read/modify/write value in isr, it shoud be volatile
[15:01:23] <tpw_rules> it is, i didn't notate that here
[15:01:33] <tpw_rules> sorry
[15:02:19] <sebus> hummm....
[15:02:48] <tpw_rules> lemme write a test case
[15:17:02] <tpw_rules> ugh now it's involving the Z register and i'm just upset
[15:23:59] <tpw_rules> i can't make it do the thing i want in a small sample
[15:33:21] <tpw_rules> okay here is it pared down: http://pastebin.com/1NNdWQ9w
[15:33:39] <tpw_rules> i'm apparently gonna have to write a macro to do it in asm
[15:41:13] <sebus> why you don't use serial rx interrupt? blocking functions are ugly
[15:41:24] <sebus> http://pastebin.com/YauUvppu meh
[15:42:23] <tpw_rules> what options did you use
[15:43:07] <tpw_rules> and i mean i do. the real code has the rx interrupt put incoming chars into a circular buffer. main code calls that function which either returns a character or falls asleep until one comes
[15:43:33] <sebus> -o2 as usual / atmel toolchain 3.5.0.1662
[15:43:48] <tpw_rules> so not avr gcc
[15:44:18] <tpw_rules> yeah -o2 with avr gcc generates code that looks like that. -os is the problem
[15:44:19] <tpw_rules> weird
[15:55:34] <Lambda_Aurigae> Thomas Watson....Waht's the P stand for?
[15:56:35] <sebus> Lambda_Aurigae :D
[15:57:06] <Lambda_Aurigae> yeah, I've been on the avr-gcc, avrdude, and avr-libc mailing lists since 2008
[15:57:41] <Lambda_Aurigae> hmmm...avrdude since 2006 it seems.
[16:07:46] <Lambda_Aurigae> http://www.microchip.com/wwwproducts/en/47C16
[16:08:08] <Lambda_Aurigae> EERAM....eeprom backed sram
[16:08:09] <tpw_rules> Lambda_Aurigae: so i don't care much but how did you figure that out?
[16:08:18] <tpw_rules> is that what my email client sent to the list
[16:08:27] <Lambda_Aurigae> tpw_rules, your name? you posted to the avr-gcc mailing list.
[16:08:39] <tpw_rules> ah okay. it asked for my name and i only typed in Thoma
[16:08:40] <tpw_rules> s
[16:08:42] <tpw_rules> i wonder why it asked then
[16:09:06] <Lambda_Aurigae> and you signed the email with Thomas
[16:09:14] <tpw_rules> well i didn't think i gave my last name
[16:09:21] <tpw_rules> is the point
[16:11:02] <tpw_rules> what's funny is when irc weirdos whois me and are like
[16:11:07] <tpw_rules> "what's up,... Albert ;)"
[16:11:24] <antto> Lambda_Aurigae fram is bett0r
[16:11:38] <tpw_rules> and it takes me like 10 seconds to be like "who is albert" and then i remind them that albert pearson is a complicated "A. Person"
[16:11:42] <tpw_rules> then they shut iup
[16:11:54] <Lambda_Aurigae> antto, this is a nifty tech..10uF cap and that chip and you have an automagic sram backup.
[16:12:04] <antto> i2c
[16:12:09] <antto> meh
[16:12:09] <Lambda_Aurigae> yup.
[16:12:13] <tpw_rules> and you don't have to worry about cycling data
[16:12:27] <antto> FRAM ftw
[16:12:29] <tpw_rules> is it brand new?
[16:12:31] <Lambda_Aurigae> unlimited writes like sram...and autobackup on power off.
[16:12:34] <Lambda_Aurigae> yeah...very new.
[16:12:39] <Lambda_Aurigae> I saw it mentioned about 2 weeks ago.
[16:12:42] <tpw_rules> the datasheet is marked 10/10/16
[16:12:42] <Lambda_Aurigae> just looked it up again.
[16:13:20] <antto> i am basically doing something like that on my atmega device, with just a normal SPI eeprom backing a 4KB chunk of RAM in the atmega
[16:13:44] <antto> i got periodical scanning in the background which updates the dirty regions
[16:13:58] <tpw_rules> Lambda_Aurigae: so how is this better than fram, actually
[16:14:08] <Lambda_Aurigae> tpw_rules, dunno..gotta look at fram and see.
[16:14:20] <antto> so if anything is modified in the RAM - it takes 2 seconds max for the cycle to reach it and update it
[16:14:35] <Lambda_Aurigae> who makes fram?
[16:14:41] <antto> cypress
[16:15:08] <antto> 20MHz SPI FRAM - noice
[16:15:10] <tpw_rules> antto: well the point of this is it could be forever. you can do infinite writes
[16:15:31] <antto> yes, just make sure you don't short that capacitor
[16:15:47] <antto> on the other hand, no worries with the FRAM
[16:16:00] <tpw_rules> how would you short it
[16:16:07] <antto> i don't know
[16:16:21] <antto> how does electronics get f*cked up some times?
[16:16:34] <tpw_rules> well you said as if i would go in and short the capactor
[16:16:37] <tpw_rules> it could certainly fail
[16:17:31] <antto> if i understand correctly, normally that eeram doesn't actually write to the eeprom unless the power goes down, then it would (i guess) use the power from the capacitor to do the actual writing
[16:17:51] <antto> well, if so.. the weak spot is in that capacitor ;P~
[16:18:08] <tpw_rules> yes
[16:18:26] <tpw_rules> i wonder if it can tell you over i2c if the capacitor is healthy
[16:18:32] <Lambda_Aurigae> will have to look at fram and compare later.
[16:18:35] <Lambda_Aurigae> gotta go do work.
[16:19:53] <antto> this is just some normal little mcu there with built-in RAM and EEPROM, nothing fancy
[16:20:18] <antto> microchip: hello? invent something new
[16:20:22] <tpw_rules> i doubt it's an mcu
[16:21:48] <Vikinger> what pastebin for code do you guys use ?
[16:47:53] <Tom_L> any one that works
[16:48:55] <Tom_L> paste.ubuntu.com works
[16:50:25] <Tom_L> https://paste.debian.net/ works
[16:53:04] <LeoNerd> I like pastie.org but it seems unreliable lately...
[16:53:32] <Vikinger> one where you can chose the language
[16:53:41] <Vikinger> i seen it before but cant remember
[17:08:16] <Vikinger> someone has some code to generate random number from 1 to 7
[17:08:17] <Vikinger> ?
[17:08:23] <LeoNerd> 6
[17:09:39] <specing> yeah sure
[17:09:55] <specing> Vikinger: https://www.xkcd.com/221/
[17:12:39] <Vikinger> im a bit stuck here
[17:12:50] <Vikinger> been trying several stuff
[17:14:12] <Vikinger> i have srand() covered
[17:14:27] <Vikinger> but rand() still doesnt get me values in the range i want
[17:18:28] <specing> Have you heard of that fancy contraption called the modulo operator?
[17:19:03] <Vikinger> nop
[17:20:48] <Vikinger> can you help me ?
[17:21:08] <specing> nope
[17:21:35] <Vikinger> ow the modulo operator yes
[17:23:21] <Vikinger> i have tried this http://brownsofa.org/blog/2010/02/09/attiny13-dice/
[17:23:30] <Vikinger> but it doesnt work
[17:32:50] <carabia> Vikinger: you are kidding right?
[17:33:18] <Vikinger> what you mean ?
[17:34:24] <carabia> as i recall you spent the whole last night trying to figure a good seed, and now that you've managed something along those lines, you can't actually figure out how to use rand()? :D
[17:34:37] <Vikinger> yep
[17:34:40] <carabia> I think this is why we have bad software
[17:34:50] <carabia> and also why we can't have nice things
[17:34:55] <carabia> and something something
[17:35:00] <Vikinger> probably
[17:35:26] <specing> lol
[17:35:33] <Vikinger> i have tried everything with rand()
[17:35:34] <carabia> though, i have to give credit for your persistence. Two nights figuring out how to get a random number from 1 to 7
[17:35:49] <Vikinger> thank you
[17:36:06] <carabia> the persistence is admirable. not the result.
[17:36:08] <Vikinger> baby steps
[17:36:13] <Vikinger> im very slow
[17:36:19] <carabia> duly noted
[17:36:23] <Vikinger> i will get the result
[17:36:42] <Vikinger> i usually get there and i only need to learn once
[17:37:13] <carabia> so any luck with modulos?
[17:37:18] <Vikinger> nop
[17:37:26] <Vikinger> rand() % 8
[17:37:31] <Vikinger> does not work
[17:37:33] <carabia> almost there.
[17:37:51] <Vikinger> 1 + (rand() % 8)
[17:37:54] <Vikinger> also not
[17:37:58] <carabia> it's kind of like
[17:38:05] * specing is like ?_?
[17:38:23] <carabia> brute forcing a problem and not stopping to think is often times a very poor method to approach problems
[17:38:35] <carabia> method of approach, even
[17:38:51] <Vikinger> i have been trying
[17:39:42] <carabia> and i'll try
[17:39:48] <carabia> oh lord i'll try
[17:39:53] <carabia> to caarry oooon
[17:40:06] <specing> code monkey right there :D
[17:40:37] <Vikinger> lol
[17:40:47] <Vikinger> sometimes
[17:41:01] <carabia> wat
[17:42:01] <Vikinger> actually i can be a cargo cult coder sometimes
[17:42:36] <Vikinger> i try to undestand what im doing, but sometimes i prefer to have it working and then analize it
[17:43:02] <Vikinger> but i do agree the best is to stop and think first
[17:44:11] <carabia> yeah everyone likes some analing from time to time
[17:45:33] <Vikinger> some people do aparently
[17:46:14] <carabia> But!
[17:46:22] <carabia> where do we go from here?
[17:46:33] <carabia> you can't give up now.
[17:47:41] <Vikinger> reading more about modulo
[17:48:37] <carabia> also to reflect upon your comment there on what you think is the best practice
[17:49:01] <carabia> unfortunately, just having the opinion that it's good, doesn't get you anywhere
[17:49:13] <Vikinger> indeed
[17:49:17] <Vikinger> very true
[17:49:35] <Vikinger> but you guys have point me on the right direction
[17:49:43] <Vikinger> and im actually reading about it now
[17:50:03] <carabia> right direction == 7th grade math?
[17:50:19] <specing> was about to suggest a highschool math book :D
[17:50:32] <Vikinger> :)
[17:50:45] <Vikinger> man i have tried the modulo on the code
[17:51:52] <carabia> specing: shut up. time to patch some ada.
[17:52:34] <carabia> does ada have great optimization on mod?
[17:54:38] <specing> Ada has no bullshit like '%'
[17:54:46] <specing> you have two infix operators: mod and rem
[17:55:29] <specing> In addition to that, you have modular types: https://en.wikibooks.org/wiki/Ada_Programming/Types/mod
[17:55:51] <specing> transparent wrap-around arithmetic
[17:56:06] <specing> Clearly Ada is lightyears ahead of C
[17:56:39] <specing>
[17:56:53] <carabia> QED
[17:57:12] <specing> :)
[18:00:24] <Vikinger> well maybe i have some other problem
[18:00:48] <Vikinger> rand() % 8, should do it
[18:01:20] <carabia> are you sure?
[18:01:29] <carabia> final answer?
[18:02:05] <carabia> would you like to ask the audience?
[18:02:21] <specing> or phone someone?
[18:02:23] <Vikinger> not specifically from 1 to 7, but i should get an integer
[18:02:35] <Vikinger> i would ask a friend
[18:02:44] <Vikinger> but nobody likes me
[18:03:30] <Vikinger> unless you guys will be my friends :)
[18:04:41] <carabia> you're from scandinavia, so i don't want to be your friend
[18:05:01] <Vikinger> ok
[18:05:14] <Vikinger> beer budy ?
[18:05:31] <Vikinger> or drinking budy
[18:05:49] <carabia> no budy, bodi, buudi, boody or the sorts.
[18:06:31] <Vikinger> ok
[18:07:10] <Vikinger> so whats the verdict ?
[18:07:55] <carabia> so
[18:08:02] <carabia> no budies.
[18:08:20] <carabia> what does the % operator give you?
[18:08:21] <Vikinger> nop
[18:08:26] <Vikinger> the remainder
[18:08:34] <carabia> good.
[18:08:47] <Vikinger> which is an integer
[18:09:03] <carabia> it's implied
[18:09:07] <Vikinger> can i ask something stupid ?
[18:09:15] <specing> >_>
[18:09:21] <Vikinger> for a change :P
[18:09:31] <Vikinger> is this allowed ? rand_numer = rand() % 8;
[18:09:44] <carabia> christ, just focus on the fucking math for now
[18:10:01] <Vikinger> ok ok
[18:10:16] <Vikinger> yes i got the remainder
[18:10:59] <carabia> so rand gives you a number ranging from 0 up to some positive value
[18:11:37] <Vikinger> yes
[18:11:49] <Vikinger> got it
[18:12:14] <carabia> so now the million $$$ question, when you perform your rem on that number, what's the possible range for the remainder?
[18:13:20] <Vikinger> 0 to 7
[18:13:40] <carabia> okay, great.
[18:13:59] <carabia> now you wanted your range to be 1 to 7
[18:14:07] <Vikinger> yes
[18:14:11] <carabia> how in the fuck, could we possibly manage that?
[18:14:34] <Vikinger> if zero add one, for example
[18:14:44] <carabia> good good, what about the upper end?
[18:14:56] <carabia> 7+1 is clearly outside your range
[18:15:01] <Vikinger> yep
[18:15:03] <specing> My forehead is now flat
[18:15:06] <carabia> so, wtf do you do?
[18:15:14] <carabia> specing: shut up we're working here
[18:15:31] <Vikinger> i just check for 0 and add 1
[18:15:36] <Vikinger> leave the rest alone
[18:15:48] <carabia> his forehead just got flatter
[18:16:04] <carabia> there's a more elegant way of doing that
[18:16:14] <carabia> stop brute forcing the issue.
[18:16:31] <Vikinger> me ???
[18:16:35] <carabia> yes
[18:16:39] <Vikinger> ok
[18:16:57] <Vikinger> make
[18:17:09] <Vikinger> % 9
[18:17:14] <Vikinger> and - 1
[18:17:23] <Vikinger> no wait
[18:17:24] <carabia> no you could get a negative number
[18:17:29] <Vikinger> yes
[18:18:51] <Vikinger> nop
[18:18:55] <carabia> one more try, i can feel it this one's for the money.
[18:20:54] <Lambda_Aurigae> or edit stdlib.h and change RAND_MAX to 7
[18:21:31] <Vikinger> i think ive tried that
[18:21:45] <carabia> that would actually be the most efficient way
[18:21:50] <carabia> at least in this framework
[18:21:51] <Vikinger> i must have messed up somewhere since it didnt work at the time
[18:22:14] <carabia> no seriously
[18:22:16] <specing> Lambda_Aurigae: LOL
[18:22:30] <Lambda_Aurigae> what? I'm being serious here....for a change.
[18:22:34] <carabia> me too.
[18:22:43] * Lambda_Aurigae points at specing
[18:22:44] <carabia> i was just going to say that i seriously cannot take this
[18:23:03] <specing> well the sillyness of doing that depends on the reasoning
[18:23:22] <carabia> perhaps. but efficiency is king
[18:23:23] <Vikinger> i dont see it now
[18:23:30] <specing> i.e. knowing damn well what you are doing
[18:23:41] <specing> this is not the case with Vikinger :D
[18:23:47] <Lambda_Aurigae> specing, well, not knowing basic math and all,,,
[18:23:49] <Vikinger> nop
[18:23:51] <carabia> (rand() % 7) + 1
[18:23:57] <carabia> i'm out to kill myself
[18:24:03] <Vikinger> ow
[18:24:07] <Vikinger> thats right
[18:24:08] <carabia> i do not fucking get it
[18:24:10] <Vikinger> :)
[18:24:13] <Vikinger> genious
[18:24:19] <Tom_L> seen abcminiuser today?
[18:24:19] <specing> lol
[18:24:24] <carabia> how much more simpler should have i put it.
[18:24:30] <carabia> i tried. oh lawd i tried.
[18:24:37] <carabia> but no. no no no.
[18:24:39] <Vikinger> thank you carabia
[18:24:45] <carabia> Vikinger: no. Fuck you
[18:24:50] <Lambda_Aurigae> carabia, you should have done it in Ada,,,or FORTRAN
[18:24:55] <Vikinger> sorry for the headacke
[18:24:57] <Vikinger> lol
[18:25:14] <Lambda_Aurigae> carabia, I stopped trying to teach in here a long time ago.
[18:25:37] <carabia> i think i contracted aids or something.
[18:25:39] <Lambda_Aurigae> years ago I found people don't want to learn. They just want the answer.
[18:25:49] <Lambda_Aurigae> carabia, yeah...teacher's aids
[18:25:52] <Vikinger> thats not my case
[18:26:01] <carabia> Lambda_Aurigae: i know, and i also know it is exactly his case.
[18:26:04] <Vikinger> im might be tick sometimes
[18:26:16] <carabia> but hey, it's christmas time
[18:26:26] <Vikinger> believe me guys
[18:26:36] <carabia> i for one like the tradition. no liberals will ruin it for me
[18:26:56] <Vikinger> and thanks a lot carabia
[18:27:26] <Lambda_Aurigae> I avoid religious holidays,,,and hallmark holidays,,,and general celebrations of anything....I tend to sleep through them.
[18:27:38] <Vikinger> i do not forget when im helped
[18:27:47] <Lambda_Aurigae> only thing christmas means to me is two paid days off work.
[18:28:25] <carabia> more often than not christmas isn't viewed as a particularly religious holiday in here
[18:28:39] <Vikinger> still not working like i suspected
[18:28:40] <Tom_L> hallmark has a card for every day
[18:28:57] <carabia> Vikinger: then you are doing something else wrong.
[18:29:36] <Vikinger> i was trying to tell you that
[18:29:50] <Vikinger> you could have spared yourself the headacke
[18:30:07] <Vikinger> im persistent and patient ;)
[18:30:48] <carabia> Vikinger: no, in fact what you told me was that you couldn't figure out how to offset rand
[18:30:54] <carabia> well, to offset the result, anywho
[18:31:41] <Vikinger> i did try to ask you something else
[18:31:53] <carabia> so i just like christmas. something that's stuck since i was a kid. it has a good vibe, even though i have cynical tendencies
[18:32:59] <Vikinger> but at least now i can narrow down further my problem
[18:33:36] <Lambda_Aurigae> carabia, never was a christmas fan since I was about 10 or so.
[18:33:44] <carabia> on what are you running your junk on?
[18:34:09] <Vikinger> attiny13a
[18:34:16] <Vikinger> uint8_t rand_numer = 1;
[18:34:28] <Vikinger> rand_numer = ((rand() % 7) + 1);
[18:34:38] <Vikinger> i should get an integer after this, right ?
[18:35:53] <carabia> yes
[18:35:59] <Lambda_Aurigae> you might need a cast or two.
[18:36:11] <Lambda_Aurigae> rand() returns a 16bit integer.
[18:36:13] <carabia> though people more software nerdy than i am would know at what point does the rand get casted
[18:36:17] <carabia> cast, even
[18:37:00] <Vikinger> https://codetidy.com/9909/]
[18:37:03] <Vikinger> https://codetidy.com/9909/
[18:37:03] <Lambda_Aurigae> Vikinger, you certainly aren't going to get a float out of it.
[18:37:04] <carabia> but I think that should actually be fine.
[18:37:24] <Vikinger> yes Lambda i got that far
[18:37:48] <Vikinger> ok guys, shoot me again
[18:37:56] * Vikinger opens arms wide
[18:38:12] <carabia> you're not showing any of those led routines. Also that would eventually light up all your leds unless each routine clears all the bits
[18:38:54] <Vikinger> you see the uncomented line
[18:39:09] <Vikinger> if comment it in, and uncoment the one under it
[18:39:16] <Vikinger> the right led goes on
[18:39:24] <Vikinger> i have debuged the leds
[18:39:26] <Vikinger> that is fine
[18:40:20] <carabia> well you could cast it but i don't think it should be strictly necessary
[18:40:43] <carabia> though i guess there's something i'm overlooking...
[18:41:09] <Vikinger> unlesshttps://codetidy.com/9910/
[18:41:25] <Vikinger> https://codetidy.com/9910/
[18:41:30] <Vikinger> here you go then
[18:41:50] <carabia> What the fuck is this?
[18:41:58] <Vikinger> charlieplex
[18:42:18] <Vikinger> i know its not the most elegant
[18:42:29] <Vikinger> but i will work on it later
[18:42:48] <carabia> shouldn't have posted this, specing will criticize
[18:43:13] <Vikinger> by now i realize i worst then a noob
[18:43:16] <Vikinger> so fuck it
[18:43:39] <Vikinger> i will learn something after this
[18:44:00] <Vikinger> i could use arduino, but i want to learn
[18:44:05] <Vikinger> see :P
[18:46:27] <Vikinger> im actually working on a funtion and a table to replace those led funtions
[18:46:47] <Vikinger> but now i need to see this working first so i dont get lost
[18:48:23] <carabia> what's your delay
[18:48:41] <Vikinger> 300ms
[18:50:56] <twnqx> hm
[18:51:56] <carabia> either there's something i'm overlooking if you're certain that the led routines work the way you think you do
[18:51:59] <carabia> or then they don't
[18:52:21] <carabia> the way you think they do, even.
[18:53:26] <twnqx> first of all, i'd remove the PB3 writes, they are pointless
[18:54:22] <twnqx> second, you never change the values of PORTB PB0 and PB2 back
[18:54:43] <Vikinger> PB3 changes
[18:54:48] <Vikinger> i cant ignore it
[18:55:04] <Vikinger> sorry my bad i did not put all the numbers
[18:55:07] <twnqx> i see DDRB &= ~_BV(PB3); in both but never any PORTB PB3
[18:55:15] <Vikinger> w8
[18:55:29] <Lambda_Aurigae> there is a port W?
[18:55:45] <twnqx> ...
[18:55:59] <twnqx> you should be on the internet for long enough to know the meaning of w8
[18:56:24] <Lambda_Aurigae> sorry...screen reader does not convert idiot shorthand properly.
[18:56:24] <carabia> that's what i was thinking, you're never setting the states back
[18:56:49] <carabia> but i'm done with this endeavor
[18:57:21] <Vikinger> https://codetidy.com/9911/
[18:58:34] <Vikinger> ok carabis
[18:58:35] <Vikinger> ok carabia
[18:58:46] <Vikinger> ill bug you more tomorow
[18:59:05] <carabia> i'm leaving town tomorrow. so that's a no-go
[18:59:33] <Vikinger> i will create another project when you get back just for you :)
[19:00:21] <Vikinger> or if you are lucky ill find another prefered victim
[19:00:32] <Vikinger> you can rest now
[19:00:34] <Vikinger> :)
[19:01:04] <Vikinger> twnqx whats your veridict now ?
[19:01:37] <carabia> Vikinger: see this is the root of your problem
[19:02:26] <Vikinger> im just kiding man
[19:02:34] <carabia> instead of debugging it, you're just asking around for people to solve your problems. i'm guilty of enabling this kinda shizzle, though
[19:02:37] <Vikinger> i am still learning
[19:02:59] <Vikinger> and i have been debugging
[19:03:03] <carabia> no you're not. you're interrogating
[19:03:11] <Lambda_Aurigae> eliminate everything but the problem you are working on...make it flawless...then add other parts.
[19:03:23] <Vikinger> like this
[19:03:23] <twnqx> there's a few things
[19:03:41] <twnqx> first of all, you should switch the order of your DDR writes - first turning off bits, then turning on bits
[19:03:45] <Vikinger> i spent like 3 days debugging the leds routine
[19:04:17] <Vikinger> and i have been working like Lambda_Aurigae is saying
[19:04:22] <twnqx> secondly, it would be easier to just use constants for both DDR and PORT registers
[19:05:04] <carabia> Vikinger: well obviously you have not. To double-check me, you can add the cast (or two) to the rand
[19:05:20] <Vikinger> i have tried the cast now
[19:05:21] <twnqx> thirdly, you never clear the old state, so you might accidentally enable pullup resistors
[19:06:19] <Vikinger> twnqx clear the old state, meaning to clear all bits on DDR ?
[19:06:22] <twnqx> you should just try a sequence to see if they work if switched one by one, like led1_on(); delay; led2_on(); delay
[19:06:27] <twnqx> no, on port
[19:07:05] <twnqx> third, you definitely want to learn about the switch() statement
[19:07:09] <twnqx> or fourth or so
[19:07:24] <Vikinger> i have tried a sequence with diferent speeds on all of them, exactly like it is
[19:07:30] <Vikinger> and all work
[19:08:03] <carabia> Vikinger: and to actually eliminate any possibility of overflows, use int n = (rand() % 7) + 1;
[19:08:06] <Vikinger> twnqx i also tried the switch() before the if else
[19:08:43] <Vikinger> ok carabia
[19:08:44] <carabia> well, could do uint
[19:09:21] <carabia> but no, it shouldn't need to be like so. it's clear that it's not the problem
[19:09:29] <twnqx> The rand() function computes a sequence of pseudo-random integers in the range of 0 to RAND_MAX (as defined by the header file <stdlib.h>).
[19:09:31] <carabia> as if it were, the else would fire anyway.
[19:09:36] <twnqx> so no floats involved
[19:10:06] <Vikinger> thats the weird part
[19:10:11] <twnqx> given the function of the RNG behin it, it will always produce the same sequence
[19:10:19] <Vikinger> the else doesnt work
[19:10:25] <carabia> twnqx: given the same seed, that is
[19:10:39] <twnqx> well, you don't really have a source for a seed
[19:10:45] <Vikinger> and with the switch the same efect
[19:11:00] <carabia> twnqx: ? of course you do
[19:11:00] <Vikinger> switch or else here i get the same result
[19:11:22] <twnqx> do you? delay between the initial keypresses?
[19:11:32] <twnqx> ADC noise?
[19:11:41] <twnqx> ok, you'd have a source or another
[19:11:41] <carabia> yes, for example
[19:12:10] <Vikinger> and like i said the uncomment line makes, rand_numer = 2;
[19:12:14] <Vikinger> and then it works
[19:12:23] <carabia> well, try all the leds.
[19:12:30] <Vikinger> or if i change it to rand_numer = 5;
[19:12:34] <Vikinger> all work
[19:12:56] <Vikinger> but if i make it rand_numer = ((rand() % 7) + 1);
[19:13:04] <Vikinger> nothing, zero, nill
[19:13:06] <carabia> try all of your routines
[19:13:27] <twnqx> ok, you get no LEDs on _at all_?
[19:13:35] <Lambda_Aurigae> so
[19:13:37] <Lambda_Aurigae> break it out
[19:13:38] <Vikinger> nop
[19:13:48] <Lambda_Aurigae> get rid of everything else but the random generation and see what it puts out.
[19:13:53] <Vikinger> like not even the, else
[19:13:55] <Vikinger> works
[19:14:21] <twnqx> so
[19:14:24] <twnqx> do me a favor
[19:14:26] <twnqx> use your leds
[19:14:47] <carabia> here comes the money
[19:14:50] <twnqx> led1_on(); rand_numer = ((rand() % 7) + 1); led2_on(); while (1) {};
[19:15:36] <twnqx> what you are describing can only happen if the program crashes in rand()
[19:15:45] <twnqx> or hangs
[19:15:47] <Vikinger> exactly
[19:15:57] <twnqx> so check if it happens?
[19:16:07] <Vikinger> it does
[19:16:48] <Vikinger> im going to try something more simple
[19:16:50] <twnqx> so with above code, led1 turns on, but stays?
[19:17:04] <twnqx> and doesn't instantly switch to led 2?
[19:17:07] <Lambda_Aurigae> rand() use too much ram?
[19:17:36] <twnqx> hmmm
[19:17:44] <Lambda_Aurigae> only 64 bytes of ram on that chip.
[19:17:59] <carabia> oh wait yeah
[19:18:36] <twnqx> possible
[19:18:38] <Lambda_Aurigae> function calls are nasty for ram
[19:18:47] <twnqx> anyway, i should be in bed for an hour or two
[19:18:58] <twnqx> out of stack? :P
[19:19:10] <carabia> has to be really
[19:19:23] <Vikinger> yep
[19:19:35] <Vikinger> rand() crashes
[19:19:44] <Lambda_Aurigae> stack and heap running into each other.
[19:19:53] <Lambda_Aurigae> stack grows from top down..heap from bottom up.
[19:20:04] <Lambda_Aurigae> when the two meet,,,reboot
[19:20:08] <Vikinger> wunderbar
[19:20:36] <carabia> so there was something i was overlooking. there you finally have it, after two days.
[19:21:03] <Vikinger> :)
[19:21:13] <Lambda_Aurigae> back to,,,,elimiate everything else and test just the one function.
[19:21:17] <Lambda_Aurigae> which, wasn't done.
[19:21:37] <Vikinger> which function ?
[19:21:42] <Lambda_Aurigae> rand()
[19:21:48] <Vikinger> i did
[19:22:08] <carabia> well, it kind of is done. I don't think he has uart set up for debugging...
[19:22:13] <Vikinger> rand is from the avr-lib
[19:22:15] <Vikinger> rand is from the avr-libc
[19:22:22] <Lambda_Aurigae> he has simple LEDs that can blink.
[19:22:58] <Vikinger> there is no uart
[19:23:01] <carabia> well sure, but at least according to him he has debugged them and proven to work
[19:24:05] <Vikinger> i chose the perfect avr to start :|
[19:25:50] <Vikinger> yes the leds are working
[19:26:04] <Tom_L> what avr did you start with?
[19:26:07] <Vikinger> all the trouble start when i use rand()
[19:26:32] <Vikinger> ow im lying
[19:26:40] <carabia> all the trouble started when you used a piss poor overpriced avr
[19:26:42] <Vikinger> i have used atmega328 before
[19:27:02] <Tom_L> good all around chip
[19:27:19] <Vikinger> with avr-gcc i used then uart buttons and other stuff
[19:27:32] <Vikinger> it didnt got me 1/4 of the problem
[19:27:40] <Vikinger> this one is giving
[19:28:19] <Vikinger> http://brownsofa.org/blog/2010/02/09/attiny13-dice/
[19:28:24] <Vikinger> this guy did it
[19:28:43] <carabia> for a beginner to start out with a 64B ram chip is a fucking suicide anyway
[19:29:53] <Vikinger> he is using this function
[19:29:55] <carabia> Vikinger: the guy has his own piss-poor prng function
[19:30:05] <carabia> oh wait no he doesn't
[19:30:15] <Vikinger> int rng(int min, int max)
[19:30:15] <Vikinger> { return (min + (rand() / (RAND_MAX/(max+1)))); // not using _quite_ the most naive application of rand()
[19:30:19] <Vikinger> }
[19:30:30] <Vikinger> fuck
[19:30:41] <Vikinger> return (min + (rand() / (RAND_MAX/(max+1))));
[19:30:46] <Lambda_Aurigae> Vikinger, linux, windows, or mac?
[19:30:48] <Vikinger> ^
[19:30:49] <Vikinger> this
[19:31:18] <Vikinger> Lambda_Aurigae Linux, vim, avr-gcc
[19:31:48] <Lambda_Aurigae> ok...if you were using windows you could use atmel studio and simulate it and see where it goes wrong.
[19:34:02] <Vikinger> anyone else using linux
[19:34:27] <Vikinger> i have been getting this when compiling
[19:34:30] <Vikinger> make: Warning: File 'main.o' has modification time 243 s in the future
[19:34:42] <Vikinger> make: warning: Clock skew detected. Your build may be incomplete.
[19:34:51] <Vikinger> could this be fucking my code ?
[19:36:19] <Lambda_Aurigae> not likely.
[19:36:29] <Lambda_Aurigae> there is a file somewhere with a bad time stamp.
[19:36:58] <Lambda_Aurigae> make clean
[19:37:05] <Lambda_Aurigae> if your makefile has a clean function
[19:38:44] <Vikinger> i did it
[19:38:57] <Vikinger> no change
[19:39:16] <Vikinger> so im
[19:39:29] <Vikinger> starting to think i have to use another micro
[19:39:37] <Lambda_Aurigae> or fix your code
[19:39:49] <Lambda_Aurigae> which means figuring out what the problem is...
[19:40:14] <Lambda_Aurigae> eliminate some variables for starters...
[19:43:09] <Vikinger> ok
[19:43:25] <Vikinger> it all goes to well as soon has i use rand()
[19:43:38] <Vikinger> i thing thats pretty much narrowed down
[19:50:01] <Vikinger> ok
[19:50:07] <Vikinger> fuck i think i got it :)
[19:50:50] <Vikinger> Lambda_Aurigae: i had forgoten to clean some fucking table, a 2 dimensions one
[19:50:55] <Vikinger> even worse
[19:51:13] <Vikinger> Fuck yes
[19:51:40] <carabia> ?
[19:53:47] <carabia> some crap in your code eating away your precious 64B?
[19:54:03] <Vikinger> yep
[19:54:15] <carabia> seriously why are people attracted to attinys. The mega line is shit enough with its ram.
[19:54:16] <Vikinger> see i learned something precious
[19:54:26] <Lambda_Aurigae> yes
[19:54:29] <Vikinger> in my case
[19:54:30] <Lambda_Aurigae> or not
[19:54:31] <Vikinger> pins
[19:54:33] <Lambda_Aurigae> I told you earlier
[19:54:41] <Lambda_Aurigae> GET RID OF EVERYTHING ELSE
[19:54:43] <Vikinger> and sop8
[19:54:53] <Vikinger> soic8
[19:54:57] <carabia> pins? pins? pins waht the fuck?
[19:55:10] <Vikinger> yes
[19:55:12] <carabia> too many never hurt.
[19:55:14] <Vikinger> miniaturization
[19:55:16] <carabia> you get more pins for less $
[19:55:39] <Vikinger> when the project is finished ill show you
[19:55:52] <Vikinger> thank you a lot guys
[19:56:03] <Vikinger> Merry Xmas
[19:56:14] <Lambda_Aurigae> and you used a 2D array on a chip with 64 bytes of ram?
[19:56:38] <carabia> Lambda_Aurigae: that was very clairvoyant of you. Did never occur to me he had that going on.
[19:56:58] <Vikinger> lol
[19:57:04] * Lambda_Aurigae is psychotic,,,errr,,,psychic.
[19:57:20] <Vikinger> yes i kept it to use it later, but i forgot to comment out
[19:57:31] <Vikinger> lesson learned
[19:57:43] <carabia> Vikinger: you can get arms with 2K ram, soic8
[19:57:52] <carabia> with less than half the price of the tiny13
[19:58:20] <Lambda_Aurigae> so, carabia, you hang around here to entice people to arm?
[19:58:32] <carabia> yes
[19:58:49] <Lambda_Aurigae> ok..just checking.
[19:58:56] <carabia> 's fine
[19:59:09] <carabia> probably bigger pics too, i'm quite sure
[19:59:13] <Vikinger> yes i will chose wiser next time
[19:59:39] <Lambda_Aurigae> I like my pic32mx chips for overall power.
[19:59:50] <Lambda_Aurigae> but avr is still easier to use overall in my opinion.
[20:00:09] <Vikinger> i have used pic many times
[20:00:16] <Vikinger> avr not so much
[20:00:38] <Vikinger> but i like that i can use VIM and linux
[20:00:50] <Vikinger> with pic is possible but not so eficient
[20:00:51] <Lambda_Aurigae> I can do the same with pic.
[20:00:53] <Lambda_Aurigae> and pic32
[20:01:07] <Vikinger> mplabx runs on linux
[20:01:18] <Vikinger> but can you use vim ?
[20:01:19] <carabia> your flavor of text editor makes no difference
[20:01:19] <Lambda_Aurigae> for pic32, I just use gcc.
[20:01:24] <Lambda_Aurigae> I use vi.
[20:01:41] <Vikinger> i guess if you have a proper makefile
[20:01:49] <Lambda_Aurigae> you kids and your new fangled junk. :}
[20:02:07] <Vikinger> have you tried sdcc ?
[20:02:32] <Lambda_Aurigae> not for pic32.
[20:02:35] <Lambda_Aurigae> it's too limited.
[20:02:43] <Lambda_Aurigae> pic32 is a mips core chip
[20:02:47] <Lambda_Aurigae> gcc fully supported.
[20:03:05] <Vikinger> i didnt know about gcc
[20:03:14] <Lambda_Aurigae> xc32 is just gcc
[20:03:24] <Lambda_Aurigae> hell, microchip even gives you the source for it.
[20:03:24] <Vikinger> but you have to tweak gcc around
[20:03:27] <Lambda_Aurigae> if you can compile it.
[20:03:45] <Vikinger> or can you just use out of the box like with avr-gcc
[20:03:46] <Lambda_Aurigae> nope...just add headers and libc stuff.
[20:04:09] <Vikinger> ok cool
[20:04:23] <carabia> yes and do you guys know, what else has a fully functional gnu toolchain?
[20:04:24] <Vikinger> i used pic14 and 16 mostly
[20:04:28] <Lambda_Aurigae> there's ways and there's ways.
[20:04:37] <Lambda_Aurigae> carabia, thumb processors?
[20:04:43] <Vikinger> arm
[20:04:51] <carabia> :)
[20:05:25] <Vikinger> i have bought an arm from olimex
[20:05:30] <Vikinger> my next adventure
[20:05:40] <carabia> what arm
[20:06:46] <Vikinger> lpc1343
[20:07:34] <carabia> cm3's pretty nice to start with
[20:07:47] <carabia> nxp's stuff is a bit... meh, though.
[20:08:36] <Vikinger> i had made a makefile
[20:08:51] <Vikinger> havent touched it 2 years :P
[20:08:58] <Vikinger> need to get back to it
[20:09:11] <carabia> ETA on that?
[20:09:29] <carabia> anyway i'm gonna head to bed. it's close to 4am
[20:09:32] <carabia> night.
[20:09:55] <Vikinger> yes
[20:09:57] <Vikinger> same here
[20:10:01] <Vikinger> thanks dude
[20:10:09] <Vikinger> out
[20:51:51] <Lambda_Aurigae> http://maxstrauch.github.io/projects/bsc-thesis/index.html
[20:51:58] <Lambda_Aurigae> this constitutes a masters thesis?
[20:55:25] <Snert> yea, emulating a decrepit thing of yesterdecade is devoid of intrest for me.
[20:55:57] <Snert> maybe others might wanna duplicate it out of nostalgia sake.