ROBOTC.net forums http://www.robotc.net/forums/ 

Protoboard http://www.robotc.net/forums/viewtopic.php?f=52&t=3553 
Page 1 of 1 
Author:  maths222 [ Wed Oct 05, 2011 2:07 pm ] 
Post subject:  Protoboard 
Can someone please explain bit masks and hexadecimal values for us to use with the protoboard. 
Author:  MHTS [ Wed Oct 05, 2011 6:36 pm ] 
Post subject:  Re: Protoboard 
Can you be more specific what you want to be explained? 
Author:  maths222 [ Mon Oct 24, 2011 8:53 am ] 
Post subject:  Re: Protoboard 
I want to understand how to use bit masks to read digital values from the protoboard. 
Author:  MHTS [ Mon Oct 24, 2011 2:54 pm ]  
Post subject:  Re: Protoboard  
To understand bitwise operation, you must first understand hexadecimal number system. Computers only understand binary number system (base 2) because they only know 1's and 0's. The right most digit represents either a 0 or a 1, every subsequent digit to the left is an increment of the power of 2. So if the right most digit is 1, it represents one. If the next digit to the left is a 1, it represents 2. The next digit to the left represents 4, the next 8, the next 16 and so on. Therefore, the following decimal number can be translated to binary.
But binary numbers are not friendly to human because representing a typical number may require way too many digits. Hexadecimal system (base 16) is a good compromise because 16 is a power of 2 so it can be easily translated between binary and hexadecimal because it uses fewer digits. Every 4 binary bits can be combined to one hexadecimal digit. As the name implies a hexadecimal has 16 possible values (from 0 to 15). To represent the digit in a single character, we added letters (af) to represent 1015. So the number 100 from the above example can be represented as:
To manipulate bits, you must understand the following bitwise operators:  "&" This is to do a bitwise "AND" of two binary numbers. Typically, it allows you to "clear" a bit in a variable. For example:
 "" This is to do a bitwise "OR" of two binary numbers. Typically, it allows you to "set" a bit in a variable. For example:
 "~" This is to do a bitwise "NEGATE" of a binary number. Typically, it allows you to negate a value to form a bitmask for clearing a bit. For example:
 "^" This is to do a bitwise "EXCLUSIVEOR". Typically, it allows you to flip a bit. For example:

Page 1 of 1  All times are UTC  5 hours [ DST ] 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ 