[En-Nut-Discussion] PWM

Nic Cave-Lynch nic at tymar.com
Mon Aug 7 23:22:46 CEST 2006


So: 50Hz, 1-2ms == 0-180 degrees. 5 microseconds resolution, 10 servos. Only 
tolerance allowed is in the frequency, not the 1-2 ms pulse width. As they say 
here, I think you're pushing !@#$ up hill with a sharp stick.

The only way I can think to do it is to have one of the timers which gives your 
pulse timing, and in its interrupt routine set the pin for the current servo 
output, then set up the same timer for the next servo's pulse. I'd probably take 
the output of the timer to one of the hardware interrupts so it gets highest 
priority. You could, with some tweaking, get accurate and repeatable pulse 
widths, but it'd be hard work.

Alternatively, a nice little FPGA with counters in that you write the servo 
pulse values to. Easy (if you know how), repeatable, deterministic

Nic

Raul Valle wrote:
> for the moment i am simply sending a pwm code to rc standard servos for 
> a car
> 
> ----- Original Message ----- From: <en-nut-discussion-request at egnite.de>
> To: <en-nut-discussion at egnite.de>
> Sent: Monday, August 07, 2006 3:16 AM
> Subject: En-Nut-Discussion Digest, Vol 34, Issue 7
> 
> 
>> Send En-Nut-Discussion mailing list submissions to
>> en-nut-discussion at egnite.de
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>> or, via email, send a message with subject or body 'help' to
>> en-nut-discussion-request at egnite.de
>>
>> You can reach the person managing the list at
>> en-nut-discussion-owner at egnite.de
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of En-Nut-Discussion digest..."
>>
>>
>> Today's Topics:
>>
>>   1. RE:PWM (Raul Valle)
>>   2. RE: PWM (Raul Valle)
>>   3. Re: RE: PWM (Nic Cave-Lynch)
>>   4. Re: PWM (Curtis Maloney)
>>   5. PPP Sample (Andrey G. Polenov)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Sun, 6 Aug 2006 12:06:15 -0700
>> From: "Raul Valle" <rvl180 at hotmail.com>
>> Subject: [En-Nut-Discussion] RE:PWM
>> To: <en-nut-discussion at egnite.de>, <Michael.e.Jones at web.de>
>> Message-ID: <BAY21-DAV738186F0975065777910B9E560 at phx.gbl>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> Michaels thanks for the help.
>>
>> The thing is i have to control around 8 to 10 servos which are for 
>> controlling
>> a robotic arm for a rover  and to control a camera. The servos are 
>> going to be control by a software that is going to send some 
>> characters and with those i will give an order to the servos. I was 
>> reading about the Nutsleep and you are right , that why i am switching 
>> better to NutDelay and is making the delay but, i think that with a 
>> delay of 2us i should not be noticing because it should be very fast, 
>> but it seems the delay is longer because for now , testing i send from 
>> the ethernut a word , then i make the delay and then send another 
>> word  and it seems the delay is longer than 2us.   I am not using the 
>> pwm channel because there are so many servos that i have to come up 
>> with something else fast enough that all the servos seem to be working 
>> i guess at the same time.
>>
>> any help is going to be appreciated it.Thanks
>>
>>
>> ...........................................................
>> Message: 6
>> Date: Thu, 3 Aug 2006 14:15:52 -0700
>> From: "Raul Valle" <rvl180 at hotmail.com>
>> Subject: [En-Nut-Discussion] ethernut--pwm
>> To: <en-nut-discussion at egnite.de>
>> Message-ID: <BAY21-DAV4A18599B9490158CA459D9E530 at phx.gbl>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> hi to all:
>> can someone give me an idea on how to make a servo function on 
>> ethernut1.3 .
>> The one i did i dont know exactly why is not working . here is the code:
>> pos++;
>>       sbi(PORTE,2);
>>       for(i=0;i<pos;i++){
>>        NutSleep(.02);
>>       }
>>
>>       cbi(PORTE,2);
>>       for(b=0;i<(1500-pos);b++){
>>        NutSleep(.02);
>>
>> ------------------------------
>>
>> Message: 7
>> Date: Thu, 3 Aug 2006 23:38:14 +0200
>> From: "Michael Jones" <Michael.e.Jones at web.de>
>> Subject: RE: [En-Nut-Discussion] ethernut--pwm
>> To: "'Ethernut User Chat (English)'" <en-nut-discussion at egnite.de>
>> Message-ID: <008501c6b745$2081ed10$de10a8c0 at LSB.lan>
>> Content-Type: text/plain; charset="us-ascii"
>>
>>
>> Hi,
>>
>> I think you have got a few problems to solve here. The first being that
>> NutSleep(...) does not take a float (well not that I am aware off) so 
>> that
>> 02 turns into 0. The second being that you can't use NutSleep(...) to
>> generate deterministic time slices as NutSleep(...) will pass control to
>> another thread and will only return when that thread (and/or others) 
>> yields
>> CPU time back to your thread by itself calling NutSleep(...) or similar
>> functions.
>>
>> What exactly are you trying to implement?
>>
>> Depending on the actually method you are using to control the servo there
>> are different solutions. Are you using an ADC? Then you might want to 
>> use an
>> ADC completion interrupt handler which then decides if and which 
>> direction
>> the motor is supposed to run.
>>
>> Regards,
>> Michael
>>
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Sun, 6 Aug 2006 12:47:56 -0700
>> From: "Raul Valle" <rvl180 at hotmail.com>
>> Subject: [En-Nut-Discussion] RE: PWM
>> To: <en-nut-discussion at egnite.de>, <cmaloney at cardgate.net>
>> Message-ID: <BAY21-DAV229AF924A160E855B27579E560 at phx.gbl>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> Curtis thanks for  the reply:
>>
>> The thing is the channels available are not enough, there are more 
>> servos to control......they are going to be controlled by a command 
>> sent to them from the computer .... any idea in how to achieve to 
>> control all the servos not affecting program please let me know... I 
>> appriciate the help./
>>
>> ---------------------------------------------------
>> Raul Valle wrote:
>>> hi to all:
>>> can someone give me an idea on how to make a servo function on 
>>> ethernut1.3 .
>>> The one i did i dont know exactly why is not working . here is the code:
>>> pos++;
>>>        sbi(PORTE,2);
>>>        for(i=0;i<pos;i++){
>>>         NutSleep(.02);
>>>        }
>>>
>>>        cbi(PORTE,2);
>>>        for(b=0;i<(1500-pos);b++){
>>>         NutSleep(.02);
>>
>> Is there a particular reason you're avoiding using the hardware PWM? 
>> They'd be
>> much simpler, more accurate, and would take no CPU time once set up.
>>
>> Of course, if they're all already in use, or you have to use a pin 
>> they can't
>> control, I'll understand.
>>
>> -- 
>> Curtis Maloney
>> cmaloney at cardgate.net
>>
>>
>>
>> ------------------------------
>>
>> Message: 3
>> Date: Mon, 07 Aug 2006 08:44:06 +1200
>> From: Nic Cave-Lynch <nic at tymar.com>
>> Subject: Re: [En-Nut-Discussion] RE: PWM
>> To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
>> Message-ID: <44D65496.6040201 at tymar.com>
>> Content-Type: text/plain; format=flowed; charset=ISO-8859-1
>>
>> What pulse width resolution do you need, and what frequency? Are you 
>> doing all
>> the PID stuff in the Ethernut, or just sending a pwm code to something 
>> like
>> standard RC servos used in model cars/planes/yachts/...?
>>
>> Raul Valle wrote:
>>> Curtis thanks for  the reply:
>>>
>>> The thing is the channels available are not enough, there are more 
>>> servos to control......they are going to be controlled by a command 
>>> sent to them from the computer .... any idea in how to achieve to 
>>> control all the servos not affecting program please let me know... I 
>>> appriciate the help./
>>>
>>> ---------------------------------------------------
>>> Raul Valle wrote:
>>>> hi to all:
>>>> can someone give me an idea on how to make a servo function on 
>>>> ethernut1.3 .
>>>> The one i did i dont know exactly why is not working . here is the 
>>>> code:
>>>> pos++;
>>>>        sbi(PORTE,2);
>>>>        for(i=0;i<pos;i++){
>>>>         NutSleep(.02);
>>>>        }
>>>>
>>>>        cbi(PORTE,2);
>>>>        for(b=0;i<(1500-pos);b++){
>>>>         NutSleep(.02);
>>>
>>> Is there a particular reason you're avoiding using the hardware PWM? 
>>> They'd be
>>> much simpler, more accurate, and would take no CPU time once set up.
>>>
>>> Of course, if they're all already in use, or you have to use a pin 
>>> they can't
>>> control, I'll understand.
>>>
>>> -- 
>>> Curtis Maloney
>>> cmaloney at cardgate.net
>>>
>>> _______________________________________________
>>> En-Nut-Discussion mailing list
>>> En-Nut-Discussion at egnite.de
>>> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>>>
>>
>>
>> ------------------------------
>>
>> Message: 4
>> Date: Mon, 07 Aug 2006 10:12:33 +1000
>> From: Curtis Maloney <cmaloney at cardgate.net>
>> Subject: [En-Nut-Discussion] Re: PWM
>> To: Raul Valle <rvl180 at hotmail.com>
>> Cc: en-nut-discussion at egnite.de
>> Message-ID: <44D68571.2070602 at cardgate.net>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> Raul Valle wrote:
>>> Curtis thanks for  the reply:
>>>
>>> The thing is the channels available are not enough, there are more 
>>> servos to control......they are going to be controlled by a command 
>>> sent to them from the computer .... any idea in how to achieve to 
>>> control all the servos not affecting program please let me know... I 
>>> appriciate the help./
>>>
>>
>> All I can suggest is you look at the PWM series of AVRs (listed as 
>> "Lighting"
>> AVRs on the web site).  According to the site, the AT90PWM3 has 
>> 10-channel
>> "advanced" PWM, though I haven't looked closely at what that entails.
>>
>> -- 
>> Curtis Maloney
>> cmaloney at cardgate.net
>>
>>
>> ------------------------------
>>
>> Message: 5
>> Date: Mon, 07 Aug 2006 09:24:48 +0600
>> From: "Andrey G. Polenov" <apolenov at adc.kz>
>> Subject: [En-Nut-Discussion] PPP Sample
>> To: "Ethernut User Chat (English)" <en-nut-discussion at egnite.de>
>> Message-ID: <44D6B27F.30403 at adc.kz>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> Good afternoon!
>> At me connection in ppp.c (example) is not connect my provider
>> I use Ethernut 2 and ethernut-4.1.9-rc7
>> P.S. In ethernut-4.0.3 at me problems were not
>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> En-Nut-Discussion mailing list
>> En-Nut-Discussion at egnite.de
>> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>>
>>
>> End of En-Nut-Discussion Digest, Vol 34, Issue 7
>> ************************************************
>>
> 
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
> 



More information about the En-Nut-Discussion mailing list