#avr | Logs for 2015-04-18

Back
[00:11:02] <ws004> hi frnds..
[00:11:13] <ws004> i need one help
[00:11:50] <ws004> i have to one small error for undefined function form_open() codeigniter
[06:43:18] <Lambda_Aurigae> ws004, the word is "friends"
[06:56:02] <vsync_> i wonder if he needs two helps instead of one help
[06:56:08] <vsync_> i damaeg braen
[07:01:03] <Lambda_Aurigae> form_open() sounds like something you might find in the acrobat reader source.
[07:01:32] <Lambda_Aurigae> his second help would require teaching him how to actually post the information one would need to help him.
[11:35:22] <benvei> Hey there. I'm currently trying to decode the signal from a RC receiver, i've measured it with my oscilloscope, the duty cycle is 10% in neutral, and 14% at "full". On the internet i didn't find any useable (documentated) example of how i can calculate the duty cycle with an avr, and trigger an event at 13% or something like that. Do you know some examples? I'm a beginner with AVRs. Thanks!
[11:47:58] <LeoNerd> I'd consider using the input capture pin on a timer
[11:49:39] <A124> I would use a filter.
[11:49:54] <benvei> LeoNerd: yeah, i think i have to use that, then set a trigger on the rising edge, and one on the falling edge, and then i have to calculate the time between them
[11:50:09] <benvei> but yeah, since i'm a beginner, i don't have any good point to start :/
[11:50:21] <A124> benvei Only duty cycle changes?
[11:50:34] <A124> You can probably only make a busy loop for the IO
[11:50:42] <A124> What freq it is?
[11:51:03] <benvei> it should be about 400Hz, give me a second, i'm going to get the sheet
[11:51:16] <A124> Slow enough to use interupt or a busy loop.
[11:51:51] <A124> Other way.. RC filter and measure ADC xD
[11:52:25] <benvei> A124: uh, sorry, it was 71,5Hz :D
[11:53:41] <A124> Which is 223k ticks. ticks at 16MHz or something like that
[11:54:15] <A124> You can as well set normal interrupt if that would be enough and measure the time with timer.
[11:55:16] <benvei> is there a overview what things like "ICNC1" mean?
[11:55:26] <A124> Datasheet has all.
[11:55:49] <benvei> ah ok, thanks
[11:56:07] <Lambda_Aurigae> benvei, from an RC receiver? You mean the output that would go to a servo?
[11:57:00] <benvei> Lambda_Aurigae: yes
[11:57:08] <Lambda_Aurigae> if it is a servo port output on an RC receiver, the pulses should be between 1ms and 2ms long.
[11:57:31] <Lambda_Aurigae> 1ms being full swing one way..2ms being full swing the other way.. 1.5ms should be servo centered.
[11:57:44] <Lambda_Aurigae> standard servo control.
[11:58:11] <A124> Thats 750HZ average :P
[11:58:37] <benvei> hmm ... maybe i should measure that again
[11:58:50] <Lambda_Aurigae> http://martinsant.net/?p=1078
[11:59:14] <Lambda_Aurigae> the pulses are not necessarily full speed...there could be longer pauses between them...often there are.
[11:59:31] <Lambda_Aurigae> I've driven servos with 60 pulses per second and even lower.
[11:59:37] <Lambda_Aurigae> depending on the application.
[11:59:49] <A124> I measured nano/microseconds. For.. ms things I just use timer and busy loop to detect edge.
[12:01:23] <Lambda_Aurigae> the higher the frequency of the pulses the more the servo tries to hold its position...
[12:01:54] <Lambda_Aurigae> you send a single pulse and the servo tries to go to the position that pulse signifies....send several and it will get there eventually if it starts a long way away.
[12:02:08] <Lambda_Aurigae> once there, if there is no back force you don't have to send more pulses....
[12:02:20] <Lambda_Aurigae> but,,,of course benvei appears to be going the other way, reading the pulse width.
[12:02:50] <Lambda_Aurigae> http://www.avrfreaks.net/forum/how-measure-pulse-width
[12:03:24] <benvei> Lambda_Aurigae: i'm going to check it again with the oscilloscope, thanks!
[12:03:29] <Lambda_Aurigae> welcome.
[12:03:52] <Lambda_Aurigae> not sure which google you were searching but there is all kinds of info on RC servo control and such stuff.
[12:04:23] <benvei> yeah, there is info about controlling a servo, but not about reading the signal
[12:04:25] <Lambda_Aurigae> https://www.servocity.com/html/how_do_servos_work_.html#.VTKKYOQ3VUE
[12:04:39] <Lambda_Aurigae> google search for decoding rc servo avr
[12:04:40] <Lambda_Aurigae> or
[12:04:48] <Lambda_Aurigae> search for measure pulse width avr
[12:05:10] <Lambda_Aurigae> that will be $2.96 for a lesson in how to use google please.
[12:05:48] <benvei> as i said, i'm a beginner, so i've looked for a well documentated code so that i can understand it
[12:05:59] <benvei> and yeah, kinda found one now, but yeah
[12:06:45] <Lambda_Aurigae> don't get stuck on servos...you are looking for measuring pulse width.
[12:08:28] <Lambda_Aurigae> servos just happen to be one use of pulses.
[12:08:41] <benvei> Lambda_Aurigae: you have been right, its 1.5ms centered, 2 at full, but only 1.25ms at "break". however, since its the channel for the gas servo, maybe its some "feature" from the transmitter
[12:08:52] <benvei> so yeah, i'm now trying to find something to decode that
[12:09:25] <Lambda_Aurigae> the 1, 1.5, 2 is average...different servos have different timings...
[12:09:51] <Lambda_Aurigae> heck, I've had 4 servos of the same brand from the same batch and they all needed trimming to match.
[12:11:30] <Lambda_Aurigae> http://www.nerdkits.com/forum/thread/2301/
[12:13:17] <benvei> yeah, so i kinda understand it now. When i'm using interrupts, i have to set TCCR1B to the rising edge, if that event happens, start the timer, and set TCCR1B to the falling edge, and stop the timer, am i right?
[12:14:49] <Lambda_Aurigae> should work.
[12:18:04] <benvei> hmm
[12:18:46] <benvei> Lambda_Aurigae: http://pastebin.com/raw.php?i=7zev7euj <-- i've got it so far. Sorry for the german comments. However, i need something now for an if event. How can i check if there is a rising edge on the input?
[12:21:10] <benvei> i need something like "if there is a rising edge, start the timer, set the trigger to falling edge, wait for the falling edge, stop the timer, export the time"
[12:21:23] <benvei> but i don't know how to "if there is a rising edge" :/
[12:36:07] <Lambda_Aurigae> should be able to set triggers on timer for rising and/or falling edge.
[13:56:49] <litb> hello all. I've got an arduino Uno R3
[13:57:52] <litb> and i wanna run DuinOS on it
[13:59:41] <Lambda_Aurigae> that's nice.
[13:59:49] <Lambda_Aurigae> you should probably ask in the arduino channel.
[14:04:25] <benvei> Lambda_Aurigae: i tried to write a code for detecting the rising / falling edge now, i also attatched an LCD so i can see if the values are right
[14:04:40] <benvei> the only problem is, i'm getting random numbers on the LCD, no metter how i configure the function generator :(
[14:04:47] <benvei> could you have a look at that code? http://pastebin.com/Xuvs2mUn
[14:06:41] <Lambda_Aurigae> not sure on your logic there.
[14:07:19] <benvei> what do you mean exactly?
[14:07:21] <Lambda_Aurigae> I would watch for a rising edge on the line in code then when it went high turn on the timer and wait for a falling edge trigger the interrupt and stop the timer.
[14:07:30] <Lambda_Aurigae> but, I'm kinda brain fried at the moment.
[14:08:02] <benvei> i think thats what i did? i'm triggering on rising edge, if the pin is high, start the timer, if the pin goes low, stop the timer
[14:08:16] <benvei> but i'm not sure if it is right, and since it doesn't work, it CAN'T be right. :D
[14:08:31] <Lambda_Aurigae> if you trigger on rising edge, the pin is always going to be high.
[14:08:46] <benvei> why?
[14:08:49] <Lambda_Aurigae> rising..
[14:08:52] <Lambda_Aurigae> going from low to high.
[14:09:09] <Lambda_Aurigae> trigger on rising, read the pin, it is going to be high.
[14:09:26] <Lambda_Aurigae> you need two triggers.
[14:09:32] <Lambda_Aurigae> one rising edge, one falling edge.
[14:09:39] <benvei> and how can i seperate them?
[14:10:18] <Lambda_Aurigae> well, you could use two external interrupt pins.
[14:10:31] <Lambda_Aurigae> one set to trigger on rising, one set to trigger on falling.
[14:10:44] <Lambda_Aurigae> rising trigger resets and starts timer.
[14:10:51] <Lambda_Aurigae> falling edge stops and reads timer.
[14:11:33] <Lambda_Aurigae> just tie int0 and int1 together and feed your input to that.
[14:11:38] <Lambda_Aurigae> that's the simplest way I would think.
[14:12:24] <Lambda_Aurigae> I suspect there is a way to do it with the timer itself but can't think of how right off the top of my head..would have to look it up.
[14:21:00] <benvei> hmmm
[14:21:32] <benvei> i could set it to trigger on high, and disable the pullup, if the pin goes high, i could set it to trigger on low, and if it goes low, stop the timer
[14:21:34] <benvei> could that work?
[14:21:51] <Lambda_Aurigae> uhh...possibly.
[14:22:14] <Lambda_Aurigae> rue_house, would be a better one on this I think..
[14:22:27] <Lambda_Aurigae> aaand, I kinda gotta run.
[14:22:34] <Lambda_Aurigae> keep poking at it.
[15:35:36] <litb> can I ask questions about avr-libc here?
[15:35:49] <litb> Lambda_Aurigae, i only bought it to interface witht he AVR chip
[15:36:45] <litb> I don't know where the manual for the avr-libc is. in particular I wanted to search for the DDRB macro definition but on http://www.nongnu.org/avr-libc/user-manual/modules.html I can't find it
[15:39:14] <litb> ah silly, that seems to be a register