OUT - ED-4752
Download
Report
Transcript OUT - ED-4752
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.
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)
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
Computer Sensing and Control
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.
OUT 888, 128
Output Commands
Out Register Address, Register Contents
OUT 888, 128
OUT 888, 1
OUT 888, 64 + 32
turns on pin 1
turns on pin 8
turns on pin 2 and 3
To turn off the voltage, we issue??
OUT 888, 0
PC Gadget: Input
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?
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??
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
AND Truth Table
1
1
1
0
1
0
AND
=
1
0
0
0
0
0
Bitwise AND
01100011
AND 01000000
= 01000000
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.
Review
• 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
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.