Why can't you use 255 in PWM?

I’ve heard that most people don’t allow their PWMs to go to 255 and that it has something to do with the serout command. Nowhere in the serout documentation is there a reason given, so I assumed it had something to do with the RC.

Is it because IFI uses 0xff, 0xff as a marker for start of data sequence? If 2 PWMs next to each other in the serial stream were to max out at the same time, it would appear to the master uP as if the data stream had restarted and the remaining variables would be shifted.

If someone knows anything different, I’d appreciate a heads up.

*Originally posted by Andrew *
Is it because IFI uses 0xff, 0xff as a marker for start of data sequence? If 2 PWMs next to each other in the serial stream were to max out at the same time, it would appear to the master uP as if the data stream had restarted and the remaining variables would be shifted.

That’s exactly it. :smiley:

 Serout USERCPU, OUTBAUD, 
**255,255**,(PWM1),relayA,(PWM2),relayB,(PWM3),(PWM4), (...)]

last year our programmer didnt know this…i went full in one direction and the robot stops, jerks, goes, stops jerks…

And it would have to be in the Serout from the Robot Controller that it went haywire, as the OI is programmed to max out any analog input at 254, unless there is no resistor on the input at all, which goes to 127.

The Serin statement uses the same synchronization method as the Serout, not that a programmer needs that information.

yeah, it sure was fun, making the robot dance, until we realized that…

good rule of thumb, don’t let anything get above 254, ever. well, as long as you’re the programmer at least :p.