Hi,
first of all I know little
of electronics and programming,
but highly motivated

I'm trying to recreate microchip an696a
appnote using CCS C and PIC18f452.
It took me a while to figure out data types
between compilers are not the same.
I've got some of the things setup, PWM
is working fine, using 40Mhz crystal @ slightly
over 20Khz PWM, Timer2 setup to 4 division
and period of 120.(I'm using it as locked antiphased
as it was called) So my PWM range is arround 0-239 negative
direction 241-480 for positive direction.

My problem lies in trajectory generation,
being a newbie, I'm confused. I'm not doing it
exactly as it was done in the appnote, I can't
understand (yet) the shifting and rotating they did
on that. (As I understand, it was done because
there was no 32bit support on the earlier compilers).
I want to make it simpler so as to understand
what is going on and since CCS support int32.

Now, what I need is a sample code in C
(I was gonna say preferrably in C but that's
all I know for now) for trajectory generation
or motion profile, I'm confused between
velocity profile and position profile are they
both used at the same time? My googling
hits, mention something to calculate time
during acceleration to maximum acceleration to
decceleration, to get a trapezoidal profile. I'm
not quite sure how to implement that. So any
help would be greatly appreciated. BTW the
PID I'm using comes from here:
http://www.lewisw.worldonline.co.uk/cservo.htm
It's basically the same thing as in appnote(I think)
but no use of union that confused me with shift and rotate thingy.

Basically I'm going to use this to give new life to
a dead epson1270 that I found and convert it to
cut vinyl stickers(if successful), it has 2 servos
one with rotary the other with linear encoders.
not sure of the count yet, it seems so many.
the pic18f452 is already setup for 2 PWM output,
with one encoder input is using external interrupt,
the other is using timers as in appnote an696a.
Actually I set it up like Timer0 and External Interrupt for
encoder one, Timer1 and External Interrupt1 for
encoder two. The counting seems to be working.

Thanks.