View Single Post
  #16   Spotlight this post!  
Unread 08-08-2006, 14:56
Qbranch Qbranch is offline
wow college goes fast.
AKA: Alex
FRC #1024 (Kil-A-Bytes)
Team Role: Alumni
 
Join Date: Apr 2006
Rookie Year: 2006
Location: Indianapolis
Posts: 1,174
Qbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond reputeQbranch has a reputation beyond repute
Re: Globe Motor Programming Questions

Quote:
Originally Posted by Mark McLeod
You're correct that if pwm01 gets set to a number greater than 255 it will wrap around to zero and you'll suddenly go from full forward to full reverse.
In the TxData struct, all PWM values are defined as type 'unsigned char' - or one byte. Assigning a value greater than 255 will cause unpredictable processor operation unless you are VERY lucky.

Most programmers are used to C/C++/C#/C.NET which traps all your errors.... such as overflow. In the processor, it does exactly what you tell it to do. All defining some thing as a uchar does is tell the linker to offset the next thing in memory by 1 byte. Sooooo if you write a number bigger than a byte, you will interfere with the next bit down the line in processor memory. This would in effect change the value of the next variable.

-Q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08