#avr Logs

Dec 02 2017

#avr Calendar

02:51 AM polprog: anonnumberanon: good point, ill correct that ;)
02:54 AM nuxil: mornings
02:54 AM polprog: morning
02:54 AM nuxil: brne Cycles: 1 if condition is false 2 if condition is true .
02:54 AM nuxil: so twise as fast with a false condition :p
02:56 AM nuxil: i would like to learn some asm myself. seems fun.
02:57 AM anonnumberanon: I'm trying...
02:58 AM anonnumberanon: i may poll for a timer counter instead of waiting for an interrupt lol, in order to cancel all push pop operations done by the isr
02:59 AM theBear: yeah, VERY trying most days <wink>
02:59 AM nuxil: i see all these branch instructions use 1 cycle for the false condition.
02:59 AM anonnumberanon: theBear, let's just say I like to understand why things don't work rather than the opposite
02:59 AM polprog: nuxil: yes, because they dont have to jump
03:01 AM nuxil: so there is a lot of optimalization to gain if these commands are use alot.
03:01 AM nuxil: i mean.
03:01 AM theBear: anonnumberanon, i spent most of my working years fixing all manner of things somewhere between maybe 30 and 80 hours every week, i feel quite the same way.... i also enjoy that old incredibly bad wordplay trick when someone says they're trying <grin>
03:02 AM nuxil: normaly C you do if foo {bar} else {moo} ,, if the program does foo condition most of the time, it would be better to change it to if (!foo), :p
03:02 AM nuxil: if you get what i mean
03:02 AM polprog: ok, fixes the typo
03:02 AM polprog: fixed*
03:03 AM anonnumberanon: polprog, oh you want more?
03:03 AM anonnumberanon: :)
03:03 AM polprog: anonnumberanon: im happy my work was found useful by somebody :)
03:03 AM anonnumberanon: nah the rest is fine, this was just technical so could not be ignored!
03:03 AM anonnumberanon: polprog, yes it was
03:03 AM anonnumberanon: i could not understand why out, in
03:03 AM anonnumberanon: now i do
03:04 AM anonnumberanon: and other things, but that one was the most
03:04 AM polprog: good
03:41 AM anonnumberanon: if i make a function in assembly does it need to push and pop registers used in its scope at its beginning and its end?
03:45 AM nuxil: dosent call and ret handle that for you ?
03:50 AM polprog: they are for a reson there, otherwise you'd just use jump
03:50 AM polprog: or maybe..
03:50 AM polprog: i think you have to
03:51 AM polprog: because Calls to a subroutine within the entire program memory. The return address (to the instruction after the CALL) will be stored onto the stack
03:51 AM polprog: from the manual
03:51 AM polprog: call puts the return adress on the stack and then ret returns from the subroutine taking the adress from the stack
03:52 AM polprog: so you have to
03:52 AM polprog: see example http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_RCALL.html
03:55 AM anonnumberanon: that page is pretty dry and the example is poor
03:56 AM anonnumberanon: :)
03:56 AM polprog: yes, since it's technical documentation
03:57 AM polprog: they expect the readers be engineers, not hobbyists like you and me
03:59 AM anonnumberanon: i want to become an engineer how do i do that
03:59 AM nuxil: read
03:59 AM nuxil: read alot
03:59 AM nuxil: and go to school
04:00 AM polprog: this prettu much
04:01 AM polprog: and experience
04:01 AM polprog: that helped me to land the internship
04:01 AM nuxil: and seek out friends/communitys with same intrests. "electronics/mcu/mpu etc", join forums like eevblog etc
04:02 AM polprog: just don tjoin edaboard or elektroda.pl
04:03 AM polprog: they are enough to kill your aspirations, bloody gatekeepers
04:04 AM polprog: i find irc is pretty good, even nowadays
04:04 AM nuxil: irc has always been good.
04:04 AM anonnumberanon: it's alright :)
04:05 AM anonnumberanon: sometimes a distraction, instead of just "doing the thing"
04:05 AM nuxil: i mean. its still around after like 25 year
04:09 AM anonnumberanon: me need a sandwich
04:09 AM anonnumberanon: these instructions are making my head spin
04:09 AM anonnumberanon: trying to reduce the pops and pushes
04:13 AM polprog: make clean && make sandwich I=--cheese
04:16 AM hetii: Hi
04:16 AM hetii: :)
04:16 AM nuxil: hi
04:21 AM nuxil: anonnumberanon, i never done asm. so i have no ida how to do that,
04:21 AM nuxil: what is you function suppose to do?
04:23 AM nuxil: this is the best i can come up with. :p with no push and pops. altho i bet its all wrong ,lol https://pastebin.com/JKqNkD8Y
04:29 AM anonnumberanon: nuxil, from reading a bunch i'm starting to believe i dont need all the push and pops
04:29 AM anonnumberanon: but it is inside the isr
04:30 AM anonnumberanon: im gonna just read the datasheet, long but gonna have that info I'm sure
04:31 AM anonnumberanon: if it's true though i could remove 20 cycles from the isr
04:31 AM anonnumberanon: that sounds exciting, like getting a sandwich brb
04:33 AM polprog: nuxil: the overall thought process is good ;)
04:34 AM polprog: one mistake i can see is mov can be used to move between registers, to load literal 10 into a register you use ldi (load immediate)
04:34 AM polprog: anonnumberanon: there's also naked isr
04:34 AM anonnumberanon: yeah im reading that
04:34 AM polprog: for superfast ISRs
04:37 AM nuxil: yea i see the ldi. seems to be a better instruction to use.
04:56 AM polprog: heh, i just set up Netstorm under wine
04:56 AM polprog: looks like a cool game
06:11 AM anonnumberanon: it 's actually non trivial to write an assembly file from scratch, it's nothing like the version you get from decompiling or using objdump
06:11 AM anonnumberanon: example, one with an interrupt service routine: https://gist.github.com/lukecameron/2644258
07:34 AM nuxil: nontrivial is the reason high level languages where invented :)
07:36 AM polprog: anonnumberanon: once you break the cryptic chain of operands into functional several-operations blocks
07:36 AM polprog: it gets trivial
07:37 AM polprog: i might have described the objdump output actually
07:37 AM polprog: yeah i did
07:38 AM anonnumberanon: nuxil, avr-gcc on any optimization setting is too dumb to understand what I wanna do haha
07:38 AM polprog: the first instruction (traditionally - since assembly is freedom as free as it gets - nobody tells you to put ISR handler jumps in the vector table, if you dint use interrupts you dont have to put jumps there and can use it like
07:38 AM polprog: it wasnt there
07:39 AM polprog: so the first jmp jumps to __ctors_end (that's what gcc calls the place where the Int vect table ends)
07:39 AM anonnumberanon: im thinking of polling the timer output compare flag
07:39 AM polprog: then it sets up the stack pointer
07:39 AM anonnumberanon: this would be faster than interrupts my intuition is telling me
07:40 AM polprog: (if you dont use stack that can be ommited as well lol - extreme case)
07:40 AM anonnumberanon: heh, no i would have to
07:40 AM polprog: then the main program
07:40 AM anonnumberanon: for at least 2 registers
07:40 AM polprog: why
07:40 AM anonnumberanon: 1 register is there to take care of SREG
07:41 AM anonnumberanon: and the other one I'm not sure
07:41 AM * anonnumberanon looks at code again
07:41 AM polprog: imagine your assembly program doesnt have any subroutines, doesnt use interrupts. then you are free to start it at 0x00 and the only thing you have to to is to clear SREG
07:41 AM polprog: that would be a pretty limited program though
07:42 AM polprog: brb, dinner
07:42 AM anonnumberanon: you lost me
07:44 AM nuxil: just https://www.youtube.com/watch?v=vCadcBR95oU and then https://www.youtube.com/watch?v=010KyIQjkTk :D
07:48 AM anonnumberanon: hehehhe
07:49 AM polprog: hahaha
07:52 AM polprog: anonnumberanon: at which point? ;)
07:52 AM anonnumberanon: then you are free to start it at 0x00
07:52 AM anonnumberanon: why would i start my program anywhere?
07:52 AM polprog: the cpu starts to run from 0x00
07:52 AM polprog: always
07:52 AM anonnumberanon: what address are you talking about here?
07:52 AM polprog: flash adress (which is program counter value)
07:52 AM anonnumberanon: ok
07:52 AM polprog: in AVR program code is stored in flash and variables are stored in ram
07:52 AM polprog: contrary to traditional computers you use everyday, where the program is copied from storage to ram
07:53 AM nuxil: unless you use progrem and stor variables in the flash aswell
07:53 AM polprog: yes
07:53 AM polprog: but let's keep it simple
07:54 AM polprog: take a look at the listing on the blog
07:55 AM polprog: after 0x00, the interrupt vector table starts
07:55 AM polprog: it's all "empty" (jumps to __bad_interrupt) sinde the C code had no ISRs defined
07:56 AM anonnumberanon: wait polprog
07:56 AM anonnumberanon: I'm not right right now
07:57 AM anonnumberanon: what are we talking about first? i want to know what you're trying to explain
07:57 AM anonnumberanon: are you answering a question or something?
07:57 AM anonnumberanon: I've been at this for 10 hours or so now im not fresh
07:58 AM nuxil: go take a coffe break
07:58 AM nuxil: about time :)
07:58 AM anonnumberanon: ok yeah
07:58 AM anonnumberanon: (i've had a few already..)
07:58 AM anonnumberanon: brb
08:14 AM anonnumberanon: okay
08:14 AM anonnumberanon: anonlaptop
08:15 AM anonnumberanon: is ready
08:17 AM nuxil: polprog, whats the point of the L1 lable in your code?
08:18 AM nuxil: cant the dec stuff be under the loop lable ?
08:18 AM nuxil: oh never mind
08:18 AM nuxil: i see now
08:20 AM anonnumberanon: okay polprog
08:28 AM nuxil: anonnumberanon, i just found this, might be handy to read http://www.avr-asm-download.de/beginner_en.pdf
08:34 AM anonnumberanon: oh nice nuxil
08:34 AM anonnumberanon: now im writing the logic to be able to get an efficient list of bitmasks to use for when i turn pins off
08:35 AM anonnumberanon: if 2 PWMs are turning off at the same time better make it one operation otherwise they won't turn off at the same time
08:36 AM anonnumberanon: my code is timing critical because if 2 PWMs are exactly only 1 microsecond apart I don't want there to be more than 1 microsecond between when one turns off and the next one turns off
08:36 AM anonnumberanon: polprog is dead
08:38 AM nuxil: hes a deadprog now.
08:39 AM nuxil: lets clear him, xor polprog, polprog
08:47 AM nuxil: anonnumberanon, what chip was it that you are messing with?
08:47 AM nuxil: some atiny?
08:48 AM anonnumberanon: atmega328
08:50 AM nuxil: nice. i got a couple of atmega324p-20pu i havent gotten around to mess with yet.
08:50 AM nuxil: need to make myself a programmer board 1st. but been busy with other real life stuff.
08:51 AM nuxil: its a beast :p
08:51 AM anonnumberanon: you can get an arduino uno
08:51 AM nuxil: no thanks
08:51 AM anonnumberanon: but for a basic board just get the chip, a breadboard, a crystal, a capacitor
08:51 AM nuxil: im not into that aweduino stuff
08:52 AM anonnumberanon: it's cheap and a great board, remove the bootloader from it so you cant cheat like the arduino guys!
08:52 AM anonnumberanon: i did it
08:52 AM anonnumberanon: sometimes it's more convenient than my breadboards
08:53 AM anonnumberanon: you can load it with straight plain avr code and it will run better than arduino code
08:53 AM anonnumberanon: heh
08:54 AM nuxil: well. im new to this hole mcu stuff. atiny85 is the only chip i messed with
08:54 AM nuxil: and i guess i havent reached 1% of what i can do with it.
08:54 AM anonnumberanon: on the breadboard?
08:55 AM nuxil: when i see what "gods" like Jartza can do with them. here is one video https://www.youtube.com/watch?v=Y2gl3R3jzjs :p
08:56 AM anonnumberanon: yep, vga is pushing it
08:56 AM nuxil: i have the breadboard i mess around on for the mostly. but i also have prototype cards i can use
08:57 AM nuxil: i hacked my door bell tho
08:57 AM anonnumberanon: lol
08:57 AM nuxil: added a atiny85 to it using tinytune lib
08:58 AM nuxil: so each time someone rings my door. it plays bennyhill chiptune :p lol
08:58 AM anonnumberanon: i use these for robots and for geek stuff
08:58 AM anonnumberanon: lol nice, nice
08:59 AM nuxil: made a squarewave generator with it aswell. but gave up on that. it wasnt verry presice.
09:00 AM nuxil: 8bit is not enuf unless you want huge gaps in freq
09:01 AM nuxil: atleasy i learned how to code "rotary encoders" when doing that project :p
09:02 AM anonnumberanon: wait what ? a square wave generator? isn't that just a pwm?
09:02 AM nuxil: yea. but i have variable duty cycle aswell. down to 5%
09:03 AM anonnumberanon: well this is what I'm playing with right now too
09:04 AM anonnumberanon: outputting 16 of them at a time
09:04 AM anonnumberanon: 18
09:05 AM anonnumberanon: have you used a potentiometer yet? it was a wow moment for me the first time
09:05 AM nuxil: i used rotary encoders. 2x. one for freq and one for duty
09:06 AM anonnumberanon: wait is this like a better version of a potentiometer?
09:06 AM anonnumberanon: pot is only 3 pins
09:06 AM nuxil: its digital
09:07 AM anonnumberanon: ok
09:07 AM nuxil: http://howtomechatronics.com/tutorials/arduino/rotary-encoder-works-use-arduino/
09:07 AM anonnumberanon: i have never played with those
09:08 AM nuxil: i tried using pots 1st
09:08 AM nuxil: but the ones i had where so old and not good.
09:08 AM nuxil: ther where from a old stereo
09:08 AM nuxil: rotary encoders are cool tho. super precise
09:09 AM anonnumberanon: you hook it up to your ADC on the micro, read the voltage and apply a value to a piezo speaker, it makes you a basic music instrument!
09:09 AM nuxil: you can do that
09:10 AM anonnumberanon: yeah look, (except this is a linear potentiometer but it is the same concept)
09:10 AM anonnumberanon: https://www.youtube.com/watch?v=7KfSt8IXqGY
09:14 AM nuxil: i know the consept. but lets say you want to increase your OCR0A or OCR0B or whatever, by 1. thats way harder with a pot than using rot encoders. rot encoders may require more code tho.
09:16 AM nuxil: if you got a dicky pot. even with caps. you might jump 2-3 on a small adjustment
09:38 AM anonnumberanon: gn
09:39 AM anonnumberanon: nuxil, what's the resolution on one of these rotary encoders?
09:39 AM anonnumberanon: nah ok gn heh
09:39 AM anonnumberanon: im dead
10:41 AM polprog: im back!
10:43 AM nuxil: anonnumberanon, they can be anything you like. you do it all in software
10:44 AM nuxil: mine are old 200 p/r ish (puls per round)
10:45 AM nuxil: the encoders itself. the but how much in should increment/decriment is controlled by your code
02:23 PM rue_mohr: optical encoders are nice, the cheap mechanical ones from china are a nightmare
02:23 PM rue_mohr: I'm working on how to etch thin foil so I can make encoders
02:28 PM polprog: i read that as tin foil and thought you were crazy
02:28 PM polprog: i think optical encoders would be rather easy
02:29 PM rue_mohr: :) put 256 lines on a 15cm disc and call me in the morning
02:29 PM polprog: why 256 lines
02:29 PM nuxil: 0.O
02:29 PM polprog: i can put 8 rings with gray code
02:29 PM nuxil: 15cm
02:29 PM rue_mohr: I have an idea to use UV laquer for photomasking
02:30 PM nuxil: you making a encoder for a big troll?
02:30 PM polprog: im thinking of putting an 8-bit gray code disk image on a t shirt
02:30 PM rue_mohr: "you spin me right round baby right round"
02:30 PM polprog: tell me it's not beautiful https://upload.wikimedia.org/wikipedia/commons/a/a8/Gray_code_rotary_encoder_13-track_opened.jpg
02:31 PM rue_mohr: or you could put one ring of stripes and have a mask with 8 offsets
02:32 PM rue_mohr: vernier
02:33 PM polprog: mm
02:33 PM rue_mohr: why would someone smash the disc on an absolute encoder?
02:33 PM polprog: what do you mean
02:33 PM rue_mohr: its got the side smashed out of it
02:33 PM polprog: eww
02:33 PM rue_mohr: maybe it just fractured
02:33 PM polprog: yeah
02:33 PM polprog: might be why it was taken apart
02:33 PM rue_mohr: anyhow
02:34 PM polprog: what are those chips? 74hc161
02:34 PM rue_mohr: variable differential capacitors work great as absolute rotation sensors too
02:34 PM rue_mohr: 161 is a shift register
02:34 PM rue_mohr: iirc
02:35 PM polprog: the second one seems to be a dual flip flop
02:35 PM rue_mohr: 7474?
02:35 PM polprog: "synchronous presettable 4-bit binary counter, asynchronous clear" - 74hc161
02:35 PM polprog: yes, 7474
02:35 PM polprog: "dual D positive edge triggered flip-flop, asynchronous preset and clear"
02:35 PM polprog: hmm
02:35 PM polprog: looks like glue logic
02:36 PM polprog: im more curious by that optolab chip
02:36 PM polprog: looks very unusual
02:39 PM rue_mohr: I cant find the rotary position detector
02:40 PM rue_mohr: I THINK its part of
02:40 PM rue_mohr: http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/f2013/hl577_jeh295_msh276/hl577_msh276_jeh295/index.html
02:40 PM rue_mohr: but thats not the right writeup
02:40 PM rue_mohr: http://ruemohr.org/~ircjunk/tutorials/elex/ldvc/ldtc.html
02:40 PM rue_mohr: I did this writup based on it
02:41 PM polprog: im impressed
02:42 PM polprog: also i like the esthetic design of that multimeter
02:42 PM rue_mohr: its a fast meter, most of them these days aren't
02:42 PM rue_mohr: I have another meter that takes almost 750ms to get a sample
02:51 PM polprog: i have a brymen 876s which im happy with
02:51 PM polprog: 50k / 500k counts
02:57 PM rue_mohr: ~$250usd ea?
03:09 PM polprog: something like that
03:11 PM polprog: i got it at a sale though, locally
03:11 PM polprog: so no customs
03:11 PM polprog: worth it, really
03:11 PM polprog: i wanted a fluke but the new ones were even more expensive and the used ones were dirty as seven hells
04:02 PM rue_mohr: http://elm-chan.org/works/vlp/report_e.html
04:02 PM rue_mohr: aha!
04:02 PM rue_mohr: http://elm-chan.org/works/vlp/report_e.html
04:02 PM rue_mohr: http://elm-chan.org/works/vlp/report_e.html
04:02 PM rue_mohr: http://elm-chan.org/works/vlp/report_e.html
04:02 PM rue_mohr: http://elm-chan.org/works/vlp/report_e.html
04:02 PM rue_mohr: http://elm-chan.org/works/vlp/report_e.html
04:02 PM rue_mohr: wrong channel
04:06 PM nuxil: mmm. if i had the parts i make onr
04:06 PM rue_mohr: the capacitove position sensor is the important part
04:08 PM rue_mohr: http://ruemohr.org/~ircjunk/tutorials/elex/ldvc/ldtc.html
04:10 PM nuxil: i got no servos, mirrors, laser etc
04:29 PM polprog: laser projector was somethign i wanted to make
04:29 PM polprog: :P
04:29 PM polprog: goodnight!
04:31 PM nuxil: gn
11:21 PM day__ is now known as daey
11:47 PM nuxil: mornings
11:48 PM * nuxil yawns