Re: Period Wave Modulation

arvid <[email protected]> Fri, 4 Feb 2005 14:13:08 +0100
Newsgroups gmane.linux.real-time.rtlinux.general
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi all,

i've done exactly what wayne suggests a few ago. i wrote someo code to 
output 12 pwm signals at the parallel port to drive r/c servo motors in 
parallel at about 100hz.
my approach sorted the duty cycles by time and set bit masks for every 
time mark; the periodic thread then just applied the bit masks at the 
right time, using a method similar to wayne's.

it worked okay, but on the board i used back then (it was a 5x86 amd 
cpu at 100-something mhz) the jitter was much too high. hardware 
interrupts (such as network traffic) resulted in small servo 
instabillies.

i'd post the code here, but i'm afraid it has gone the way all code 
goes without backups.
sorry about that.

hope to have hepled,
arvid



On 03.02.2005, at 06:49, Wayne E. Van Loon Sr. wrote:

>
>
> Jesse Vogt wrote:
>> Hello,
>> I am using RTLinux and a CIO-DIO48H digital I/O board to control
>> several servo motors. I need to create a 10 kHz  wave with a variable
>> duty cycle.  I am able to generate a solid 10 kHz wave using periodic
>> thread but that only allows a 50% duty cycle.  Any ideas?
>
> Change the periodic rate every interrupt.
>
> If your rtl application always needs to be able to respond to other 
> events such as hardware interrupts, then I would do something like the 
> following:
>
> ghrtime = gethrtime();
>
> (calculate next_transition_time)
>
> pthread_make_periodic_np( pthread_self(), ghrtime,
>   		  next_transition_time - ghrtime  );
> pthread_wait_np();
>
> (flip a bit)
>
> This changes the period of the process but doesn't suspend it. This 
> way your rtl process can still respond to interrupts.
>
> The CPU is surrendered at the pthread_wait_np(), so it doesn't waste 
> CPU cycles. Your task will resume at next_transition_time, at which 
> time, you flip your PWM bit and start the whole cycle over again.
>
> Wayne
>> Thanks,
>> Jesse
>> _______________________________________________
>> Rtl mailing list
>> [email protected]
>> http://www2.fsmlabs.com/mailman/listinfo/rtl
>
> _______________________________________________
> Rtl mailing list
> [email protected]
> http://www2.fsmlabs.com/mailman/listinfo/rtl
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFCA3TljbXqeutGyj4RAlMxAJ9/wS7bSAgRwYb4I3Ud6Upd1e6FLgCeLJCB
UC1CvvOpvCZNlvHFpCj6ENs=
=NY9y
-----END PGP SIGNATURE-----

_______________________________________________
Rtl mailing list
[email protected]
http://www2.fsmlabs.com/mailman/listinfo/rtl