It uses the config node “mcp_pcf_chip” for all reading and writing on i2c bus
More about I2C…
msg.pin
and msg.state
if msg.payload=-1
On=green
Off=grey
Uninitialised=yellow
Error=red
Requires ‘i2c-bus’ module. link…
( It gets automatically installed, except if you want to use it directly from function nodes. )
WARNING: input interrupts part of this component is experimental.
Each node has a global Main-Chip, that can be configured with “I2C bus number” + “Chip Address”. (The PCF8574(A) chips are showed currently with an Address multiplied by 2. Like: 0x21 * 2 = 0x42 )
Interval: is used to determine how frequently all inputs are polled. ( Reads all 8+8 ports from bank A+B. )
! Should be minimum 20ms, because a read process of 16 pins takes 12-14ms on a Raspberry Pi 4.
Bit: is a number from 0 to 15 reflecting the pin (0-7 at FCP8574 chips) If “All0” or “All1” is recieved, the bit becames: -1 in logs.
Pull Up: engages the low power pull up resistor. More: https://en.wikipedia.org/wiki/Pull-up_resistor
(Inputs only.)
Debounce: is a timer where the state must remain at the new level for the specified time (millisec)
(Inputs only.)
( It will filter out too short changes, like sparkles. )
Invert is a software-override for both Input + Output pins. It will show and act the opposite way of On/Off.
0>>1 , 1>>0
( For example some relay boards are “closing = pulling” if they get GND instead of 5V on their pins,
so they need to be negated with resistors. In those cases the chip must get 0x00 to “turn on”. )
Start All Outputs High: when node-red is started and first chip gets inicialized, it will send a 0xFFFF signal to all pins, so they
Thanks to Mike Wilson for the original v0.1 node: MCP23017chip
by László Szakmári (www.pizzaprogram.hu)
mcp-pcf-aio.js
file at 50. line.
Added require(“worker_threads”) dependency;by László Szakmári (www.pizzaprogram.hu)
by László Szakmári (www.pizzaprogram.hu)
by László Szakmári (www.pizzaprogram.hu)
WARNING! Naming of commands and msg values changed !!! (No more Capital beginnings.)
"All0"
-> "all0"
"All1"
-> "all1"
msg.AllStatesRaw
-> msg.allStatesRaw
… also fixed name convention at source code, like OnOFF
-> on_off
Read more here
If read-interval is set to 0 it will clear any running timer.
by László Szakmári (www.pizzaprogram.hu)
BUG Fix: Too long read time caused a (.warning) error instead of increasing the timer interval x2.
Enh.: If the last read time is shorter than interval, it resumes the timer at original interval.
by László Szakmári (www.pizzaprogram.hu)
PCF chips show now correct Address -at Main-Chip setup. Fixed.
Fixed “interval too short” auto-increase happaning if “interrupt-triggered” read occures
Added examples
by László Szakmári (www.pizzaprogram.hu)
msg.pin
and msg.state
to lower case.by László Szakmári (www.pizzaprogram.hu)
you can set 1-1 node only pro 0-7 or 8-15 and control via msg.Pin=
and msg.State=
if msg.Payload=-1
fixed consol.warning
bug if Timer set = 0ms.
by László Szakmári (www.pizzaprogram.hu)
by László Szakmári (www.pizzaprogram.hu)
FIRST OFFICIAL RELEASE
Enhanced html help of the node
fixed bugs (like: partial Deploy did not clear prev. instances from context)
by László Szakmári (www.pizzaprogram.hu)
Added PCF8574 + PCF8574A chip support. Both In + Out.
Fixed Naming of PFC… to PCF… (the original code was spelled wrong!).
Detailed Logging to consol can be turned on/off with const log2consol = False;
and timerLog = false;
Fixed Input Bugs. Now stable.
Fixed bug if same chip had both in+out pins mixed.
Fixed crashing of Node-red if chip or I2C bus was suddenly removed from system.
Inject (Interrupt) trigger adds extra values to msg. [] … see help
New Github upload. (PFC false-named one got deleted)
by László Szakmári (www.pizzaprogram.hu)
!!! IMPORTANT CHANGE: – [ x ] Inverse is now affecting Output too ! (Some relay boards are functioning “the opposite way”, turning ON if pin is Low.)
Changed Bus open/close behaviour. Separate open before/after each read/write operation block. (This way no more non-stop opened bus > no more NodeRed crash if unexpected disconnect.)
Fixed other NR crashes: Added Error handling (try - catch) for each i2c bus operation.
Each operation has it’s own value to report proper error text. (Like: “Bus opening failed”, … etc)
(But execution time increased from 8ms to 12ms on Raspberri 4)
Fixed 16pin array initialization (16x null)
Added multiple/same pin initialization error handling. (Highlander: “There Can Be Only One” :-D )
Added lots of comments and constants to JS file (like IOCON, IODIR_A, etc…)
Changed icon to a chip-like one. (font-awesome/fa-ticket)
Faster initialisation: if set to output » skips pullup & invert writes.
Prevents the input-timer to run if the previous function is still running.
+2 states of a node and color change of Off: On=green Off=grey Uninitialised=yellow Error=red
Does not starting input-timer, if there are no input nodes available.
Auto-increasing read-interval if < 15ms or if reading took too long.
If error occured during read-timer » changing interval to 5 sec » if normal again » changing back
Dokument + Code changes: – Pretty print of JS code (inline) – All local variables start now with _underline – Many comments + constants + references added to code – Fixed help in mcp_pcf_chip.html file
Fixed input
msg.immediateReadSuccess = true. If any error:Result = false
Limit debounce timeing to max = interval - 20ms