2019_cargo_present_sensor
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| 2019_cargo_present_sensor [2019/02/21 23:09] – tell | 2019_cargo_present_sensor [2019/02/24 22:51] (current) – [combining open-drain outputs to make a logic gate] tell | ||
|---|---|---|---|
| Line 13: | Line 13: | ||
| The adafruit sensors open-collector output is low when the beam is broken (not received), and high when the beam is received. | The adafruit sensors open-collector output is low when the beam is broken (not received), and high when the beam is received. | ||
| - | ===== combining | + | ===== combining |
| But can we do better and run fewer cables? | But can we do better and run fewer cables? | ||
| Line 25: | Line 25: | ||
| Remember that the sensor output is low (closed, grounded, 0) when the beam is not recieved, and high (open, 1) when the beam is recieved. | Remember that the sensor output is low (closed, grounded, 0) when the beam is not recieved, and high (open, 1) when the beam is recieved. | ||
| - | ^ sensor A ^ Sensor B | + | ^ |
| - | | 0 | 0 | 0 | | + | | |
| - | | 0 | 1 | 0 | | + | | |
| - | | 1 | 0 | + | | **1** light recieved |
| - | | 1 | 1 | + | | **1** light received |
| - | See https:// | + | Unfortunately, |
| + | Exercise: write out the truth table for 4 sensors. | ||
| + | See https:// | ||
| + | ===== Inverting the sensor output ===== | ||
| + | Wiring the signals together gives us an " | ||
| + | We need an OR. Turns out we can get there by creating intermediate signals, one for each sensor, that have the opposite sense: | ||
| + | ^ | ||
| + | | **0** | ||
| + | | **1** light received | ||
| + | Now, run these new, opposite signals through the same combination as above: | ||
| + | ^ | ||
| + | | **0** (light) | ||
| + | | **0** (light) | ||
| + | | **1** (dark) | ||
| + | | **1** (dark) | ||
| + | |||
| + | By inverted the meaning of the inputs, we've arranged for the AND function to do what want: | ||
| + | a 1 means that all sensors are dark - none are seeing reflected light from the cargo ball. | ||
| + | |||
| + | |||
| + | ===== An inverter with one transistor ===== | ||
| + | |||
| + | Here's the basic idea: | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | The 2n7000 is a " | ||
| + | * Source, (pin 1 above) which we connect to ground, or the most negative voltage. | ||
| + | * Gate (pin 2), an input. | ||
| + | * Drain (3), into which current can flow | ||
| + | |||
| + | When the gate is connected to a positive voltage (with respect to the source) the source and drain are connected, and current flows from drain to source. | ||
| + | |||
| + | When the gate is low (near ground potential or zero volts) the transistor is off, and the pullup resistor | ||
| + | provides a tiny bit of current to pull the output up to a 5 volts, representing a logic 1. | ||
| + | |||
| + | For a few more details on discrete mosfets for logic, see [[mosfet hints]]. | ||
| + | |||
| + | |||
| + | ===== combining open-drain outputs to make a logic gate ===== | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | Finishing up: | ||
| + | |||
| + | Instead of pullup resistors, we can use a resistor in series with an LED. In fact, we can connect the output of this gate to one of our [[DIO tester and breakout]] boards. | ||
| + | |||
| + | If we build anything with mosfets as a standalone board, we never want to connect a mosfet gate only to an input connector (as drawn above for clarity). | ||
2019_cargo_present_sensor.1550808561.txt.gz · Last modified: 2019/02/21 23:09 by tell
