No, 100 is correct. If you look in the source code ZIP file, you will=20 see that he sets PR2 to 100(-1), so Timer2 counts 0-99. When Timer2 =3D=20 CCPR1L, the output turns off. A value of 100 in CCPR1L means it will=20 never turn off. On 1/4/2015 8:29 AM, Justin Richards wrote: > Porting Roman's DC_motor_xtal.c (from > http://www.romanblack.com/onesec/DCmotor_xtal.htm ) to assembly and have = a > question re CCPR1L. Referring to the code snippet below ... he uses a > setting of 100 for CCPR1L for full power. > > Is it possible he intended to use 255 and was thinking 100% so entered 10= 0. > > I suspect it is not possible to know exactly without asking the author bu= t > it appears to be a typo and hope those familiar with PWM may shed some > light. > > > #define MOTOR_PROP_GAIN 10 > > if(mpos < rpos) // if motor lagging behind > { > mlag =3D (rpos - mpos); // find how far i= t's > lagging behind > if(mlag >=3D (100/MOTOR_PROP_GAIN)) CCPR1L =3D 100; // full power i= f is > too far behind > else CCPR1L =3D (mlag * MOTOR_PROP_GAIN); // else adjust PW= M if > slightly behind > } > > > For the un-initiated, Roman has published some excellent detailed project= s. > > Justin --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .