#avr Logs

Oct 23 2018

#avr Calendar

12:00 AM rue_shop3: maybe this is about how bad a job you can get away with before its noticable
08:49 AM Emil: CA857051390ATCA857051390ATCA857051390AT2018-10-23 09:20:34 +0300 -!- JoeLlama [~snork@unaffiliated/joellama] has quit [Quit: “I am so sick of killing mice!” --=Billy Quizboy]
08:49 AM Emil: 2018-10-23 09:20:34 +0300 -!- JoeLlama [~snork@unaffiliated/joellama] has quit [Quit: “I am so sick of killing mice!” --=Billy Quizboy]
08:49 AM Emil: 2018-10-23 09:20:34 +0300 -!- JoeLlama [~snork@unaffiliated/joellama] has quit [Quit: “I am so sick of killing mice!” --=Billy Quizboy]
08:49 AM Emil: 2018-10-23 09:20:34 +0300 -!- JoeLlama [~snork@unaffiliated/joellama] has quit [Quit: “I am so sick of killing mice!” --=Billy Quizboy]
08:49 AM Emil: 2018-10-23 09:20:34 +0300 -!- JoeLlama [~snork@unaffiliated/joellama] has quit [Quit: “I am so sick of killing mice!” --=Billy Quizboy]
08:49 AM Emil: 2018-10-23 09:20:34 +0300 -!- JoeLlama [~snork@unaffiliated/joellama] has quit [Quit: “I am so sick of killing mice!” --=Billy Quizboy]
08:50 AM rue_mohr: haha, he's taken to flooding our channel now
08:52 AM polprog: and hes blaming his keyboard for that :P
08:53 AM rue_mohr: hmm, did I count my interrupts wrong?
08:54 AM rue_mohr: http://paste.debian.net/1048636/
08:55 AM rue_mohr: it shouldn't matter if I'm out by 1, but
08:55 AM rue_mohr: I need to count off 4 calls
08:59 AM rue_mohr: in the first pass its set to 4
09:00 AM rue_mohr: the next its dec to 3
09:00 AM rue_mohr: the next its dec to 2
09:00 AM rue_mohr: the next its dec to 1
09:00 AM rue_mohr: the next its dec to 0
09:00 AM rue_mohr: then its enterted again and set back to 4
09:00 AM rue_mohr: that seems to be /5
09:02 AM rue_mohr: I wonder if the adc fsm restarts if I throw a SC during a conversion
09:08 AM cehteh: wtf are you doing?
09:08 AM rue_mohr: ;)
09:08 AM rue_mohr: I'm using the adc conversion complete interrupt as a time base for serial data
09:09 AM rue_mohr: cause its a successive approx and always takes "13" cycles
09:09 AM rue_mohr: (it seems to be closer to 14, but the clock jitter makes it hard to tell)
09:10 AM cehteh: hum
09:10 AM cehteh: free running adc?
09:10 AM rue_mohr: yea
09:10 AM rue_mohr: and you set the adc prescaler to the rate you want
09:10 AM rue_mohr: so 13 * (2, 4, 8, 16, 32, 64, 128)
09:11 AM cehteh: the adc works best when its in some frequency range
09:11 AM rue_mohr: i'M NOT USING THE ADC
09:11 AM rue_mohr: sorry
09:11 AM cehteh: neither too slow nor too fast
09:11 AM rue_mohr: I'm not using the adc
09:11 AM rue_mohr: I'm using the interrupt it generates
09:11 AM cehteh: ah
09:11 AM cehteh: why that then?
09:11 AM rue_mohr: cause I need the timer
09:11 AM cehteh: out of timers?
09:11 AM rue_mohr: hah, 1 isn't enough
09:11 AM rue_mohr: (tiny13)
09:12 AM cehteh: why not?
09:12 AM rue_mohr: I want to do hobby servo pulses
09:12 AM rue_mohr: I need them to be stable
09:12 AM cehteh: my mµOS needs only one timer :D
09:12 AM rue_mohr: If found that hobby servos are really sensitive to jitter
09:13 AM cehteh: and yes tiny13 should die, 25/45/85 are so much more versatile
09:13 AM rue_mohr: so, I'm kinda worried about the jitter I see in the system clock
09:13 AM rue_mohr: tiny13 is pretty cheap from china
09:13 AM rue_mohr: iirc
09:13 AM cehteh: sure servo pulses need some exact timing, they are somewhat odd, long frames and precision signals
09:13 AM rue_mohr: 50c ea dip and 40cea soic
09:14 AM cehteh: yes but does 20-50cent difference really matter for a hobby project? or do you plan to for a product with 10000 pieces manufactured?
09:14 AM rue_mohr: if I run at 4.8Mhz, with the timer set to /64 then 2ms = 150 counts
09:15 AM rue_mohr: I just dont want to ave to have $20 of controllers sitting in my bins
09:15 AM rue_mohr: the 25/45 dont have any more timers do they?
09:15 AM cehteh: and doesnt the tiny13 have 2 timers?
09:15 AM rue_mohr: nope, 1 8 bit timer :/
09:16 AM cehteh: 25/45/85 have 2 timers iirc
09:16 AM rue_mohr: I'm pushing the limit of the t13 far past what I'd normally even try, but its kinda fun
09:16 AM cehteh: but most likely i would stay with one because i dont want each one to interfere, except 2nd one may be free spinning for timer capture when you need that
09:17 AM cehteh: t13 is so limited, can be fun, but imo isnt worth it
09:17 AM rue_mohr: the idea is to have the timer clear the io bit for me, tho wait a min, my plans diverged, I wanted 4 channels
09:17 AM cehteh: not enough ram not enough flash for serious fun
09:18 AM rue_mohr: hey hey I got a 9600 baud controlled 4 channel software pwm made in 510 bytes of flash!
09:18 AM cehteh: you may do it without interrupts
09:18 AM rue_mohr: problem is I need the interrupt time for recieving the serial bits
09:19 AM cehteh: plenty of time to calculate whatever you need in the frame pauses and doing busy waits for pushing servo data
09:19 AM cehteh: that absolutely static/exact then and no overhead from the isr's
09:19 AM cehteh: (and no stack wasted to call isr's/nested functions)
09:20 AM rue_mohr: right now I'm just playing with using that adc interrupt to time serial, and so far it didn't work
09:20 AM cehteh: glhf :D
09:20 AM rue_mohr: but, calculating the clock rate of the t13 isn't comming out right
09:21 AM rue_mohr: I got like 4.5Mhz last night, a few times
09:21 AM cehteh: still clkdiv8 enabled? :)
09:21 AM rue_mohr: no, but I came out of it last night feeling I'm gonna have to play with the osccal
09:21 AM cehteh: internal osc is somewhat off/unstable .. but when you can sync it to some external source it works fine
09:22 AM cehteh: i did a ppm parser for servo signals, syncing clock by the PPM frames
09:22 AM rue_mohr: hmm
09:23 AM cehteh: but dont forget that OSCCAL is coarser than you think, you need some deadband on the frequency and compensate for inexactness somehow else, otherwise you get horrible jitter
09:23 AM rue_mohr: if its averaging 4.5Mhz right now, I feel I can tweek it
09:24 AM cehteh: so write some controller to get OSCCAL as close as you can get, but not too much
09:24 AM rue_mohr: I need to look at how far off the bit-times my irq's are too
09:24 AM cehteh: do you have some external timing source?
09:24 AM rue_mohr: not for this, just the 9600 baud data and the hobby servo output
09:24 AM cehteh: serial clock, PPM, RTC, whatever
09:24 AM rue_mohr: you thinking I realtime cal on the 9600?
09:25 AM cehteh: well when you can trust the 9600 baud you can use that
09:25 AM cehteh: yeah
09:25 AM rue_mohr: so I get close and use it for tuning, hmm
09:25 AM rue_mohr: awefull heavy for 1k of flash
09:25 AM cehteh: nah doesnt need much code
09:26 AM rue_mohr: \:|
09:27 AM cehteh: you only need to check the dervitation (slowly, not on every byte) and if its more than allowed increment/decrement osccal until you in deadband range
09:27 AM rue_mohr: preferadly locking onto 1 bittime, but I'd have to get and know I had a 010 or 101
09:28 AM cehteh: when you do softserial you already track the clock somehow to cope with such inexactness
09:28 AM cehteh: but dont be tempted to calibrate too fast
09:29 AM rue_mohr: every edge I adjust the timer to 0.5 bits left
09:30 AM rue_mohr: less the frist, its 1.5
09:30 AM cehteh: (aka only increment/decrement OSCCAL. add that saied deadband and integrate slowly) .. maybe store osscal in eeprom
09:31 AM rue_mohr: http://paste.debian.net/1048641/
09:31 AM rue_mohr: I was wrong, its 4.8Mhz
09:31 AM rue_mohr: but it might be just borderline working
09:31 AM cehteh: the internal osc drifts a bit with temperature and has some jitter
09:32 AM rue_mohr: you should have seen me trying to make a 1-10Mhz osc
09:32 AM rue_mohr: wow the drifting!
09:32 AM rue_mohr: and the sensitivity!, standing NEAR it would cause the freq to start going up
09:32 AM cehteh: thats where tiny45 etc shines with the internal PLL
09:32 AM cehteh: lol
09:33 AM cehteh: so bbl
09:34 AM rue_mohr: china wants almost $2ea for a tiny45
09:34 AM rue_mohr: t13 is 0.50
09:34 AM rue_mohr: for perspective, stm32 is $3
09:34 AM rue_mohr: work, bbl
10:52 AM Maya-sama is now known as Miyu
11:11 AM gruetze is now known as gruetze_
11:23 AM gruetze_ is now known as gruetzkopf
12:00 PM [1]MrMobius is now known as MrMobius
01:02 PM pwillard: does CHINA make Tiny45 or does Atmel? And Mouser.com only wants a $ or so.
01:19 PM Ameisen: Atmel doesn't exist anymore
01:19 PM Ameisen: and there are two Chinas
01:19 PM Ameisen: and they only want one dollar sign?
03:42 PM nohit: --
04:02 PM nohit: <rue_mohr>for perspective, stm32 is $3
04:02 PM nohit: you mean the cheapest or what ?
04:21 PM rue_shop3: bluepill
04:21 PM rue_shop3: want a link?
04:22 PM nohit: nah im good
09:08 PM rue_shop3: ok, the adc timed serial receive is working
09:08 PM rue_shop3: I had the divider wrong for the adc clock
09:09 PM rue_shop3: so that leaves the timer free to do whatever evil bidding I wish of it
09:09 PM rue_shop3: so, how do I get it to manage 4 hobby servo pwm ports
10:03 PM rue_mohr: zippo:/files/programming/c/constdiv# ./a.out
10:03 PM rue_mohr: fractional number to multiply by? 0.588
10:03 PM rue_mohr: precision? for target 0.588000 8
10:03 PM rue_mohr: o = 0;
10:03 PM rue_mohr: i >>= 1; // Shift dividend right. Shift#1
10:03 PM rue_mohr: o += i; // Add dividend to accumulator (dividend /2.000000)
10:03 PM rue_mohr: i >>= 1; // Shift dividend right. Shift#2
10:03 PM rue_mohr: i >>= 1; // Shift dividend right. Shift#3
10:03 PM rue_mohr: i >>= 1; // Shift dividend right. Shift#4
10:03 PM rue_mohr: o += i; // Add dividend to accumulator (dividend /16.000000)
10:03 PM rue_mohr: i >>= 1; // Shift dividend right. Shift#5
10:03 PM rue_mohr: o += i; // Add dividend to accumulator (dividend /32.000000)
10:03 PM rue_mohr: Final error: 0.005750 would require 1/173.913043 th of dividend to be added to accumulator
10:28 PM Thrashbarg: neat
10:37 PM rue_mohr: its handy
10:37 PM rue_mohr: esp for servo stuff
10:38 PM Thrashbarg: yup
10:39 PM rue_mohr: tell me if you ever need a copy
10:39 PM Thrashbarg: k lol
10:46 PM rue_mohr: ok, if the timer interrupt clears all the output channels, and I set the bit I want to operate before I set loose the timer, it should work out well
10:47 PM rue_mohr: hmm
10:47 PM rue_mohr: if I put a change interrupt on the outputs
10:47 PM rue_mohr: I can use it to start the timer
10:50 PM rue_mohr: BUT that would suck because, either I have to play with enabling/disabling the pin change, or deal with the double interrupt when I set the output back low
11:15 PM day__ is now known as day