In this tutorial you will see how to access the available pins of your device as variables, you will create a Pin Map Table, configure it and interact with the pins from your PLC programs.
A mapping table is a table that links a source, like the memory address of an I/O, and its target name which functions as an alias. For example, if a microcontroller has an I/O with the name
, a mapping table can be used to access that resource with the name
If you are familiar with the C languages, it is similar with the way a pointer works.
Using mapping tables makes your programs easier to read, which is always a good practice for long-term maintenance.
Remember to connect the 24V input on the device to see the status LEDs of the digital outputs. The LEDs indicate if the output is HIGH, which means it is delivering out power. If you do not connect the 24V DC Supply you will not be able to see the state of the pins, as they are being controlled by the microcontroller but they are not delivering power.
First of all, open the Arduino PLC IDE and create a new project (or open an existing one).
Navigate to the Resources tile window, you will see a list of the available mappings for your device, in the case of the Portenta Machine Control you have:
Each element of the table contains the Variable cell to define a variable in which the data or status of the pin is going to be stored.
To create a variable for a pin map you have two options:
By default they are not available as variables, in any case, you can get the values by accessing their memory registers, which is not as easy as having variables with the data.
Double-click the Pin Map that you want to edit, for example, the Digital Output table.
To assign a new variable you can type the name on the variable column, if it is new it will be automatically created if it exists it will change its value to the pin's state.
We will assign to the Digital Output pin 2 the name
To interact with the digital output pin you can use this code:
1// Set the Digital Output 01 to HIGH23digitalOut01 := 1;
Go to your project tile window, and right-click on the Global Variable element.
Navigate to New Variable > Mapped Variable.
Now on the popup menu, you can set the name of the variable, then select the type of pins that are going to contain scroll on the Location section, and you will see several types of pins, we will select the System Digital OUTPUTS and name it as
As it is an array you will be able to access its pin in a For loop like the following:
1// Set all the Digital Outputs to HIGH23FOR pinNumber := 0 TO 7 DO4 digitalOut[pinNumber] := 1;5END_FOR;
Now that you've learned how to assign Pin Maps, you could: