Hardware PWM on PIC

rjenkinsgb

Well-Known Member
Most Helpful Member
If I'm correct, that the ENVELOPE is over 24ms,
That's because it is using a number of "channel" times, some real and some dummy ones, to get to the total time before it repeats.

The repeat time is not in any way critical; 20mS (50Hz) is a historical value, it's supposed to be somewhere around 40Hz to 200Hz repeat rate, so 5 - 25mS but that's not too critical with most servos.
Some do not like too high repeat rates and that can cause jitter.

If you want is slightly shorter, change this:

C:
    If index > 15 Then
//15 * average 1.5mS = 22.5mS, a reasonable frame repeat time

eg. changing 15 to 12 would reduce the cycle duration by 4.5mS

It will vary with total length of the servo pulses at that exact instant, though. That's the cost of not having any separate reset timing system.

Use 14 instead of 15 if you want it just slightly faster.

camerart

Active Member
That's because it is using a number of "channel" times, some real and some dummy ones, to get to the total time before it repeats.

The repeat time is not in any way critical; 20mS (50Hz) is a historical value, it's supposed to be somewhere around 40Hz to 200Hz repeat rate, so 5 - 25mS but that's not too critical with most servos.
Some do not like to high repeat rates and that can cause jitter.

If you want is slightly shorter, change this:

C:
    If index > 15 Then
//15 * average 1.5mS = 22.5mS, a reasonable frame repeat time

eg. changing 15 to 12 would reduce the cycle duration by 4.5mS

It will vary with total length of the servo pulses at that exact instant, though. That's the cost of not having any separate reset timing system.

Use 14 instead of 15 if you want it just slightly faster.
Hi R,
I was just looking at that //15 calculation!
I need 6xCH, RB0-5. RB6+ are used by PICKIT3, do the dummy CH effect anything?

As it is now, it is slightly too long, but is that acceptable? (I want to avoid jitter) I don't know what the boundaries are.

At the moment, I only have 5xCH, and just tried a SERVO on all of the CH PINS. All moved, repeated and no jitter.
C.

Nigel Goodwin

Super Moderator
Most Helpful Member
Hi R,
I was just looking at that //15 calculation!
I need 6xCH, RB0-5. RB6+ are used by PICKIT3, do the dummy CH effect anything?

As it is now, it is slightly too long, but is that acceptable?
(I want to avoid jitter) I don't know what the boundaries are.
As already explained above, it's EXTREMELY non-critical - double would be fine, five times could well be fine - slightly too long doesn't matter whatsoever.

camerart

Active Member
As already explained above, it's EXTREMELY non-critical - double would be fine, five times could well be fine - slightly too long doesn't matter whatsoever.
Hi N,
Ok, thanks.
A lot has been said and often it is repeated, hopefully the repeats will not be needed eventually

I need 6xCH, RB0-5. RB6+ are used by PICKIT3, do the dummy CH effect anything?
C.

Last edited:

camerart

Active Member
Hi,
The SERVO wasn't moving to it's full range, so I changed [ servo_times(x) = 0600 ] and the other side to [ servo_times(x) = 2400 ] This worked, so is this ok?

I've re-read #121 and now can see the range.

Sometimes the SERVO does a bit of jittering.

Does high repeat range mean longer or shorter length of time?
C

Last edited:

rjenkinsgb

Well-Known Member
Most Helpful Member
do the dummy CH effect anything?
The dummy channels just pad out the overall sequence to give a reasonable delay before repeating.

For normal servos the repeat should not be less than 10mS, so with 6 x 0.8mS (4.8) you need four extra 1.5mS padding cycles (6mS) to guarantee you reach that. So, minimum total count of 10.

Experiment with different values - it won't hurt anything!

OK on widening the time range; if it works with the servos you have, it's fine.
Just be wary that different makes/types may hit the ends of the travel and stall or overload if you go outside the 1-2mS range.

camerart

Active Member
The dummy channels just pad out the overall sequence to give a reasonable delay before repeating.

For normal servos the repeat should not be less than 10mS, so with 6 x 0.8mS (4.8) you need four extra 1.5mS padding cycles (6mS) to guarantee you reach that. So, minimum total count of 10.

Experiment with different values - it won't hurt anything!

OK on widening the time range; if it works with the servos you have, it's fine.
Just be wary that different makes/types may hit the ends of the travel and stall or overload if you go outside the 1-2mS range.
Hi R,
I think I've got it.
I've hit the buffers a couple of times.
I'll do some playing, then program some movement.
Interesting stuff, thanks.
C

camerart

Active Member
Hi,
I'm sure I was advised to set TRISD to all OUT, can someone let me know if this is correct, and why, please?
I'm trying to add the SPI setting, and think they are clashing.
C

Replies
7
Views
6K
Replies
1
Views
2K
Replies
19
Views
3K
Replies
15
Views
10K
Replies
2
Views
2K