#avr | Logs for 2015-07-07

Back
[01:04:11] <stevejobsinhell> what pwm functions lets me set the width of the pulse in nano seconds? How do I set the size of the period?
[01:07:06] <Casper> what do you mean in nano seconds?
[01:07:29] <stevejobsinhell> in other words, not as a percentage.
[01:07:54] <Casper> none?
[01:08:37] <Casper> the frequency is fixed, and the width is x/TOP
[01:08:55] <stevejobsinhell> my servos expect a pulse every 20ms. or 20000000 nano seconds. does avr assume this?
[01:09:23] <stevejobsinhell> what's the fixed period ?
[01:09:45] <Casper> you then set the PWM frequency so it match 50Hz
[01:09:58] <Casper> then set the pulse so you get your 1-2ms on time
[01:11:28] <stevejobsinhell> is 50Hz = 20ms?
[01:11:37] <Casper> yes
[01:11:44] <stevejobsinhell> I thought a Hert was 1 second.
[01:11:47] <Casper> 1/50 of a second is 20ms
[01:11:55] <Casper> hertz is the number of cycle in 1 second
[01:13:10] <Casper> you might want/need to use the 16 bits timer
[01:13:15] <stevejobsinhell> thanx
[01:14:21] <stevejobsinhell> what do you mean by --> then set the pulse so you get your 1-2ms on time
[01:14:59] <Casper> to make it simple, I'll use round numbers...
[01:16:03] <Casper> first, you make the timer so it "reset" 50 times a second. To do so, you take the frequency of the µC and divide it by the max value of the timer
[01:16:27] <Casper> ex: 16000000/65536 (16 bits), that give you the divider to use
[01:16:47] <Casper> now your timer reset 50 times a second
[01:17:06] <stevejobsinhell> hence the 50Hz
[01:17:14] <Casper> now, 0 = 0ms and 65536 = 20ms
[01:17:39] <Casper> so you just set the PWM max to whatever you need it so it output the right pulse width
[01:17:54] <Casper> in practice, it get more complex
[01:18:07] <Casper> there is only some divider avail, not random...
[01:18:29] <Casper> so you need to set the max value, so the timer won't run up to 65536, but whatever it need to so it give 20ms...
[01:18:51] <Casper> those servo are a bit annoying to use
[01:20:25] <stevejobsinhell> should I use the commands/registers mentioned in https://www.newbiehack.com/MicrocontrollerControlAHobbyServo.aspx ?
[01:20:37] <stevejobsinhell> or http://extremeelectronics.co.in/avr-tutorials/servo-motor-control-by-using-avr-atmega32-microcontroller/
[01:22:30] <Casper> been a while since I coded in avr, so can't say for sure
[01:22:47] <Casper> I was supposed to make a garden light for this spring...
[01:23:02] <Casper> ... look like it will be next one
[02:43:12] <osteri> stevejobsinhell: those 20 ms base pulse servos are not truly PWM, because the frecuency varies. they are pain in the ass :/
[02:44:10] <osteri> they are usually 20 ms + (1300 us - 1700 us)
[02:44:38] <osteri> why they can't just do pure PWM?
[02:45:58] <osteri> this is one thing i don't understand in servo controllers
[03:05:58] <Mr_Sheesh> because they started off as analog and we stay backwards compatible with all past mistakes
[03:45:48] <osteri> that would explain it
[04:57:01] <Mr_Sheesh> Are folks in here staying with the AVRISP mkII or migrating to the Dragon? My AVRISP mkII is missing temporarily (moving in yet, I know which stack of boxes it is in I think) and that got me thinking on the "Is it time to get a Dragon?" topic. Also about organizing more LOL
[04:59:18] <twnqx> i've read multiple times that the dragon is pretty susceptible to damage
[04:59:30] <twnqx> ESD and the like
[04:59:46] <twnqx> if i wanted real stuff i'd get a jtagice mk3
[05:27:20] <Mr_Sheesh> I've thought of that; Just a tight budget atm
[05:35:13] <twnqx> then i'd go for a cheap avr isp and save up
[05:45:55] <Mr_Sheesh> Hmm, jtagice3 has come way down in price tho; $53ish on Mouser
[05:46:06] <Mr_Sheesh> Worth looking I thought, and Hmmmm.
[05:46:19] <Mr_Sheesh> Get that, sell the avrisp, maybe.
[05:46:24] <Mr_Sheesh> TY for the ideas :)
[05:58:59] <kdehl> So I run an AVR µC at 20 MHz, I have an external SRAM with an access time of 55 ns. If I understand it correctly, all instructions on an AVR takes one clock cycle, which means 50 ns. Is it enough, after you've put an address on the pins to the memory to only wait one instruction, or should I wait two before I read the data?
[06:00:04] <kdehl> Isn't there any delay after putting the address on the pins or before data is actually read when I read data on the data bus that could take about 5 ns or so?
[06:01:29] <kdehl> I've tested it, and it does work, but it feels somehwat unstable. On the other hand, it feels like such a waste to wait two instructions when I shouldn't have to wait more than one.
[06:01:46] <kdehl> (Not waiting at all does not work.)
[06:14:25] <kdehl> Never mind. The instruction I tested was two cycles (100 ns). An instruction that only takes one cycle (= 50 ns) wasn't enough.
[06:15:33] <Mr_Sheesh> 1 wait state should be pretty safe
[06:17:35] <kdehl> What's a "wait state"?
[06:23:14] <kdehl> Oh.
[06:23:26] <kdehl> Well, yes. But question was how long it had to be.
[06:24:57] <twnqx> kdehl: external memory access requires at least two clock cycles
[06:25:22] <twnqx> or do you access it from code?
[06:25:46] <twnqx> and not an avr with external memory interface
[06:28:36] <kdehl> Yeah, code.
[06:28:51] <LeoNerd> Woo.. fiiiiinally, my hotair station arrives
[06:29:13] <kdehl> Well, two nops, that is 100 ns seems to be working anyway.
[06:43:45] <Mr_Sheesh> OK, 2. Yeah just using the term as most know what it means from old PCs :)
[07:15:40] <JanC> or clock down a bit and you probably only need 1 wait state... ;)
[10:56:25] <szwetsloot> Hey guys
[10:56:38] <szwetsloot> Does one of you know how to set an atmega2560 to 16Mhz internally?
[10:56:58] <szwetsloot> I tried using the calculator here: http://www.engbedded.com/fusecalc/ but it sets to 8MhZ
[11:04:27] <szwetsloot> anyone?
[12:19:41] <megal0maniac> Gosh. Don't people know how IRC works? Timezones and people having lives and stuff...
[12:19:49] <megal0maniac> OndraSter|off: How's it going?
[12:24:05] <Tom_itx> no you don't you got nothing better to do than sit here and answer anything that comes across here!
[12:25:09] <Tom_itx> i don't think you can do it anyway. pretty sure it defaults to 8Mhz with ckdiv unset
[12:44:26] <Lambda_Aurigae> I thought it set to 8mhz with ckdiv set, making it run at 1mhz
[12:44:40] <Lambda_Aurigae> and to get 16mhz you gotta have an external clock or crystal or such.
[12:45:07] <Tom_itx> i'm pretty sure that's how it is
[12:45:13] <Tom_itx> without looking
[12:47:38] <Lambda_Aurigae> that's how all the other AVR chips I have worked.
[14:25:45] <Jartza> ouch
[14:25:59] <Jartza> I have problem with avr asm, something I just don't grasp :)
[14:26:45] <Jartza> when mixing C and asm (in separate files), I know how to access variables themselves
[14:27:10] <LeoNerd> Ah, separate files? Tricky - I usually just do individual __asm__-based functions
[14:27:11] <Jartza> but if I have global array in C file, how can I get the address of that array into Z register?
[14:40:40] <Jartza> let's say the array is called "line" in my C file. I define it as ".extern line" in asm.
[14:40:45] <Jartza> then tried the following:
[14:41:12] <Jartza> ldi ZL, lo8(line)
[14:41:12] <Jartza> ldi ZH, hi8(line)
[14:41:25] <Jartza> ld r16, Z
[14:41:40] <Jartza> but the data now in r16 is not the first element in "line" array
[14:51:58] <Jartza> oh. or maybe it is.
[14:52:10] <Jartza> I might have misunderstood the ldd r16, Z+