Human-Machine Interface for Din Box
Hmi4DinBox is a human-machine interface designed to be implemented on the front of a DIN rail enclosure.
Its features are as follows :
HIRQ
which indicates that one or
more actions have been performed on the navigation button (key presses and
releases in the 5 directions stored in a buffer), Published in open-source hardware, it comes with :
The HMI is connected to your board by the 5-pin J1 MOLEX KK254 connector on the back of the PCB.
The pinout of the J1 connector is as follows :
# | Name | Description |
---|---|---|
1 | VCC | 5V or 3.3V power supply, protected against overvoltages and polarity inversions |
2 | SCL | I2C clock, no pull-up resistance on this line ! put one on the master board ! |
3 | SDA | I2C data, no pull-up resistance on this line ! put one on the master board ! |
4 | HIRQ | Indicates that one or more actions have been performed on the navigation button |
5 | GND | Ground |
HIRQ
is in the high state as long as there are unread actions in the buffer (capacity of 32 actions).
It goes low when all actions have been read with key()
.
This library allows the client-side control of the Hmi4DinBox connected by an I2C bus. It is intended to be used in an Arduino environment (also compatible with the PiDuino library on Pi boards such as Raspberry Pi or NanoPi).
To install the library for Arduino IDE, simply download its zip file and integrate it into your sketch according to explanations on the Arduino site.
At the beginning of the file Hmi4DinBox.h, we see the definition of constants describing the hardware solution:
#define LED1 0
#define LED2 1
#define LED3 2
#define LED4 3
#define LED5 4
We have 5 leds, the numbering starts at 0.
#define LED_RED LED1
#define LED_GREEN1 LED2
#define LED_GREEN2 LED3
#define LED_YELLOW1 LED4
#define LED_YELLOW2 LED5
We define more explicit constants corresponding to the colors of the leds: the led N° 1 is red, the N° 2 and 3 green ...
Then we find the constants for the keyboard function:
#define KUP 1
#define KDOWN 2
#define KLEFT 3
#define KRIGHT 4
#define KCENTER 5
We have 5 keys corresponding to the 4 directions of the navigation button and the center button.
To use this HMI in a program, you must declare a global variable of type Hmi4DinBox:
Hmi4DinBox hmi;
If one uses the navigation pad, it is necessary during this declaration to specify the number of pin Arduino used by the HMI to indicate that keys are in the internal buffer (it will thus be necessary to read them ...).
const int hirqPin = 7;
Hmi4DinBox hmi (hirqPin);
Then we can access:
hmi.lcd
,hmi.led
,hmi.keyb
,hmi.backlight
.The WireLcd class is derived from the Print class.
You can then use the print()
, println()
, write()
functions:
int i = 5;
hmi.lcd.print("Helloworld ! ");
hmi.lcd.println(i++);
hmi.lcd.write('C');
To clear the screen:
hmi.lcd.clear();
To move to the beginning of line 2:
hmi.lcd.setCursor (1, 0);
To return to the top right:
hmi.lcd.home();
To turn off the display:
hmi.lcd.noDisplay();
To turn on the display:
hmi.lcd.display();
To turn on the cursor:
hmi.lcd.cursor();
To turn off the cursor:
hmi.lcd.noCursor();
To enable cursor blinking:
hmi.lcd.blink();
To disable cursor blinking:
hmi.lcd.noBlink();
The contrast of the LCD can be changed, the value can vary from 0 to 63:
hmi.lcd.setcontrast (24);
The contrast can also be read and adjusted in relation to the current value:
byte c = hmi.lcd.getcontrast();
hmi.lcd.adjcontrast (-1); // decrement the contrast value by 1
You can watch the sketch HelloWorld.ino:
As can be seen in the sketch LedDemo.ino:
hmi.led.set (LED1);
turn on the LED1,
hmi.led.clear (LED1);
turn off the LED1,
hmi.led.toggle (LED1);
toggles the state of LED1,
hmi.led.get (LED1);
read the state of the LED1,
The hmi.led.writeAll ()
function allows you to modify all leds at the same time.
By default, a call to this function without parameters turns on all leds.
If we pass him a parameter, that corresponds to the state of the leds.
Bit 0 of this parameter is used to control LED1, bit 1, LED2 ...
As can be seen in the sketch KeyboardDemo.ino:
hmi.keyb.available ()
to test if keys are available for reading,
key = hmi.keyb.key ();
allows you to read the next key,
hmi.keyb.released ()
lets you know if this key has been released and,
hmi.keyb.pressed ()
if she was pressed.
As can be seen in the sketch BacklightDemo.ino:
hmi.backlight.write (bl);
allows to modify the value of the backlight (between 0 and 255), as this value is stored in EEPROM by the HMI, it is possible to read the current value thanks to:
bl = hmi.backlight.read ();
The burning of the bootloader and firmware is explained in the wiki.
Category | Quantity | Reference | Value | Order Code | Package |
---|---|---|---|---|---|
Resistors | 7 | R1,R2,R11,R13,R17,R19,R21 | 300 | 0805 | |
Resistors | 1 | R3 | 33 | 0805 | |
Resistors | 2 | R4,R9 | 1M | 0805 | |
Resistors | 1 | R5 | 10k | 0805 | |
Resistors | 2 | R6,R7 | 22 | 0805 | |
Resistors | 1 | R8 | 100k | 0805 | |
Resistors | 5 | R10,R12,R14,R18,R20 | 12k | 0805 | |
Resistors | 2 | R15,R16 | 47k | 0805 | |
Capacitors | 4 | C1,C2,C11,C14 | 1uF | 0805 | |
Capacitors | 6 | C3-C6,C8,C12 | 100nF | 0805 | |
Capacitors | 1 | C7 | 10uF | 0805 | |
Capacitors | 2 | C9,C10 | 22pF | 0805 | |
Integrated Circuits | 1 | U1 | ATMEGA32U4 | TQFP44-12X12MM | |
Integrated Circuits | 1 | U2 | USBLC6-4 | SOT457 | |
Transistors | 1 | Q1 | BSS 316N | SOT23 | |
Transistors | 10 | Q2-Q11 | BC846B | SOT23 | |
Transistors | 2 | Q12,Q13 | DMG2305UX | SOT23 | |
Diodes | 1 | D1 | 1N4148 | SOD123 | |
Diodes | 1 | D2 | BZT52C6V8S-7 | SOD123 | |
Diodes | 1 | D3 | SMBJ5.0CA | SMB | |
Diodes | 1 | D6 | LED-RED | LED-RED | |
Diodes | 2 | D7,D10 | LED-YELLOW | LED-YELLOW | |
Diodes | 2 | D8,D9 | LED-GREEN | LED-GREEN | |
Miscellaneous | 1 | J1 | CONN-5 | CONN-5-KK254 | |
Miscellaneous | 1 | J2 | 65100516121 | MINI-USB | |
Miscellaneous | 1 | J3 | CONN-2X5 | CONN-2X5-HE14-SMD | |
Miscellaneous | 1 | K1 | SKRHAAE010 | NAV-SKRHAAE010 | |
Miscellaneous | 1 | L1 | MH2023-300Y | IND805 | |
Miscellaneous | 1 | LCD1 | MCCOG21605B6W-SPTLYI | LCD-MCCOG21605B6W | |
Miscellaneous | 19 | PT1-PT3,PT5-PT20 | TEST-POINT | CONN-1-VIA | |
Miscellaneous | 1 | PT4 | TEST-POINT | TP-TAB37800868 | |
Miscellaneous | 1 | X1 | 16M | HC-46X |
Name | Size | # Downloads |
---|---|---|
hmi4dinbox-firmware.project | 6.18 kB | 372 |
hmi4dinbox-layout.pdf | 974.19 kB | 208 |
hmi4dinbox-pcb.pdf | 65.38 kB | 235 |
hmi4dinbox-sch.pdf | 364.81 kB | 374 |
hmi4dinbox.project | 6.42 kB | 355 |
keywords.txt | 1.5 kB | 253 |
library.properties | 270 B | 278 |
test_backlight.project | 5.28 kB | 378 |
test_button.project | 5.28 kB | 358 |
test_delay.project | 5.27 kB | 410 |
test_lcd.project | 5.25 kB | 418 |
test_led.project | 5.27 kB | 402 |
test_task.project | 5.25 kB | 375 |
Name | Size | # Downloads |
---|---|---|
BacklightDemo.ino | 1.39 kB | 309 |
FullTest.ino | 6.44 kB | 294 |
HelloWorld.ino | 963 B | 282 |
Hmi4DinBox.cpp | 2.7 kB | 253 |
Hmi4DinBox.h | 1.92 kB | 264 |
KeyboardDemo.ino | 1.45 kB | 339 |
LcdContrast.ino | 1.39 kB | 303 |
LedDemo.ino | 1.79 kB | 288 |
Makefile | 5.74 kB | 290 |
WireHmi.cpp | 8.46 kB | 294 |
WireHmi.h | 3.07 kB | 305 |
WireLcd.cpp | 6.89 kB | 300 |
WireLcd.h | 1.61 kB | 294 |
avrio-board-button.h | 2.88 kB | 245 |
avrio-board-kernel.h | 3.5 kB | 299 |
avrio-board-lcd.h | 8.96 kB | 267 |
avrio-board-lcdbacklight.h | 1.39 kB | 277 |
avrio-board-led.h | 2.6 kB | 256 |
avrio-board-serial-sw.h | 3.45 kB | 287 |
avrio-board-serial.h | 1.83 kB | 267 |
avrio-board-tc.h | 1.54 kB | 325 |
avrio-board-twi.h | 3.71 kB | 285 |
avrio-config.h | 1.52 kB | 280 |
backlight.h | 1.08 kB | 273 |
button.c | 2.71 kB | 277 |
button.h | 608 B | 272 |
config.h | 1.3 kB | 255 |
hirq.h | 914 B | 294 |
hmi.c | 7 kB | 249 |
hmi.h | 966 B | 282 |
hmi4dinbox-firmware.hex | 6.39 kB | 247 |
led.c | 1.22 kB | 262 |
led.h | 551 B | 206 |
main.c | 425 B | 229 |
test_backlight.c | 1.16 kB | 195 |
test_button.c | 677 B | 213 |
test_delay.c | 677 B | 247 |
test_lcd.c | 1.44 kB | 205 |
test_led.c | 540 B | 275 |
test_task.c | 1.32 kB | 208 |
version.h | 178 B | 224 |