<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MINI &#8211; CONTROLLINO</title>
	<atom:link href="https://www.controllino.com/category/mini/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.controllino.com</link>
	<description>Industrial PLCs &#124; 100% Arduino-compatible</description>
	<lastBuildDate>Fri, 06 Dec 2024 12:13:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.controllino.com/wp-content/uploads/2023/05/cropped-C_Logo_Filled_RGB-1-32x32.png</url>
	<title>MINI &#8211; CONTROLLINO</title>
	<link>https://www.controllino.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>OpenPLC Water Reserve Control</title>
		<link>https://www.controllino.com/water-reserve-control-system/</link>
		
		<dc:creator><![CDATA[CONTROLLINO]]></dc:creator>
		<pubDate>Sat, 30 Nov 2024 22:50:39 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[OpenPLC]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.controllino.com/?p=17463</guid>

					<description><![CDATA[Introduction This tutorial explains how to implement an automatic water reserve control system using a CONTROLLINO PLC and OpenPLC. The system monitors the water levels of a cistern (minimum level) and an elevated tank (minimum and maximum levels) to control a pump that transfers water from the cistern to the elevated tank. Additionally, manual pump [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p>This tutorial explains how to implement an automatic water reserve control system using a CONTROLLINO PLC and OpenPLC. The system monitors the water levels of a cistern (minimum level) and an elevated tank (minimum and maximum levels) to control a pump that transfers water from the cistern to the elevated tank. Additionally, manual pump control is possible using start and stop buttons.</p>



<h2 class="wp-block-heading">Prerequisites</h2>



<p>Before starting, ensure you have the following:</p>



<ul class="wp-block-list">
<li>OpenPLC software installed.</li>



<li>A CONTROLLINO PLC (any model) or a compatible PLC.</li>



<li>Sensors for water level detection:</li>



<li>Minimum level sensor for the cistern.</li>



<li>Minimum and maximum level sensors for the elevated tank.</li>



<li>Two buttons for manual control (Start and Stop).</li>



<li>Basic knowledge of ladder logic programming.</li>
</ul>



<h2 class="wp-block-heading">Step-by-Step Guide</h2>



<h3 class="wp-block-heading">Step 1: Install and Set Up OpenPLC</h3>



<ol class="wp-block-list">
<li><strong>Download OpenPLC</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Visit the <a href="https://www.openplcproject.com/">OpenPLC official website</a> and download the software.</li>



<li>Follow the installation instructions for your operating system.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Set Up the OpenPLC Environment</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Open the OpenPLC editor.</li>



<li>Configure the device by selecting your CONTROLLINO model in <strong>Settings &gt; Device</strong>.</li>



<li>Assign the correct COM port for communication with the PLC.</li>
</ul>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://github.com/CONTROLLINO-PLC/OpenPLC_examples/tree/master" target="_blank" rel="noreferrer noopener">Controllino&#8217;s OpenPLC repository</a></div>
</div>



<h3 class="wp-block-heading">Step 2: Configure System Inputs and Outputs</h3>



<p>Define the following inputs and outputs in your ladder logic program:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th><strong>Name</strong></th><th><strong>Type</strong></th><th><strong>Description</strong></th><th><strong>Pin</strong></th></tr></thead><tbody><tr><td><code>Pool_Low_Level_Sensor</code></td><td>BOOL</td><td>Indicates the minimum water level in the cistern.</td><td><code>%IX0.0</code></td></tr><tr><td><code>Tank_High_Level_Sensor</code></td><td>BOOL</td><td>Indicates the maximum water level in the tank.</td><td><code>%IX0.1</code></td></tr><tr><td><code>Tank_Low_Level_Sensor</code></td><td>BOOL</td><td>Indicates the minimum water level in the tank.</td><td><code>%IX0.2</code></td></tr><tr><td><code>Automatic_Manual_Switch</code></td><td>BOOL</td><td>Switch for selecting automatic or manual mode.</td><td><code>%IX0.3</code></td></tr><tr><td><code>Stop_Button</code></td><td>BOOL</td><td>Push button to stop the pump manually.</td><td><code>%IX0.4</code></td></tr><tr><td><code>Start_Button</code></td><td>BOOL</td><td>Push button to start the pump manually.</td><td><code>%IX0.5</code></td></tr><tr><td><code>Water_Pump</code></td><td>BOOL</td><td>Output controlling the water pump.</td><td><code>%QX0.0</code></td></tr></tbody></table></figure>



<h3 class="wp-block-heading">Step 3: Program the Ladder Logic</h3>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://github.com/CONTROLLINO-PLC/OpenPLC_examples/tree/master/water_control">Download OpenPLC project here</a></div>
</div>



<ol class="wp-block-list">
<li><strong>Automatic Mode</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>The pump (<code>Water_Pump</code>) is activated automatically when:
<ul class="wp-block-list">
<li>The cistern is above its minimum level (<code>Pool_Low_Level_Sensor</code> is active).</li>



<li>The tank is below its minimum level (<code>Tank_Low_Level_Sensor</code> is active).</li>
</ul>
</li>



<li>The pump is deactivated when:
<ul class="wp-block-list">
<li>The tank reaches its maximum level (<code>Tank_High_Level_Sensor</code> is active).</li>



<li>The cistern falls below its minimum level (<code>Pool_Low_Level_Sensor</code> is inactive).</li>
</ul>
</li>
</ul>



<ol class="wp-block-list">
<li><strong>Manual Mode</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>The pump can be directly controlled using the buttons:
<ul class="wp-block-list">
<li>The Start Button (<code>Start_Button</code>) activates the pump.</li>



<li>The Stop Button (<code>Stop_Button</code>) deactivates the pump.</li>
</ul>
</li>



<li>The switch (<code>Automatic_Manual_Switch</code>) must be in manual mode to enable this functionality.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Switching Between Modes</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>The <code>Automatic_Manual_Switch</code> toggles between automatic and manual modes.</li>



<li>In manual mode, sensor readings do not affect the pump operation.</li>
</ul>



<h3 class="wp-block-heading">Step 4: Connect the Hardware</h3>



<ol class="wp-block-list">
<li><strong>Wiring</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Connect the level sensors to the respective input pins.</li>



<li>Connect the Start and Stop buttons to other input pins.</li>



<li>Connect the water pump to the assigned output pin.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Pin Mapping</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Ensure that the variable names in OpenPLC match the physical connections.</li>
</ul>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="766" src="https://www.controllino.com/wp-content/uploads/2024/11/Esquema-de-conexion-1024x766.png" alt="" class="wp-image-17482" srcset="https://www.controllino.com/wp-content/uploads/2024/11/Esquema-de-conexion-1024x766.png 1024w, https://www.controllino.com/wp-content/uploads/2024/11/Esquema-de-conexion-300x225.png 300w, https://www.controllino.com/wp-content/uploads/2024/11/Esquema-de-conexion-768x575.png 768w, https://www.controllino.com/wp-content/uploads/2024/11/Esquema-de-conexion-1200x898.png 1200w, https://www.controllino.com/wp-content/uploads/2024/11/Esquema-de-conexion.png 1526w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Step 5: Test the System</h3>



<ol class="wp-block-list">
<li><strong>Load the Program</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Save your project in the OpenPLC editor.</li>



<li>Connect your CONTROLLINO PLC to the computer and upload the program.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Test Automatic Mode</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Ensure the cistern is above its minimum level.</li>



<li>Lower the water level in the tank below its minimum.</li>



<li>Observe how the pump automatically activates and fills the tank until it reaches the maximum level.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Test Manual Mode</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Switch to manual mode using the <code>Automatic_Manual_Switch</code>.</li>



<li>Press the Start Button to activate the pump and the Stop Button to deactivate it.</li>
</ul>



<h2 class="wp-block-heading">Ladder Logic Explanation</h2>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="602" src="https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1024x602.jpg" alt="" class="wp-image-17484" srcset="https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1024x602.jpg 1024w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-300x176.jpg 300w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-768x451.jpg 768w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1536x902.jpg 1536w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1200x705.jpg 1200w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Automatic Mode</h3>



<ol class="wp-block-list">
<li><strong>Automatic Activation</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>When both <code>Pool_Low_Level_Sensor</code> and <code>Tank_Low_Level_Sensor</code> are active, the pump (<code>Water_Pump</code>) turns on.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Automatic Deactivation</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>The pump turns off when either:
<ul class="wp-block-list">
<li><code>Tank_High_Level_Sensor</code> is active (tank full).</li>



<li><code>Pool_Low_Level_Sensor</code> is inactive (cistern empty).</li>
</ul>
</li>
</ul>



<h3 class="wp-block-heading">Manual Mode</h3>



<ol class="wp-block-list">
<li><strong>Manual Control</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Pressing <code>Start_Button</code> turns on the pump manually.</li>



<li>Pressing <code>Stop_Button</code> turns off the pump manually.</li>
</ul>



<h2 class="wp-block-heading">Troubleshooting</h2>



<ol class="wp-block-list">
<li><strong>Check Wiring</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Ensure sensors and buttons are connected to the correct input pins.</li>



<li>Verify the pump is connected to the correct output pin.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Verify Variables</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Check that the variable names in OpenPLC match the physical connections.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Debugging</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Use the OpenPLC debugging tools to monitor the state of inputs, outputs, and signals.</li>
</ul>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Congratulations! You have successfully implemented a water reserve control system with both automatic and manual modes. This system is ideal for efficiently managing water levels in elevated tanks and cisterns. You can further customize the system by adding additional sensors or modifying the logic to suit specific requirements.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>OpenPLC Staircase Light Control</title>
		<link>https://www.controllino.com/openplc-staircase-light-control-tutorial/</link>
		
		<dc:creator><![CDATA[CONTROLLINO]]></dc:creator>
		<pubDate>Sat, 30 Nov 2024 22:46:34 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[OpenPLC]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.controllino.com/?p=17461</guid>

					<description><![CDATA[Introduction This tutorial demonstrates how to create an automatic staircase lighting system using OpenPLC and a CONTROLLINO PLC. The system uses two push buttons for manual control and a PIR sensor for automatic activation. The light toggles manually with button presses or turns on automatically when motion is detected, staying on for 20 seconds before [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">Introduction</h1>



<p>This tutorial demonstrates how to create an automatic staircase lighting system using OpenPLC and a CONTROLLINO PLC. The system uses two push buttons for manual control and a PIR sensor for automatic activation. The light toggles manually with button presses or turns on automatically when motion is detected, staying on for 20 seconds before turning off if no further motion occurs.</p>



<h2 class="wp-block-heading">Prerequisites</h2>



<p>Before you begin, ensure you have the following:</p>



<ul class="wp-block-list">
<li>OpenPLC software installed.</li>



<li>A CONTROLLINO PLC (any model) or compatible PLC.</li>



<li>A Passive Infrared (PIR) motion sensor.</li>



<li>Two push buttons (for manual control).</li>



<li>Basic knowledge of ladder logic programming.</li>
</ul>



<h2 class="wp-block-heading">Step-by-Step Guide</h2>



<h3 class="wp-block-heading">Step 1: Install and Configure OpenPLC</h3>



<ol class="wp-block-list">
<li><strong>Download OpenPLC</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Visit the <a href="https://www.openplcproject.com/">OpenPLC website</a> and download the software.</li>



<li>Follow the installation instructions for your operating system.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Set Up the OpenPLC Environment</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Open the OpenPLC Editor.</li>



<li>Configure the environment for your CONTROLLINO PLC by selecting the correct model in <strong>Settings &gt; Device</strong>.</li>



<li>Assign the appropriate COM port for communication.</li>
</ul>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://github.com/CONTROLLINO-PLC/OpenPLC_examples/tree/master">Controllino&#8217;s OpenPLC repository</a></div>
</div>



<h3 class="wp-block-heading">Step 2: Define System Inputs and Outputs</h3>



<p>Configure the following inputs and outputs in your ladder logic program:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Pin</th></tr></thead><tbody><tr><td><code>stairs_pir_sensor</code></td><td>BOOL</td><td>Input from the PIR motion sensor.</td><td><code>%IX0.0</code></td></tr><tr><td><code>control_button_down</code></td><td>BOOL</td><td>Input from the downstairs push button.</td><td><code>%IX0.1</code></td></tr><tr><td><code>control_button_up</code></td><td>BOOL</td><td>Input from the upstairs push button.</td><td><code>%IX0.2</code></td></tr><tr><td><code>stairs_light</code></td><td>BOOL</td><td>Output to control the staircase light.</td><td><code>%QX0.0</code></td></tr></tbody></table></figure>



<p><strong>Timers</strong>:</p>



<ul class="wp-block-list">
<li><code>TOF0</code> (Off Delay Timer): Controls the light timeout after motion detection.</li>



<li>Duration: <code>T#20s</code>.</li>
</ul>



<h3 class="wp-block-heading">Step 3: Create the Ladder Logic Program</h3>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://github.com/CONTROLLINO-PLC/OpenPLC_examples/tree/master/stairs_light_control">Download OpenPLC project here</a></div>
</div>



<ol class="wp-block-list">
<li><strong>Manual Light Control</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>When either <code>control_button_down</code> or <code>control_button_up</code> is pressed, the <code>lights_buttons_state</code> toggles the <code>stairs_light</code>.</li>



<li>This allows manual on/off control of the staircase light.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Automatic Light Control</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>When the <code>stairs_pir_sensor</code> detects motion, it activates the timer <code>TOF0</code>.</li>



<li>The light (<code>stairs_light</code>) remains on while the timer is active or as long as motion is detected.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Light Timeout</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>When no motion is detected for 20 seconds, the <code>TOF0</code> timer deactivates.</li>



<li>The light turns off automatically unless toggled manually.</li>
</ul>



<h3 class="wp-block-heading">Step 4: Connect the Hardware</h3>



<ol class="wp-block-list">
<li><strong>Wiring</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Connect the PIR sensor output to a digital input pin (e.g., <code>DI0</code>).</li>



<li>Connect the downstairs push button to another input pin (e.g., <code>DI1</code>).</li>



<li>Connect the upstairs push button to a separate input pin (e.g., <code>DI2</code>).</li>



<li>Connect the staircase light to a digital output pin (e.g., <code>DO0</code>).</li>
</ul>



<ol class="wp-block-list">
<li><strong>Pin Mapping</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Assign the corresponding input and output variables in OpenPLC:
<ul class="wp-block-list">
<li><code>stairs_pir_sensor</code> → <code>%IX0.0</code></li>



<li><code>control_button_down</code> → <code>%IX0.1</code></li>



<li><code>control_button_up</code> → <code>%IX0.2</code></li>



<li><code>stairs_light</code> → <code>%QX0.0</code></li>
</ul>
</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="765" src="https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1024x765.png" alt="" class="wp-image-17488" srcset="https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1024x765.png 1024w, https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-300x224.png 300w, https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-768x573.png 768w, https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1200x896.png 1200w, https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram.png 1334w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Step 5: Load and Test the Program</h3>



<ol class="wp-block-list">
<li><strong>Upload the Program</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Save your ladder logic project in the OpenPLC Editor.</li>



<li>Connect your CONTROLLINO PLC to your computer and upload the program.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Test Manual Light Control</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Press the upstairs (<code>control_button_up</code>) or downstairs (<code>control_button_down</code>) push button.</li>



<li>Confirm that the light toggles on and off with each press.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Test Automatic Light Control</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Walk near the PIR sensor to simulate motion detection.</li>



<li>Observe the light turning on and staying active for 20 seconds after the motion stops.</li>



<li>Ensure the light turns off automatically after the timer expires.</li>
</ul>



<h3 class="wp-block-heading">Ladder Logic Explanation (Detailed)</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="676" src="https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1-1024x676.jpg" alt="" class="wp-image-17490" srcset="https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1-1024x676.jpg 1024w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1-300x198.jpg 300w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1-768x507.jpg 768w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1-1536x1014.jpg 1536w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1-1200x792.jpg 1200w, https://www.controllino.com/wp-content/uploads/2024/11/OpenPLC-program-1.jpg 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">Manual Light Control</h4>



<ol class="wp-block-list">
<li><strong>Toggling the Light</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Each button press (<code>control_button_up</code> or <code>control_button_down</code>) changes the state of <code>lights_buttons_state</code>.</li>



<li>The state of <code>lights_buttons_state</code> determines whether <code>stairs_light</code> is turned on or off.</li>
</ul>



<h4 class="wp-block-heading">Automatic Light Control</h4>



<ol class="wp-block-list">
<li><strong>PIR Sensor Activation</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>When the <code>stairs_pir_sensor</code> detects motion, the timer <code>TOF0</code> starts.</li>



<li>The <code>stairs_light</code> remains on while motion is detected or while the timer is active.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Light Timeout</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>The <code>TOF0</code> timer turns off the light 20 seconds after the PIR sensor stops detecting motion.</li>
</ul>



<h4 class="wp-block-heading">Combining Manual and Automatic Control</h4>



<ul class="wp-block-list">
<li>The light can be manually toggled on or off at any time using the push buttons.</li>



<li>Automatic activation by the PIR sensor operates independently, ensuring flexibility.</li>
</ul>



<h3 class="wp-block-heading">Troubleshooting</h3>



<ol class="wp-block-list">
<li><strong>Verify Wiring</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Ensure all sensors and buttons are correctly connected to the appropriate input pins.</li>



<li>Confirm the light is connected to the correct output pin.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Check Variable Assignments</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Double-check that the input and output variables in OpenPLC match your physical connections.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Debugging</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Use the OpenPLC debugging tools to monitor the state of variables and timers.</li>
</ul>



<h3 class="wp-block-heading">Conclusion</h3>



<p>Congratulations! You have successfully implemented an automatic staircase lighting system using OpenPLC and a CONTROLLINO PLC. This system combines manual and automatic control for optimal flexibility and convenience. Experiment with different timer durations or additional sensors to customize the system further.</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>OpenPLC Light Intensity Control</title>
		<link>https://www.controllino.com/pwm-light-intensity-control-system-tutorial/</link>
		
		<dc:creator><![CDATA[CONTROLLINO]]></dc:creator>
		<pubDate>Sat, 30 Nov 2024 22:40:52 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MICRO]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[OpenPLC]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.controllino.com/?p=17457</guid>

					<description><![CDATA[Introduction This tutorial explains how to create a PWM-based light intensity control system using OpenPLC software and a CONTROLLINO Micro PLC. The system adjusts the brightness of a light through a single push button, using a digital output. Each button press decreases the brightness until it cycles back to full intensity. This project showcases ladder [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">Introduction</h1>



<p>This tutorial explains how to create a PWM-based light intensity control system using OpenPLC software and a CONTROLLINO Micro PLC. The system adjusts the brightness of a light through a single push button, using a digital output. Each button press decreases the brightness until it cycles back to full intensity. This project showcases ladder logic programming to control light intensity using PWM.</p>



<h2 class="wp-block-heading">Prerequisites</h2>



<p>Before you begin, ensure you have the following:</p>



<ul class="wp-block-list">
<li>OpenPLC software installed.</li>



<li>A CONTROLLINO Micro PLC.</li>



<li>Basic knowledge of ladder logic and PWM.</li>



<li>Hardware setup ready, including a connected push button and light output.</li>
</ul>



<h2 class="wp-block-heading">Step-by-Step Guide</h2>



<h3 class="wp-block-heading">Step 1: Install and Configure OpenPLC</h3>



<ol class="wp-block-list">
<li>Download OpenPLC from the official <a href="https://www.openplcproject.com/">OpenPLC website</a>.</li>



<li>Install the software on your computer.</li>



<li>Open the OpenPLC Editor and configure the environment for your CONTROLLINO Micro PLC:</li>
</ol>



<ul class="wp-block-list">
<li>Navigate to <strong>Settings &gt; Device</strong> and select &#8220;CONTROLLINO Micro&#8221; from the list.</li>



<li>Ensure the correct COM port is selected.</li>
</ul>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://github.com/CONTROLLINO-PLC/OpenPLC_examples/tree/master">Controllino&#8217;s OpenPLC repository</a></div>
</div>



<h3 class="wp-block-heading">Step 2: Create the Ladder Logic Program</h3>



<ol class="wp-block-list">
<li><strong>Define Variables</strong>:<br>Open the OpenPLC editor and define the variables listed below: Name Type Description <code>Control_button</code> BOOL Push button input to control brightness cycling. <code>Light_output</code> BOOL PWM output controlling the light intensity. <code>Light_bright</code> INT Tracks the current brightness level. <code>Pulse_regulator</code> TIME Timing variable for PWM modulation. <code>Light_on_state</code> BOOL Indicates whether the light is currently on. <code>Reset_state</code> BOOL Resets the brightness level to maximum. <code>Flag_cicle</code> BOOL Controls PWM signal cycling. <code>Full_bright</code> BOOL Indicates the full brightness state.</li>
</ol>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="370" src="https://www.controllino.com/wp-content/uploads/2024/11/OpemPLC-Variables-1024x370.jpg" alt="" class="wp-image-17498" srcset="https://www.controllino.com/wp-content/uploads/2024/11/OpemPLC-Variables-1024x370.jpg 1024w, https://www.controllino.com/wp-content/uploads/2024/11/OpemPLC-Variables-300x108.jpg 300w, https://www.controllino.com/wp-content/uploads/2024/11/OpemPLC-Variables-768x277.jpg 768w, https://www.controllino.com/wp-content/uploads/2024/11/OpemPLC-Variables-1536x554.jpg 1536w, https://www.controllino.com/wp-content/uploads/2024/11/OpemPLC-Variables-1200x433.jpg 1200w, https://www.controllino.com/wp-content/uploads/2024/11/OpemPLC-Variables.jpg 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<ol class="wp-block-list">
<li><strong>Draw the Ladder Diagram</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Implement the logic as described in the <strong>Ladder Logic Explanation</strong> section below.</li>



<li>Use counters (CTU), timers (TP and TOF), and comparators (EQ, GT) to create the control logic.</li>
</ul>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://github.com/CONTROLLINO-PLC/OpenPLC_examples/tree/master/Dimmer_light_control">Download OpenPLC project here</a></div>
</div>



<h3 class="wp-block-heading">Step 3: Understanding the Ladder Logic</h3>



<h4 class="wp-block-heading">Button Press and Brightness Cycling</h4>



<ol class="wp-block-list">
<li><strong>Counter (CTU0)</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Each button press increments the counter.</li>



<li>The counter cycles through brightness levels (0, 1, 2, 3) and resets to 0 after reaching the maximum level.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Brightness Level Comparison</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Use comparators to determine the brightness level (<code>Light_bright</code>) and adjust the PWM pulse width accordingly.</li>
</ul>



<ol class="wp-block-list">
<li><strong>PWM Signal Generation</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Use timers to control the on/off duration of the PWM signal based on the current brightness level.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Light Output Control</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>The variable <code>Pulse_regulator</code> adjusts the <code>Light_output</code> signal to modulate light intensity.</li>
</ul>



<h3 class="wp-block-heading">Step 4: Connect the Hardware</h3>



<ol class="wp-block-list">
<li><strong>Wiring</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Connect the push button to a digital input pin (e.g., <code>CONTROLLINO_D0</code>).</li>



<li>Connect the light output to a PWM-capable pin (e.g., <code>CONTROLLINO_Q0</code>).</li>
</ul>



<ol class="wp-block-list">
<li><strong>Pin Mapping</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Assign the <code>Control_button</code> variable to the input pin connected to the push button.</li>



<li>Assign the <code>Light_output</code> variable to the output pin connected to the light.</li>
</ul>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1-1024x768.png" alt="" class="wp-image-17495" srcset="https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1-1024x768.png 1024w, https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1-300x225.png 300w, https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1-768x576.png 768w, https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1-1536x1152.png 1536w, https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1-1200x900.png 1200w, https://www.controllino.com/wp-content/uploads/2024/11/Electric-diagram-1.png 1630w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Step 5: Load and Run the Program</h3>



<ol class="wp-block-list">
<li><strong>Upload the Program</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Save your ladder logic project.</li>



<li>Use the OpenPLC Editor to upload the program to your CONTROLLINO Micro.</li>
</ul>



<ol class="wp-block-list">
<li><strong>Test the System</strong>:</li>
</ol>



<ul class="wp-block-list">
<li>Power on the CONTROLLINO Micro.</li>



<li>Press the push button and observe the light cycling through brightness levels.</li>
</ul>



<h3 class="wp-block-heading">Ladder Logic Explanation (Detailed)</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="819" src="https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-1-1024x819.jpg" alt="" class="wp-image-17496" srcset="https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-1-1024x819.jpg 1024w, https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-1-300x240.jpg 300w, https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-1-768x614.jpg 768w, https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-1-1200x960.jpg 1200w, https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-1.jpg 1358w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>Counter (CTU0)</strong>:</p>



<ol class="wp-block-list">
<li></li>
</ol>



<ul class="wp-block-list">
<li>Tracks the number of button presses and increments the <code>Light_bright</code> variable.</li>



<li>Resets to 0 after reaching the maximum brightness level.</li>
</ul>



<p><strong>Reset and Cycling</strong>:</p>



<ul class="wp-block-list">
<li>When the brightness reaches the lowest level, the <code>Reset_state</code> variable resets the system to the maximum brightness level.</li>
</ul>



<p><strong>Brightness Control</strong>:</p>



<ol class="wp-block-list">
<li></li>
</ol>



<ul class="wp-block-list">
<li>Use comparators (<code>EQ</code>, <code>GT</code>) to map the brightness level to a PWM duty cycle.</li>



<li>Timers (<code>TP0</code>, <code>TOF0</code>) generate the PWM signal by controlling the on/off duration of <code>Light_output</code>.</li>
</ul>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="474" src="https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-2-1024x474.png" alt="" class="wp-image-17497" srcset="https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-2-1024x474.png 1024w, https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-2-300x139.png 300w, https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-2-768x355.png 768w, https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-2-1200x555.png 1200w, https://www.controllino.com/wp-content/uploads/2024/11/OplenPLC-Program-2.png 1344w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Troubleshooting</h3>



<ol class="wp-block-list">
<li>Verify the wiring between the push button, light, and CONTROLLINO.</li>



<li>Ensure that the correct input and output pins are assigned to the variables.</li>



<li>Check for errors in the ladder logic program using the OpenPLC debugger.</li>
</ol>



<h3 class="wp-block-heading">Conclusion</h3>



<p>You have successfully implemented a PWM-based light intensity control system using a CONTROLLINO Micro and OpenPLC. By integrating ladder logic and PWM, this project demonstrates an efficient way to control light brightness with a single push button. Experiment with the timing variables and additional functionality to customize the system further.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>I2C Master Slave I/O</title>
		<link>https://www.controllino.com/i2c-master-slave-i-o/</link>
		
		<dc:creator><![CDATA[CONTROLLINO]]></dc:creator>
		<pubDate>Tue, 17 Sep 2024 20:45:54 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.controllino.com/?p=17065</guid>

					<description><![CDATA[Introduction This tutorial will guide you through setting up I2C communication between a master and a slave device using a CONTROLLINO PLC. The master device reads analog and digital inputs and sends this data to the slave, while the slave responds with data that controls the outputs on the master. Prerequisites I2C Connection example This [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p>This tutorial will guide you through setting up I2C communication between a master and a slave device using a CONTROLLINO PLC. The master device reads analog and digital inputs and sends this data to the slave, while the slave responds with data that controls the outputs on the master.</p>



<h2 class="wp-block-heading">Prerequisites</h2>



<ul class="wp-block-list">
<li>Installed Arduino IDE.</li>



<li>CONTROLLINO PLC board (e.g., MINI, MAXI, or MEGA).</li>



<li>Basic understanding of I2C communication and pin setup.</li>
</ul>



<h5 class="wp-block-heading">I2C Connection example</h5>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="584" src="https://www.controllino.com/wp-content/uploads/2024/09/I2C-Controllino-Mega-1024x584.jpg" alt="" class="wp-image-17342" srcset="https://www.controllino.com/wp-content/uploads/2024/09/I2C-Controllino-Mega-1024x584.jpg 1024w, https://www.controllino.com/wp-content/uploads/2024/09/I2C-Controllino-Mega-300x171.jpg 300w, https://www.controllino.com/wp-content/uploads/2024/09/I2C-Controllino-Mega-768x438.jpg 768w, https://www.controllino.com/wp-content/uploads/2024/09/I2C-Controllino-Mega.jpg 1112w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>This example of connection is based on the Controllino Mega but I2C connections for Maxi and Mini uses the same pins of the same X1 connector. </p>



<h2 class="wp-block-heading">Example Code</h2>



<p>Please grab the following example .ino file from Github:</p>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library/tree/master/examples/Expand_I2C/Master" target="_blank" rel="noreferrer noopener">I2C Master Code Example</a></div>
</div>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library/tree/master/examples/Expand_I2C/Slave" target="_blank" rel="noreferrer noopener">I2C Slave Code Example</a></div>
</div>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library/blob/master/examples/Expand_I2C/README.md" target="_blank" rel="noreferrer noopener">Readme file Link</a></div>
</div>



<h2 class="wp-block-heading">Step-by-Step Guide</h2>



<h3 class="wp-block-heading">Step 1: Setup the Arduino Environment</h3>



<ol class="wp-block-list">
<li>Connect your CONTROLLINO board to your computer.</li>



<li>Open the Arduino IDE.</li>



<li>Ensure that the appropriate CONTROLLINO board and port are selected in the&nbsp;<strong>Tools</strong>&nbsp;menu.</li>



<li>Include the&nbsp;<strong>Wire</strong>&nbsp;and&nbsp;<strong>Controllino</strong>&nbsp;libraries in your project.</li>
</ol>



<h3 class="wp-block-heading">Step 2: Initialize I2C Communication and Serial Debugging</h3>



<ol class="wp-block-list">
<li>In the&nbsp;<code>setup()</code>&nbsp;function, initialize the I2C communication by calling&nbsp;<code>Wire.begin()</code>. This sets up the CONTROLLINO device as a master.</li>



<li>Initialize serial communication for debugging purposes using&nbsp;<code>Serial.begin(9600)</code>.</li>
</ol>



<h3 class="wp-block-heading">Step 3: Configure Digital and Analog Pins</h3>



<ol class="wp-block-list">
<li>Set up the digital pins:
<ul class="wp-block-list">
<li>The first 5 digital pins (<code>CONTROLLINO_D0</code>&nbsp;to&nbsp;<code>CONTROLLINO_D4</code>) are configured as inputs.</li>



<li>The corresponding relay pins (<code>CONTROLLINO_R0</code>&nbsp;to&nbsp;<code>CONTROLLINO_R4</code>) are set as outputs.</li>
</ul>
</li>



<li>Set up the analog pins:
<ul class="wp-block-list">
<li>The next 2 analog input pins (<code>CONTROLLINO_A0</code>&nbsp;and&nbsp;<code>CONTROLLINO_A1</code>) are configured as inputs.</li>



<li>The same pins will also serve as PWM outputs, configured as outputs.</li>
</ul>
</li>
</ol>



<h3 class="wp-block-heading">Step 4: Sending Analog and Digital Inputs to the Slave</h3>



<ol class="wp-block-list">
<li>In the&nbsp;<code>loop()</code>&nbsp;function, start communication with the slave by calling&nbsp;<code>Wire.beginTransmission(slaveAddress)</code>.</li>



<li>Read the values from the analog input pins and split each 10-bit value into two bytes. Send these bytes to the slave using&nbsp;<code>Wire.write()</code>.</li>



<li>Read the states of the digital input pins, and store them in a single byte using bitwise operations. Send this byte to the slave.</li>
</ol>



<h3 class="wp-block-heading">Step 5: Receiving Data from the Slave</h3>



<ol class="wp-block-list">
<li>After ending the transmission with&nbsp;<code>Wire.endTransmission()</code>, request data from the slave by calling&nbsp;<code>Wire.requestFrom(slaveAddress, 5)</code>.</li>



<li>Once data is available, read the byte that contains the digital output states and update the output pins accordingly.</li>



<li>For analog data, combine the two bytes received into a single integer, and use this value to set the PWM outputs on the master.</li>
</ol>



<h3 class="wp-block-heading">Step 6: Control Digital Outputs Based on Slave Data</h3>



<ol class="wp-block-list">
<li>Use the byte received from the slave to set the states of the digital output pins (<code>CONTROLLINO_R0</code>&nbsp;to&nbsp;<code>CONTROLLINO_R4</code>).</li>



<li>Each bit in the byte represents the state of one output pin, and the&nbsp;<code>digitalWrite()</code>&nbsp;function is used to control these pins.</li>
</ol>



<p>Certainly! Here’s an expanded explanation with more details on how the slave code works and its interaction with the master:</p>



<h3 class="wp-block-heading">Step 7: Set Up the Slave Address and Digital/Analog Pins</h3>



<p>In the slave code, the device is initialized with a specific I2C address using <code>Wire.begin(8)</code>. This address must match the address used in the master code for communication to work.</p>



<p>The digital and analog pins on the slave are then configured:</p>



<ul class="wp-block-list">
<li>The first 5 digital pins are set as inputs and outputs, similar to the master.</li>



<li>The next 2 pins are designated as PWM outputs (for receiving analog data from the master) and as analog inputs (for sending data back to the master).</li>
</ul>



<p>This ensures that both the master and slave are working with the same configuration, which is essential for seamless data exchange.</p>



<h3 class="wp-block-heading">Step 8: Handling Data Received from the Master</h3>



<p>The <code>receiveEvent()</code> function in the slave code is triggered whenever the master sends data to the slave. This function:</p>



<ol class="wp-block-list">
<li>Reads the analog values sent by the master, reconstructing each value from two bytes.</li>



<li>Writes the reconstructed analog values to the designated PWM output pins on the slave, enabling the master to control the analog output on the slave remotely.</li>



<li>Reads the byte representing the digital output states, where each bit corresponds to the state of one digital output pin.</li>
</ol>



<p>The slave then uses <code>digitalWrite()</code> to set its digital output pins based on the master’s instructions, allowing the master to control these outputs directly.</p>



<h3 class="wp-block-heading">Step 9: Responding to the Master’s Data Request</h3>



<p>When the master requests data from the slave, the <code>requestEvent()</code> function on the slave is executed:</p>



<ol class="wp-block-list">
<li>The analog inputs are read, its value is splited into two bytes for transmission.</li>



<li>The combined digital input states are read and stored in a single byte, with each bit representing one digital input.</li>
</ol>



<p>The slave then sends these values back to the master via <code>Wire.write()</code>, allowing the master to read the current state of the slave’s inputs and use this data in its control logic.</p>



<h3 class="wp-block-heading">Step 10: Synchronizing Data Between Master and Slave</h3>



<p>The master and slave continuously communicate over I2C to maintain synchronization:</p>



<ol class="wp-block-list">
<li>The master sends analog values to control the PWM outputs on the slave.</li>



<li>The master also sends digital states to control specific digital outputs on the slave.</li>



<li>The slave responds with its own digital and analog input states, enabling the master to monitor and react to the slave’s environment.</li>
</ol>



<p>This bidirectional data flow ensures the master can dynamically control and respond to the conditions on the slave, creating a cohesive system where both devices operate in harmony.</p>



<h3 class="wp-block-heading">Troubleshooting</h3>



<ul class="wp-block-list">
<li>Ensure the I2C address of the slave matches the value set in&nbsp;<code>slaveAddress</code>.</li>



<li>Check the wiring between the master and slave, ensuring the I2C SDA and SCL lines are connected properly.</li>



<li>Verify the CONTROLLINO board and port are correctly selected in the Arduino IDE.</li>
</ul>



<h2 class="wp-block-heading">Conclusion</h2>



<p>You have now successfully established I2C communication between a CONTROLLINO master and slave. By reading analog and digital inputs on the master and controlling its outputs based on data received from the slave, this setup enables synchronized control between two devices. Experiment with different pin configurations and data handling to expand your project!</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Board &#038; Library Setup with Platform.io</title>
		<link>https://www.controllino.com/board-library-setup-with-platform-io/</link>
		
		<dc:creator><![CDATA[marcoriedi]]></dc:creator>
		<pubDate>Tue, 30 May 2023 09:21:28 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MICRO]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://page2023.controllino.com/?p=5080</guid>

					<description><![CDATA[Intro Platform.io together with VS Code is the current de-facto standard for advanced programmers to develop on Arduino boards. CONTROLLINO is natively compatible with Platform.io How to use CONTROLLINO with Platform.io Please refer to the official tutorials from Platform.io on how to connect your board:]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Intro</h2>



<p>Platform.io together with VS Code is the current de-facto standard for advanced programmers to develop on Arduino boards. CONTROLLINO is natively compatible with Platform.io</p>



<h2 class="wp-block-heading">How to use CONTROLLINO with Platform.io</h2>



<p>Please refer to the official tutorials from Platform.io on how to connect your board:</p>



<ul class="wp-block-list">
<li><a href="https://docs.platformio.org/en/latest/boards/atmelavr/controllino_mini.html">Controllino MINI</a></li>



<li><a href="https://docs.platformio.org/en/latest/boards/atmelavr/controllino_maxi.html">Controllino MAXI</a></li>



<li><a href="https://docs.platformio.org/en/latest/boards/atmelavr/controllino_maxi_automation.html">Controllino MAXI Automation</a></li>



<li><a href="https://docs.platformio.org/en/latest/boards/atmelavr/controllino_mega.html">Controllino MEGA</a></li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Interrupts</title>
		<link>https://www.controllino.com/interrupts/</link>
		
		<dc:creator><![CDATA[marcoriedi]]></dc:creator>
		<pubDate>Tue, 30 May 2023 07:22:00 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://page2023.controllino.com/interrupts/</guid>

					<description><![CDATA[Intro Interrupts are useful for automatically executing things in microcontroller programs and can solve timing problems. Good tasks for using an interrupt may include reading a rotary encoder or monitoring user input.The Arduino Uno has 2 and the Mega has 6 external interrupt pins available: On the other hand the pin change interrupts can be enabled [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Intro</h2>



<p>Interrupts are useful for automatically executing things in microcontroller programs and can solve timing problems. Good tasks for using an interrupt may include reading a rotary encoder or monitoring user input.<br>The Arduino Uno has 2 and the Mega has 6 external interrupt pins available:</p>



<ul class="wp-block-list">
<li><b>Arduino Uno/Controllino MINI/INT.x interrupt:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2/IN0/INT.0&nbsp; –&nbsp; 3/IN1/INT.1&nbsp;</b></li>



<li><strong>Arduino Mega/Controllino MAXI,MEGA/INT.x interrupt: 2/D0/INT.0&nbsp; –&nbsp; 3/D1/INT.1&nbsp; –&nbsp; 18/IN0/INT.5&nbsp; –&nbsp; 19/IN1/INT.4&nbsp; –&nbsp; 20/SDA/INT.3&nbsp; –&nbsp; 21/SCL/INT.2</strong></li>
</ul>



<p>On the other hand the pin change interrupts can be enabled on many more pins.</p>



<h2 class="wp-block-heading">Hardware Required</h2>



<ul class="wp-block-list">
<li>Controllino MINI/MAXI/MEGA</li>



<li>12/24V DC Power supply</li>
</ul>



<h2 class="wp-block-heading">Circuit</h2>



<h1 class="wp-block-heading"><a href="https://www.controllino.com/wp-content/uploads/2017/07/CONTROLLINO-SPS-PLC-Tutorial-Connection-Digital-Relay-Blink.jpg" target="_blank" rel="noopener noreferrer"><img loading="lazy" decoding="async" class="alignnone wp-image-1967 size-medium" src="https://www.controllino.com/wp-content/uploads/2017/07/CONTROLLINO-SPS-PLC-Tutorial-Connection-Digital-Relay-Blink-215x300.jpg" sizes="auto, (max-width: 215px) 100vw, 215px" srcset="https://www.controllino.com/wp-content/uploads/2017/07/CONTROLLINO-SPS-PLC-Tutorial-Connection-Digital-Relay-Blink-215x300.jpg 215w, https://www.controllino.com/wp-content/uploads/2017/07/CONTROLLINO-SPS-PLC-Tutorial-Connection-Digital-Relay-Blink.jpg 711w" width="215" height="300"></a></h1>



<p>Note*<br>Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the Controllino permanently.</p>



<h2 class="wp-block-heading">Code</h2>



<h4 class="wp-block-heading">Controllino MINI/MAXI/MEGA</h4>



<div class="wp-block-kevinbatdorf-code-block-pro" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#include <Controllino.h&gt;

const byte digital_output = CONTROLLINO_D0;
const byte interruptPin = CONTROLLINO_IN1;
volatile byte state = LOW;

void setup() {
 pinMode(digital_output, OUTPUT);
 pinMode(interruptPin, INPUT);
 attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
}

void loop() {
 digitalWrite(digital_output, state);
}

void blink() {
 state = !state;
}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">include</span><span style="color: #8FBCBB"> </span><span style="color: #ECEFF4">&lt;</span><span style="color: #8FBCBB">Controllino.h</span><span style="color: #ECEFF4">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">const</span><span style="color: #D8DEE9FF"> byte digital_output </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_D0</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #81A1C1">const</span><span style="color: #D8DEE9FF"> byte interruptPin </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_IN1</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #81A1C1">volatile</span><span style="color: #D8DEE9FF"> byte state </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> LOW</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">setup</span><span style="color: #ECEFF4">()</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">digital_output</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> OUTPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">interruptPin</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> INPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">attachInterrupt</span><span style="color: #ECEFF4">(</span><span style="color: #88C0D0">digitalPinToInterrupt</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">interruptPin</span><span style="color: #ECEFF4">),</span><span style="color: #D8DEE9FF"> blink</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> CHANGE</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">loop</span><span style="color: #ECEFF4">()</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">digitalWrite</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">digital_output</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> state</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">blink</span><span style="color: #ECEFF4">()</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF"> state </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">!</span><span style="color: #D8DEE9FF">state</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span></code></pre></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using a 16&#215;2 LCD</title>
		<link>https://www.controllino.com/using-a-16x2-lcd/</link>
		
		<dc:creator><![CDATA[marcoriedi]]></dc:creator>
		<pubDate>Tue, 30 May 2023 07:22:00 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://page2023.controllino.com/16x2-lcd-maxi/</guid>

					<description><![CDATA[Intro The LiquidCrystal library allows you to control LCD displays that are compatible with the Hitachi HD44780 driver. These are the LCDs that are usually connected over a 16-pin interface. This example sketch prints “Hello World!” to the LCD and shows the time in seconds since the Arduino was reset. To see more about 16×2 LCD and related pins please [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Intro</h2>



<p>The <em><a href="https://www.arduino.cc/reference/en/libraries/liquidcrystal/"><span class="wikiword">LiquidCrystal</span></a></em> library allows you to control LCD displays that are compatible with the Hitachi <span class="wikiword">HD44780</span> driver. These are the LCDs that are usually connected over a 16-pin interface.</p>



<p>This example sketch prints “Hello World!” to the LCD and shows the time in seconds since the Arduino was reset. To see more about 16×2 LCD and related pins please visit <a href="https://www.arduino.cc/en/Tutorial/HelloWorld?from=Tutorial.LiquidCrystal">https://www.arduino.cc/en/Tutorial/HelloWorld?from=Tutorial.LiquidCrystal</a></p>



<h2 class="wp-block-heading">Required Hardware</h2>



<ul class="wp-block-list">
<li>Controllino MINI/MAXI/MEGA (no Pure versions, as the 5V Pin Headers are needed)</li>



<li>12/24V DC Power supply</li>



<li>16×2 LCD</li>



<li>10k ohm potentiometer</li>



<li>hook-up wires</li>
</ul>



<h2 class="wp-block-heading">Circuit</h2>



<p>Instead of the pins that we use in this example you can use every other communication, output and input pin. We suggest to use first communication and output pins because of internal resistors and then input pins.<br>In this example we don’t need UART and SPI communication and we are using these pins to have all input and output pins free.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1024" height="607" src="https://www.controllino.com/wp-content/uploads/2023/05/Using-a-16x2-LCD-Image-1.jpg" alt="" class="wp-image-4995" srcset="https://www.controllino.com/wp-content/uploads/2023/05/Using-a-16x2-LCD-Image-1.jpg 1024w, https://www.controllino.com/wp-content/uploads/2023/05/Using-a-16x2-LCD-Image-1-300x178.jpg 300w, https://www.controllino.com/wp-content/uploads/2023/05/Using-a-16x2-LCD-Image-1-768x455.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" src="https://www.controllino.com/wp-content/uploads/2023/05/Using-a-16x2-LCD-Image-2.jpg" alt="" class="wp-image-4996" width="768" height="569" srcset="https://www.controllino.com/wp-content/uploads/2023/05/Using-a-16x2-LCD-Image-2.jpg 768w, https://www.controllino.com/wp-content/uploads/2023/05/Using-a-16x2-LCD-Image-2-300x222.jpg 300w" sizes="auto, (max-width: 768px) 100vw, 768px" /></figure>
</div>


<h2 class="wp-block-heading">Code</h2>



<p><em><strong>Note:</strong><br>Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the Controllino permanently!</em></p>



<div class="wp-block-kevinbatdorf-code-block-pro" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="/*
 LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display. The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints &quot;Hello World!&quot; to the LCD

 This example code is in the public domain.

 https://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include &lt;LiquidCrystal.h&gt;
//#include &lt;Controllino.h&gt;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(1, 0, 53, 51, 50, 52);

void setup() {
 
 // set up the LCD's number of columns and rows:
 lcd.begin(16, 2);
 
 // Print a message to the LCD.
 lcd.print(&quot;Controllino MAXI&quot;);
 
}

void loop() {
 
 // set the cursor to column 0, line 1
 // (note: line 1 is the second row, since counting begins with 0):
 
 lcd.setCursor(0, 1);
 
 // print the number of seconds since reset:
 lcd.print(&quot;Hello World!&quot;);
 
 delay(5);
 
}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #616E88">/*</span></span>
<span class="line"><span style="color: #616E88"> LiquidCrystal Library - Hello World</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> Demonstrates the use a 16x2 LCD display. The LiquidCrystal</span></span>
<span class="line"><span style="color: #616E88"> library works with all LCD displays that are compatible with the</span></span>
<span class="line"><span style="color: #616E88"> Hitachi HD44780 driver. There are many of them out there, and you</span></span>
<span class="line"><span style="color: #616E88"> can usually tell them by the 16-pin interface.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> This sketch prints &quot;Hello World!&quot; to the LCD</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> This example code is in the public domain.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> https://www.arduino.cc/en/Tutorial/LiquidCrystal</span></span>
<span class="line"><span style="color: #616E88"> */</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">// include the library code:</span></span>
<span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">include</span><span style="color: #8FBCBB"> </span><span style="color: #ECEFF4">&lt;</span><span style="color: #8FBCBB">LiquidCrystal.h</span><span style="color: #ECEFF4">&gt;</span></span>
<span class="line"><span style="color: #616E88">//#include &lt;Controllino.h&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">// initialize the library with the numbers of the interface pins</span></span>
<span class="line"><span style="color: #D8DEE9FF">LiquidCrystal </span><span style="color: #88C0D0">lcd</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">1</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">53</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">51</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">50</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">52</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">setup</span><span style="color: #ECEFF4">()</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// set up the LCD&#39;s number of columns and rows:</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">lcd</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">begin</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">16</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">2</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// Print a message to the LCD.</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">lcd</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">print</span><span style="color: #ECEFF4">(</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Controllino MAXI</span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">loop</span><span style="color: #ECEFF4">()</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// set the cursor to column 0, line 1</span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// (note: line 1 is the second row, since counting begins with 0):</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">lcd</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">setCursor</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">1</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// print the number of seconds since reset:</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">lcd</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">print</span><span style="color: #ECEFF4">(</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Hello World!</span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">delay</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">5</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span></code></pre></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Controllino HMI with Modbus</title>
		<link>https://www.controllino.com/controllino-hmi-with-modbus/</link>
		
		<dc:creator><![CDATA[marcoriedi]]></dc:creator>
		<pubDate>Tue, 30 May 2023 07:22:00 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MICRO]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://page2023.controllino.com/controllino-hmi-with-modbus/</guid>

					<description><![CDATA[Intro Information: In this tutorial we are using the HMI from Beijer. Controllino&#160;HMIs are industrial HMI panels with high-resolution touch-screens and modern design. The panels combine IP65 corrosion resistant plastic housing with the full version of the iX software, providing an advanced HMI solution for every kind of&#160;applications.Combine&#160;HMI with Controllino and you can create simple as [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Intro</h2>



<p><em>Information: In this tutorial we are using the <a href="https://www.beijerelectronics.com/">HMI from Beijer</a>.</em></p>



<p>Controllino&nbsp;HMIs are industrial HMI panels with high-resolution touch-screens and modern design. The panels combine IP65 corrosion resistant plastic housing with the full version of the iX software, providing an advanced HMI solution for every kind of&nbsp;applications.<br>Combine&nbsp;HMI with Controllino and you can create simple as well as the sophisticated applications in very short time.</p>



<p><strong>IMPORTANT</strong>: Please, select proper target board in&nbsp;<strong>Tools-&gt;Board-&gt;Controllino MINI/MAXI/MEGA</strong>&nbsp;before Upload to your CONTROLLINO.<br>(Please, refer to https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library if you do not see the CONTROLLINOs in the Arduino IDE menu&nbsp;<strong>Tools-&gt;Board</strong>.)</p>



<h2 class="wp-block-heading">MODBUS TCP/IP</h2>



<h3 class="wp-block-heading">Hardware Required</h3>



<ul class="wp-block-list">
<li>Controllino MAXI/MEGA</li>



<li>24V DC Power supply</li>



<li>Controllino HMI</li>



<li>2x Ethernet cable</li>



<li>Router</li>
</ul>



<h3 class="wp-block-heading">Circuit</h3>



<h1 class="wp-block-heading"><a href="https://www.controllino.com/wp-content/uploads/2017/09/Controllino-HMI-TCP-connection.jpg" target="_blank" rel="noopener noreferrer"><img loading="lazy" decoding="async" class="alignnone wp-image-2194 size-medium" src="https://www.controllino.com/wp-content/uploads/2017/09/Controllino-HMI-TCP-connection-300x177.jpg" width="300" height="177"></a></h1>



<p>Note*<br>Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the Controllino permanently.</p>



<h3 class="wp-block-heading">HMI setup</h3>



<p>To set up the Controllino HMI for communication and application we use the iX Software. iX Software is a revolutionary software that features drivers to communicate with your automation equipment, enhanced HMI functionality, state-of-the-art graphics, an intuitive design environment and a truly open platform for today’s automation market. iX Developer is a licensed application that runs on a Windows PC and is used to program iX operator panels.<br>Here we are going to show&nbsp;some steps on how to set it up properly. If you want to check more information and &nbsp;the iX user manual click&nbsp;<a href="https://beijerinc.com/product/ix/" target="_blank" rel="noopener noreferrer">here</a>.</p>



<p>Download the&nbsp;<a href="https://www.controllino.com/wp-content/uploads/2017/09/Controllino_HMI_Modbus_TCP_IP_and_RTU_iX_example.zip">Controllino HMI – TCP/IP</a>&nbsp;example and run it in the iX software.<br>From the left side of the main screen in the iX example there is the&nbsp;<em>Tags</em>&nbsp;button. Open the&nbsp;<em>Tags&nbsp;</em>to set your application addresses. You can see example of this on the next picture:</p>


<div class="wp-block-image">
<figure class="aligncenter"><a href="https://www.controllino.com/wp-content/uploads/2017/09/Tags.jpg" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://www.controllino.com/wp-content/uploads/2017/09/Tags.jpg" alt="" class="wp-image-2214"/></a></figure>
</div>


<p>For more information about&nbsp;<em>Tags&nbsp;</em>and addressing of them navigate&nbsp;to&nbsp;<em>Controllers/Settings</em>&nbsp;and click on the help&nbsp;button of the&nbsp;<em>Modbus Master</em>&nbsp;controller.</p>



<p>After that&nbsp;go to the&nbsp;<em>Controllers tab&nbsp;</em>to choose the right controller for communication. When we are using the Controllino device we want to choose&nbsp;<em>MODICON -&gt; Modbus Master</em>&nbsp;controller. In this example it is already done and they are named&nbsp;<em>Modbus_TCP&nbsp;</em>and&nbsp;<em>Modbus_RTU</em>.</p>



<p>Press on&nbsp;the&nbsp;<em>Modbus_TCP&nbsp;</em>controller, activate it and click on the&nbsp;<em>Settings</em>&nbsp;button to&nbsp;do the folowing:</p>


<div class="wp-block-image">
<figure class="aligncenter"><a href="https://www.controllino.com/wp-content/uploads/2017/09/Controllino-HMI-TCP-settings.jpg" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://www.controllino.com/wp-content/uploads/2017/09/Controllino-HMI-TCP-settings.jpg" alt="" class="wp-image-2216"/></a></figure>
</div>


<p>Set communication mode to the Ethernet TCP/IP and the IP address of the station to your Controllino IP address. To get your Controllino IP address and&nbsp;to ensure that the connections work, run the&nbsp;<strong>ArduinoIDE-&gt;File-&gt;Examples-&gt;Ethernet-&gt;DhcpAddressPrinter</strong>&nbsp;example, upload it and open Serial&nbsp;Monitor. If everything works, you should get your IP address on the screen.</p>



<h3 class="wp-block-heading">Code</h3>



<p>Before uploading the program to the Controllino you have to install the Modbus TCP library. You can download it <a href="https://www.controllino.com/wp-content/uploads/2017/09/Mudbus.zip">here</a>. To install it copy the Modbus folder to your <strong>Arduino->libraries</strong> folder.<br>After getting the IP address of the Controllino the new program has to be uploaded to the device.</p>



<div class="wp-block-kevinbatdorf-code-block-pro" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#include &lt;Controllino.h&gt;
#include &lt;SPI.h&gt;
#include &lt;Ethernet.h&gt;

#include &quot;Mudbus.h&quot;

Mudbus Mb;

int D0 = CONTROLLINO_D0;
int D1 = CONTROLLINO_D1;
int R0 = CONTROLLINO_R0;
int A0_ = CONTROLLINO_A0;


//Function codes 1(read coils), 3(read registers), 5(write coil), 6(write register)
//signed int Mb.R[0 to 125] and bool Mb.C[0 to 128] MB_N_R MB_N_C
//Port 502 (defined in Mudbus.h) MB_PORT

void setup()
{
 uint8_t mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
 uint8_t ip[] = { 192, 168, 0, 103 }; // CHANGE this to the IP address of your CONTROLLINO
 uint8_t gateway[] = { 192, 168, 0, 254 };
 uint8_t subnet[] = { 255, 255, 255, 0 };
 Ethernet.begin(mac, ip, gateway, subnet);

 delay(5000);
 Serial.begin(9600);
 Serial.println(&quot;Started&quot;);
 
 pinMode(D0, OUTPUT); 
 pinMode(D1, INPUT); 
 pinMode(R0, OUTPUT); 
 pinMode(A0_, INPUT); 
}

void loop()
{ 
 
 Mb.Run();

 analogWrite(D0, Mb.R[0]);
 digitalWrite(R0, Mb.R[2]);
 Mb.R[1] = digitalRead(D1); 
 Mb.R[3] = analogRead(A0_); 
 
}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">include</span><span style="color: #8FBCBB"> </span><span style="color: #ECEFF4">&lt;</span><span style="color: #8FBCBB">Controllino.h</span><span style="color: #ECEFF4">&gt;</span></span>
<span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">include</span><span style="color: #8FBCBB"> </span><span style="color: #ECEFF4">&lt;</span><span style="color: #8FBCBB">SPI.h</span><span style="color: #ECEFF4">&gt;</span></span>
<span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">include</span><span style="color: #8FBCBB"> </span><span style="color: #ECEFF4">&lt;</span><span style="color: #8FBCBB">Ethernet.h</span><span style="color: #ECEFF4">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">include</span><span style="color: #8FBCBB"> </span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Mudbus.h</span><span style="color: #ECEFF4">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D8DEE9FF">Mudbus Mb</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">int</span><span style="color: #D8DEE9FF"> D0 </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_D0</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #81A1C1">int</span><span style="color: #D8DEE9FF"> D1 </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_D1</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #81A1C1">int</span><span style="color: #D8DEE9FF"> R0 </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_R0</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #81A1C1">int</span><span style="color: #D8DEE9FF"> A0_ </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_A0</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">//Function codes 1(read coils), 3(read registers), 5(write coil), 6(write register)</span></span>
<span class="line"><span style="color: #616E88">//signed int Mb.R[0 to 125] and bool Mb.C[0 to 128] MB_N_R MB_N_C</span></span>
<span class="line"><span style="color: #616E88">//Port 502 (defined in Mudbus.h) MB_PORT</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">setup</span><span style="color: #ECEFF4">()</span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">uint8_t</span><span style="color: #D8DEE9FF"> mac</span><span style="color: #81A1C1">[]</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">0x</span><span style="color: #B48EAD">00</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">0x</span><span style="color: #B48EAD">AA</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">0x</span><span style="color: #B48EAD">BB</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">0x</span><span style="color: #B48EAD">CC</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">0x</span><span style="color: #B48EAD">DE</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">0x</span><span style="color: #B48EAD">02</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">}</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">uint8_t</span><span style="color: #D8DEE9FF"> ip</span><span style="color: #81A1C1">[]</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">192</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">168</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">103</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">}</span><span style="color: #81A1C1">;</span><span style="color: #616E88"> // CHANGE this to the IP address of your CONTROLLINO</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">uint8_t</span><span style="color: #D8DEE9FF"> gateway</span><span style="color: #81A1C1">[]</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">192</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">168</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">254</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">}</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">uint8_t</span><span style="color: #D8DEE9FF"> subnet</span><span style="color: #81A1C1">[]</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">255</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">255</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">255</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">0</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">}</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Ethernet</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">begin</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">mac</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> ip</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> gateway</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> subnet</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">delay</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">5000</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">begin</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">9600</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">println</span><span style="color: #ECEFF4">(</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Started</span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">D0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> OUTPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">D1</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> INPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">R0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> OUTPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">A0_</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> INPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">loop</span><span style="color: #ECEFF4">()</span></span>
<span class="line"><span style="color: #ECEFF4">{</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Mb</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">Run</span><span style="color: #ECEFF4">()</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">analogWrite</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">D0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Mb</span><span style="color: #ECEFF4">.</span><span style="color: #D8DEE9">R</span><span style="color: #ECEFF4">[</span><span style="color: #B48EAD">0</span><span style="color: #ECEFF4">])</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">digitalWrite</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">R0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Mb</span><span style="color: #ECEFF4">.</span><span style="color: #D8DEE9">R</span><span style="color: #ECEFF4">[</span><span style="color: #B48EAD">2</span><span style="color: #ECEFF4">])</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Mb</span><span style="color: #ECEFF4">.</span><span style="color: #D8DEE9">R</span><span style="color: #ECEFF4">[</span><span style="color: #B48EAD">1</span><span style="color: #ECEFF4">]</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">digitalRead</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">D1</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Mb</span><span style="color: #ECEFF4">.</span><span style="color: #D8DEE9">R</span><span style="color: #ECEFF4">[</span><span style="color: #B48EAD">3</span><span style="color: #ECEFF4">]</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">analogRead</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">A0_</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span></code></pre></div>



<h2 class="wp-block-heading">MODBUS&nbsp;RTU VIA RS485</h2>



<h3 class="wp-block-heading">Hardware Required</h3>



<ul class="wp-block-list">
<li>Controllino MAXI/MEGA</li>



<li>24V DC Power supply</li>



<li>Controllino HMI</li>



<li>3 wires or serial port adapter (male)</li>
</ul>



<h3 class="wp-block-heading">Circuit</h3>



<figure class="wp-block-image"><a href="https://www.controllino.com/wp-content/uploads/2017/09/Controllino-HMI-RTU-connection.jpg" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://www.controllino.com/wp-content/uploads/2017/09/Controllino-HMI-RTU-connection-300x169.jpg" alt="" class="wp-image-2229"/></a></figure>



<p>Note*<br>Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the Controllino permanently.</p>



<h3 class="wp-block-heading">HMI setup</h3>



<p>To set up the Controllino HMI for communication and application we use the iX Software. iX Software is a revolutionary software that features drivers to communicate with your automation equipment, enhanced HMI functionality, state-of-the-art graphics, an intuitive design environment and a truly open platform for today’s automation market. iX Developer is a licensed application that runs on a Windows PC and is used to program iX operator panels.<br>Here we are going to show&nbsp;some steps on how to set it up properly. If you want to check more information and &nbsp;the iX user manual click&nbsp;<a href="https://beijerinc.com/product/ix/" target="_blank" rel="noopener noreferrer">here</a>.</p>



<p>Download the&nbsp;<a href="https://www.controllino.com/wp-content/uploads/2017/09/Controllino_HMI_Modbus_TCP_IP_and_RTU_iX_example.zip">Controllino HMI – RTU</a>&nbsp;example and run it in the iX software.<br>From the left side of the main screen in the iX example there is the&nbsp;<em>Tags</em>&nbsp;button. Open the&nbsp;<em>Tags&nbsp;</em>to set your application addresses. You can see example of this on the next picture:</p>


<div class="wp-block-image">
<figure class="aligncenter"><a href="https://www.controllino.com/wp-content/uploads/2017/09/Tags.jpg" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://www.controllino.com/wp-content/uploads/2017/09/Tags.jpg" alt="" class="wp-image-2214"/></a></figure>
</div>


<p>For more information about&nbsp;<em>Tags&nbsp;</em>and addressing of them navigate&nbsp;to&nbsp;<em>Controllers/Settings</em>&nbsp;and click on the help&nbsp;button of the&nbsp;<em>Modbus Master</em>&nbsp;controller.</p>



<p>Notice here that the Modbus_RTU tags are starting with “5:”.&nbsp;For communication with other stations than the default station, the station number is given as a prefix to the device. This is stated either as a fixed number or as an index register between I1 and I8. The station number is referring to a specific unit id. (5:40001 addresses holding register 40001 in station 5.) &nbsp;In our case the Controllino is slave device on station 5. We can always define his station in the code that we upload.</p>



<p>After that&nbsp;go to the&nbsp;<em>Controllers tab&nbsp;</em>to choose the right controller for communication. When we are using the Controllino device we want to choose&nbsp;<em>MODICON -&gt; Modbus Master</em>&nbsp;controller. In this example it is already done and they are named&nbsp;<em>Modbus_TCP&nbsp;</em>and&nbsp;<em>Modbus_RTU</em>.</p>



<p>Press on&nbsp;the&nbsp;<em>Modbus_RTU&nbsp;</em>controller, activate it and click on the&nbsp;<em>Settings</em>&nbsp;button to&nbsp;do the folowing steps:</p>



<figure class="wp-block-image"><a href="https://www.controllino.com/wp-content/uploads/2017/09/Controllino-HMI-RTU-settings.jpg" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://www.controllino.com/wp-content/uploads/2017/09/Controllino-HMI-RTU-settings.jpg" alt="" class="wp-image-2234"/></a></figure>



<p>Set communication mode to the Serial and the COM2 port of&nbsp;your Controllino HMI.&nbsp;Don’t forget to match the baud rate of&nbsp;Controllino and HMI. Choose the COM2 port to be RS-485.</p>



<h3 class="wp-block-heading">Code</h3>



<p>The Controllino HMI is communicating to the Controllino slave device on the station 5 so we have to set it in the line: <strong><em>define SlaveModbusAdd 5</em></strong></p>



<div class="wp-block-kevinbatdorf-code-block-pro" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#include <Controllino.h&gt; /* Usage of CONTROLLINO library allows you to use CONTROLLINO_xx aliases in your sketch. */
#include &quot;ModbusRtu.h&quot; /* Usage of ModBusRtu library allows you to implement the Modbus RTU protocol in your sketch. */
/*
 CONTROLLINO - Modbus RTU protocol Slave example for MAXI and MEGA, Version 01.00
 
 The sketch is relevant only for CONTROLLINO variants MAXI and MEGA (because of necessity of RS485 interface)!

 This sketch is intended as an example of the communication between devices via RS485 with utilization the 
 ModbusRTU protocol.
 In this example the CONTROLLINO is used as the Modbus slave!
 For more information about the Modbus protocol visit the website: https://modbus.org/
 
 Modbus master device can read Modbus 16bit registers (provided by the slave):
 0 - analog CONTROLLINO_A0 value (0 - 1024)
 1 - digital CONTROLLINO_D0 value (0/1)
 2 - Modbus messages received
 3 - Modbus messages transmitted

 Modbus master device can write Modbus 16bit registers:
 4 - relay CONTROLLINO_R0 (0/1)
 5 - relay CONTROLLINO_R1 (0/1)
 6 - relay CONTROLLINO_R2 (0/1)
 7 - relay CONTROLLINO_R3 (0/1)

 To easily evaluate this example you need a second CONTROLLINO as Modbus master running DemoModbusRTUMaster 
 example sketch.
 Please note that both CONTROLLINOs need 12/24V external supply and you need to interconnect GND, -, + signals 
 of RS485 screw terminal.

 Modbus Master-Slave library for Arduino (ModbusRtu.h) was taken from the website: 
 https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino
 It was necessary to modify setting of the PORTJ for pins DE and RE control. These pins are located at the 
 PORJ and on the pins PIN6(DE) and PIN5(RE).

 IMPORTANT INFORMATION!
 Please, select proper target board in Tools-&gt;Board-&gt;Controllino MAXI/MEGA before Upload to your CONTROLLINO.
 (Please, refer to https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library if you do not see the CONTROLLINOs in 
 the Arduino IDE menu Tools-&gt;Board.)

 Created 30 March 2017
 by David


 (Check https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library for the latest CONTROLLINO related software stuff.)
*/
int D0 = CONTROLLINO_D0;
int D1 = CONTROLLINO_D1;
int R0 = CONTROLLINO_R0;
int A0_ = CONTROLLINO_A0;

// This MACRO defines Modbus slave address.
// For any Modbus slave devices are reserved addresses in the range from 1 to 247.
// Important note only address 0 is reserved for a Modbus master device!

#define SlaveModbusAdd 5

// This MACRO defines number of the comport that is used for RS 485 interface.
// For MAXI and MEGA RS485 is reserved UART Serial3.

#define RS485Serial 3

// The object ControllinoModbuSlave of the class Modbus is initialized with three parameters.
// The first parametr specifies the address of the Modbus slave device.
// The second parameter specifies type of the interface used for communication between devices - in this sketch 
// is used RS485.
// The third parameter can be any number. During the initialization of the object this parameter has no effect.

Modbus ControllinoModbusSlave(SlaveModbusAdd, RS485Serial, 0);

// This uint16 array specified internal registers in the Modbus slave device.
// Each Modbus device has particular internal registers that are available for the Modbus master.
// In this example sketch internal registers are defined as follows:
// (ModbusSlaveRegisters 0 - 3 read only and ModbusSlaveRegisters 4 - 7 write only from the Master perspective):
// ModbusSlaveRegisters[0] - Read an analog value from the CONTROLLINO_A0 - returns value in the range from 0 to 1023.
// ModbusSlaveRegisters[1] - Read an digital value from the CONTROLLINO_D0 - returns only the value 0 or 1.
// ModbusSlaveRegisters[2] - Read the number of incoming messages - Communication diagnostic.
// ModbusSlaveRegisters[3] - Read the number of number of outcoming messages - Communication diagnostic.
// ModbusSlaveRegisters[4] - Sets the Relay output CONTROLLINO_R0 - only the value 0 or 1 is accepted.
// ModbusSlaveRegisters[5] - Sets the Relay output CONTROLLINO_R1 - only the value 0 or 1 is accepted.
// ModbusSlaveRegisters[6] - Sets the Relay output CONTROLLINO_R2 - only the value 0 or 1 is accepted.
// ModbusSlaveRegisters[7] - Sets the Relay output CONTROLLINO_R3 - only the value 0 or 1 is accepted.

uint16_t ModbusSlaveRegisters[8];

// The setup function runs once when you press reset (CONTROLLINO RST button) or connect the CONTROLLINO to the PC
// In the setup function is carried out port setting and initialization of communication of the Modbus slave protocol.

void setup()
{
 delay(5000);
 Serial.begin(9600);
 Serial.println(&quot;Started&quot;);
 
 pinMode(D0, OUTPUT); 
 pinMode(D1, INPUT); 
 pinMode(R0, OUTPUT); 
 pinMode(A0_, INPUT); 

 ControllinoModbusSlave.begin( 19200 ); // Start the communication over the ModbusRTU protocol. Baund rate is set at 19200.
 Serial.begin(9600);
 
}

// The loop function runs over and over again forever
void loop()
{
 // This instance of the class Modbus checks if there are any incoming data.
 // If any frame was received. This instance checks if a received frame is Ok.
 // If the received frame is Ok the instance poll writes or reads corresponding values to the internal registers 
 // (ModbusSlaveRegisters).
 // Main parameters of the instance poll are address of the internal registers and number of internal registers.
 
 ControllinoModbusSlave.poll(ModbusSlaveRegisters, 8);

 // While are not received or sent any data, the Modbus slave device periodically reads the values of analog and 
 // digital outputs.
 // Also it updates the other values of registers.

 analogWrite(D0, ModbusSlaveRegisters[0]);
 digitalWrite(R0, ModbusSlaveRegisters[2]);
 ModbusSlaveRegisters[1] = digitalRead(D1); 
 ModbusSlaveRegisters[3] = analogRead(A0_); 
 
}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">include</span><span style="color: #8FBCBB"> </span><span style="color: #ECEFF4">&lt;</span><span style="color: #8FBCBB">Controllino.h</span><span style="color: #ECEFF4">&gt;</span><span style="color: #8FBCBB"> </span><span style="color: #616E88">/* Usage of CONTROLLINO library allows you to use CONTROLLINO_xx aliases in your sketch. */</span></span>
<span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">include</span><span style="color: #8FBCBB"> </span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">ModbusRtu.h</span><span style="color: #ECEFF4">&quot;</span><span style="color: #8FBCBB"> </span><span style="color: #616E88">/* Usage of ModBusRtu library allows you to implement the Modbus RTU protocol in your sketch. */</span></span>
<span class="line"><span style="color: #616E88">/*</span></span>
<span class="line"><span style="color: #616E88"> CONTROLLINO - Modbus RTU protocol Slave example for MAXI and MEGA, Version 01.00</span></span>
<span class="line"><span style="color: #616E88"> </span></span>
<span class="line"><span style="color: #616E88"> The sketch is relevant only for CONTROLLINO variants MAXI and MEGA (because of necessity of RS485 interface)!</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> This sketch is intended as an example of the communication between devices via RS485 with utilization the </span></span>
<span class="line"><span style="color: #616E88"> ModbusRTU protocol.</span></span>
<span class="line"><span style="color: #616E88"> In this example the CONTROLLINO is used as the Modbus slave!</span></span>
<span class="line"><span style="color: #616E88"> For more information about the Modbus protocol visit the website: https://modbus.org/</span></span>
<span class="line"><span style="color: #616E88"> </span></span>
<span class="line"><span style="color: #616E88"> Modbus master device can read Modbus 16bit registers (provided by the slave):</span></span>
<span class="line"><span style="color: #616E88"> 0 - analog CONTROLLINO_A0 value (0 - 1024)</span></span>
<span class="line"><span style="color: #616E88"> 1 - digital CONTROLLINO_D0 value (0/1)</span></span>
<span class="line"><span style="color: #616E88"> 2 - Modbus messages received</span></span>
<span class="line"><span style="color: #616E88"> 3 - Modbus messages transmitted</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> Modbus master device can write Modbus 16bit registers:</span></span>
<span class="line"><span style="color: #616E88"> 4 - relay CONTROLLINO_R0 (0/1)</span></span>
<span class="line"><span style="color: #616E88"> 5 - relay CONTROLLINO_R1 (0/1)</span></span>
<span class="line"><span style="color: #616E88"> 6 - relay CONTROLLINO_R2 (0/1)</span></span>
<span class="line"><span style="color: #616E88"> 7 - relay CONTROLLINO_R3 (0/1)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> To easily evaluate this example you need a second CONTROLLINO as Modbus master running DemoModbusRTUMaster </span></span>
<span class="line"><span style="color: #616E88"> example sketch.</span></span>
<span class="line"><span style="color: #616E88"> Please note that both CONTROLLINOs need 12/24V external supply and you need to interconnect GND, -, + signals </span></span>
<span class="line"><span style="color: #616E88"> of RS485 screw terminal.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> Modbus Master-Slave library for Arduino (ModbusRtu.h) was taken from the website: </span></span>
<span class="line"><span style="color: #616E88"> https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino</span></span>
<span class="line"><span style="color: #616E88"> It was necessary to modify setting of the PORTJ for pins DE and RE control. These pins are located at the </span></span>
<span class="line"><span style="color: #616E88"> PORJ and on the pins PIN6(DE) and PIN5(RE).</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> IMPORTANT INFORMATION!</span></span>
<span class="line"><span style="color: #616E88"> Please, select proper target board in Tools-&gt;Board-&gt;Controllino MAXI/MEGA before Upload to your CONTROLLINO.</span></span>
<span class="line"><span style="color: #616E88"> (Please, refer to https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library if you do not see the CONTROLLINOs in </span></span>
<span class="line"><span style="color: #616E88"> the Arduino IDE menu Tools-&gt;Board.)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> Created 30 March 2017</span></span>
<span class="line"><span style="color: #616E88"> by David</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88"> (Check https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library for the latest CONTROLLINO related software stuff.)</span></span>
<span class="line"><span style="color: #616E88">*/</span></span>
<span class="line"><span style="color: #81A1C1">int</span><span style="color: #D8DEE9FF"> D0 </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_D0</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #81A1C1">int</span><span style="color: #D8DEE9FF"> D1 </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_D1</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #81A1C1">int</span><span style="color: #D8DEE9FF"> R0 </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_R0</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #81A1C1">int</span><span style="color: #D8DEE9FF"> A0_ </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> CONTROLLINO_A0</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">// This MACRO defines Modbus slave address.</span></span>
<span class="line"><span style="color: #616E88">// For any Modbus slave devices are reserved addresses in the range from 1 to 247.</span></span>
<span class="line"><span style="color: #616E88">// Important note only address 0 is reserved for a Modbus master device!</span></span>
<span class="line"></span>
<span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">define</span><span style="color: #5E81AC"> </span><span style="color: #88C0D0">SlaveModbusAdd</span><span style="color: #5E81AC"> </span><span style="color: #B48EAD">5</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">// This MACRO defines number of the comport that is used for RS 485 interface.</span></span>
<span class="line"><span style="color: #616E88">// For MAXI and MEGA RS485 is reserved UART Serial3.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #5E81AC; font-weight: bold">#</span><span style="color: #81A1C1">define</span><span style="color: #5E81AC"> </span><span style="color: #88C0D0">RS485Serial</span><span style="color: #5E81AC"> </span><span style="color: #B48EAD">3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">// The object ControllinoModbuSlave of the class Modbus is initialized with three parameters.</span></span>
<span class="line"><span style="color: #616E88">// The first parametr specifies the address of the Modbus slave device.</span></span>
<span class="line"><span style="color: #616E88">// The second parameter specifies type of the interface used for communication between devices - in this sketch </span></span>
<span class="line"><span style="color: #616E88">// is used RS485.</span></span>
<span class="line"><span style="color: #616E88">// The third parameter can be any number. During the initialization of the object this parameter has no effect.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D8DEE9FF">Modbus </span><span style="color: #88C0D0">ControllinoModbusSlave</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">SlaveModbusAdd</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> RS485Serial</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">0</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">// This uint16 array specified internal registers in the Modbus slave device.</span></span>
<span class="line"><span style="color: #616E88">// Each Modbus device has particular internal registers that are available for the Modbus master.</span></span>
<span class="line"><span style="color: #616E88">// In this example sketch internal registers are defined as follows:</span></span>
<span class="line"><span style="color: #616E88">// (ModbusSlaveRegisters 0 - 3 read only and ModbusSlaveRegisters 4 - 7 write only from the Master perspective):</span></span>
<span class="line"><span style="color: #616E88">// ModbusSlaveRegisters[0] - Read an analog value from the CONTROLLINO_A0 - returns value in the range from 0 to 1023.</span></span>
<span class="line"><span style="color: #616E88">// ModbusSlaveRegisters[1] - Read an digital value from the CONTROLLINO_D0 - returns only the value 0 or 1.</span></span>
<span class="line"><span style="color: #616E88">// ModbusSlaveRegisters[2] - Read the number of incoming messages - Communication diagnostic.</span></span>
<span class="line"><span style="color: #616E88">// ModbusSlaveRegisters[3] - Read the number of number of outcoming messages - Communication diagnostic.</span></span>
<span class="line"><span style="color: #616E88">// ModbusSlaveRegisters[4] - Sets the Relay output CONTROLLINO_R0 - only the value 0 or 1 is accepted.</span></span>
<span class="line"><span style="color: #616E88">// ModbusSlaveRegisters[5] - Sets the Relay output CONTROLLINO_R1 - only the value 0 or 1 is accepted.</span></span>
<span class="line"><span style="color: #616E88">// ModbusSlaveRegisters[6] - Sets the Relay output CONTROLLINO_R2 - only the value 0 or 1 is accepted.</span></span>
<span class="line"><span style="color: #616E88">// ModbusSlaveRegisters[7] - Sets the Relay output CONTROLLINO_R3 - only the value 0 or 1 is accepted.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">uint16_t</span><span style="color: #D8DEE9FF"> ModbusSlaveRegisters</span><span style="color: #ECEFF4">[</span><span style="color: #B48EAD">8</span><span style="color: #ECEFF4">]</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">// The setup function runs once when you press reset (CONTROLLINO RST button) or connect the CONTROLLINO to the PC</span></span>
<span class="line"><span style="color: #616E88">// In the setup function is carried out port setting and initialization of communication of the Modbus slave protocol.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">setup</span><span style="color: #ECEFF4">()</span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">delay</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">5000</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">begin</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">9600</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">println</span><span style="color: #ECEFF4">(</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Started</span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">D0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> OUTPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">D1</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> INPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">R0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> OUTPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">pinMode</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">A0_</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> INPUT</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">ControllinoModbusSlave</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">begin</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">19200</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #616E88"> // Start the communication over the ModbusRTU protocol. Baund rate is set at 19200.</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">begin</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">9600</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">// The loop function runs over and over again forever</span></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">loop</span><span style="color: #ECEFF4">()</span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// This instance of the class Modbus checks if there are any incoming data.</span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// If any frame was received. This instance checks if a received frame is Ok.</span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// If the received frame is Ok the instance poll writes or reads corresponding values to the internal registers </span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// (ModbusSlaveRegisters).</span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// Main parameters of the instance poll are address of the internal registers and number of internal registers.</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">ControllinoModbusSlave</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">poll</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">ModbusSlaveRegisters</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">8</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// While are not received or sent any data, the Modbus slave device periodically reads the values of analog and </span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// digital outputs.</span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">// Also it updates the other values of registers.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">analogWrite</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">D0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> ModbusSlaveRegisters</span><span style="color: #ECEFF4">[</span><span style="color: #B48EAD">0</span><span style="color: #ECEFF4">])</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">digitalWrite</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">R0</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> ModbusSlaveRegisters</span><span style="color: #ECEFF4">[</span><span style="color: #B48EAD">2</span><span style="color: #ECEFF4">])</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> ModbusSlaveRegisters</span><span style="color: #ECEFF4">[</span><span style="color: #B48EAD">1</span><span style="color: #ECEFF4">]</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">digitalRead</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">D1</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> ModbusSlaveRegisters</span><span style="color: #ECEFF4">[</span><span style="color: #B48EAD">3</span><span style="color: #ECEFF4">]</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">analogRead</span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">A0_</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span></code></pre></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Port Manipulation</title>
		<link>https://www.controllino.com/port-manipulation/</link>
		
		<dc:creator><![CDATA[marcoriedi]]></dc:creator>
		<pubDate>Tue, 30 May 2023 07:22:00 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://page2023.controllino.com/port-manipulation/</guid>

					<description><![CDATA[Intro More information about port manipulation on this site:&#160;https://www.arduino.cc/en/Reference/PortManipulation Port registers allow for lower-level and faster manipulation of the i/o pins of the microcontroller on an Controllino PLC.&#160;Each port is controlled by three registers, which are also defined variables in the arduino language: DDR and PORT registers may be both written to, and read. PIN [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Intro</h2>



<p>More information about port manipulation on this site:&nbsp;<a rel="noopener noreferrer" href="https://www.arduino.cc/en/Reference/PortManipulation" target="_blank">https://www.arduino.cc/en/Reference/PortManipulation</a></p>



<p>Port registers allow for lower-level and faster manipulation of the i/o pins of the microcontroller on an Controllino PLC.&nbsp;Each port is controlled by three registers, which are also defined variables in the arduino language:</p>



<ul class="wp-block-list">
<li>DDR register – determines whether the pin is an INPUT or OUTPUT</li>



<li>PORT register – controls whether the pin is HIGH or LOW</li>



<li>PIN register – reads the state of INPUT pins set to input with&nbsp;<em>pinMode()</em></li>
</ul>



<p>DDR and PORT registers may be both written to, and read. PIN registers correspond to the state of inputs and may only be read.</p>



<h3 class="wp-block-heading">Output Parallelization</h3>



<p>There is the possibility to parallelize some digital outputs to drive loads with the need of more current under the following conditions:</p>



<ul class="wp-block-list">
<li>Outputs are controlled from the same processor port (possibility to set it via one instruction)</li>



<li>There is no delay between control signls for parallelized outputs ( shall be managed by the SW)</li>
</ul>



<h3 class="wp-block-heading">Possible outputs for parallelization</h3>



<p>MINI<br>1st group: D0, D1, D2, D3<br>2nd group: D4, D5<br>3rd group: D6, D7</p>



<p>MAXI:<br>1st group: D0, D1, D3<br>2nd group: D2<br>3rd group: D4, D5, D6, D7<br>4th group: D8, D9, D10, D11</p>



<p>MEGA:<br>1st group: D0, D1, D3<br>2nd group: D2<br>3rd group: D4, D5, D6, D7<br>4th group: D8, D9, D10, D11<br>5th group: D12, D13, D14, D15, D16, D17, D18, D19<br>6th group: D20, D21, D22<br>7th group: D23</p>



<h3 class="wp-block-heading">Controllino PORTS</h3>



<p>In order to see which Controllino pin corresponds to which PORT on microprocessor open the Controllino PINOUT tables.<br>Link to PINOUT table is&nbsp;<a href="https://www.controllino.com/downloads/#datasheets">here</a>.</p>



<p>IMPORTANT INFORMATION!<br>Please, select proper target board in&nbsp;<strong>Tools-&gt;Board-&gt;Controllino MINI/MAXI/MEGA</strong>&nbsp;before Upload to your CONTROLLINO.<br>(Please, refer to https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library if you do not see the CONTROLLINOs in the Arduino IDE menu&nbsp;<strong>Tools-&gt;Board</strong>.)</p>



<h2 class="wp-block-heading">Hardware Required</h2>



<ul class="wp-block-list">
<li>Controllino MINI/MAXI/MEGA</li>



<li>12/24V DC Power supply</li>
</ul>



<h2 class="wp-block-heading">Circuit</h2>



<figure class="wp-block-image"><a href="https://www.controllino.com/wp-content/uploads/2017/07/CONTROLLINO-SPS-PLC-Tutorial-Connection.jpg" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://www.controllino.com/wp-content/uploads/2017/07/CONTROLLINO-SPS-PLC-Tutorial-Connection-215x300.jpg" alt="" class="wp-image-1997"/></a></figure>



<p>Note*<br>Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the Controllino permanently.</p>



<h2 class="wp-block-heading">Code</h2>



<p>To&nbsp; check where is the Overload LED connected we open the PINOUT table of the Controllino and find it.</p>



<figure class="wp-block-image"><a href="https://www.controllino.com/wp-content/uploads/2017/10/Overload-LED.jpg" target="_blank" rel="noopener noreferrer"><img decoding="async" src="https://www.controllino.com/wp-content/uploads/2017/10/Overload-LED.jpg" alt="" class="wp-image-2269"/></a></figure>



<p>Here we can see that the OVL LED is connected to the 7th bit of the PORT E on ATmega2560. There is no arduino number for this pin so we cannot set it like other arduino i/o pins.<br>The manipulation of this pin is shown in the next example:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="void setup() 
{

 //Define the LED as an OUTPUT
 DDRE = DDRE | B10000000;
 
}

void loop() 
{

 //Set the 7th bit of the PORT E to HIGH without influence on other bits (OR logic)
 PORTE = PORTE | B10000000;
 delay(1000);
 //Set the 7th bit of the PORT E to LOW without influence on other bits (AND logic)
 PORTE = PORTE &amp; B01111111;
 delay(1000);
 
}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">setup</span><span style="color: #ECEFF4">()</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">//Define the LED as an OUTPUT</span></span>
<span class="line"><span style="color: #D8DEE9FF"> DDRE </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> DDRE </span><span style="color: #81A1C1">|</span><span style="color: #D8DEE9FF"> B10000000</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">loop</span><span style="color: #ECEFF4">()</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">//Set the 7th bit of the PORT E to HIGH without influence on other bits (OR logic)</span></span>
<span class="line"><span style="color: #D8DEE9FF"> PORTE </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> PORTE </span><span style="color: #81A1C1">|</span><span style="color: #D8DEE9FF"> B10000000</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">delay</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">1000</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #ECEFF4"> </span><span style="color: #616E88">//Set the 7th bit of the PORT E to LOW without influence on other bits (AND logic)</span></span>
<span class="line"><span style="color: #D8DEE9FF"> PORTE </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> PORTE </span><span style="color: #81A1C1">&amp;</span><span style="color: #D8DEE9FF"> B01111111</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">delay</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">1000</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span></code></pre></div>



<p>To check the state of the&nbsp;Overload LED:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="void setup() 
{
 Serial.begin(9600);
 DDRE = DDRE &amp; B01111111; //Set PE7 (OVL pin) as INPUT
 Serial.println(&quot;CONTROLLINO Overload read:&quot;);
}

void loop() 
{
 Serial.print(&quot;Overload signal: &quot;);
 int Overload_signal = PINE &gt;&gt; 7;
 if (Overload_signal == 1) Serial.println(&quot;OFF&quot;);
 else Serial.println(&quot;ON&quot;);
 delay(1000);
}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">setup</span><span style="color: #ECEFF4">()</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">begin</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">9600</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> DDRE </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> DDRE </span><span style="color: #81A1C1">&amp;</span><span style="color: #D8DEE9FF"> B01111111</span><span style="color: #81A1C1">;</span><span style="color: #616E88"> //Set PE7 (OVL pin) as INPUT</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">println</span><span style="color: #ECEFF4">(</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">CONTROLLINO Overload read:</span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">loop</span><span style="color: #ECEFF4">()</span><span style="color: #D8DEE9FF"> </span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">print</span><span style="color: #ECEFF4">(</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Overload signal: </span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">int</span><span style="color: #D8DEE9FF"> Overload_signal </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> PINE </span><span style="color: #81A1C1">&gt;&gt;</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">7</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">if</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">(</span><span style="color: #D8DEE9FF">Overload_signal </span><span style="color: #81A1C1">==</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">1</span><span style="color: #ECEFF4">)</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">println</span><span style="color: #ECEFF4">(</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">OFF</span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">else</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Serial</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">println</span><span style="color: #ECEFF4">(</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">ON</span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">delay</span><span style="color: #ECEFF4">(</span><span style="color: #B48EAD">1000</span><span style="color: #ECEFF4">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span></code></pre></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Supply Voltage Terminal (12/24V DC)</title>
		<link>https://www.controllino.com/supply-voltage-terminal-12-24v-dc/</link>
		
		<dc:creator><![CDATA[marcoriedi]]></dc:creator>
		<pubDate>Tue, 30 May 2023 07:21:59 +0000</pubDate>
				<category><![CDATA[MAXI]]></category>
		<category><![CDATA[MEGA]]></category>
		<category><![CDATA[MINI]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://page2023.controllino.com/supply-voltage-terminal-12-24v-dc/</guid>

					<description><![CDATA[Intro The terminal “12V/24V” and “GND” on the upper side of the CONTROLLINO terminals are for the supply voltage connection. You can supply the CONTROLLINO with 12V or 24V. The range of voltage should be in the range of 10.8V-13.2V and 21.6V-26.4V direct voltage. IMPORTANT!&#160;Please make sure using a stabilized supply voltage! The maximal supply [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Intro</h2>



<p>The terminal “12V/24V” and “GND” on the upper side of the CONTROLLINO terminals are for the supply voltage connection. You can supply the CONTROLLINO with 12V or 24V. The range of voltage should be in the range of 10.8V-13.2V and 21.6V-26.4V direct voltage.</p>



<p><strong>IMPORTANT!</strong>&nbsp;Please make sure using a stabilized supply voltage!</p>



<p>The maximal supply current I not the same for MINI, MAXI and MEGA:</p>



<ul class="wp-block-list">
<li>MINI: 8A</li>



<li>MAXI: 20A</li>



<li>MEGA: 30A</li>
</ul>



<p>Exceeding the maximum current would lead to a fusing of the internal fuse of the CONTROLLINO.</p>



<p>The right supply voltage will be indicated by 2 LEDs. The LEDs are marked with “12V” and “24V”. Depending on the supply voltage the LEDs will show the state of the CONTROLLINO.</p>



<p>12V LED 24V LED state</p>



<p>green orange 12V supply voltage active</p>



<p>orange green 24V supply voltage active</p>



<p>orange orange supply voltage outside of supported range</p>



<p><em>INFO: After connecting the supply voltage CONTROLLINO will start immediately executing the loaded program!</em></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
