tag:blogger.com,1999:blog-8200098102909041178.post4022706498477728048..comments2024-03-24T09:12:10.872-04:00Comments on Shane Colton: Arduino Interrupt-Driven Servo RoutineShane Coltonhttp://www.blogger.com/profile/10603406287033587039noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-8200098102909041178.post-4843754257502205212016-05-06T07:15:13.741-04:002016-05-06T07:15:13.741-04:00Shane,
I'd like to hire you for an Arduino ser...Shane,<br />I'd like to hire you for an Arduino servo control project. You have some availability in the next week or so? Please contact me at jimbeckham@zeroreels.com. <br />I look forward to hearing back from you.<br />Jim BeckhamAnonymoushttps://www.blogger.com/profile/15753168370573866883noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-22786685952041048902016-02-29T08:28:50.626-05:002016-02-29T08:28:50.626-05:00Hey Shane, i cant download your code anymore, wich...Hey Shane, i cant download your code anymore, wich im verry interested in for a school project.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-33196646067168499322014-10-22T17:40:30.200-04:002014-10-22T17:40:30.200-04:00Please share Jatra's 333Hz code, I am interest...Please share Jatra's 333Hz code, I am interested in running a single RC servo at precisely this frequency.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-56313887126485479752013-11-10T23:33:58.244-05:002013-11-10T23:33:58.244-05:00I used the multiplex concept in your code to imple...I used the multiplex concept in your code to implement servos on ATTiny84:<br /><br />http://forum.arduino.cc/index.php?topic=198337.0Corwinhttps://www.blogger.com/profile/07793805953962451254noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-76457932881034113542012-03-11T00:27:12.654-05:002012-03-11T00:27:12.654-05:00The other thing that just now hit me too is that u...The other thing that just now hit me too is that using your code, I have no control over the speed in which the servo is moving from one position to the next. At least, I can't figure out how to do that. However, if I can't get it to do a full 180 degrees sweep, it becomes a moot point as I would have to go back to the standard Servo library.KirAsh4https://www.blogger.com/profile/10153436297616657178noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-25597769135845058132012-03-11T00:25:34.023-05:002012-03-11T00:25:34.023-05:00It's not the Servo.read() that's doing the...It's not the Servo.read() that's doing the blocking. It's the Ethernet process itself. Between it processing the request from the browser and sending back the data, it causes enough of a delay to disturb the servo's movement.KirAsh4https://www.blogger.com/profile/10153436297616657178noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-11685061891647026432012-03-11T00:24:59.710-05:002012-03-11T00:24:59.710-05:00This comment has been removed by the author.KirAsh4https://www.blogger.com/profile/10153436297616657178noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-44983304498724011982012-03-10T22:38:06.127-05:002012-03-10T22:38:06.127-05:00I can't see how servo.read() could halt the se...I can't see how servo.read() could halt the servo interrupt running in the background, although I admit I don't know exactly what the function does. I'm more suspicious of the other Ethernet shield functions. Have you done any tests isolate the two and see which is causing the delay?<br /><br />This code isn't set up to go to 2400us. You'd have to modify the timer to reset with a different period by changing the Timer 1 setup registers.Shane Coltonhttps://www.blogger.com/profile/10603406287033587039noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-79296323960611953732012-03-09T23:16:12.016-05:002012-03-09T23:16:12.016-05:00Hey Shane, I wonder if you can give me some advice...Hey Shane, I wonder if you can give me some advice here. I am using the standard Servo library that comes with the Arduino IDE to sweep two servos from 0 to 180 degrees. At the same time, by using an Ethernet shield, I can send a query from a browser that then tells me what the angle of the servo is at the time that request came in (through servo.read() ). The problem is, this request, process, and subsequent response, blocks the servo sweep for a very brief moment. Doing successive requests causes the servo to become jittery. I need to somehow get a response back to the browser without interrupting the servo.<br /><br />Someone then suggested using an interrupt based solution but seeing as how the Servo library already does this, I went looking for a different solutions, implemented differently, and came across your code. I compiled it, uploaded and I can have my servos sweep back and forth from servopwm(250) to servopwm(500). However, I noticed this isn't a full 180 degrees sweep, but a 90 degrees sweep.<br /><br />So my first question is, how can I change this to a full 180 degrees sweep? The servo documentation says it can if you feed it a pulse ranging from 600usec (0 degrees) to 2400usec (180 degrees).<br /><br />Second, how can I go about getting an angle reading from a servo, very much like servo.read() does it (which in and by itself isn't ideal because the servo would have to have moved first since it simply returns whatever the last instruction was that was sent to the servo, but hey, it's better than nothing.)<br /><br />Any suggestions?KirAsh4https://www.blogger.com/profile/10153436297616657178noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-16138161438920192682012-02-19T21:21:00.929-05:002012-02-19T21:21:00.929-05:00Got it, thanks! Also, that Frankensegway is awesom...Got it, thanks! Also, that Frankensegway is awesome! I love the tail rotor for steering.<br /><br />I don't think the satellite receiver would be much lighter than the XBee, do you? Also the XBee is nice because I get two-way data with it.Shane Coltonhttps://www.blogger.com/profile/10603406287033587039noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-71987579601086844682012-02-15T01:42:07.538-05:002012-02-15T01:42:07.538-05:00OK, I'll send it to the email on your Resumé. ...OK, I'll send it to the email on your Resumé. I don't know how to otherwise. You can post it here for anyone else who is interesed if you like.<br /><br />Its still a work in progress and could easily ported to other Ports as well. Tell me what you think and if I have any major no-no's. Programing is only a hobby for me, not an occupation.<br /><br />I can see that a 1kHz refresh would be much better than 333Hz.<br /><br />Ja, I'm building a balancing robot. I guess everyone has to sometime... I thought it would be an excellent learning platform where I am completely dependent on the controller for stability, but still close to the ground so that it does't hurt that much when it Falls. Once thats done I will let myself graduate to flying things.<br /><br />By the way have you seen the Frankenstein of balancing robots... <br />http://www.youtube.com/watch?v=mWDFp1-twNU&list=UUgdOnrr1VzRW_AxUoZPbDnQ&index=14&feature=plcp<br /><br />I'm not building one like that though, just a "normal" one with a couple of twists.<br /><br />One thing I'm using though that might be interesting for you if you want to save some weight on your 4PCB is a DSM2 Orange RX100 Satelite reciever 11$ connected directly to the RX pin of the arduino, with code adapted from the ArduNXT project. (Binding beforhand with a normal RX610)Jatrahttps://www.blogger.com/profile/08832300594069072809noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-12123448837685814912012-02-13T09:24:33.312-05:002012-02-13T09:24:33.312-05:00That sounds great - I would definitely like to see...That sounds great - I would definitely like to see it.<br /><br />The PCB quad uses a brushless motor control chip with 0-5V analog input for speed, which is nice. I set the timers to run a 62.5kHz PWM and filter it at about 1kHz bandwidth. Very nice option for a small quadrotor.<br /><br />What are you using the IMU filter for? (A balancing robot?)Shane Coltonhttps://www.blogger.com/profile/10603406287033587039noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-23997701417745351002012-02-12T13:35:04.981-05:002012-02-12T13:35:04.981-05:00This Post is a bit old, but I also waned to thank ...This Post is a bit old, but I also waned to thank you for the idea. I ended up going a bit of a different way though. I took the Arduno interupt driven servo library and the Software servo library and made a hybrid simultaneous interupt driven servo library out of them. Result, a digital servo/esc capable simultaneous servo library. At the moment only on PortB, so 6 Servos sumultaneously (up to 333Hz possible) I only use it at 200Hz though.<br /><br />Theory: Sorts all the PPMs in ascending order, shift the non simultaneous and following ones by 25micro seconds. Uses Timer 1.<br /><br />Just thought something like this would improve your print Quad dynamic response.<br /><br />I also wanted to thank you for your simplified balancing robot IMU filter, allows me to run my Pro-mini at 200Hz loop speed. Still a work in progress though.<br /><br />If you are interesed in the library let me know on this post.<br /><br />Regards.<br />JasonAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-69523685252755729692011-02-18T15:29:05.665-05:002011-02-18T15:29:05.665-05:00That is a great idea. It could also let you contro...That is a great idea. It could also let you control a large number of servos (basically every digital pin could be a servo). And it still doesn't interfere with any of the other timers.<br /><br />Thanks!Shane Coltonhttps://www.blogger.com/profile/10603406287033587039noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-69830214794168841392011-02-18T09:45:05.708-05:002011-02-18T09:45:05.708-05:00Just wanted to thank you so much for the idea (and...Just wanted to thank you so much for the idea (and implementation). I've been looking for something like this for a while now (for Quadcopter). Anyways, I think I found a way to make the update rate (period) faster and thought I should also contribute (based on your idea). The period of the PWM signals are directly proportional to the number of servos. It is possible, however, to decrease these periods by 1/2 by using OCR1B as well (not only OCR1A) in the following way. Use OCR1A to control half the servos of the array, while the other half is controlled by OCR1B. <br /><br />I am getting 4ms period for 4 servos using this new method (useful for faster ESC update rates).<br /><br />For 8 servos, in your example above, this implementation would yield 8 ms period (instead of 16 ms).<br /><br />Please let me know if you want the full arduino code. I'd be happy to share it. <br /><br />Sincerely,<br />Alex<br />aamartir@gmail.comAlex Martirhttps://www.blogger.com/profile/12720113382733750994noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-66373833191230302582010-11-01T08:47:01.814-04:002010-11-01T08:47:01.814-04:00What ESC do you use? I'm on the lookout for qu...What ESC do you use? I'm on the lookout for quick-reacting ESCs for quadrotors. Anything <10ms would probably be good. And small (~10A).Shane Coltonhttps://www.blogger.com/profile/10603406287033587039noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-17742461689457471022010-10-28T01:15:14.980-04:002010-10-28T01:15:14.980-04:00A quick thanks and response:
I get that the newer ...A quick thanks and response:<br />I get that the newer arduino servo libs use Timer1 and so they don't "SUCK" but in my particular case... To control a single ESC should tie up approx 2ms-3ms of processor time using your method... I've implemented it in singleton fashion (forget arrays) and used it convert either hall or 0-5v throttles to RC ESC with great success, efficiency and since my particular ESC reacts with as little as 6ms of OFF time it means my refresh rate is as fast as 8ms even at WOT. By timing my A2D sampling right, I estimate total analog action->ppm reaction time to be on the figure of 6-10ms maximum. Thanks again!<br />Thanks!mkeeferhttps://www.blogger.com/profile/11322537491459792671noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-40198175646116455532010-09-03T23:05:23.329-04:002010-09-03T23:05:23.329-04:00As a quick update: In going through the most up-to...As a quick update: In going through the most up-to-date Arduino servo library (servo.h) it does in fact use interrupts on Timer 1 to generate the servo values. Only the old "software servo library" uses the less efficient method. The new version also has the pin 9/10 PWM conflict.<br /><br />So, Arduino did eventually make a servo library that doesn't suck. I just wish more people understood why. ;)Shane Coltonhttps://www.blogger.com/profile/10603406287033587039noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-44886285962507908632010-09-02T13:36:21.722-04:002010-09-02T13:36:21.722-04:00Sending pulses faster than 20ms is definitely poss...Sending pulses faster than 20ms is definitely possible with this interrupt setup, especially if you only want to control a single ESC. As written, the time between pulses depends on the number of servos multiplexed onto the timer, just over 2ms per channel. So if you use only 5-6 channels, the period would be 10-12ms. If you only need one channel, you can use "dummy" channels that don't actually go to a pin to make the gap whatever you want.<br /><br />Either way you dedicate Timer 1 (and only Timer 1) to running servo pulses, which means it won't be able to use analogWrite() on pins 9 or 10. The other PWMs are on Timer 0 and Timer 2, so they would still work fine. If you want to keep all six PWMs operational and control servo pulses, delay() and delayMicroseconds() might be the better option. This method ties up the processor for the duration of the pulse, but for only a single 1-2ms pulse every 10ms, that's not bad.<br /><br />I don't have the capital to produce and sell boards, but I do provide the EAGLE and Gerber files so that anyone can get them printed. I would be more than happy if somebody (or some site like Sparkfun) wanted to take on board production and sell them at a reasonable cost. I just can't do it myself. I also can't provide support for them beyond the initial documentation: It's sort-of build at your own risk. :)Shane Coltonhttps://www.blogger.com/profile/10603406287033587039noreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-10909242653483699102010-08-30T07:02:53.460-04:002010-08-30T07:02:53.460-04:00Just curious - if I wanted to just output or contr...Just curious - if I wanted to just output or control an ESC which I have just discovered accepts as low as 11ms low between pulses as opposed to the 20ms - could I create this effect with the use of a single timer to allow arduino pwm timer to continue?<br /><br />The idea is I need to provide throttle control as fast as possible to prevent over current conditions and thus FET damage in high end RC controllers - I've measured current transient detection time and have it down to 3ms with a dedicated comparator - the normal ppm would require between 21ms and 22ms per pulse, since servos are forgiving I thought I'd check how low I could set the constant for low pulse and it's near half - would this not in effect translate to nearly twice as fast reaction (since they won't support I2C bus control)?<br /><br />Nice stuff btw - and love the BLDC bridge solution - do you ever consider offering your PCBs for shields and other things for the general public - there would be a market for it and it could help fund your research and development?mwkeeferhttp://www.endless-sphere.com/forumsnoreply@blogger.comtag:blogger.com,1999:blog-8200098102909041178.post-67190520460577512352010-07-29T01:48:56.144-04:002010-07-29T01:48:56.144-04:00what do those numbers mean?what do those numbers mean?ChArLeShttp://www.etotheipiplusone.netnoreply@blogger.com