#avr Logs

Apr 12 2018

#avr Calendar

12:03 AM polprog: Breakfast, off to school later
12:13 AM * _ami_ still listens to music while sipping americano.
12:13 AM * _ami_ is doing a boring work.
12:24 AM Emil: off to work in 5minutes
12:25 AM Emil: I woke up at 7 hoping to get to work by 8
12:25 AM Emil: then I just lagged
12:25 AM Emil: and 9 it is :D
12:51 AM polprog: Hehe.. I need to be at school at 0945
12:51 AM polprog: Its 10 to eight
12:55 AM _ami_: omg! 10 to fucking 8pm?
12:56 AM _ami_: polprog, ^
12:57 AM polprog: 0750
12:57 AM _ami_: thats crazy
12:58 AM _ami_: 5 days per week? or 6days
01:04 AM polprog: 5 days per week
01:04 AM polprog: I wake up at 6 every working day
01:04 AM polprog: I need to get to school at 8 some days, and some days at 9
01:06 AM polprog: Got 4 lessons today starting at 10
01:07 AM polprog: Usually we have 5 but maths is cancelles, the teacher is on a leave
01:07 AM polprog: 2 of them is PE so thursdays are light
01:59 AM polprog: Damn it. Only 2 days till weekend
03:38 AM polprog: Hyvää huomenta
03:38 AM nuxil: random fact of the day. todat its been 57 years since the 1st man was in space, "Juri Gagarin" 12 april 1961 :)
03:38 AM nuxil: *today
03:39 AM polprog: Nice
03:41 AM nohitzwork: huomenta
03:41 AM polprog: :)
03:50 AM Emil: hyväää huomentaaaaaaa
03:52 AM polprog: AYYYYVR
09:36 AM dStruct: polprog: I was able to make some progress with that github example you linked, something isn't right and my ISR isn't triggering, but it's progress
09:37 AM polprog: did you sei() ?
09:40 AM dStruct: polprog: https://paste.ubuntu.com/p/9TdP4ndfJJ/
09:42 AM dStruct: polprog: I think I need to move the if(update) statement back out of the function and put it back into void loop(), I put it there as a test
09:43 AM polprog: id say yes
09:43 AM polprog: add a small bit that will turn on/off a led in the ISR
09:43 AM dStruct: polprog: even then if I do if(update) { digitalWrite(13,HIGH); } it never gets triggered
09:45 AM dStruct: polprog: I adapted the example to my code, using a different timer method, in the example it's using TCCR1B |= _BV(CS10), and TIMSK1 |= _BV(TOIE1) but my code does it different, because that example doesn't seem to reach the frequency I need
09:54 AM dStruct: polprog: one thing about the example that was slightly confusing was the comment next to prescaler setup, it says turn on timer with no prescaler and then has TCCR1B using CS10, which if I understand right would be a /8 prescaler
09:54 AM polprog: hmm yeah
09:55 AM polprog: what was the line next to the comment?
09:55 AM dStruct: polprog: oh wait completely disregard that, I just realized TCCR1B is the 16-bit timer and uses CS10/11/12, it's TCCR0B, so the example is absolutely correct
09:56 AM polprog: are you using the arduino ide?
09:56 AM dStruct: yes, with a 328p nano
09:57 AM polprog: im reading about the "arduino language" and it doesnt mention the ISR macro anywhere - i never used that ide, im not sure if thats the case
09:57 AM dStruct: polprog: not the best IDE i've ever used but it works for now, but I feel a bit like a child using it, maybe it's the color scheme :D
09:57 AM dStruct: polprog: it supports AVR, C, and a bunch of other stuff, it knows about ISR's
09:57 AM polprog: okay
09:59 AM dStruct: polprog: I usually write code using their built in shortcuts like pinMode, digitalRead/Write etc and then convert them DDRA=, portb= etc later
10:01 AM polprog: i have a theory
10:01 AM Ameisen: I think I'm going to test a few compression algorithms today
10:01 AM Ameisen: on AVR and ARM
10:02 AM Ameisen: for performance and compression ratio
10:02 AM Ameisen: Are there any compression algorithms designed for 8-bit systems like AVR?
10:02 AM Ameisen: similar to how algorithms like Snappy were designed for 64-bit?
10:03 AM polprog: you are wetting WGM12 which makes it mode 4 = CTC, then you set OCR1A to some value. You are triggering on overflow - yet the timer clears its value when the compare fires. your timer never reaches the max (0xFFFF) therefore the overflow interrupt doesnt fire. comment out TCCR1B |= _BV(WGM12); and give it a go
10:03 AM polprog: add some led flipping code inside that timer, like PORTx ^= 0xFF; that will flip whole port's value
10:03 AM polprog: back to physics :D
10:04 AM polprog: s/wetting/setting ^^
10:05 AM dStruct: polprog: you're 100% correct, and commenting it out does infact trigger the interrupt, albeit at 122hz and not 10989hz
10:05 AM polprog: were getting closer
10:05 AM polprog: :)
10:05 AM Ameisen: while I was asleep kinda... I had a programming idea
10:05 AM Ameisen: I have this weird phase in my sleep where I'm both awake and asleep, and aware of it, near the end
10:05 AM Ameisen: apparently it's an actual disorder
10:05 AM Ameisen: but nobody can fix it
10:06 AM Ameisen: but I sometimes end up with functional, but odd, ideas
10:06 AM dStruct: Ameisen: sleep paralysis?
10:06 AM Ameisen: not quite paralysi
10:06 AM Ameisen: paralysis
10:06 AM * polprog reflashes ameisen with COMPILER_WRITER_HISTORIAN.iso
10:06 AM Ameisen: sleep paralysis, you're fully awake, but your _body_ isn't
10:06 AM Ameisen: your brain has not restored manual control
10:06 AM Ameisen: During this... I'm kind of asleep and awake
10:06 AM Ameisen: my brain is conscious, can think, sometimes i can perceive around me... but I'm also asleep
10:06 AM Ameisen: and my dreams intrude
10:06 AM Ameisen: it's... weird, and sometimes very disturbing
10:06 AM Ameisen: and confusing
10:06 AM * polprog installs sets H-History of the world and P - programming and computer science
10:07 AM Ameisen: but I get weird ideas that often work during that time
10:07 AM * dStruct laughs
10:07 AM Ameisen: because they're not 100% rational to be made
10:07 AM Ameisen: but my brain is in the right 'state' to start mixing ideas
10:07 AM Ameisen: either way
10:07 AM polprog: i once read about sleep paralysis. doesnt sound pleasant
10:07 AM Ameisen: I think I know how to implement write-through hardware registers in C++ so that you don't require volatile, and thus the compiler can compact subsequent operations.
10:07 AM Ameisen: IE, if you write something like
10:08 AM Ameisen: PORTA |= 0b001;
10:08 AM Ameisen: PORTA |= 0b01;
10:08 AM Ameisen: right now, C and C++ cannot optimize that
10:08 AM Ameisen: they're volatile
10:08 AM Ameisen: it will emit them as separate ops
10:08 AM polprog: hmm
10:08 AM polprog: sounds brave
10:08 AM Ameisen: I think I cna implement it so the behavior can be _scoped_
10:08 AM Ameisen: within the scope, it is treated as though it's a traditional variable
10:08 AM Ameisen: once the scope exits, the write is completed as volatile
10:08 AM polprog: what about bits that trigger something on write?
10:08 AM polprog: ah
10:09 AM Ameisen: you wouldn't use this for those
10:09 AM Ameisen: wouldn't make sense
10:09 AM polprog: true
10:09 AM polprog: dStruct: check your prescaler maths
10:09 AM Ameisen: there's a few small details I need to work out about it
10:09 AM dStruct: polprog: that's precisely what I am doing now
10:09 AM Ameisen: and I need to make the syntax 'nice' enough to be easy to use
10:10 AM Ameisen: probably will end up as something like: writing(PORTA) { out |= 0b01; out |= 0b001; };
10:10 AM Ameisen: or multiple ports or such
10:10 AM Ameisen: since often we abstract away the ports into pin macros/classes/such
10:11 AM Ameisen: this would give the compiler the ability to recognize when the destination addresses are the same, and concatenate operations as possible
10:11 AM Ameisen: without imposing the restrictions of 'volatile'
10:13 AM polprog: by the way, turning completeness of the C preprocessor is a joke or is it real?
10:21 AM dStruct: polprog: should I rewrite the timer block to use CTC? If I'm not specifying WGM12 it defaults to normal mode 0 right?
10:22 AM polprog: yeah. iirc 0 is the default register value
10:24 AM polprog: you wanna use CTC because its more flexible in time
10:24 AM polprog: ie you can trim the trigger frequency better
10:24 AM polprog: finer*
10:25 AM polprog: so enable the compare interrupt and change your ISR handler to handle it
10:25 AM dStruct: polprog: so I'm thinking CTC timer1 at 10898hz using cs10, and have it trigger the int each cycle so the int can determine 0 or 1 data bit to encode to the clock output
10:25 AM polprog: as far as i understand your use case that should be right
10:28 AM dStruct: polprog: this pdf shows the clock timing diagram of what I'm trying to do, page 22 http://leonardodaga.insyde.it/Corsi/AD/Documenti/ARINCTutorial.pdf
10:29 AM polprog: looks pretty simple
10:30 AM dStruct: polprog: yup, it's just passing 32-bit words at 10khz, simple yet tricky to code at least for me
10:31 AM polprog: there are many ways to do it, some are lower level, some are higher
10:31 AM polprog: ;)
10:32 AM dStruct: polprog: well the higher level ways I had working but couldn't get the clock signal to the right freq which forced me to use lower level methods, and now I'm in the fog :D
10:32 AM polprog: dont worry, once you get the interrupt triggering, its all easy
10:33 AM polprog: also, how tolerant is the arinc? when it comes to clock jitter
10:33 AM polprog: do you have any way to check the actual speed? like an oscilloscope?
10:34 AM dStruct: polprog: ms not ns, it's very lax
10:34 AM polprog: okay
10:35 AM dStruct: I already checked the timing with my Tek TDS 3054B, this nano switches WAY faster then the specs call for
10:35 AM polprog: neat scope
10:36 AM polprog: whats the nano's frequency?
10:36 AM polprog: the cpu clock?
10:36 AM dStruct: polprog: yeah it has all the bells and whistles too, cost the company a LOT of money
10:36 AM dStruct: pol 16mhz
10:36 AM polprog: wow preonwed one is $2000+
10:36 AM dStruct: brand new I think was over $20k
10:37 AM polprog: hmm. im looking at that if..else if..else if block
10:37 AM dStruct: 32kb flash, 2kb sram, and a 1kb eeprom on this board
10:37 AM polprog: it doesnt take the CPu frequency in any form, any way
10:38 AM dStruct: yeah I think TCCR1B |= is incorrect there, changing those values does nothing
10:39 AM dStruct: if I could just wrap my head around how these TCCR1A, R1B, and R1C's work, it's not clicking for me for whatever reason
10:41 AM polprog: first you have the prescaler
10:41 AM polprog: at prescaler 1 the timer increments once per cpu cycle, at /8 once every 8 cycles etc
10:42 AM polprog: CTC mode works in a way that every timer tick it compares the value with OCR - output compare register
10:43 AM dStruct: polprog: ok that makes total sense, man I have been reading and reading, atmega328 datasheet, random websites, it finally clicks lol
10:44 AM polprog: so if you have it in CTC mode, interrupt enabled, prescaler 64, and OCR = 13, then it will trigger every 64*13 = 832 CPU cycles,
10:44 AM dStruct: polprog: what's really throwing me off is the whole WGM12, CS10 bs, couldn't you just say TCCR1A = 0x0110010
10:44 AM polprog: ah
10:44 AM dStruct: this whole |= _bv business
10:45 AM polprog: believe me, that BV business is easier to read than random numbers
10:45 AM dStruct: polprog: maybe once you're used to it
10:46 AM polprog: if you see TCCR1A |= _BV(CS10) you will know that it sets a clock source bit, whereas TCCR1A |= 0xMAGIC doesnt tell yo anything
10:46 AM polprog: i think you are overcomplicating the whole clockGen function
10:46 AM polprog: if you know you wanna generate stuff close to 10khz then its no use to generate maths for all the rest of the frequencies
10:46 AM dStruct: polprog: oh it was based on someone elses code to help kick start me into it, I'm about to rewrite the whole function
10:49 AM dStruct: in actuality it only touches the first if() due to what I have the freq set to
10:49 AM polprog: so look at it like that
10:49 AM polprog: your target frequency is 10 khz
10:49 AM polprog: your CPU frequency is 16MHz
10:49 AM dStruct: so 16mhz = 16e6, prescaler set to none for highest res, lowest delay, OCR would be 16e6 / tFreq
10:49 AM polprog: from the top off my head i will try and see if a prescaler of 64 works out nicely
10:50 AM LeoNerd: - 1
10:50 AM LeoNerd: I often forget the -1
10:50 AM polprog: so 8MHz / 64 => 250kHz
10:51 AM dStruct: LeoNerd: :D
10:51 AM polprog: 250kHz / x = 10kHz; x is here the number of your timer ticks
10:51 AM polprog: x = 250/10 = 25
10:51 AM polprog: try that. prescaler /64, OCR1A = 25
10:53 AM dStruct: I get the same 122hz output
10:54 AM polprog: hmm
10:54 AM dStruct: I'm hooked into pins OC1A and and OC1B which equates to pin 9 and 10
10:54 AM polprog: make sure its in the correct mode
10:55 AM polprog: and use the interrupt to toggle a pin, its easier
10:56 AM dStruct: https://paste.ubuntu.com/p/c54f8zrJJX/
10:57 AM polprog: i can see the problem
10:57 AM polprog: those delays
10:58 AM dStruct: well they could impact the led not firing, but what about the clock output being 122hz?
10:59 AM dStruct: commented out the whole if block and just set digitalWrite(13, HIGH); no difference
11:00 AM dStruct: i'm thinking it's the mask, TOIE1 doesn't seem right
11:01 AM polprog: ah
11:01 AM polprog: damn
11:01 AM polprog: yeah TOIE is overflow interrupt enable
11:01 AM dStruct: I learn quick :D
11:01 AM polprog: you need to enable OCIE1A and/or OCIE1B
11:02 AM polprog: OCIE1A in your case since you are using compare unit A
11:02 AM dStruct: I think I need to change it to, yes OCIE1A and then change my ISR to be compa not ovf
11:02 AM polprog: yeah
11:02 AM dStruct: hmm
11:03 AM polprog: ah and of course enable it in CTC mode so it actuall clears every compare
11:03 AM dStruct: int fires but at 122hz
11:03 AM polprog: you dont need to touch FOC1A in the TCCR1C
11:04 AM polprog: you need to set CS1 as well
11:04 AM dStruct: ahh true I don't
11:04 AM polprog: 25 is for a 64 prescaler
11:04 AM dStruct: TCCR0A then?
11:04 AM dStruct: R1A would be 10/11/12
11:05 AM polprog: hm?
11:05 AM dStruct: timer0 is 8-bit timer1 is 16
11:06 AM polprog: you are using timer 1 so all the TCCR register are TCCR1x
11:06 AM dStruct: yes
11:06 AM polprog: timer/counter control register
11:06 AM polprog: so. 25 for the compare unit is valid when the prescaler is 64
11:06 AM polprog: so TCCR1B |= _BV(CS10) | _BV(CS11);
11:07 AM dStruct: 10989hz translates to about 91 micros if that's helpful
11:07 AM polprog: i know, lets keep operating on frequencies
11:07 AM dStruct: yeah completely agreed on that one
11:08 AM dStruct: 1.91hz
11:08 AM polprog: odd
11:08 AM polprog: like, a 2 hz output?
11:08 AM dStruct: yp
11:08 AM dStruct: yup
11:09 AM polprog: something must be missing
11:09 AM polprog: whats your code now?
11:09 AM dStruct: https://paste.ubuntu.com/p/HfTyKCTnyp/
11:09 AM dStruct: int still fires
11:10 AM polprog: TCCR1A |= _BV(COM1A0) | _BV(COM1B0) | _BV(WGM12);
11:10 AM polprog: WGM12 sets the CTC mode
11:10 AM polprog: thats page 132 in the datasheet
11:11 AM dStruct: hmm
11:11 AM dStruct: no change
11:12 AM polprog: hmm
11:12 AM polprog: ah
11:12 AM polprog: i think i got it
11:12 AM polprog: those pins dont work in CTC mode
11:13 AM polprog: you need to toggle them in the interrupt
11:13 AM dStruct: TCCR1B | | | WGM12?
11:13 AM polprog: WGM is in register A
11:13 AM polprog: so
11:14 AM polprog: you can just remove those COM1A0 bit set instructions and leave TCCR1A |= _BV(WGM12);
11:14 AM polprog: and add the pin toggle in the ISR
11:14 AM dStruct: interesting
11:15 AM polprog: its all in the details, unfortunately :D
11:15 AM polprog: at least the datasheet is good
11:16 AM dStruct: do you think I should put the pin state change in the actual ISR or would putting it in the void loop work well enough?
11:16 AM polprog: put it in the ISR for now, your loop has another problem
11:17 AM polprog: albeit smaller
11:18 AM dStruct: would I just write it like if(pinState) { pinState = !pinState }
11:19 AM dStruct: or maybe just pinState = !pinState
11:19 AM polprog: id go for PORTx ^= _BV(Pxx)
11:19 AM polprog: if you know what i mean
11:19 AM polprog: a simple XOR operation with mask
11:20 AM dStruct: that's a little advanced for me
11:20 AM polprog: that will flipp all the bits in PORT that are set on the right hand of the assignment, in this case just the single pin bit
11:21 AM polprog: so if you need to toggle PC3 you would do PORTC ^= _BV(PC3);
11:21 AM dStruct: well that's a heck of a simple way to handle that :D
11:21 AM polprog: thats the beautiful part of embedded
11:21 AM dStruct: yeah this would be PB1 so PORTB ^= _BV(PB1)
11:22 AM polprog: yeah
11:22 AM dStruct: that saves on memory as well, no extra volatile, etc
11:23 AM dStruct: ok so that worked, but still 1.9hz
11:24 AM polprog: the clock is not right or the compare doesnt fire
11:24 AM polprog: damn
11:24 AM polprog: no idea
11:25 AM dStruct: changing OCR1A doesn't do anything
11:27 AM dStruct: but I think I know why, I set OCR1A = 25, not OCR1A = 0x25 ?
11:28 AM polprog: its decimal 25, i did maths in decimal
11:29 AM dStruct: ahh
12:22 PM dStruct: polprog: one step closer
12:22 PM polprog: whats up?
12:24 PM dStruct: works perfectly, except now I need to count cycles to create another output with the bits https://paste.ubuntu.com/p/ny8PJ7kwpB/
12:24 PM dStruct: data bits rather..
12:26 PM polprog: looks good
12:26 PM polprog: i dont like those delays in loop()
12:26 PM polprog: though
12:26 PM polprog: unless its just to blink a led
12:26 PM dStruct: yeah those are first on the chopping block, quick and dirty for now, that's not a critical function but would be nice to have so I know it's cycling
12:27 PM dStruct: all they're doing is blinking the built in LED wired to that pin
12:30 PM Ameisen: [10:11:53] <polprog> by the way, turning completeness of the C preprocessor is a joke or is it real?
12:30 PM Ameisen: I don't believe the C preprocessor is turing complete.
12:30 PM Ameisen: C++ templates are, though
12:31 PM Ameisen: the CPP can only be turing complete if you let it re-execute indefinately.
12:31 PM Ameisen: The C spec also defines limits for the CPP which prevent turing completeness - max nesting levels, max initial characters, etc
12:32 PM polprog: okay
12:32 PM polprog: makes sense
12:32 PM polprog: !
12:32 PM Ameisen: C++ templates, though, _are_ turing complete
12:32 PM Ameisen: somebody wrote tetris in C++ templates.
12:32 PM Ameisen: compiling played a game of tetris.
12:32 PM polprog: i dont remember what templates were
12:32 PM polprog: but i believe that its possoble
12:32 PM Ameisen: C++ metaprogramming constructs
12:32 PM Ameisen: kiiiinda like generics in Java
12:32 PM Ameisen: but far more powerful
12:33 PM Ameisen: concepts will make things a bit cleaner in C++
12:33 PM Ameisen: since they're already in the C++20 pre-spec
12:33 PM polprog: i wish i had a use for all this C++ goodness
12:33 PM Ameisen: though I wish they were called constraints, not concepts.
12:33 PM polprog: so i could learn it
12:34 PM polprog: :D
12:34 PM Ameisen: a concept is sorta like... a type of a type.
12:34 PM Ameisen: you could make a concept called integer_concept
12:34 PM Ameisen: and define constraints that match integers
12:34 PM Ameisen: then you could have a function that takes integer_concept types
12:34 PM Ameisen: and anything matching the constraints in that concept would be accepted as arguments
12:35 PM Ameisen: you can mostly due that with templates now though it's messy
12:35 PM polprog: i was trying to understand lambda caluculus from destroyallsoftware screencast
12:41 PM Ameisen: I feel like physics and other levels of math on a computer should be done using base-8 or base-16 units, rather than metric or customary (base-10 and base-*)
12:41 PM Ameisen: the _interfaces_ can be whatever
12:41 PM polprog: after all its all done in binary
12:42 PM Ameisen: but if the internal units are based on base-16 or base-8, some of the operations can be simplified dramatically on computers.
12:42 PM polprog: true
12:42 PM polprog: i mean
12:42 PM Ameisen: like scaling values
12:42 PM Ameisen: metric, you have to scale values by 10s
12:42 PM polprog: base 10 really sucks
12:42 PM Ameisen: if it were base-16... you could shift.
12:42 PM polprog: you can only easily divide by 5 and 2
12:42 PM Ameisen: I'm just thinking in terms of what the actual operations would compile to
12:42 PM Ameisen: most of the values used in metric don't map well to CPU instructions
12:43 PM polprog: i kinda like inches - you have mils and 1/2, 1/4, 1/8, 1/16
12:43 PM Ameisen: there's actually more subdivisions
12:43 PM polprog: i know
12:43 PM Ameisen: those are the common ones though
12:43 PM polprog: it can go deeper, or 3/8, 5/8 etc
12:43 PM Ameisen: I mean, there's more units between mils/thous and inches
12:43 PM polprog: but inch-based?
12:44 PM Ameisen: 1 inch is 6 pica
12:44 PM Ameisen: 1 pica is 12 points
12:44 PM polprog: ah those
12:44 PM Ameisen: same in survey units
12:44 PM polprog: i was just reading on those, learnt about twips
12:44 PM Ameisen: 1 league i 3 miles. 1 mile is 8 furlongs. 1 furlong is 4 rods. 1 rod is 25 links, or 16.5 feet.
12:44 PM polprog: i twip = 1/20 point
12:44 PM Ameisen: We sure like having completely random bases.
12:45 PM Ameisen: I think we should redefine US Customary using base-16
12:45 PM Ameisen: then it can be a real competitor to metric.
12:45 PM polprog: true
12:45 PM Ameisen: their 'base' argument won't hold water
12:45 PM polprog: like 1 something = 16 inches, one soething2 = 16 somethings
12:45 PM Ameisen: and redefine them using natural units as well, so there's actually a relation between them
12:45 PM Ameisen: like
12:46 PM Ameisen: make 1 cubic foot 10 gallons
12:46 PM Ameisen: instead of ~ 7 1/2
12:46 PM Ameisen: well
12:46 PM Ameisen: base 16
12:46 PM polprog: https://upload.wikimedia.org/wikipedia/commons/e/eb/English_length_units_graph.svg
12:46 PM Ameisen: soooo. 8 gallons.
12:46 PM polprog: rofl^^
12:46 PM polprog: that is the problem
12:46 PM dStruct: polprog: so I'm working on a method to count these clock/timer cycles to interate my data bits out a seperate line, something like detect high PB1 and i++ then when i = 32 for example start the loop over. Does this seem too complicated to put in an ISR?
12:47 PM Ameisen: I like how it jumps from foot to mile...
12:47 PM Ameisen: why?
12:47 PM polprog: dStruct: try to implement a state machine - the ISR would then have to just increment the state number and the bit number
12:47 PM Ameisen: That's like doing 1km = 10000dm
12:47 PM polprog: bbl
12:47 PM dStruct: polprog: i've not done that before, but I'm handy with the google :D
12:53 PM polprog: ive implemented one here http://polprog.net/blog/serial/
12:53 PM polprog: youd have to add the index variable as well
12:56 PM Ameisen: I am surprised that all the things like 3d printers don't encode and/or compress things like gcode
12:57 PM Ameisen: the AVR ones _do_ suffer from input speed problems
12:57 PM Ameisen: if you have lots of small commands, it stutters
12:57 PM Ameisen: so you're sending plaintext (inefficient) which has to be parsed (inefficient)
12:57 PM Ameisen: and usually include things like checksums per line... as text
01:03 PM dStruct: polprog: good stuff, thanks. I'll see if I can make some use of it
01:22 PM polprog: When i first learnt about state machines i was amazed how simple they are once you drop all the math formal notation
01:24 PM nuxil: so i got time to finished up my simple printboard today. "shitty cam" https://gyazo.com/5737b7bd0aec96117e67db65fc4ace7d . The circuit i tested using jumpers on the dip socket. however my code on the atiny13a does not work.
01:24 PM nuxil: https://pastebin.com/TKetmVtk
01:24 PM nuxil: what is wrong with it?
01:25 PM nuxil: i suspect its something with my isr
01:27 PM polprog: Not sure about that isr but your counter var overflows
01:27 PM polprog: Prepare for surprise fan noises in the middle of the night
01:28 PM nuxil: no. noise_state must be hight aswell :)
01:28 PM nuxil: *erm low
01:28 PM nuxil: besides.
01:28 PM nuxil: i dont leave it on all night
01:29 PM nuxil: i was woundering if i should just remove the isr and put the pin check in the while loop instead
01:43 PM polprog: rofl: https://blog.benjojo.co.uk/post/encoding-data-into-dubstep-drops
01:43 PM polprog: not safe for nuxil
01:44 PM polprog: thats cool
02:00 PM * Ameisen will look into compression algorithms tonight
02:00 PM Ameisen: particularly for 8-bit and MCU 32-bit
02:04 PM nuxil: polprog, why do you think is it not safe?
02:04 PM nuxil: *it is
02:04 PM nuxil: its not like its requires high prescition timeing.
02:04 PM polprog: < nuxil> polprog, now fix your music taste :p
02:04 PM polprog: :D
02:04 PM polprog: joking
02:04 PM polprog: i dont like dubstep at all
02:07 PM nuxil: same here.
02:08 PM nuxil: im more like https://www.youtube.com/watch?v=Ufhhq5K0vYY ;D
02:27 PM dStruct: nuxil: no it's all about https://www.youtube.com/watch?v=V-_O7nl0Ii0
02:27 PM polprog: dangit
02:27 PM polprog: nuxil: good metal
02:27 PM nuxil: :D
02:28 PM nuxil: dStruct, dont make me go kill myself :p
02:28 PM dStruct: nuxil: lmfao
02:29 PM dStruct: nuxil: in actuality https://www.youtube.com/watch?v=4nl20j9wY5U
02:29 PM polprog: nuxil: https://www.youtube.com/watch?v=0Euz1CmRjgA ?
02:30 PM dStruct: polprog: so I managed a pulsed output timed to the clock using switch/case but I want to somehow use interrupts without going out and back in a pin
02:31 PM nuxil: polprog, meh. screw that. amatures take other peoples work and mix it up. no skills to play instruments on their own :p
02:31 PM polprog: you could just create an array of 4*n chars (or a 32 bit integers) that stores the data to be sent, and use the interrupt to send a signle bit, increment an index (bit index and array index)
02:32 PM polprog: nuxil: they did compose stuff
02:32 PM polprog: dStruct: if you wanna read further on that its called bitbanging
02:32 PM dStruct: polprog: oh yes, I know :D
02:32 PM dStruct: polprog: I've done it before but never in AVR with a atmega mcu
02:33 PM polprog: where did you do it?
02:33 PM Emil: mfw I use our course platform as a teacher to "shitpost" and prove a point to a friend on that course :D
02:33 PM polprog: nuxil: maybe this? https://www.youtube.com/watch?v=N3oCS85HvpY
02:33 PM dStruct: polprog: I just mean bitbanging type of stuff
02:34 PM polprog: ah
02:34 PM polprog: i was curious what microcontroller/thing was doing the bitbanging
02:34 PM dStruct: polprog: so switch/case in main loop creates some jitter on the outputs, not super thrilled with this method
02:35 PM polprog: yeah thats why you need to prepare the data in memory - that way you just set a PORT bit and you're done!
02:35 PM polprog: now that i think about it you could make the interrupt run twice as fast to get a consistent, 50% pulse width clock
02:36 PM dStruct: yeah I thought about that as well
02:36 PM polprog: but that could be done with a simple _delay_ms in the main loop - if tuned carefully
02:36 PM dStruct: hmm, I would much rather count/match/nand on cycles
02:36 PM polprog: you're the man ;)
02:37 PM dStruct: well *if* i can :D
02:37 PM dStruct: the switch/case is not behaving anyways, the clock flips high/low with the pulse high on the data line, it doesn't fully sync
02:56 PM nuxil: move as much as you can to isr's
02:56 PM nuxil: avoid stuff in main :p
02:56 PM polprog: void main() {}
02:56 PM polprog: :P
02:56 PM nuxil: :D
02:57 PM polprog: put your ISR init in .initN sections xD
02:57 PM polprog: thats would be cool
02:57 PM nuxil: dStruct, youre working with timeing stuff. and should not be doing stuff in main at all.,
02:57 PM polprog: upload a repo to github that contains a program with an empty main
02:57 PM dStruct: nuxil: yeah I tell me about it :D
02:58 PM nuxil: can you do part of your code as inline asm ? that might speed things up and reduce some jitter.
02:59 PM dStruct: I just need to basically NAND if clock high and this array bit high, take PB2 high for one clock high/low cycle
02:59 PM dStruct: nuxil: that would be beyond my abilities at the moment
03:00 PM nuxil: polprog, give him the link to that all asm instructions pdf file you got :p
03:00 PM polprog: http://polprog.net/papiery/avr/inline%20assembly%20with%20gcc.pdf
03:00 PM nuxil: dStruct, its not that hard. just need to think a bit different :)
03:00 PM polprog: this?
03:00 PM polprog: yeah i have a tutorial on that too
03:00 PM nuxil: :)
03:00 PM polprog: but try to get your C working ;)
03:01 PM nuxil: indeed.
03:02 PM dStruct: yeah I don't think I can tackle asm at the moment, I've done some 8086 asm back in the day but haven't touched it in like 25+ years
03:03 PM polprog: thjats more time than i was alive
03:03 PM dStruct: nuxil: the timing doesn't need to be exact, the tighest tolerance is +/- 3 micros on state changes
03:03 PM polprog: am*
03:04 PM nuxil: dStruct, do you got a logic analyzer to analyze your signal with?? 3ms is alot of time
03:04 PM polprog: hehe i found on wikipedia something that im actuall ybuilding https://upload.wikimedia.org/wikipedia/commons/b/ba/Shure_FP33_%28front%29.jpg
03:04 PM dStruct: polprog: I'm SO tempted to just set PB1 as output and run it to another pin and attach it to a int and poll the clock that way, it feels like I would be doing it "wrong" tho
03:05 PM polprog: feels wrong too ;)
03:05 PM dStruct: nuxil: I have a Tek TDS3054B which should do, I also have a Fluke 115
03:06 PM nuxil: dStruct, ok. you can get a saleae logic analyzer colone for 5 bucks on ebay which works with the orginale software
03:06 PM dStruct: nuxil: no 3ms, 3 microseconds
03:06 PM dStruct: *not
03:06 PM nuxil: ops .. sorry
03:06 PM dStruct: just sayin :D
03:06 PM nuxil: yea. thats a another ballpark.
03:07 PM nuxil: are you using internal RC or do you got a crystal ?
03:07 PM dStruct: this 328p switches in the ns range, using stock internal xtal
03:07 PM nuxil: aww
03:07 PM dStruct: I know
03:07 PM nuxil: that might be your problem
03:08 PM dStruct: trust me. it is LIGHTYEARS better then what is being used right now, imagine for a moment about 5 2n2222's a bunch of carbon ceramic resistors and a 100k pot...
03:08 PM nuxil: the intrnal rc drifts, unpresice
03:08 PM dStruct: nuxil: well I can create a rocksolid square wave clock dead on the money 10989hz however I'm trying to create 2 other lines sync'd to it, so they all output at the same time
03:09 PM dStruct: nuxil: http://leonardodaga.insyde.it/Corsi/AD/Documenti/ARINCTutorial.pdf look at pdf page 22 (paper page 20)
03:10 PM nuxil: leave it running for a while and you see it has changed :) unless you got a super stable enviourment. both electical and termal.
03:10 PM dStruct: nuxil: I was actually quite shocked when I ran it and let it sit and heat up etc, let it idle outputting the clock for over 7 hours and had no measurable drift, at least not in any range that would affect my project
03:10 PM dStruct: nuxil: I have an extremely stable environment, power is extremely clean
03:11 PM dStruct: nuxil: they don't make linear supplies like they used to
03:11 PM nuxil: true
03:12 PM nuxil: i like linear. so much cleaner than these noisy switchin psu's
03:14 PM dStruct: actually I found a company that makes extremely quiet switchers, like surprisingly quiet and stable. Astec out of Hong Kong believe it or not
03:15 PM nuxil: people say that inefficient, and all that crap. its true. but i just say. do you know where i live ? 70-80% of the electical usage goes to heating the house. So a linear psu is like 2 in one. heating the house at the same time.:)
03:16 PM nuxil: it gets cold up here in north norway and we got long winters :)
03:17 PM nuxil: yea you can get switching psu clean. just require more filtering
03:17 PM nuxil: alot more
03:17 PM dStruct: nuxil: we generate so much heat mostly from linear supplies we need 5 tons of AC to keep this room under control and even that struggles during the summer time
03:18 PM nuxil: :D
03:18 PM dStruct: 4U rackmount transistor devices inc.
03:26 PM nuxil: Anywho. time for a cup of coffee and get some code done.
04:55 PM polprog: Darude sandstorm but every time it goes dudu dududu its emil's fault
05:10 PM Emil: god damn it :D
09:19 PM _ami_: have you guys tried lm358 for pwm dac purpose?
09:22 PM _ami_: it seems lm358 add noise and increased rise/fall time on square signal wave > 2Khz
09:30 PM _ami_: i get the spikes too ~ 1v if i use raw sallen key filter using lm358
09:30 PM _ami_: when i add a buffer between cap and output. it got improved. ~120mV spikes but still not good enough.
09:43 PM _ami_: https://hackaday.com/2017/03/08/dont-fear-the-filter-lowpass-edition/
09:44 PM _ami_: aha, crossover distortion.
09:44 PM _ami_: so lm358 is not a right choice
11:33 PM day__ is now known as day
11:46 PM rue_mohr: >:| this perphial was made for a 4 bit processor...
11:47 PM rue_mohr: _ami_, what circuit are you thinking for the lm358?
11:47 PM rue_mohr: do you want to turn an analog voltage inot a pwm stream?
11:48 PM rue_mohr: lm358 does not makea good comparitor
11:48 PM rue_mohr: the LM393 does, and there is one in that old computer power supply in the closet of your room
11:48 PM rue_mohr: remember the pullup resistor
11:48 PM rue_mohr: but you dont need chips
11:49 PM rue_mohr: http://ruemohr.org/~ircjunk/tutorials/elex/micropwm/p1080966.jpg
11:49 PM rue_mohr: _ami_, ^^^
11:50 PM rue_mohr: if you wan REALLY high speed pwm...
11:50 PM rue_mohr: http://ruemohr.org/~ircjunk/projects/newpower/p1070742.jpg
11:51 PM rue_mohr: a cd4060 can generate freqs easier, as it can take more common crystals and divide them down more
11:52 PM polprog: Thats a tidy schematic
11:52 PM rue_mohr: its uses the approach that its easier to take a square wave and make it a triangle than to generate a high speed triangle
11:53 PM rue_mohr: polprog, it uses my rules
11:54 PM rue_mohr: http://ruemohr.org/~ircjunk/tutorials/elex/schematic.jpg
11:55 PM polprog: Genius!
11:56 PM _ami_: rue_mohr, thanks. i am generating pwm from overclocked stm32 https://pbs.twimg.com/media/Dal-ICGVAAA4GPR.jpg
11:56 PM rue_mohr: do you know what country _ami_ is in?
11:56 PM _ami_: 1.29Mhz
11:56 PM rue_mohr: ok
11:57 PM rue_mohr: what did you want the amp for?
11:57 PM rue_mohr: you said adc?
11:57 PM _ami_: rue_mohr, for DAC
11:57 PM _ami_: i wanted to control those cheap buck converter voltage using mcu.
11:57 PM rue_mohr: resistor?
11:58 PM rue_mohr: :S microcontroller based power pwm?
11:58 PM rue_mohr: your suing capacitor coupling incase the controller freezes, right?
11:58 PM rue_mohr: using
11:58 PM _ami_: i have used 10k,100nF in sallen key filter.
11:58 PM rue_mohr: wait, what?
11:59 PM rue_mohr: wait, what?
11:59 PM rue_mohr: what?
11:59 PM rue_mohr: your.... generating an analog voltage for the regulator ref?