This tutorial is focused on illustrating the hardware aspects of the ISOIOM17427 Isolated I/O module specifically accessing the control registers to manipulate the relays, read the input port status and modify the LED color.
This tutorial assumes you're somewhat familiar with the Raspberry Pi and have setup the NodeJS environment. All the code in this tutorial is written in JavaScript and will utilize the à la mods "comm" library (alamods-comm.js) to simplify reading and writing the modules internal registers.
The .js source file can be downloaded here.
We need to load the à la mods "comm" library first before we begin working on the app. To get the à la mods "comm" library and install it run the following commands from the home directory. This will retrieve the compressed library file, extract all the files into its directory structure and then using "npm" install all the NodeJS dependency modules.
Another method of getting the à la mods "comm" library is via the "software" section within the resources page of the website.
One more general thing to do before we get into the actual application. We need to setup the file structure for NodeJS development. When running "npm init" you can use the defaults to most of the questions.
Once that is complete we can develop an app that runs on the Raspberry Pi to control the I/O and LED of the ISOIOM17427 module. If you're developing this directly on the Raspberry Pi you can use "nano" or your favorite editor.
Add the following code:
When the app file is completed save it and run the following command:
The output on the terminal should be 17427 on the first line then the value of the digital inputs every second. In addition the LED should be flashing and the relays toggling every second.
You must run the app as root (using "sudo") because the hardware access to the serial buses SPI/I2C are through "/dev/mem" and not "/dev/gpiomem" which is required to be run as root.