From: tom on
Morning

I was wondering if anyone had any pointers on Ramp generating on a PIC?

I have four channels that are on consecutively, they are provided from
another PIC, I need to code a further PIC that will take these binary
inputs and turn them into slow start/stop channels, the rise and fall
being over about a second.

I'm looking at using the F505, once I have the ramps working I need the
other 4 pins for an override function.

I was thinking of generating a single 10KHz heartrate then doing the
work inside the periods of that. The idea being of having 10 periods
in the second, the first with a 10% of the pulses high, then 20% then
30% etc sadlythis doesn't work that well because 60% is every x.xx
pulses then 70% is only a fraction more, not whole pulses different.
Does that make sense?!

Tom

From: Tom Simmons on
OK, having finally got the last PIC project working I have had a chance to
read around.

I was originally under the impression that the PWM functions that some PICs
have was hardware based and existed on dedicated pins, however having
skimmed the App Note for F72 it seems that you can use the PWM timers etc
and output top what ever pins you decide, is this true?

Tom

<tom(a)ts-net.co.uk> wrote in message
news:1139216832.659187.101000(a)g44g2000cwa.googlegroups.com...
> Morning
>
> I was wondering if anyone had any pointers on Ramp generating on a PIC?
>
> I have four channels that are on consecutively, they are provided from
> another PIC, I need to code a further PIC that will take these binary
> inputs and turn them into slow start/stop channels, the rise and fall
> being over about a second.
>
> I'm looking at using the F505, once I have the ramps working I need the
> other 4 pins for an override function.
>
> I was thinking of generating a single 10KHz heartrate then doing the
> work inside the periods of that. The idea being of having 10 periods
> in the second, the first with a 10% of the pulses high, then 20% then
> 30% etc sadlythis doesn't work that well because 60% is every x.xx
> pulses then 70% is only a fraction more, not whole pulses different.
> Does that make sense?!
>
> Tom
>


From: Tom on
When you implement the PWM in software do you do the whole thing
yourself?

I guess what I mean is, do you use the multiple timers that these
bigger PIC's have?

I can see how I could easily implement a single PWM in a normal PIC,
what I need is to use PWM to ramp say RB0 up, then once I have a 100%
duty cycle I hold this for say 5 seconds then Ramp down again using the
PWM.

At the point the RB0 starts comping down I need to start ramping RB1
up, this will in turn stay up for 5 secs then ramp down.

As RB1 comes down RB2.....

When RB3 starts coming down RB0 starts going up again.

What controls the whole thing is 4 normal binary feeds on say A0-3 (A0
goes high RB0 starts climbing, A0 goes low BR0 starts falling)

Whats that I hear you say, piece of cake you'll have it done by
tomorrow for me.....Thanks awfully!

Tom

From: Artenz on
> I was thinking of generating a single 10KHz heartrate then doing the
> work inside the periods of that. The idea being of having 10 periods
> in the second, the first with a 10% of the pulses high, then 20% then
> 30% etc sadlythis doesn't work that well because 60% is every x.xx
> pulses then 70% is only a fraction more, not whole pulses different.
> Does that make sense?!

Generating a PWM signal is easy.

Assume "P" is your desired output value, from 0 to 100%. Initialize S
to 0.

At every 100 usec heartbeat do this:

if( (S += P) >= 100 )
{
S -= 100;
set_output()
}
else
clear_output();

You can change P whenever you want to change the output value. To make
a 1 second ramp, just increment/decrement P every 100 heartbeats. You
don't even have to use a second timer.

As an optimization, you could use 128 or 256 instead of 100, and make
use of assembly tricks to simplify things.