Categories

# Solution manual for Introduction to Mechatronic Design by J.Edward Carryer R.Matthew Thomas wKenny

Product Code: 222
Availability: In Stock
Price: \$24.99
Qty:     - OR -

## Description

Chapter 3 Microcontroller Math and Number Manipulation
3.1) Convert the following binary patterns to hexadecimal: 1101
01010
10011
11001100
110011000001
Do Not Circulate
3.2) Construct a comparison expression that will test if bits 0, 2 & 4 in a byte are all in the high state without altering the state of the byte.
3.3) Construct an expression that will clear bits 1, 3 & 5 in a byte-sized variable called Bumpers while not altering any of other bits.
3.4) Construct an expression that will set bit 1 in a byte-sized variable called PortA without affecting any of the other bits in the variable.
3.5) Write out the 16 bit hexadecimal representation of the following signed decimal numbers (assume the representation is 2s complement):
10 17 27 -45 -128 127
Carryer, Ohline & Kenny

1101 = 0xD
01010 = 0xA
10011 = 0x13
11001100 = 0xCC 110011000001 = 0xCC1
If ((ByteToTest & 0x15) == 0x15) is true
Bumpers = (Bumpers & 0xD5)
PortA = (Bumpers | 0x02)

10 = 0x000A 17 = 0x0011 27 = 0x001B -45 = 0xFFD3 -128 = 0xFF80 127 = 0x007F
Solution Manual for Introduction to Mechatronic Design Do Not Circulate
3.6) Construct an expression that will test if either bit 0 or bit 3 in a byte-sized variable is in the high state without altering the state of the byte.
3.7) Construct an expression that will test if either bit 1 or bit 3 in a byte-sized variable is in the low state without altering the state of the byte.
3.8) What result would you expect from the following expressions if all values were contained in byte-sized variables?
(240 2)/4 (240 2)/10 (240/10) 2 (240/4) 2
3.9) Construct an expression that will clear bit 1 in a byte-sized variable called PortA without altering any of the other bits.
3.10) Construct an expression to toggle (change a zero to a 1 or a 1 to a zero) bit 3 in a byte-sized variable called PortB that doesnt alter the value of any of the other bits.
3.11) Construct an expression that quickly divides an integer variable by 32 without using the division operator.
Carryer, Ohline & Kenny Copyright 2011 3-2
If ((ByteToTest & 0x09) != 0) is true
If ((ByteToTest & 0x0A) != 0x0A) is true
(240 2)/4 = 56 (240 2)/10 = 22 (240/10) 2 = 48 (240/4) 2 = 120
Bumpers = (Bumpers & 0xFD)
PortB = (PortB ^ 0x08)
Variable = Variable >> 5

Solution Manual for Introduction to Mechatronic Design Do Not Circulate 3.12) Complete the blank cells in the following table:
3.13) What is the range of a 24 bit twos compliment number?

## Write a review

Your Review: Note: HTML is not translated!