We will now look at the P1AM Arduino expansion analog modules. This analog expansion is part of the P1000 cards that the P1AM Arduino can use as it’s inputs and outputs. The productivity open P1AM I/O interface chip-set supports the full suite of Productivity 1000 I/O expansion modules. These modules are industry approved and proven in the industrial environment. Modern industrial signal levels for digital and analog inputs and outputs are used.
P1000 modules available to you include the following:
• Discrete
• Analog
• Temperature
• Relay
• High-speed Input
• PWM
We will be wiring and programming our P1-4ADL2DAL-1 combination analog input and output module that came with the P1AM-START1 ProductivityOpen starter kit with Ethernet. Let’s get started.
Previous posts in this Productivity Open Arduino Compatible Industrial Controller Series
A full list can be obtained at the following location:
Productivity Open (P1AM-100) Arduino Controller
Productivity Open Arduino Controller Hardware
– Starter Kit Unboxing Video
– Powering Up Video
Installing the Software – Video
First Program – Video
Program Structure – Video
Variables Data Types – Video
Serial Monitor COM – Video
Program Control – Video
Operators – Video
GPIO Inputs and Outputs – Video
Math Instructions – Video
Time Instructions – Video
Watch the video below to see the wiring and sample program (sketch) using the P1000 analog combination module on our productivity open industrial arduino controller.
P1AM CPU Base LED
When this LED is on it indicates the Base Controller is powered and has been initialized by calling P1.init().
Note: External 24V or a P1000 Series power supply must be used for the Base Controller and modules to be powered.
P1-4ADL2DAL-1 Analog Expansion Combination Module
The P1000 P1-4ADL2DAL-1 analog expansion module has 4 input channels (points) with a range of 0 to 20mA. These 13-bit inputs have a resolution of 0 to 8191. This means that the input signal is divided up into 0.00244mA signal steps.
The module also has 2 output channels (points) with a range of 4 to 20mA. 12-bit resolution is used which is 0 to 4095. The output can be controlled in 0.00391mA increments.
P1-4ADL2DAL-1 Analog Expansion Wiring
An external 24VDC supply must be wired to the module directly as seen in the above diagram. We will wire this directly from our 24VDC supply unit. A connector will be used for the +24VDC side so we can demonstrate when this supply is lost on the module.
See the video below.
Here are the specifications for the unit.
Our first input I1 (2) will be connected to our analog input tester that we have discussed and made previously.
Analog Voltage Tester – Video
The first output I1 (7) will be wired directly to I2 (3) input.
P1AM Arduino Expansion P1000 Analog IO Sample Program
Our sample program (sketch) will see if the switch on the CPU is on. If it is then it will take our first analog input (Analog tester – 0-20mA) and print this to the monitor. This 13-bit analog input will then be scaled to a 12-bit analog signal and outputted to the fist analog output. We will then read the analog input from the second analog input. This is the signal directly wired from the first output. The second analog input (4-20mA) will be read and scaled from 0 to 100 representing a percent. This will be also written to the monitor.
If the switch is off then we will print the P1000 expansion modules connected to the monitor and also display if we have any errors. This will include the 24VDC supply to the analog card and over/under signals for the inputs.
The use of P1 expansion modules is set to true. This will put in the library for the P1AM and P1_HSC. The monitor will be configured using 115200 baud, 8N1. We will also set a Boolean variable (on/off) to High.
#include <P1AM.h> #include <P1_HSC.h> /****************************************************************************************** * Automationdirect.com * This version of ProductivityBlocks supports P1AM-100 Library V1.0.0 * To download this library, please visit https://github.com/facts-engineering/P1AM * For information on the P1AM-100 hardware, please visit https://www.automationdirect.com ******************************************************************************************/ bool _PBVAR_1_One_Shot= false ; boolean __proBlocksDigitalRead(int pinNumber) { pinMode(pinNumber, INPUT); return digitalRead(pinNumber); } int _PBVAR_2_Integer_Variable = 0 ; int _PBVAR_3_Slot1Lost24V = 0 ; int _PBVAR_4_Slot1UnderRangeError = 0 ; int _PBVAR_5_Slot1OverRangeError = 0 ; void setup() { Serial.begin(115200); while(!P1.init()) { } Serial.begin(115200, SERIAL_8N1); _PBVAR_1_One_Shot = HIGH ; }
When the CPU switch is on we will read the analog signal from slot 1 point 1 into an integer variable. This is the first analog input. We will then print this on the monitor. The input signal will be 0 – 20 mA = 0 to 8191. This is a 13-bit resolution signal.
Using the Set Analog block we output this integer variable after it is scaled. (0 – 8191 (13-bit) to 0-4095 (12-bit))
The map instruction block is then used again to scale the second analog input into a percentage. (0-100) Our first output is a 4-20mA signal (1638 to 8191) wired to the second analog input 0-20mA. This percentage is then printed to the monitor.
The boolean one-shot variable is set to High. (reset)
void loop() { if (__proBlocksDigitalRead(31)) { //Read Analog Input - 0-20mA - 13 bit resolution _PBVAR_2_Integer_Variable = P1.readAnalog(1, 1) ; Serial.print(_PBVAR_2_Integer_Variable); //Set Analog output - 4-20mA - 12 bit resolution P1.writeAnalog(map ( _PBVAR_2_Integer_Variable , 0 , 8191 , 0 , 4095 ) , 1, 1); Serial.print("_ Scaled Percent (%) ="); //Scale the second input being fed from the first as a percent. 4-20mA to 0-20mA Serial.println(map ( P1.readAnalog(1, 2) , 1638 , 8191 , 0 , 100 ) ); _PBVAR_1_One_Shot = HIGH ; }
When the CPU switch is off then we will set the one-shot variable to low. Then will ensure that we will perform the following function once when the CPU switch turns off.
Use the print modules block to print the P1000 expansion modules that are attached to our system.
The read status block is used to determine the status of the attached I/O cards. Here are the status bytes available for the analog combination module.
We will read these status bytes into variables. If an error or lack of 24VDC is detected then this will be printed to the monitor.
else { if (_PBVAR_1_One_Shot) { _PBVAR_1_One_Shot = LOW ; P1.printModules(); _PBVAR_3_Slot1Lost24V = (int)P1.readStatus(3, 1) ; _PBVAR_4_Slot1UnderRangeError = (int)P1.readStatus(7, 1) ; _PBVAR_5_Slot1OverRangeError = (int)P1.readStatus(11, 1) ; if (( ( _PBVAR_3_Slot1Lost24V ) == ( 2 ) )) { Serial.println("Slot 1 has lost 24VDC supply."); } if (( ( _PBVAR_4_Slot1UnderRangeError ) > ( 0 ) )) { Serial.println("Slot 1 has an under range error." + String(_PBVAR_4_Slot1UnderRangeError)); } if (( ( _PBVAR_5_Slot1OverRangeError ) > ( 0 ) )) { Serial.println("Slot 1 has an over range error." + String(_PBVAR_5_Slot1OverRangeError)); } } } }
Our program is complete.
Click the verify button in productivity blocks to compile and translate our program to the C++ code for our P1AM-100 CPU.
Note: You can also choose upload in productivity blocks to automatically compile and upload in one step.
Once the arduino software (IDE – integrated development environment) is finished compiling, select the upload button to send the program to our P1AM CPU.
Once the upload to the P1AM Arduino CPU is complete, we can select the serial monitor.
When the CPU switch is on will see our screen updating with our analog input 1 and scaled analog input 2 percentage. If we disconnect the 24VDC supply from the analog combination card the input will go to 0.
When the CPU switch is off the modules connected and any error status will be displayed on the monitor. In our case the message Slot 1 has lost 24VDC supply will be displayed.
Watch the video below to see the operation of our sample time program with the productivity open industrial arduino controller.
Download the P1AM-100 sample sketch and Productivity Block program here.
Productivity Open Arduino Compatible Links:
Product Hardware
– Productivity Open (Automation Direct)
– P1AM-100 Specifications
– Productivity Open User Manual
– Configure a Productivity Open Arduino-based Controller
– Open Source Controllers (Arduino-Compatible)
– Productivity Open Documentation (Facts Engineering)
– P1AM Design Files
Software
– Arduino IDE (Integrated Development Environment)
– P1AM-100 library (Easy Interface for controlling P1000 Modules)
– Productivity Blocks (Development Timesaver)
– Productivity Blocks Documentation (Wiki)
Community
– Automation Direct Forum – Open Source Devices
Next time we will look at the P1000 Expansion Digital Inputs and Outputs on our P1AM-100 Arduino Industrial Controller.
Watch on YouTube: Productivity Open P1AM Industrial Arduino P1000 Expansion Analog Combination Module https://youtu.be/f7myzcPP0_8
If you have any questions or need further information please contact me.
Thank you, Garry
If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII, and Floating Point. To get this free article, subscribe to my free email newsletter.
The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.
Excellent. Gary, please email me!
Hi Dr.G
Thanks for the comment.
Garry