Discussion forum for the BasicX family of microcontroller chips.
InputCapture and PulseOut - maxvtol - Jul 15 20:34:19 2007
I'm trying to read a pulsewidth using InputCapture in a looping task.
I want to speed the frequency of the output pulse, so I am using
PulseOut in a different looping task at the frequency I want. The
problem is, the out pulses are getting chopped some of the time,
therefore making them unusable.
It appears in the manual that these are not in conflict when used in
the same task, sense they would be sequential, and they in fact work
fine in the same task.
Is there any way to make InputCapture work in a looping task with
PulseOut in a looping task? I've tried using LockTask(), changing the
output pin to a different port than the input capture pin (that
seemed to help some), but I can't seem to get it to work.
Would using Timer1 for Edge Capture work (as in the manual and
example EdgeCaptureExample.bas). Since InputCapture and this example
use Timer1, I guess it's unlikely to work.
Thanks,
Joe

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: InputCapture and PulseOut - Tom Becker - Jul 15 21:41:30 2007
> > ... Is there any way to make InputCapture work in a looping task with PulseOut in a
looping task?
Both InputCapture and PulseOut use Timer1. You could share Timer1
between two tasks with a semaphore, but all that would do is assure
exclusive use of the timer, alternately between the InputCapture task
and the PulseOut task, perhaps the same as using both alternately in a
single task.
Although it offers only 8-bit resolution, Timer2 can also be used to
generate pulses (to pin 25) by bit-banging the processor registers. It
sounds like you're trying to reproduce an RC servo channel; will 8 bits
suffice?
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: InputCapture and PulseOut - maxvtol - Jul 15 22:33:04 2007
Yes, I'm trying to read the PPM signal for 5 channels off a hacked RC
receiver. I want to mix the signals and put them out to 12 channels.
In my example below, I was just trying to start small with one
channel.
I have digital servos, so I was trying to get 1usec resoulution. If
my pulsewith varies more than 4usec, I can see noticeable movement.
I'm not sure what that is in bit resolution. I'm also trying to
reduce the frequency of the pulseout to the digital servos to between
4 and 8 msec. I'm using analog gyros to update the signal in the
mixing math.
Thanks.
Joe
--- In b...@yahoogroups.com, Tom Becker
wrote:
> > > ... Is there any way to make InputCapture work in a looping
task with PulseOut in a looping task?
>
> Both InputCapture and PulseOut use Timer1. You could share Timer1
> between two tasks with a semaphore, but all that would do is assure
> exclusive use of the timer, alternately between the InputCapture
task
> and the PulseOut task, perhaps the same as using both alternately
in a
> single task.
>
> Although it offers only 8-bit resolution, Timer2 can also be used
to
> generate pulses (to pin 25) by bit-banging the processor
registers. It
> sounds like you're trying to reproduce an RC servo channel; will 8
bits
> suffice?
> Tom
>

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )Re: Re: InputCapture and PulseOut - Tom Becker - Jul 15 23:39:35 2007
> ... and put them out to 12 channels [] 1usec resolution [] between 4
and 8 msec.
Not a trivial task.
I suspect you will need additional hardware which can probably be
steered by the processor at 125-250Hz if you can get the updates to the
hardware quickly. Generating 12 concurrent PWM signals requires more
timing capability than the BX-24 has by a good margin.
Someone earlier mentioned Al Williams; he has an eight-channel PWM
generator. http://www.awce.com/pak5.htm Two of them will give you 16
PWM channels. They take 9600 baud, 2-bytes-per-PWM-pin commands, so (1
/ (10/9600*2*12)) = 40Hz for 12 channel updates. They'll give you eight
bits of 2µS resolution, it looks like. You'll find other similar
devices available elsewhere, too.
Perhaps another method is analog. Basic-X DACPin function might be used
to store a voltage that steers a 555 duty cycle. Seems bulky, but 12
BX-24 pins can feed 12 opamps (to hold each DACPin output), which feed
12 555s, one per output. The 555s would run at 250Hz; you'd steer the
duty cycles as rapidly as you could loop through the 12 DACPins.
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )