#avr Logs

Aug 21 2017

#avr Calendar

12:35 AM Thrashbarg_ is now known as Thrashbarg
01:56 AM Thrashbarg_ is now known as Thrashbarg
03:12 AM polprog: good morning
04:10 AM Emil: Wait
04:10 AM Emil: you need to in/out sreg?
04:10 AM Emil: I thought you could access it directly
04:10 AM Emil: well watever
04:16 AM polprog: with in/out you use the lower adresses
04:16 AM polprog: also lower adresses let you use sbi/cbi
09:20 AM lemm|ngs is now known as lemmings
11:05 AM polprog: any good and cheap lithium cell management chips?
11:06 AM polprog: preferably something that can be used to build a charger, or to be integrated in a design so i can use a lithium cell
11:15 AM bss36504: Single or multi cell?
11:15 AM bss36504: Microchip makes some stuff
11:15 AM polprog: single cell for now
11:15 AM polprog: basically i have 6 cells from a dead laptop battery
11:16 AM polprog: some of them are OK, some of them are definitely dead
11:16 AM polprog: i need to find a use for the ones that are ok
11:21 AM rue_bed: anyone know when the eclipse hits?
11:24 AM polprog: in an hour special reports start on CBS and ABC
11:25 AM rue_bed: 10, ok
11:25 AM polprog: which part of the states are you in?
11:26 AM polprog: west?
11:26 AM polprog: https://www.greatamericaneclipse.com/nation/
11:37 AM bss36504: I'm up in VT, so about 70% eclipse
11:37 AM bss36504: But I'll get the full effect of the 2024 eclipse
11:47 AM lemm|ngs is now known as lemmings
01:36 PM Emil: polprog: you need two chips
01:36 PM polprog: ?
01:36 PM Emil: polprog: a charger and a low volgage protection chip
01:36 PM polprog: i think i will see what's inside those powerbanks
01:37 PM polprog: but im all ears
01:37 PM Emil: I tried finding one that combines them but failed
01:44 PM renn0xtk9: Does it make any difference when you make an infintie loop (in the main) with while(true) or with for(;;) does it has any impact ?
01:44 PM Lambda_Aurigae: we have eclipse!
01:44 PM Lambda_Aurigae: renn0xtk9, shouldn't make any difference either way.
01:44 PM LeoNerd: renn0xtk9: I expect those will compile to identical assembly code
01:45 PM LeoNerd: and if not your C compiler is probably being very odd for at least one of them
01:45 PM Lambda_Aurigae: I have done both...while(1){} is the preferred method according to official programming instructors I
01:45 PM polprog: and if not you can always decompile it with avr-objdump or whatever else you have
01:45 PM Lambda_Aurigae: 've been privy to hear
01:46 PM Lambda_Aurigae: I'm at 92% coverage area for the eclipse today.
01:46 PM polprog: lucky
01:46 PM Lambda_Aurigae: and 98% cloud coverage.
01:47 PM renn0xtk9: when doing for, I noticed that If I don't reset that watchdog in each loop, It reseted the muc
01:47 PM renn0xtk9: is that normal?
01:47 PM polprog: by watchdog you mean the variable?
01:47 PM renn0xtk9: I think so. basically calling wdt_reset()
01:48 PM polprog: i think id need to see the code
01:51 PM renn0xtk9: well that is the core of my main
01:51 PM renn0xtk9: https://pastebin.com/6fs5jKv9
01:52 PM renn0xtk9: btw if you have any idea why the led are not glowing on LED_BIT
01:52 PM renn0xtk9: it used to be, but does not ...
01:53 PM polprog: hmm
01:54 PM polprog: where else in the code you set the value of debug
01:54 PM renn0xtk9: in an ISR
01:55 PM polprog: ok
01:55 PM renn0xtk9: for I2C
01:55 PM renn0xtk9: the weir is taht at the very begiingi I try to light up /dow n a led
01:55 PM renn0xtk9: and it does not work :S
01:55 PM polprog: so when the ISR fires it eventually breaks the while(over==0) loop and exits main
01:55 PM polprog: are you sure the program actually runs then?
01:56 PM Lambda_Aurigae: renn0xtk9, if you have to keep resetting the watchdog then the watchdog timer is on...which is a good thing unless you don't want it on..in which case, turn it off.
01:56 PM renn0xtk9: hmm I thought the ISR set debug to 1 then resume where it was (in the main) it sends the shutdown instruction and then yes exit the while and run out of main
01:57 PM polprog: because watchdog timer is used to reset the cpu
01:57 PM polprog: what happens is: ISR runs, sets the valuse, ISR ends, CPU goes back to main() and exits loop cos the if(debug==1) is executed
01:58 PM polprog: s/valuse/value
01:58 PM renn0xtk9: polprog yes that is the goal
01:59 PM polprog: to exit main()?
01:59 PM renn0xtk9: well the only place where i am using a timer , it is defing before the main, it is copy paste from the IRMP library https://pastebin.com/E5Q2WMXr
01:59 PM renn0xtk9: and I don't know if it kind of conflict with the watchdog /whatsoever
02:00 PM renn0xtk9: polprog, yes and the programm would stop then? would not it?
02:00 PM Lambda_Aurigae: stop?
02:00 PM Lambda_Aurigae: on an avr, the program doesn't stop.
02:00 PM polprog: in avr-gcc at least the program then goes to an infinite loop iirc
02:00 PM Lambda_Aurigae: if you end main it goes to a loop, or is supposed to.
02:01 PM Lambda_Aurigae: during which interrupts should still fire and be handled if you have interrupt handlers programmed.
02:01 PM polprog: if you exit main, then (in theory) it's impossible to go back. you have to reset the CPU, for example by watchdog
02:01 PM LeoNerd: reading the disasm output of a gcc-compiled AVR binary is interesting for that:)
02:01 PM LeoNerd: it has an _exit symbol
02:01 PM LeoNerd: that just does cli(); while(1) ;
02:01 PM renn0xtk9: my main concern at the moment is why the LED don't even displays :S
02:02 PM polprog: LeoNerd: http://www.atmel.com/webdoc/avrlibcreferencemanual/mem_sections_1sec_dot_fini.html
02:03 PM polprog: renn0xtk9: try adding a simple LED_PORT_OUTPUT |= _BV(LED_BIT) at the very beginning of main
02:04 PM Lambda_Aurigae: LeoNerd, so, it shuts off interrupts...interesting.
02:04 PM polprog: it should not according to the atmel link i posted
02:05 PM polprog: is this the very same libc that is used by gcc on a typical toolchain?
02:05 PM renn0xtk9: Polprog now my main looks like that https://pastebin.com/VfLimZ3j and the led lights up, lights down (at the very beginning) and over and over again (which to me means the mcu is reseted )
02:06 PM renn0xtk9: is it because of the _delays (1000) thaht make the watchdog jumping?
02:06 PM Lambda_Aurigae: I would turn watchdog off.
02:06 PM LeoNerd: http://paste.debian.net/982393/ <== the very end of 'make disasm' on one of my AVR projects
02:07 PM polprog: renn0xtk9: it is possible tht the delay triggers the WDT
02:07 PM polprog: LeoNerd: youre right
02:08 PM polprog: odd, because the libc doesnt mention anything about interrupts being disabled...
02:08 PM Lambda_Aurigae: delay doesn't trigger it..it triggers on its own if it's not reset constantly.
02:09 PM renn0xtk9: Lambda_Aurigae but it will triggers after a number of instruction unresetted or after a given time?
02:09 PM polprog: it possible that it tiggers itself because the delay is long enough that it takes all the time that the program has to reset the WDT
02:09 PM Lambda_Aurigae: time...hence, the name,,,watchdog TIMER
02:09 PM Lambda_Aurigae: turn it off.
02:10 PM Lambda_Aurigae: eliminate one possible issue.
02:10 PM polprog: ^^ good idea
02:10 PM Lambda_Aurigae: eliminate everything not absolutely necessary for the program to run.
02:10 PM Lambda_Aurigae: it's called debugging!
02:10 PM Lambda_Aurigae: take the code apart and try one piece at a time.
02:10 PM polprog: never make assumptions about stuff you can easily check, that's also useful
02:10 PM Lambda_Aurigae: eliminate everything not otherwise necessary, like sleeping and watchdog and crap.
02:11 PM Lambda_Aurigae: once each piece of the code works independently THEN start putting the pieces together.
02:11 PM Lambda_Aurigae: hell, this is a procedure I learned when I was 12 and taught myself to program on trs-80 and apple-2 computers.
02:12 PM Lambda_Aurigae: it hasn't changed in 38 years.
02:12 PM polprog: i should get a retro computer
02:12 PM polprog: my dad had a c64
02:12 PM polprog: maybe it's still in the basement at grandparents
02:12 PM Lambda_Aurigae: I just got rid of all my commodore gear except for a single vic-20 and some cartridge games.
02:17 PM renn0xtk9: Lambda_Aurigae yeah this is what I have done basically, using the IRMP (infra red sending) alone works, Using the I2C alone work
02:17 PM renn0xtk9: putting the two together fails
02:17 PM Lambda_Aurigae: so now you need to figure out where it fails.
02:18 PM Lambda_Aurigae: and get rid of that damned watchdog...absolutely unnecessary in the middle of this process.
02:18 PM Lambda_Aurigae: if your IRMP uses timers and interrupts, you could be overloading the interrupt system which is likely needed by your i2c communications.
02:19 PM Lambda_Aurigae: if you are still running that timer interrupt as fast as you were last week, I would be that's a major issue.
02:19 PM renn0xtk9: yeah they are off the watchdog
02:19 PM Lambda_Aurigae: that chip can only do so many things in a given amount of time.
02:19 PM renn0xtk9: Okay but if you want to send IR you need to be fast don't you
02:20 PM renn0xtk9: I don't know I copy paste code from IRMP library some people seem to use it without problem
02:20 PM Lambda_Aurigae: that all depends on how you are doing it.
02:20 PM polprog: but you cant have two thing at the same time
02:20 PM renn0xtk9: I don't know I copy paste code from IRMP library some people seem to use it without problem
02:20 PM polprog: theres your problem
02:20 PM Lambda_Aurigae: I have never used that irmp library.
02:20 PM polprog: neither did i
02:20 PM Lambda_Aurigae: read the code, learn it, understand it.
02:20 PM polprog: this so much
02:20 PM Lambda_Aurigae: copy/paste without understanding leads to frustration.
02:20 PM renn0xtk9: I know about two things at the same time, but right there it should be one thing after the other
02:21 PM Lambda_Aurigae: how fast is that timer overflowing?
02:21 PM polprog: how can you know an ISR isn't firing when the cpu is inside another ISR?
02:21 PM polprog: do you wrap in in a cli(); sei() block?
02:22 PM Lambda_Aurigae: polprog, when in an interrupt routine, it should be cli already.
02:22 PM polprog: i dont know
02:22 PM Lambda_Aurigae: when you exit it, the next interrupt gets triggered.
02:22 PM Lambda_Aurigae: up to a certain amount..I forget how many it will stack.
02:22 PM polprog: if you say so i believe you... no idea about that
02:22 PM renn0xtk9: polprog, apart from those of the IRMP there is one ISR only that is used and this is the one that is being triggerd by I2C and i fire it manually via another chip via usb
02:23 PM Lambda_Aurigae: again, how fast is the IRMP timer overflowing?
02:23 PM Lambda_Aurigae: and, how fast is that chip running?
02:24 PM Lambda_Aurigae: and how big is your interrupt routine?
02:24 PM renn0xtk9: you mean that line OCR1A = (F_CPU / F_INTERRUPTS) - 1; // compare value: 1/15000 of CPU frequency
02:24 PM renn0xtk9: chip is running 16Mhz
02:25 PM renn0xtk9: F_intterupts is 10000 there
02:26 PM Lambda_Aurigae: figure out how many times per second that routine runs...figure out how many clock cycles that routine takes...multiply clock cycles by times per second...
02:26 PM Lambda_Aurigae: now figure out how big your i2c routine is and how many times that fires in one second.
02:26 PM Lambda_Aurigae: I'm betting the two come out bigger than 1000000
02:27 PM Lambda_Aurigae: which, granted, is less than 16000000, however, there is probably some overlap and interference in there somewhere.
02:27 PM Lambda_Aurigae: you have to have balance.
02:36 PM renn0xtk9: don't know for me the program is linear, it is either the code of the library or the material that is unreliabale
03:06 PM Lambda_Aurigae: it's not linear when you are working with interrupts.
03:06 PM Lambda_Aurigae: it is multiple code segments trying to run independently of each other, sometimes trying to run at the same time but as the chip is single threaded they can't, which means something has to wait.
03:21 PM Emil: renn0xtk9: you want 10k interrupts a second?
03:21 PM Emil: You ISR must be pretty big if 1600 cycles is not enough
03:23 PM polprog: you assume he's running at 16M
03:23 PM Emil: >2017-08-21 21:53:16 +0300 < renn0xtk9> chip is running 16Mhz
03:23 PM polprog: ah
03:23 PM polprog: sorry :P
03:23 PM Emil: polprog: lol you tried to smite me
03:23 PM Emil: can't touch this
03:41 PM renn0xtk9: so I moved around a bit of things in the main and magically it now works
03:41 PM renn0xtk9: the ISR is .. well... https://pastebin.com/9iLGLb0U
03:42 PM renn0xtk9: lots of line but not everyhting gonna get exectuted at a time ..
03:43 PM twnqx: i'd turn that into a switch () block for readability :P
03:44 PM twnqx: the first block i mean, like the second
03:46 PM renn0xtk9: Yes I think I twill get the rid out of all of those
03:46 PM renn0xtk9: althoug my initiall idea was to support most of those
03:46 PM Emil: 1400 lines of code
03:46 PM renn0xtk9: so that i can just chosses which one i want form the computer :p
03:46 PM Emil: how do you manage to produce such huge amounts of code for such a trivial thing :D
03:47 PM renn0xtk9: Emil yes ^^
03:47 PM renn0xtk9: It is not mine actually :p
03:47 PM renn0xtk9: I just copy pasted it (I know it is not an excuste ^^)
03:47 PM Emil: Oh god
03:47 PM Emil: Oh GOD
03:47 PM renn0xtk9: well it is really that trivial? I mean if you really want to suppport all protocols
03:47 PM Emil: Ifdefs all around
03:47 PM Emil: readability went down the shitter
03:48 PM renn0xtk9: yes this is true ..
03:48 PM Emil: wait
03:48 PM Emil: are you using your own ISR definition?
03:48 PM Emil: irsnd_ISR
03:49 PM Emil: Yeaaaaaah I ain't touching that code :D
03:50 PM renn0xtk9: nono irsnd_ISR the method place inside the ISR
03:50 PM renn0xtk9: i already pastebined 1400 lines of codes, so I though I would spare you the three other ones ^^
03:51 PM Emil: ................
03:51 PM Emil: Good luck on your selected journey :D
03:53 PM Emil: By three other ones
03:53 PM Emil: you mean
03:53 PM Emil: another almost 3k lines of code?
03:57 PM polprog: wtf is going on hete
03:57 PM polprog: s/hete/here
04:15 PM Emil: polprog: look at that link
04:16 PM Emil: polprog: I understand there's three times that much code
04:16 PM Emil: Over 4000 lines of it
04:16 PM polprog: lol
04:16 PM polprog: im looking through that
04:16 PM polprog: it's literally huge
04:17 PM polprog: at least it's preconfigurable
04:17 PM polprog: with all that preprocessor stuff
04:17 PM polprog: at least that
04:18 PM Lambda_Aurigae: must have been written for an ardweeny
04:19 PM polprog: no that's a universal library
04:19 PM polprog: he copied it he said
04:21 PM renn0xtk9: Emil no just the 3 lines that say ISR{ irsnd_ISR }
04:22 PM renn0xtk9: I have at home on of those LED chain that people usually put as a decoreation. I thas an IR remote, Anyone happen to know if those klind of things uses a standard protocol, and if yes which it could be
04:23 PM polprog: y'know faster would be to reverse engineer this protocol
04:23 PM Lambda_Aurigae: yes, it's a standard protocol for that brand.
04:23 PM polprog: and for sure it's not grundig
04:23 PM Lambda_Aurigae: probably one of 4 or 5 standards for that brand in fact.
04:23 PM polprog: as ive seen that name in the paste :P
04:23 PM renn0xtk9: yes they wanted to be very general i think ^^
04:24 PM renn0xtk9: yeah right now I only make somehting that sends IR
04:24 PM Lambda_Aurigae: I can send IR with a match and a piece of cardboard.
04:24 PM renn0xtk9: as a next project maybe onething that receive and with which i can retro engineer
04:24 PM polprog: so it's faster to check the protocol and write one handler than to implement handlers for all the ir protocols out there
04:24 PM renn0xtk9: it is already a miracle if I managed being given that i use this dodgy IR library + V-USB
04:25 PM polprog: jeez you have a broken i2c handler why add v-usb
04:25 PM polprog: just but the cheapest usb-uart chip out there
04:25 PM renn0xtk9: Lambda_Aurigae? WTF how do you do?
04:25 PM polprog: renn0xtk9: cool hack
04:25 PM Lambda_Aurigae: polprog, he has backed down from one chip with v-usb and the IR stuff to 2 chips with i2c between them and v-usb and ir separated.
04:26 PM polprog: renn0xtk9: i mean the match and paper is a cool hack, you can google it
04:26 PM Lambda_Aurigae: renn0xtk9, you light match, hold up cardboard, and wiggle it back and forth in front of the match...didn't say it was any kind of a standard protocol.
04:26 PM Lambda_Aurigae: you can't exactly control anything with it
04:26 PM polprog: you can send morse
04:26 PM renn0xtk9: polprog the original stuff was to learn how to make a USB driver on linux ^^ Once I saw that I got response from the ATMEGA, I thought well now I have to do something with it .. and party gone started ^^
04:26 PM Lambda_Aurigae: but you can still send 1 and 0 or high and low or morse code or something.
04:27 PM polprog: some say chuck norris read his email by looking at the blinking router lights :D
04:27 PM Lambda_Aurigae: and it is kind of broad spectrum too...IR, right down to some yellow.
04:27 PM polprog: but what a pleasant spectrum it is
04:27 PM renn0xtk9: Maybe I could use a driver USB with one ATMEGa v-usb sending I2c message to the other one , itself sending i2c messages to a step motor controller that would do the wiggling ^^ hahahahah
04:27 PM Lambda_Aurigae: I prefer the spectrum of burning magnesium porche engine blocks.
04:28 PM Lambda_Aurigae: oh hell...driving a stepper is super simple.
04:28 PM polprog: i like sodium spectrum
04:28 PM Lambda_Aurigae: can do that with one chip and v-usb
04:28 PM polprog: like in sodium lamps
04:28 PM polprog: hell you can drive a stepper via the paralell port
04:28 PM Lambda_Aurigae: look at the v-usb projects page..they even drive hobby servos with one chip.
04:28 PM Lambda_Aurigae: multiple hobby servos.
04:29 PM Lambda_Aurigae: and steppers are so much easier to drive than servos
04:30 PM polprog: yeah
04:33 PM polprog: http://www.righto.com/2017/08/inside-fake-ram-chip-i-found-something.html
04:33 PM polprog: this is the stuff that i like
04:34 PM polprog: IC design is so interesting
04:35 PM polprog: if only i had a microscope... i need to see if i could get a used one cheaply. preferably one which can have a camera hooked up to it
04:52 PM debo: driving steppers over paralel port makes me remember when back in high school I put an usb web camera on two steppers, made an at89c51 + uln2003 stepper driver programmed in BASCOM and controlled it by using 4 parallel port data pins. i also made a web application that displayed the video and enabled you to control the motion. it was the IoT before IoT became the thing, except it wasn't really IoT :D
04:52 PM polprog: cool!
04:57 PM debo: i can't tell you how much vibration that thing produced due to really poor stepping algorithm I wrote :D
04:59 PM polprog: nobodys perfect
04:59 PM polprog: :D good night
10:31 PM HighInBC is now known as Chillum
11:08 PM Thrashbarg__ is now known as Thrashbarg
11:08 PM Thrashbarg is now known as Thrashbarg__
11:09 PM Thrashbarg__ is now known as Thrashbarg
11:42 PM day_ is now known as daey