User Tools

Site Tools


home:mbhp:module:din

This is an old revision of the document!


About

A DIN module is used to connect buttons and encoders to the Midibox. The Name comes from “Digital Input” and means that the module can detect two states: ON or OFF. It then sends this information to be processed by the mbhp core module.It comes with multiple serial registers 74HC165; every register provides 8 digital inputs, which are sampled with the latch enable signal LD and shifted out with the clock signal CLK. The advantage of using such shift registers is, that they can be cascaded to a long chain without the need of more than 5 cables to the core module. The DIN board has been designed on a way which allows to cascade not only the ICs on the board, but also several DIN modules. But note that it depends on the firmware how much inputs are processed by the core module. For instance, the MIDIbox64 allows to connect up to 64 buttons = 8 ICs = 2 * DINX4, the MIDIO128 supports 128 inputs = 16 ICs = 4 DINX4 modules.

Getting Started

Special Instructions

Details

Pins

DIN & DOUT pin-numbers

The following table shows the relation between pin- and serial-register-numbers on the software side, and physical pins and their labeling on the hardware side. Shiftregisters are always counted from 1 (also on the software-side), and pins are always counted from 0.
Please note that the order of DOUT pins is reversed compared to DIN pins. For a deeper explanation of this issue, refer the information after the table.

Pin table

Shift Register SR number Pin Number (sw) Pin Hex number (sw) Pin Name (DIN PCB / SR IC) Pin Name (DOUT PCB / SR IC)
first100x00D0 / QAD7 / H
first110x00D1 / QBD6 / G
first120x00D2 / QCD5 / F
first130x00D3 / QDD4 / E
first140x00D4 / QED3 / D
first150x00D5 / QFD2 / C
first160x00D6 / QGD1 / B
first170x00D7 / QHD0 / A
second280x0 8D0 / QAD7 / H
second290x0 9D1 / QBD6 / G
second2100x0aD2 / QCD5 / F
second2110x0bD3 / QDD4 / E
second2120x0cD4 / QED3 / D
second2130x0dD5 / QFD2 / C
second2140x0eD6 / QGD1 / B
second2150x0fD7 / QHD0 / A
third3160x10D0 / QAD7 / H
third3170x11D1 / QBD6 / G
third3180x12D2 / QCD5 / F
third3190x13D3 / QDD4 / E
third3200x14D4 / QED3 / D
third3210x15D5 / QFD2 / C
third3220x16D6 / QGD1 / B
third3230x17D7 / QHD0 / A
fourth4240x18D0 / QAD7 / H
fourth4250x19D1 / QBD6 / G
fourth4260x1aD2 / QCD5 / F
fourth4270x1bD3 / QDD4 / E
fourth4280x1cD4 / QED3 / D
fourth4290x1dD5 / QFD2 / C
fourth4300x1eD6 / QGD1 / B
fourth4310x1fD7 / QHD0 / A
fifth5320x20D0 / QAD7 / H
fifth5330x21D1 / QBD6 / G
fifth5340x22D2 / QCD5 / F
fifth5350x23D3 / QDD4 / E
fifth5360x24D4 / QED3 / D
fifth5370x25D5 / QFD2 / C
fifth5380x26D6 / QGD1 / B
fifth5390x27D7 / QHD0 / A
sixth6400x2 8D0 / QAD7 / H
sixth6410x2 9D1 / QBD6 / G
sixth6420x2aD2 / QCD5 / F
sixth6430x2bD3 / QDD4 / E
sixth6440x2cD4 / QED3 / D
sixth6450x2dD5 / QFD2 / C
sixth6460x2eD6 / QGD1 / B
sixth6470x2fD7 / QHD0 / A
seventh7480x30D0 / QAD7 / H
seventh7490x31D1 / QBD6 / G
seventh7500x32D2 / QCD5 / F
seventh7510x33D3 / QDD4 / E
seventh7520x34D4 / QED3 / D
seventh7530x35D5 / QFD2 / C
seventh7540x36D6 / QGD1 / B
seventh7550x37D7 / QHD0 / A
eighth8560x3 8D0 / QAD7 / H
eighth8570x3 9D1 / QBD6 / G
eighth8580x3aD2 / QCD5 / F
eighth8590x3bD3 / QDD4 / E
eighth8600x3cD4 / QED3 / D
eighth8610x3dD5 / QFD2 / C
eighth8620x3eD6 / QGD1 / B
eighth8630x3fD7 / QHD0 / A
ninth9640x40D0 / QAD7 / H
ninth9650x41D1 / QBD6 / G
ninth9660x42D2 / QCD5 / F
ninth9670x43D3 / QDD4 / E
ninth9680x44D4 / QED3 / D
ninth9690x45D5 / QFD2 / C
ninth9700x46D6 / QGD1 / B
ninth9710x47D7 / QHD0 / A
tenth10720x4 8D0 / QAD7 / H
tenth10730x4 9D1 / QBD6 / G
tenth10740x4aD2 / QCD5 / F
tenth10750x4bD3 / QDD4 / E
tenth10760x4cD4 / QED3 / D
tenth10770x4dD5 / QFD2 / C
tenth10780x4eD6 / QGD1 / B
tenth10790x4fD7 / QHD0 / A
eleventh11800x50D0 / QAD7 / H
eleventh11810x51D1 / QBD6 / G
eleventh11820x52D2 / QCD5 / F
eleventh11830x53D3 / QDD4 / E
eleventh11840x54D4 / QED3 / D
eleventh11850x55D5 / QFD2 / C
eleventh11860x56D6 / QGD1 / B
eleventh11870x57D7 / QHD0 / A
twelfth12880x5 8D0 / QAD7 / H
twelfth12890x5 9D1 / QBD6 / G
twelfth12900x5aD2 / QCD5 / F
twelfth12910x5bD3 / QDD4 / E
twelfth12920x5cD4 / QED3 / D
twelfth12930x5dD5 / QFD2 / C
twelfth12940x5eD6 / QGD1 / B
twelfth12950x5fD7 / QHD0 / A
thirteenth13960x60D0 / QAD7 / H
thirteenth13970x61D1 / QBD6 / G
thirteenth13980x62D2 / QCD5 / F
thirteenth13990x63D3 / QDD4 / E
thirteenth131000x64D4 / QED3 / D
thirteenth131010x65D5 / QFD2 / C
thirteenth131020x66D6 / QGD1 / B
thirteenth131030x67D7 / QHD0 / A
fourteenth141040x6 8D0 / QAD7 / H
fourteenth141050x6 9D1 / QBD6 / G
fourteenth141060x6aD2 / QCD5 / F
fourteenth141070x6bD3 / QDD4 / E
fourteenth141080x6cD4 / QED3 / D
fourteenth141090x6dD5 / QFD2 / C
fourteenth141100x6eD6 / QGD1 / B
fourteenth141110x6fD7 / QHD0 / A
fifteenth151120x70D0 / QAD7 / H
fifteenth151130x71D1 / QBD6 / G
fifteenth151140x72D2 / QCD5 / F
fifteenth151150x73D3 / QDD4 / E
fifteenth151160x74D4 / QED3 / D
fifteenth151170x75D5 / QFD2 / C
fifteenth151180x76D6 / QGD1 / B
fifteenth151190x77D7 / QHD0 / A
sixteenth161200x7 8D0 / QAD7 / H
sixteenth161210x7 9D1 / QBD6 / G
sixteenth161220x7aD2 / QCD5 / F
sixteenth161230x7bD3 / QDD4 / E
sixteenth161240x7cD4 / QED3 / D
sixteenth161250x7dD5 / QFD2 / C
sixteenth161260x7eD6 / QGD1 / B
sixteenth161270x7fD7 / QHD0 / A

Numbers, labels and order of pins

Pin and SR order

For DOUT shift registers, software pin-numbers will be reflected in reverse direction on hardware level:
pin-number 0 (software level) is D7 of the first shift register (hardware level), not D0!
pin-number 15 (software level) is D0 of the second shift register(hardware level), not D7!

The first shift register is for both DIN and DOUT the one that is closest to the core on hardware level.

Labeling

In the datasheets of the shift-register IC's, D0 is often labled A / QA, D7 is labled H / QH.
In TK's layouts the labels for IC-pins are I0 - I7, O0 - 07, which corresponds to A/QA - H/QH.

DIN chain

hardware-level: CORE ← R1::qH ← R1::H ← R1 ← R1::G ….. R2::qH ← R2::H etc.
The first bit read is DIN1::I7, this goes to the MSB on software level. MSB represents the higher pin value,
so you have the same order in hard- as in software.

DOUT chain

hardware-level: CORE → R1::SER → R1::A → R1::B → R1::C ….. R2::SER → R2::A etc.
first bit pushed out is LSB of the last SR(software level), this goes to Rlast::H. Last bit pushed out is MSB of first SR (software level), this goes to R1:A. On software level, MSB represents the higher pin value, so A will represent alway the higher pin value on hw-level for DOUT chains.

Bit order

MIOS_DOUT_SRSet / MIOS_DOUT_SRGet / MIOS_DIN_SRSet / MIOS_DIN_SRGet: LSB always reflects the lowest pin number, MSB the highest pin number.

Pin mappings in software (assembler)

Sometimes the pin numbers of special DINs or DOUTs can be specified in the main.asm or setup_*.asm file of a MIOS application.

FIXME this should go in the application's user manual.

Examples

#define DEFAULT_MIDI_RX_LED 0x40        ; DOUT SR#9, pin D0
#define DEFAULT_MIDI_TX_LED 0x41        ; DOUT SR#9, pin D1
#define DEFAULT_DIN_MENU_EXEC         7       ; menu exec button assigned to DIN pin #7
#define DEFAULT_DIN_MENU_SNAPSHOT     6       ; menu snapshot button assigned to DIN pin #4
#define DEFAULT_DIN_MENU_RIGHT        5       ; NOT USED - overlayed by datawheel
#define DEFAULT_DIN_MENU_LEFT         4       ; NOT USED - overlayed by datawheel
     ;;         SR  Pin  Mode
      ENC_ENTRY  5,  0,  MIOS_ENC_MODE_NON_DETENTED   ; V-Pot 1
      ENC_ENTRY  5,  2,  MIOS_ENC_MODE_NON_DETENTED   ; V-Pot 2
      ENC_ENTRY  5,  4,  MIOS_ENC_MODE_NON_DETENTED   ; V-Pot 3
      ENC_ENTRY  5,  6,  MIOS_ENC_MODE_NON_DETENTED   ; V-Pot 4

Available Ports

Following interfaces are provided by the dinx4 module:

Name No. of pins Description
J1 5 Interface to CORE J9 (if buttons are used) and CORE J6 (if encoders are used, MIDIbox16E only). DINX4 J1 provides two power pins for 5V, 0V, the serial clock, the latch enable and the serial output of the register chain. This port can also be connected with J2 of another DINX module.
J2 5 Interface to another DINX4 module. DINX4:J2 provides nearly the same pins like J1, just only the serial output of the first IC is replaced by the serial input of the last IC. This port can be connected with J1 of another DINX module.
J3 to J9 5 These are the digital input lines, every connector comes with 4 of them and an additional pin for ground. See mbhp_dinx4_32buttons.pdf as an example how to connect buttons to these pins, and mbhp_dinx4_16enc.pdf how to connect rotary

PCB files

Schematic

List of parts

Here are suggested part numbers for various distributors for parts for the DIN board. If you find another site or dealer with a different parts list feel free add it into the list. Also if you’ve successfully used a different part from what was listed here please add the number and/or link to the list.

Part Name Description Polar soldering temp QTY Reichelt.de part# 1) Mouser.com part#
IC1-IC4 74HC165 Yes Don't! 4 74HC 165 511-M74HC165
R1-R36 Resistor 10 kOhm No ??? 36 1/4W 10k 264-10K-RC
C1-C4 Ceramic Cap 100 nF No ??? 4 Z5U-2,5 100n 80-C412C104K5R
- IC-Sockets for serial registers Yes ??? 4 GS 16 571-3902614
J* 1-row SIL Headers (50 pins) No ??? 2 STIFTL. 40G 517-6111TG
- 1-row sil female con No ??? 2 - 517-850-01-36
- Ribbon cable 3 meters No ??? 3 AWG 28-16G -

Building it

Building instructions

blah blah blah

Connection to Core Module

Check the version of your Boards; if you're using SmashTV's Core that's equipped with double rows, you can build a split-cable to connect J8/J9 to a DIN and a DOUT:


Connecting Input Devices

Testing

Testing all pins

Regardless which MIDIbox you are planning to build, you can use the MIDIO128 application to test the digital inputs of the DIN module(s)

Once MIOS and the MIDIO128 application have been uploaded, each digital input will send a Note On event (pin 1-64) or Controller Event (pin 65-128) when a button is pressed (=0V at the digital input pin), and a Note Off event (pin 1-64) or Controller Event (pin 65-128) when the button is released (=5V at the digital input pin). Rotary encoders will send two Events (because they are connected to two pins) depending on the quadrature state.

Each pin will trigger an individual note/CC number. This is the second byte of a event. The first pin will send “90 30 7F” when pressed, and “90 30 00” when released. The last 128th pin will send “B0 4F 7F” when pressed, and “90 4F 00” when released. The MIDI events can be displayed with MIOS Studio or a MIDI monitor (e.g. MIDI-Ox) The MIDIO_OUT_ENTRY definitions in midio128_presets.inc help to map the pins to the events, the DIN DOUT pin list helps to map the pin numbers to shift register pins.

Testing Shift Register Connections

If the first input pin of the first shift register (74HC165) triggers all 128 Notes at once, there is propably a problem with the Shift or Register Clock line (SC/RC signal). Both signals are driven by the core module, and they are connected to all shift registers in order to scan the chain. If these signals are not connected, or if there is a short, the core will always “see” the first digital pin, and never the remaining pins of the chain.

If some of the last shift registers cannot be scanned, it is very likely that the SC/RC line is broken, that there is a bad soldering, or similar.

Such types of errors can be located with the srio_interconnection_test application, which can be found at the MIOS download page. Step by Step instructions for the testing procedure are described in the main.asm file

Check:

  • the SC/RC output at the core module (J8/J9)
  • the SC/RC input of each DINX4 module (J1/J2)
  • the LD/CLK input of each 74HC165 (Pin #1 and Pin #2, see DINX4 schematic)

If you notice a short circuit (signals always 0V or 5V, or between these voltage levels), check the cables between the modules and especially your soldering at the bottom of the PCB. Consider also, that a PCB track could be broken or connected with another track (etching imperfection).

Connect each signle DINX4 module directly to the core in order to find the bad candidate(s).

If visual checks don't help to detect the short circuit, you could begin with a very drastic, but effective method: cut the failing track in the middle, and check if the short has disappeared. Cutting has to be repeated until you've found the cause for the failure.

Warning: Don't do this too early, this should be the last measure which normaly leads to success, but also to a bad looking PCB. After this procedure, you have to repair the track with some solder

Troubleshooting

Reference

home/mbhp/module/din.1228249534.txt.gz · Last modified: 2008/12/02 20:25 by Just Phil