OutputCapture vs OutputCaptureEx

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

OutputCapture vs OutputCaptureEx

Post by spamiam »

In one of the other threads here we discussed using OutputCapture(). I was looking at the descriptions of the two related functions. One of the differences between OutputCapture() and OutputCaptureEx() is being able to specify the output pin.

But then in the description of OutputCaptureEx() it gives a table showing valid pins for the different ZX versions. Later in the description it discusses the use of a general I/O pin as the output pin.

I presume that the specified pins in the table applies to the default pin used by OutputCapture(), and any valid pin can be used for OutputCaptureEx() . If so, it might be clearer to move that table to the OutputCapture() description.

Is it possible to use Zero as the pin for OutputCaptureEx(), and that way no pin is actually affected, but the timing is preserved?

-Tony
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: OutputCapture vs OutputCaptureEx

Post by dkinzer »

spamiam wrote:I presume that the specified pins in the table applies to the default pin used by OutputCapture(), and any valid pin can be used for OutputCaptureEx().
As noted, OutputCapture() generates output on a specific pin and OutputCaptureEx() can generate the pulse train on any I/O pin. However, with OutputCaptureEx(), waveform generation on certain I/O pins (those noted in the table captioned "Hardware Output Capture Pin") will be more precise because built-in hardware capabilities are used.
spamiam wrote:Is it possible to use Zero as the pin for OutputCaptureEx(), and that way no pin is actually affected, but the timing is preserved?
No. However, desired effect could probably be achieved using Pause().
- Don Kinzer
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Re: OutputCapture vs OutputCaptureEx

Post by spamiam »

dkinzer wrote:However, desired effect could probably be achieved using Pause().
I looked at the description of Pause(). I had never read that one before :cry: It says
This routine should be used instead of Sleep() or Delay() when higher resolution timing is required or
you don’t want a task switch to occur
In the case of an 8 channel PWM routine running as its own task. During the dead time between the 50 Hz PWM pulses, one might WANT to allow task switching, so the Pause() command might not be optimal even though it gives a more precise timing than Sleep() or Delay(). I would think that the accuracy of Sleep() and Delay() [what, about +/- 1mS?] are accurate enough for servos and will cooperate better with other tasks.

-Tony
Post Reply