OT?:Trajectory generator

Hi, I'm a newbie, and 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 the second encoder input using external interrupt, aside from the timers.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.