EtherPort Data Acquisition & Control System EtherPort DIN

48-Channel digital input board
introduction
how to use

din.jpg

The EtherPort DIN board is a 48-channel digital input board. The EtherPort DIN offers the following features:

  • Open Source/Open Hardware design (Creative Commons 4.0 license)
  • Single 5V power supply
  • LED indicates when power is applied
  • 48 independent input bits (TTL inputs, or optional pullup resistors for dry contact inputs)
  • 48 input pins divided up into 4 banks of 12 bits each (PPDIO bus connections)
  • Optional DIN rail brackets allow installation on 35mm DIN rails
  • DIN rail brackets are available in .STL format for 3D-printing
  • Optically-isolated inputs are possible using companion PPOpto-12 board
  • Input pins are also compatible with the PPRlyIO board
  • Each bank of 12 I/O pins can be brought out to screw terminals using the PPBreakout board or PPBreakin board
  • Full documentation including System Requirements Specifications (SyRS), Hardware Requirements Specifications (HRS), Hardware Inspection list (HI), Hardware Test Cases (HTC), Hardware Test Procedures (HTP), Hardware Design Description (HDD), and (reverse) Traceability Matrix (RTM) are available for the EtherPort system, including this board.
Table of Contents
Bill of Materials (BOM)
PCB Availabilty and Files
DIN Rail Mounts
Revision History
Board Layout
Connections
DIP Switches
Test Pins
Software Support
Build an EtherPort DIN Board
Testing the EtherPort DIN Board
Hardware Design Description
Software Design

 

Bill Of Materials

Bill of Materials (BOM) for the EtherPort DIN board:

  • (1) 5mm LED
  • (1) 470 Ω 1/4-watt 1% resistor
  • (2) 10 kΩ 1/4-watt 1% resistor
  • (4) 1×9 SIP resistor (10kΩ, 8 resistors+1 common)
  • (1) 2-pin screw terminal (5mm/0.2″ centers) or (1) 5.5mm Barrel Jack for power
  • (4) 20-pin (2×10) male headers (ribbon cable connectors)
  • (1) 74HC125 4-ch tri-state buffer (SOIC-14)
  • (6) 74HC165 parallel-in serial out shift registers (DIP)
  • (7) 0.1 µF decoupling capacitors
  • (1) 8-position DIP switch
  • (1) 1×12 female header with long pins (Feather bus)
  • (1) 1×16 female header with long pins (Feather bus)
  • (4) 2×10 male headers
  • (1) Teensy 3.2 with (full) headers
  • (1) EtherPort PCB
  • (1) Adafruit Ethernet Featherwing -or- Robotdyn W5500 Ethernet module (if Ethernet connection is desired)
  • (1) 2×6 female header with long pins (if using Robotdyn W5500 Ethernet module)
  • Optional: (6) test pins
  • Optional: (1) set of female headers for use a Teensy socket
  • Optional: one set of horizontal 35mm DIN rail mounts for EtherPort/DAQ boards
  • Optional: one EtherPort DIN vertical 35mm DIN rail mount
  • Optional: 1 set of 3D-printed Featherwing shrouds for the Featherwing headers (STL files here and here)

PCB Availability and Files

Note: If you only want a few EtherPort PCBs, contact Plantation Productions (randy@plantation-productions.com) to see if there are any in stock. Bare boards are $20 each plus shipping; fully assembled and tested boards are $499 each. If you need more than a couple PCBs and you’re not in a huge hurry, it costs about $50 (plus about 4-6 weeks) to have a set of 10 manufactured and shipped to you from China. I use Seeed Studio Fusion PCD service (https://www.seeedstudio.com/fusion.html). The EtherPort DIN PCBs are two-layer boards.

DescriptionLink
Gerber files for PCB (provide these files to Seeed Studio or your personal PCB manufacturer)EtherPort DIN Gerber Files for PCB
Eagle schematic capture and PCB layout files. Use these if you want to modify or enhance the EtherPort DIN design, or re-layout the PCB using EagleEtherPort DIN Eagle files (Schematic and board layout)
On-line schematic (PDF format)EtherPort DIN Schematic (PDF)
PP Standard DIN rails (STL format for 3D printer)PP Standard DIN Rail Brackets 3D printer files
Adjustable DIN rail bracket (STL format for 3D printer)Adjustable DIN Rail Bracket 3D printer file
Vertical DIN rail bracket (STL format for 3D printer)EtherPort DIN Vertical DIN Rail Bracket

DIN Rail Mounts

The DIN rail mounts were created using AutoDesk’s Fusion 360 (to produce STL files) and I personally print the results on a Lulzbot Taz6 3D printer using ABS filament (ABS is recommended for this job, PLA and PETG are a bit brittle).

There are three sets of DIN rail mounts:

  1. The “standard” Plantation Productions’ DIN rail mounts. These work on most Plantation Productions’ DAQ and EtherPort boards (3.5″ x 5.9″ / 90x150mm). There are two different mounts–one for the left side of the board and one for the right side of the board (the difference is how they tuck away the bulk of the mount underneath the PCB). These mounts have a fixed pair of arms that attach to the DIN rail. They are most easily slid onto the DIN rail from the end of the rail (if you’re strong enough to bend the plastic, you can force them on or off in the middle of the rail). The EtherPort DIN PCB attaches to the standard DIN rail mounts using a set of four 3/8″ #3 wood screws (two for each mount).
  2. The “adjustable” DIN rail mounts. These have an adjustable arm that latches onto the DIN rail. You tighten the arm down on a DIN rail using a 3/8″ #3 wood screw. There is only a single version of this rail mount as it as two sets of holes to allow placement on either side of the PCB (the drawback is that certain boards may have through-hole pins that run into the plastic on the DIN rail as the interface area to the PCB is wider than the standard rail mounts). The EtherPort DIN PCB attaches to a pair of adjustable DIN rail mounts using a set of four 3/8″ #3 wood screws (two for each mount).
  3. The EtherPort DIN vertical mount allows mounting the board vertically (rather than flat) on the DIN rail. This takes up less (horizontal) space than the standard and adjustable DIN rail mounts at the expense of not holding the board as rigidly. Also (obviously), the vertical mount requires more space above the DIN rail. One other disadvantage is that the vertical mount is specially designed for the EtherPort DIN PCB and likely won’t work with many other EtherPort or DAQ boards. The EtherPort vertical DIN rail mount also has an adjustable arm. The EtherPort DIN PCB attaches to the vertical DIN rail mount using a pair of M3x20mm bolts and nuts (washers are also recommented).

The adjustable DIN rail (for 35mm DIN rails) as one arm that swings away for easily attaching to a 35mm DIN rail. You can tighten this arm down with 3/8″ #3 wood screw. Note that it has a pair of holes on both sides so it can mount on the left or right side of an EtherPort DIN board.

Adjustable DIN Rail Mount

Standard DIN Rail Mounts (Left and Right)

Vertical EtherPort DIN mount

Revision History:

Rev 2:
Connected 3.3V to Feather Bus. Changed LED resistor to 470Ω. Mirrored pins on W5500A connector. Added holes for Feather bus doubler.

Rev 3:
Changed the silkscreen positions of pin 1 and 20 on the PPDIO connectors (they were erroneously switched on Rev 2 and earlier).
Connected Teensy PROG line to Feather bus reset line.

EtherPort DIN Board Layout

Connecting Digital Inputs to the EtherPort DIN Board

The 48 I/O lines on the PPDIO96 are broken up into 4 banks of 12 bits/bank. Each bank has a pinout that is compatible with the PPOpto-12 and PPBreakout output connectors:

Note, however, that the bit numbers are offset according to the bank number:

Bank #Starting bit #
0
D0
1
D12
2
D24
3
D36

So, for example, pins 19 and 20 for Bank 3 would actually be D36 and D37, respectively (and pins 1 and 2 would be D47 and D46, respectively).

Because the digital inputs to the EtherPort DIN aren’t usually high-frequency signals (host system generally poll these inputs at around 10-20 Hz), their cabling requirements aren’t very critical.

The 74HC595 ICs used on the EtherPort DIN run off a 5V power supply. Input pins expect a 5V/TTL-logic level. Either 3.3V or 5V logic as inputs will work just fine on the input pins. You can install SIP pull-up resistors (to +5V, through a 10kΩ 9-pin SIP) so you can use dry contact inputs as well. If you wish to connect any other voltage levels to the EtherPort DIN you will need to provide a level shifter to accomplish this. One easy way to do this is to use a PPOpto-12 board that provide optical isolation and allows input voltages betwee 5VDC and 24VDC.

The EtherPort DIN board uses the PPDIO connector for the Bank 0, Bank1, Bank 2, and Bank 3 sets of inputs. This is the same connector found on the PPDIO96 board, the PPDIO48 board, the PPOpto-12 board, and the PPRlyio-12 board. The PPDIO connector on the PPDIO96, PPDIO48, and EtherPort DIN boards are all input connections (actually, they can be outputs on the PPDIO96 as well).

The PPDIO connector on the PPOpto-12 is an output connector that will mate with any of the four PPDIO connectors (Bank 0, 1, 2, or 3) on the EtherPort DIN. The PPOpto-12 accepts dry contact or logic-level (3.3v/5v, 10v, 12v, 15v, or 24v) inputs from field wiring and runs these signals through opto-isolator ICs to optically isolate them from each other and the system boards (e.g., the EtherPort DIN). The PPOpto-12 puts out TTL (5v) logic signals on the PPDIO connector; so if you use a PPOpto-12 board to isolate field wiring from the EtherPort DIN inputs, make sure to not install the SIP pullup resistors on the EtherPort DIN board (at least on the inputs coming from the PPOpto-12).

Another board you can use with the EtherPort DIN is the Plantation Productions’ PPRlyio-12 board. This board accepts 12 inputs (logic level or dry contact), translates the result to a logic-level (TTL/5v) output, which can be fed into the EtherPort DIN board. The Rlyio-12 board provides pullup resistors (for dry contact inputs) on a bit-by-bit basis. It also provides bit inversion on a bit-by-bit basis. Finally, the Rlyio-12 board also provides independent relay control (hence the name) for all 12 inputs. With the relays, you can use the digital inputs to control some high-current device and use the inputs to the EtherPort DIN to simultaneously test their current state. You can also connect a PPOpto-12 and PPRlyio-12 board in series to optically isolate as well as provide pullups and polarity selection for each of the inputs.

DIP Switches on the EtherPort DIN

The EtherPort DIN board contains eight DIP switches, six of which connect to various input pins on the Teensy 3.2. This provides a convenient set of switches for setting default values and other options within your software. The standard software (and silkscreen markings) use these switches to set the Ethernet IP address and enable USB and an OLED display.

Test Pins on the EtherPort DIN

The EtherPort DIN board contains 6 test locations that make varous signals available to DVMs, Oscilloscopes, logic analyzers, and other devices:

  • MISO (Master In, Slave Out SPI data signal)
  • SPICLK (SPI clock signal)
  • Inh (74HC595 inhibit signal)
  • Load (74HC595 load signal)
  • Gnd
  • Vcc (+5V)

You may optionally install test pins in each of these holes. A test pin allows you to clamp a test lead to the pin allowing hands-free circuit connection (otherwise you will need to press the test probe against the test signal’s PCB pad).

Software Support for the EtherPort DIN

The standard firmware can be found here:

EPDin.ino

The standard software can be configured to work with a Robotdyn W5500 Ethernet module or an Adafruit Ethernet Featherwing (this requires changing a single define in the source code). With a little bit of hackery, you could actually use both Ethernet modules, if you really had the need.

The standard firmware supports an Adafruit OLED Featherwing module (enabled by putting DIP switch 6 in the on position during power up). It also supports USB communication (in addition to Ethernet communication) by putting DIP switch 5 in the on position during power up.

The standard firmware is an Ethernet server application that waits for an Ethernet client to connect. It supports up to eight concurrent Ethernet clients (though usually there will be only one, maybe two during software testing). Once connected, the Ethernet client can request the current digital input values from the server or set different operating modes by sending lines of text (with commands) to the EtherPort DIN and waiting for a response from the EtherPort DIN.

The EtherPort DIN standard firmware reads the digital inputs every 10 milliseconds. Because a client might not read the inputs every 10 milliseconds, the EtherPort DIN firmware maintains the last 16 readings (this is easy to change in the source code) and filters the values sent to the client based on the results of the last 16 readings. There are five different “filters” available to the client:

  1. Most recent– returns the most recently read values for each of the 48 inputs. The 15 previous readings are ignored in this filter mode.
  2. Maximum– returns the maximum count (that is, 0 or 1 based on which value was read most often) over the past 16 readings.
  3. Any 1– returns ‘1’ if there was at least a single ‘1’ reading during the last 16 readings.
  4. Any 0– returns ‘0’ if there was at least a single ‘0’ reading during the last 16 readings.
  5. Debounce– returns ‘0’ or ‘1’ if the last ‘n’ readings were ‘0’ or ‘1’ (respectively). The value for ‘n’ is settable by the client (power-up default is 3, ‘n’ must be in the range 2 through 16).

The EtherPort server software accepts the following commands from the client (all commands are ASCII text terminated by a newline/linefeed character):

  • din
  • filter n
  • debounce m

n specifies the filter to use and must be in the range 0 through 4 (0:most recent, 1:maximum, 2:any 1, 3:any 0, 4:debounce).

m specifies the debounce count and must be a value in the range 2 through 16.

The filter and debounce commands echo their command lines as the command response. The din command responds with the following:

din xxx yyy zzz ttt

where xxx, yyy, zzz, and ttt are three-digit hexadecimal numbers representing the bit pattern inputs for bank 0, 1, 2, and 3 (respectively). Bit 0 of xxx represents bit 0 on Bank 0 input pins; bit 11 of xxx represents bit 11 of xxx on Bank 0 input pins. Bit 0 of yyy represents bit 0 on Bank 1 input pins; bit 11 of yyy represents bit 11 of yy on Bank 0 input pins. Etc.

If DIP switch 5 is in the on position on power up, then the EtherPort DIN server firmware will also accept these commands from the USB port (which looks like a serial port on a typical host PC connected to the USB port).

 

Building a EtherPort DIN Board

Here’s the bare EtherPort DIN PCB (printed circuit board):


High resolution image

  1. The usual build process is to build a board from “the bottom up.” This means to first install those items closest to the PCB and work you way up to larger objects on the PCB. So, the first thing to start with in the single SMT (surface mount technology) part on the board: the 74HC125 IC. Fortunately, this is an SOIC-14 package and it’s possible (with care) to solder it onto the board with a standard (though fine-tipped) soldering iron. Begin by tacking one pin (pin 8 is a good anchor) down on the circuit board:


    High resolution image

  2. Ensure that all the 74HC125 pins are aligned with the pads on the PCB. Solder down the remaining pins (I usually start with pin 14 – the pin diagonally across from pin 8– and then solder the other pins in order). Note how I also cleaned up the tacked pin (8) while doing this:

    High resolution image
  3. Next, solder on the seven 0.1µF bypass capacistors, the two 10kΩ resistors, and the 470Ω resistor:


    High resolution image

  4. The next step is optional: install the six test pins on the PCB. Generally, test pins are useful for testing initial runs of PCBs and while developing software for the board. However, for a production run, that than possibly connecting the ground test pin, you really don’t need to install test pins. Though test pins could prove useful for field maintenance, it’s easy enough to put a scope, logic analyzer, or DVM probe directly on the test pin pads.


    High resolution image

  5. The next step is also optional: install sockets for the ICs on the board. Sockets are optional. They make field repairs easy, but using sockets actually makes the board less reliable than soldering the ICs directly on the board (after several years, the contact between the IC pins and the socket gets corroded and the contact becomes intermittent; removing and reseating the IC usually solves this issue, but it’s a problem you don’t normally have when ICs are soldered directly to the board). If you do choose to use sockets, be sure to use high-quality ones (yes, high-quality sockets often cost more than the ICs going into them). Low-quality sockets create more problems than they solve. When installing sockets, be sure to insert them into the board with the notch on the socket matching the notch in the IC outline on the silkscreen.


    High resolution image

    Note: if you choose not to install sockets, you can solder the ICs onto the PCB at this point. Again, be sure to note the orientation of the chips based on the silkscreen images for the ICs.

    When inserting ICs, you will notice that the pins on the ICs are actually slanted outward and will not directly fit in the holes on the board (or in holes on the sockets, for that matter).  If you have an IC inserter tool, it will automatically bend the pins to the appropriate position prior to insertion. If you don’t have such a tool available, just hold an IC with your fingertips with one row of pins against your workbench or desk and manually bend the pins until they are perpendicular to the body of the IC. Repeat for the pins on the other side of the IC.
    IC Insertion Tool:

    High resolution image

    Board with ICs soldered directly to the PCB:

    High resolution image

  6. If you intend to use the EtherPort DIN board with dry contact input (switches, relay contacts, open-collector/open-drain outputs, etc.), you will need to add pullup resistors to the inputs. This is done by installing SIP resistors (1×9 packages with eight resistors per package) in the SIP-1 through SIP-6 connections. Generally, it’s wisest to wire up the whole board with pullups or the whole board without pullups (use multiple boards if you need some inputs with and without pullups on them). However, if space or cost reasons prevent this, the second best solution is to install three of the SIP packages in connectors SIP-1, SIP-2, and SIP-3 (banks 0 and 1) or in SIP connectors SIP-4, SIP-5, and SIP-6 (banks 2 and 3). In theory, you could install a single SIP (or, worse, wire up 10kΩ resistors to the appropriate holes in the connector). However, such hacks look terrible and are often a source of issues. If you want to provide individual pullup resistor control on an input-by-input basis, the best solution is to connect a PPOPTO-12 or PPRlyIO-12 board to the PPDIO (bank 0, 1, 2, or 3) connectors (those boards provide the ability to provide a pullup on an input-by-input basis).

    When soldering the SIPs onto the PCB, be sure to note the location of pin 1 on the package (usually marked with a dot or some other indication). Pin 1 is the leftmost pin of each SIP connector.

    High resolution image

    Pin 1 on the SIP packages:

    High resolution image

  7. For the next step, solder the LED, DIP Switch, and power connector onto the PCB. Note that the DIP switch should always be soldered directly onto the PCB; most DIP switches have pins that are too weak and shaped improperly to go into sockets. Besides, there’s not much to fail in a switch, so the likelihood you will need to ever replace it is low.

    The EtherPort DIN PCB provides two options for the power connector: you can either install a two-pin screw terminal (I prefer the higher-quality ones that have a removable screw terminal component—see the photograph), or you can install a 5.1mm barrel jack (center pin is +5v). Note that you should install only one or the other.


    High resolution image

    Detachable two-pin screw terminals

    High resolution image

    5.5mm Barrel Jack:

    High resolution image

  8. The next step is to solder on all the dual row headers. There are four 20-pin PPDIO headers (2×10):


    High resolution image

  9. Now, it’s time to install the Teensy 3.2. The first step is to solder all the pins on the Teensy 3.2 (assuming you don’t already have one prepared). The instructions for soldering all the pins on a Teensy 3.2 appear here. That web page also describes how to manufacture a socket for the Teensy 3.2 (a good thing to build, it’s nearly impossible to remove a Teensy 3.2 from the EtherPort DIN PCB if you soldered it directly onto the PCB; using a heat gun usually damages the Teensy).


    High resolution image

  10. Now, it’s time to install the Feather Bus headers. These are a pair of 1×12 and 1×16 female headers with long leads. You can get them from Adafruit or chop up a set (if you don’t find the exact length you need) from longer ones purchased on Amazon (or elsewhere). The Feather bus headers need to raise the Featherwing above the Teensy 3.2. The Adafruit headers (which I’m pretty sure are a standard height) just barely clear the Teensy installed in a socket, leaving just enough pin length in the hole to solder them onto the PCB. The real problem is getting them soldered on in a level manner (especially the same level on both sides of the Teensy). To make this task easier, I’ve created a pair of shrouds that I’ve 3D printed into which I insert the pins of the headers. Find the 12-pin shroud here. Find the 16-pin shroud here.

    High-resolution image


    High-resolution image

  11. Insert the 1×12 and 1×15 Feather bus headers into the shrouds and insert them into the appropriate holes on either side of the Teensy 3.2. I generally insert some Featherwing into the headers to hold them at the right position while I solder the headers to the PCB:

    High-resolution image
  12. After tacking down opposite corners of the Feather bus headers, turn the board back over and verify that the headers are evenly pressed into their holes, then finish the soldering of the remaining pins.

    High-resolution image
  13. Next you have to decide whether (1) You will use Ethernet communications on the board (despite the name, Ethernet is optional; you could just use USB), and (2) if using Ethernet, which interface will you use. There are two “standard” Ethernet interfaces you can use with the EtherPort DIN: An Adafruit Etherwing board (that plugs into the Feather bus headers) or a Robotdyn W5500 Ethernet module. The Adafruit unit is a lot more reliable in my experience, the Robotdyn unit is 1/3 the cost. In reality, you can hook up any 5v W5500 Ethernet module to the EtherPort DIN board. The SPI bus lines come out to the 2×6 connectors on the board and there are even four mounting holes into which you can screw a 3D printed bracket for your own module (you could even run a 3.3v unit by running a wire from the Feather/Teensy 3.3v output to your module). However, this assembly tutorial will assume you’re attaching a Robotdyn or Adafruit Etherwing module.

    Robotdyn W5500 Ethernet module:

    High-resolution image

    Note: The STL file for the 3D printed bracket for the Robotdyn W5500 Ethernet module can be found here. You attach the bracket using four #3 3/8″ wood screw (two for the Robotdyn board, two for the EtherPort DIN PCB).

  14. If connecting a Robotdyn W5500 Ethernet module, you have two choices: you can mount the module on the top of the board or the bottom of the board.

    High-resolution image


    High-resolution image

  15. You can also install an Adafruit Etherwing on the Feather bus connector:

    High-resolution image
  16. At this point, soldering is largely complete (assuming you’ve made no mistakes that will require some rework).  Turn the board over and slowly, careful, visually inspect every solder joint. Well over 50% of the failures I’ve had were due to missing a solder connection. It’s worthwhile to visually inspect all the pins (yeah, I know, there are a lot of them) to verify you haven’t missed any.

    High-resolution image
  17. Now for the actual “smoke” test. With the ICs inserted, apply power and make sure the LED still lights up (no flickering!) and nothing gets overly hot (or worse, smokes and catches on fire! Yes, this has happened to me in the past).

Testing the EtherPort DIN Board

  1. Assuming your board passes the “smoke” test, now it’s time to do a real test on the board. This will require running software on the EtherPort DIN board.   I have written a piece of test software that runs on the EtherPort DIN board EPDinTest.ino. The test software assumes that there is an Adafruit OLED Featherwing plugged into the EtherPort DIN, though it is easy enough to remove this requirement by modifying the source code.
  2. The test software ignores the DIP switches other than to print their positions (as part of the test).
  3. The EPDinTest.ino program continuously reads the 48 I/O inputs on the EtherPort DINboard and displays their values as 4 sets of 3 hexadecimal digits (3 digits for every 12 bits). This test procedure assumes that pullup resistors (SIPs) are all installed.  The program should display all “0” characters if there are no pins shorted to ground. Now for the boring part–put a jumper on a ground pin (pin 2, 4, 5, 6, 10) and then on pin 2->1->3->5->7->9->11->13->15->7->19->20 (in succession). The corresponding hex values will be 1, 2, 4, 8, 10, 20, 40, 80, 100, 200, 400, and 800, respectively, when you ground the corresponding pin. Repeat this for all four banks.
  4. Note that the EPDinTest.ino program simply checks the functionality of each of the input pins, it does not verify the operation of the Ethernet port. It *somewhat* checks the function of the USB port as the test program writes the output to the Arduino/Teensyduino serial output display.
  5. After testing all the input pins, you should also flip each of the DIP switches and verify that they work properly. Note that the test program displays a ‘1’ bit if the switch is in the *off* position, a ‘0’ bit if the switch is in the *on* position. Also note that only switches 1-6 are wired to the Teensy 3.2.
  6. The next step is to install the standard EtherPort DIN firmware. If you flip the USB switch (sw 5) to the “on” position, you can enter DIN commands from the Arduino input line and view the output on the Arduino serial output.
  7. If you’re running on a (Windows) PC, epDinTest.exe is a small program that will connect to an EtherPort DIN board at address 192.168.2.10 (port 53456) and continuously send it “din” commands, printing the return result. If you want to play around with the source code, epDinTest.hla is written in High-Level Assembly (HLA).
  8. Another way to test the Ethernet port is via an Ethernet terminal program. I’ve always used the Hercules terminal program. Running it, I can type all the EtherPort DIN commands (“din”, “filter”, and “debounce”) and check their operation.

Hardware Design Description

The hardware design for the EtherPort DIN board is relatively straight-forward. Six 74HC595 parallel-to-serial shift registers are wired in series and connected to the Teensy 3.2’s SPI bus. The SPI-CLK output from the Teensy drives the CLK inputs on the 74HC595s. The 74HC595 Inh (inhibit) pin is driven by pin 30 on the Teensy (this is the serial shift data slave select/chip select for the SPI bus and the serial shift registers). The SH/LD’ (parallel load) input is driven by pin 31 on the Teensy. The QH line on the first 74HC595 IC (the ultimate serial output signal) will (ultimately) connect to the Teensy MISO line. However, the 74HC595 ICs are 5v outputs and it needs to be level-shifted down to 3.3v before connecting to the Teensy, so the QH line (MISO5v) first passes through one channel of a 74LVC125 3-state buffer (with the enable line controlled by the pin 30 chip select). Note: the Teensy is actually 5v-tolerant. Under normal circumstances this level shifting would not be required. However, the 74HC595 shift registers share the MISO line with the Feather bus, which is not 5v tolerant; hence the need for the level shift. Reading the data from the shift registers is a simple matter of pulling the chip select line (pin 30) low, pulsing (low) the SH/LD’ pin (31), and then using the SPI bus to shift in 48 bits. Because the 74HC595 ICs are fast, they can easily handle 20MHz on the SPI clock (probably even better, though 20 MHz is a good upper limit for the Teensy).

Note that the Bank/bit connections to the 74HC595 shift registers were made to produce cleaner traces on the PCB rather than associate particular input bits on the PCB to matching inputs on the ICs. Simply shifting in 48 bits from the shift register will not produce the bits in the order labelled on the PCB. Instead, software will have to shift the bits around to put them in their proper locations. The priority here was to reduce hardware vias on the PCB, not make the software easier to write (or understand).

To allow the shift register inputs to work with dry contact inputs (i.e., non-powered devices such as switches or relay contacts), the EtherPort DIN board includes holes for 1×9 SIP resistors (eight 10kΩ resistors per SIP). The SIPs provide pullup power for the following inputs:

DIPPorts
SIP-1Bank 0, bits 0-7
SIP-2Bank 0, bits 8-11; Bank 1, bits 0-3
SIP-3Bank 1, bits 4-11
SIP-4Bank 2, bits 0-7
SIP-5Bank 2, bits 8-11, Bank 3, bits 0-3
SIP-6Bank 3, bits 4-11

 

The Robotdyn W5500 Ethernet Module will actually work off 5v or 3.3v. However, to avoid problems the EtherPort DIN board only runs 5v to the connector for this device. The MOSI, chip select (pin 29), and clock pins are all 3.3v going to the Ethernet module (which is fine, that’s still TTL compatible). As for the shift registers, the MOSI signal coming back from the Robotdyn board has to be level shifted from 5v down to 3.3v (also using one of the channels on the 74LVC125 IC). You can wire up a different W5500-based Ethernet board to the EtherPort DIN; the +5v, Gnd, MOSI, MISO, SCK (SPI-CLK), and CS lines are clearly labelled next to the holes on the EtherPort PCB. You could even run a 3.3v version by running a jumper wire from the 3.3v output on the Teensy 3.2 to the power supply on your device (running the 3.3v output through the 74LVC125 won’t matter). Two sets of W5500 connectors were placed on the board to allow mounting the Ethernet module on the top or bottom of the board.

As a general rule, Plantation Productions’ DAQ and EtherPort boards attempt to use through-hole ICs and parts. SMT devices are usually put on breakout boards so they can be (more) easily removed from a PCB, if necessary. The 74LVC125, sadly, is only available in an SMT package (SOIC-14 for the variety used on the EtherPort DIN board). Because the IC is so cheap (well under a dollar), and it’s still easy enough to hand solder, the 74LVC125 was put directly on the EtherPort DIN PCB. If you need to remove it, a localized hot-air gun, or better yet a Chip Qwik SMD removal kit, will take it off.

The Feather bus on the EtherPort DIN is primarily intended for the Adafruit Ethernet Featherwing board (assuming a Robotdyn W5500 Ethernet module is not used). Two “canned” solutions for Ethernet were designed into the EtherPort DIN board because Robotdyn modules, being rather inexpensive, haven’t always worked. The Adafruit Ethernet Featherwing, on the other hand, has never not worked. The Feather bus also supports the Adafruit OLED Featherwing display module. The design includes four extra mounting holes for a Featherwing doubler, in case the need arised to install both an OLED display and an Ethernet Featherwing. Other possible Featherwing modules, such as the data logger or real-time clock, are generally stackable; therefore, no attempt was made to allow the installation of anything bigger than a doubler.

On most EtherPort boards (including the DIN), every attempt is made to leave the general-purpose analog and digital I/O pins unused. Except for the SPI and I2C bus pins (SDA, SCL, MOSI, MISO, and SCK) the Feather bus pins are left alone for Featherwings (wherever possible). For digital I/O lines, the EtherPort DIN uses the non-Feather I/O pins found on the Teensy 3.2.

One question I’ve been asked about this board: “Why didn’t you just use three MCP23s17 GPIO ICs?” The answer is simple: I wanted a board that does only inputs and can’t be reprogrammed (e.g., via noise on a reset line) during the middle of an operation. I learned this the hard way using PPDIO96 boards on the Plantation Productions’ DAQ system. I was using PPDIO96 boards to read inputs from field wiring on a TRIGA nuclear reactor; some relays clicked and sent a noise spike along the reset line to the MCP23S17 ICs and reprogrammed the inputs during the middle of the reactor operation (SCRAMming the reactor). Needless to say, this was a big deal. I was able to hack up the reset line and add sufficient filtering to prevent the noise from creating future problems, but I learned a good lesson from this ordeal: if you only need digital input lines, use the simplest circuit you can come up with to achieve the goal. The MCP23S17 is a wonderful (-ly complex) chip. But if you don’t need the features, don’t use it.

That said, an EtherPort GPIO board (using MCP23s17 ICs) probably would be a good thing to have and I’ll probably build one at some point in the future (with a nice fat filter on the reset line). For the time being, however, the EtherPort DIN, DOUT, and HCDOUT boards do the job they need to do without any unnecessary bells and whistles that have unintended consequences attached to them.

 

Software Design Notes

The standard firmware running on the has a couple of important defines and variables that must be set when compiling the code:

  • #define EthCS (xx): This should be set to either “(cs)” (for an Adafruit Ethernet Featherwing) or to “(W5500pin)” (for a Robotdyn W5500 Ethernet module). If you wire up a different module, you should also use the “(W5500pin)” define and use the chip select (pin 29) set aside for the W5500.
  • #define readingSpan (16): This defines the number of past readings in the history queue. Sixteen is probably a good maximum number for the history queue; eight is probably a good minimum. The software reads the ports every 10 milliseconds, so having a history queue of 16 keeps readings for the past 160 milliseconds. This is also the time multiple upon which debouncing occurs. For example, with the default debounce setting of 3, the debounce time is 30 milliseconds (meaning the system must see the same value on a pin for 30 milliseconds before it will pass it to a host requesting the data). The readingSpan equate also determines how far in the past the “Any 1” or “Any 0” filters will look for a ‘1’ or ‘0’ bit (respectively).
  • int debounceCnt = 3: This is the default debounce count when the system powers up. Minimum is 2. A reasonable value (unless you’ve got really noisy inputs) should be between 3 and 5.
  • #define baseIP2ndB 2: The EtherPort DIN responds to IP address 192.168.x.y. The x byte is specified by the baseIP2ndB define (default is 2). If you want to change this to some other value, change the define for baseIP2ndB. Note: most Plantation Productions’ software expects the second byte to be 2. Think carefully before changing this value as you might make the EtherPort DIN firmware incompatible with other Plantation Productions’ devices and firmware.
  • #define baseIPadrsLOB 10: The low-order byte of the IP base address defaults to this value (10 is the standard default). Note that the firmware reads DIP switches 1 through 4 and adds this 4-bit value to the LO byte. This allows multiple EtherPort DIN boards in the system (without modifying the firmware). Because it’s possible to enter 15 on the DIP switches, the default LO base byte value must be 240 or less.
  • #define usbDebug 0: This define should be 0 for standard firmware builds. If it is non-zero, then the firmware writes debug information to the Arduino Serial device (i.e., the USB port) during operation. For testing purposes, this output is useful. However, if you’ve enabled the USB port for host communication purposes, this debug information may interfere with the operation of the host software.
  • Because of the way the PCB was laid out, the incoming bit stream from the shift registers does not match the bit assignments on the Bank 0, 1, 2, and 3 pins. The software has to map the incoming bits as follows:
Incoming Bit Position from Shift Register
Final Bit Position
0
4
1
6
2
8
3
10
4
11
5
9
6
7
7
5
8
21
9
23
10
1
11
3
12
2
13
0
14
22
15
20
16
13
17
15
18
17
19
19
20
18
21
16
22
14
23
12
24
28
25
30
26
32
27
34
28
35
29
33
30
31
21
29
32
44
33
46
34
24
35
26
36
27
37
25
38
47
39
45
40
36
41
38
42
40
43
42
44
43
45
41
46
39
47
37

COMMENTS

Please Login to comment
  Subscribe  
Notify of
POSTED BY
SELLER
Link Location E-mailhttps://www.randallhyde.com