18
Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate with the world. We can represent a binary value in a couple of manners. It can be a one or zero, and it can also be represented by the presence or absence of voltage.

Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Embed Size (px)

Citation preview

Page 1: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Computer Sensing and Control

How is binary related to what we are trying to accomplish in electronics?

The PC GadgetMaster II uses binary to communicate with the world. We can represent a binary value in a couple of manners. It can be a one or zero, and it can also be represented by the presence or absence of voltage.

Page 2: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Register

A physical location that can hold a certain amount of data

Lots of them so each has an address

How much data a register can hold is measured in bits or bytes (8 bits = 1 byte)

Page 3: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

PC Gadget Master II

Parallel port has three 8 bit registers which are used with the PC Gadget– Output 888 and 890– Input 889

With switch in the B position:– 12 Output lines, 4 Input lines

With switch in the A position:– 11 Output lines, 8 Input lines

Page 4: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Computer Sensing and Control

Page 5: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

To get output, we issue a command in Visual Basic called OUT. If we wish to have the value (voltage) issued on a pin, we issue the corresponding binary value with the out command.

Page 6: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate
Page 7: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

OUT 888, 128

Page 8: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Output Commands

Out Register Address, Register Contents

OUT 888, 128 turns on pin 1

OUT 888, 1 turns on pin 8

OUT 888, 64 + 32 turns on pin 2 and 3

To turn off the voltage, we issue??

Page 9: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

OUT 888, 0

Page 10: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

PC Gadget: Input

Page 11: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Input Commands

INP Register Address

INP 889 checks the state of the inputs

Input returns a binary number where a 1 corresponds to a high state on a pin.

How do we know if a pin is high?

Page 12: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

N = Inp(889)

If (N and 64) = 64 then   (Do something here!)

End if

What are we trying to do with the N and 64 = 64??

Page 13: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Masking

Boolean operators are used to MASK values in decision making operations. We can “filter” an input for a specific value to ensure that we can detect its existence

Page 14: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

AND Truth Table

1

AND

1

=

1

0 1 0

1 0 0

0 0 0

Page 15: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Bitwise AND

01100011

AND 01000000

= 01000000

Page 16: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Review

Gadgetmaster II has Input register (memory area) and an Output register.

• Each register has an address:

• Input is 889.

• Output has two: 888 and 890.

• Output has twelve lines on which voltage can be sent.

• Each line corresponds to a binary number. If we wish to send voltage through

a particular line, we use the OUT command, the port number, and the value of

the line which on which we wish to have voltage. For example:

• OUT 888, 128 places voltage or a high state on pin 1.

• OUT 888, 8 places voltage on pin 5.

• OUT 888, 96 places voltage on two pins: 2 & 3.

Page 17: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

• If we wish to use the other four pins (9 – 12) we must use a separate address

which is 890.

• These four pins have a special arrangement with pin 9 and eleven switching

values so that the four pins have decimal 2, 4, 8, 1. Remember, each pin is

addressed by us in decimal but actually corresponds to a binary value on the

pin!!

• Input works a little differently than output but has similarities.

• The input register is similar to the output in that it has an address which is

889.

• It is similar to the output register in that each pin has a binary value which

corresponds to a high state on the pin. We use the decimal equivalent to

address the pin.

Review

Page 18: Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate

Review

To get the value of a pin on the input register we have to look at all values on

the register at the same time. We then examine the number returned to us

from the register and it will inform us as to which pin has voltage.

We use the INP command to get the value in the input register. For example:

intRegVal = INP (889)

tells us the value that is in the register. It is placed in a variable called

intRegVal which we declare and then examine.

There is a jumper which is set to B by default which controls the number of

lines which are active at any time. There are eight lines but only four are

active with the jumper is this position.