CONTROLLINO https://www.controllino.com Industrial PLCs | 100% Arduino-compatible Tue, 28 Nov 2023 10:53:33 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.1 https://www.controllino.com/wp-content/uploads/2023/05/cropped-C_Logo_Filled_RGB-1-32x32.png CONTROLLINO https://www.controllino.com 32 32 HTTP Web Client https://www.controllino.com/http-web-client/ https://www.controllino.com/http-web-client/#respond Tue, 28 Nov 2023 10:50:30 +0000 https://www.controllino.com/?p=15025 Introduction

Welcome to the “HTTP Web Client” tutorial using the CONTROLLINO MICRO. In this tutorial, we will learn how to create a web client that connects to a web server, using the provided example code as a starting point.

Prerequisites

  • Installed Arduino IDE.
  • CONTROLLINO MICRO board.

Example Code

Please grab the following example .ino file from Github:

Step-by-Step Guide

Step 1: Setup the Arduino Environment

  1. Connect your MICRO to your computer.
  2. Open the Arduino IDE.
  3. Ensure that the appropriate board and port are selected in the Tools menu.

Step 2: Understanding the Code

The example code can be broken down into several key parts:

Initialization

  • MAC Address: A unique identifier for your network interface. You can use the provided address.
  • IP and DNS: Optionally, you can set a static IP and DNS server address if DHCP fails.

Setup Function

  • Start Serial Communication: Initialize serial communication for debugging.
  • Initialize Ethernet: Attempt to start Ethernet with DHCP. If it fails, it uses the static IP set earlier.

Loop Function

  • Handle Incoming Data: If data is received from the Ethernet, it is printed to the serial monitor for debugging.
  • Reconnect and Send Requests: Every 10 seconds (as set by postingInterval), the httpRequest function is called to send a new request.

HTTP Request Function

  • Connect to Server: Attempt to connect to the specified server on port 80.
  • Send HTTP Request: If the connection is successful, send an HTTP GET request.
  • Handle Failed Connection: If the connection fails, print an error message.

Step 3: Create the Web Client

  1. Modify the MAC Address: Change the mac[] array if you want to use a different MAC address.
  2. Set IP and DNS (Optional): Modify ip and myDns if you need to use a static IP and DNS.
  3. Change Server Address: Replace server[] with the address of the web server you want to connect to.
  4. Upload Code: Connect your CONTROLLINO MICRO to your computer, select the appropriate board and port in the Arduino IDE, and upload the code.
  5. Monitor Output: Open the Serial Monitor in the Arduino IDE to see debug output and responses from the server.

Conclusion

You now have a basic web client running on your CONTROLLINO MICRO. This client connects to a specified web server, sends an HTTP GET request, and prints the response. You can expand on this by modifying the request, handling different types of responses, or integrating this functionality into a larger project.

Remember, networking can sometimes be tricky, so don’t hesitate to experiment and troubleshoot as needed. Enjoy exploring the capabilities of your CONTROLLINO MICRO!

]]>
https://www.controllino.com/http-web-client/feed/ 0
Scan for I2C Devices https://www.controllino.com/scan-for-i2c-devices/ https://www.controllino.com/scan-for-i2c-devices/#respond Tue, 28 Nov 2023 10:43:42 +0000 https://www.controllino.com/?p=15023 Introduction

The I2C (Inter-Integrated Circuit) protocol is a popular means of communication between various sensors and devices. In this tutorial, we will learn how to create an I2C scanner using the CONTROLLINO MICRO, which is useful for detecting the I2C addresses of devices connected to your microcontroller.

Prerequisites

  • Installed Arduino IDE.
  • CONTROLLINO MICRO board.

Example Code

Please grab the following example .ino file from Github:

Step-by-Step Guide

Step 1: Setup the Arduino Environment

  1. Connect your MICRO to your computer.
  2. Open the Arduino IDE.
  3. Ensure that the appropriate board and port are selected in the Tools menu.

Step 2: Understanding the Code

The Setup Function

void setup()
{
  Wire.setSDA(PIN_WIRE0_SDA);
  Wire.setSCL(PIN_WIRE0_SCL);
  Wire.begin();
  Serial.begin(9600);
  while (!Serial);
  Serial.println("\nI2C Scanner");
}
  • Wire.setSDA() and Wire.setSCL(): Sets the SDA (data line) and SCL (clock line) pins for I2C communication.
  • Wire.begin(): Initializes the I2C bus.
  • Serial.begin(9600): Starts serial communication at 9600 baud rate.
  • Serial.println("\nI2C Scanner"): Prints a message to the Serial Monitor.

The Loop Function

void loop()
{
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for (address = 1; address < 127; address++)
  {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0)
    {
      // Device found
    }
    else if (error == 4)
    {
      // Unknown error
    }
  }
  // Print scan results
  delay(5000); // Wait for next scan
}
  • Scans I2C addresses from 1 to 126.
  • Wire.beginTransmission(address): Starts transmission to a device at address.
  • error = Wire.endTransmission(): Ends the transmission and returns an error status.
  • If error is 0, an I2C device is found.
  • If error is 4, there’s an unknown error at the address.

Step 3: Hardware Setup

  1. Connect your I2C device(s) to the CONTROLLINO MICRO.
  2. Ensure proper connections for SDA and SCL lines, along with power and ground.

Step 4: Using the I2C Scanner

  1. Open the Serial Monitor in the Arduino IDE.
  2. Set the baud rate to 9600.
  3. Observe the output. The scanner will list the addresses of detected I2C devices.

Step 5: Interpreting Results

  • Addresses will be displayed in hexadecimal format.
  • Note down the addresses of your I2C devices for use in your projects.

Conclusion

This tutorial has guided you through setting up an I2C scanner on the CONTROLLINO MICRO. This tool is invaluable for troubleshooting and setting up I2C communication with various sensors and peripherals.

]]>
https://www.controllino.com/scan-for-i2c-devices/feed/ 0
Modbus RTU Server https://www.controllino.com/modbus-rtu-server/ https://www.controllino.com/modbus-rtu-server/#respond Tue, 28 Nov 2023 10:38:06 +0000 https://www.controllino.com/?p=15021 Introduction

This tutorial will guide you through setting up a Modbus RTU server on a CONTROLLINO MICRO. We’ll be using a modified version of an example code that demonstrates how to control an LED via a Modbus RTU server.

Prerequisites

  • Installed Arduino IDE.
  • CONTROLLINO MICRO board.

Example Code

Please grab the following example .ino file from Github:

Step-by-Step Guide

Step 1: Setup the Arduino Environment

  1. Connect your MICRO to your computer.
  2. Open the Arduino IDE.
  3. Ensure that the appropriate board and port are selected in the Tools menu.
  4. Install the ArduinoRS485 and ArduinoModbus libraries via the Library Manager in the Arduino IDE.

Step 2: Understanding the Modbus RTU Server Code

The provided code snippet establishes a Modbus RTU server. Here’s a breakdown:

  • Libraries: Include ArduinoRS485 and ArduinoModbus.
  • RS485 Configuration: Set up the RS485 serial communication.
  • Setup Function: Initialize serial communication, set up the Modbus server and LED.
  • Loop Function: Constantly checks for Modbus requests and toggles the LED based on the coil value.

Step 3: Testing the code

After uploading, your CONTROLLINO MICRO should be ready to respond to Modbus RTU client requests. Use a Modbus RTU client to send requests to your server:

  • Writing a value of 1 to coil address 0x00 should turn the LED on.
  • Writing a value of 0 should turn it off.

Troubleshooting

If the LED does not respond as expected, check the following:

  • Correct wiring of the LED and Modbus connections.
  • Verify the correct COM port and board settings in the Arduino IDE.
  • Make sure the Modbus client is correctly configured to communicate with your server.

Conclusion

You have now successfully created a Modbus RTU server on your CONTROLLINO MICRO. This server can interact with Modbus clients, allowing for various automation and control applications. Experiment with different Modbus registers and functionalities to expand your project!

]]>
https://www.controllino.com/modbus-rtu-server/feed/ 0
Modbus TCP Server https://www.controllino.com/modbus-tcp-server/ https://www.controllino.com/modbus-tcp-server/#respond Tue, 28 Nov 2023 10:32:57 +0000 https://www.controllino.com/?p=15019 Introduction

This tutorial will guide you through setting up a Modbus TCP server on a CONTROLLINO MICRO. We’ll be using a modified version of an example code that demonstrates how to control an LED via a Modbus TCP server.

Prerequisites

  • Installed Arduino IDE.
  • CONTROLLINO MICRO board.

Example Code

Please grab the following example .ino file from Github:

Step-by-Step Guide

Step 1: Setup the Arduino Environment

  1. Connect your MICRO to your computer.
  2. Open the Arduino IDE.
  3. Ensure that the appropriate board and port are selected in the Tools menu.
  4. In the Arduino IDE, include the SPI, Ethernet, ArduinoRS485, and ArduinoModbus libraries.

Step 2: Configure Network Settings

Define a MAC address and IP address for your device. Replace the mac and ip variables with your desired values.

Step 3: Initialize Ethernet and Modbus TCP Server

In the setup() function, start the Ethernet connection using Ethernet.begin(mac, ip). Verify Ethernet hardware and connection status and initialize the Modbus TCP server with modbusTCPServer.begin().

Step 4: Configure Digital Outputs & Modbus Coils

Set the LED pin as an output and initialize it to LOW (off). Configure a single coil at address 0x00 using modbusTCPServer.configureCoils(0x00, 1).

Step 5: Handling connections and updating the LED value

Handling Client Connections

In the loop() function, use ethServer.available() to listen for incoming clients. Once a client is connected, use modbusTCPServer.accept(client) to accept the connection.

Polling and Controlling the LED

Continuously call modbusTCPServer.poll() to listen for Modbus requests. Use updateLED() to read the coil value and update the LED state.

The updateLED Function

This function reads the coil value using modbusTCPServer.coilRead(0x00). It then sets the LED state based on the coil value.

Troubleshooting

  • If the LED does not respond, check your network connection and ensure your Modbus client is configured correctly.
  • Verify the MAC and IP address are correctly set for your network environment.
  • Make sure the correct board and port are selected in the Arduino IDE.

Conclusion

You have now successfully created a Modbus TCP server on your CONTROLLINO MICRO. This server can interact with Modbus clients, allowing for various automation and control applications. Experiment with different Modbus registers and functionalities to expand your project!

]]>
https://www.controllino.com/modbus-tcp-server/feed/ 0
ECC608 Crypto Chip: Random Number Generator https://www.controllino.com/ecc608-crypto-chip-random-number-generator/ https://www.controllino.com/ecc608-crypto-chip-random-number-generator/#respond Tue, 28 Nov 2023 10:26:20 +0000 https://www.controllino.com/?p=15017 Introduction

In this tutorial, we will explore how to use the ECC608 Crypto Chip on a CONTROLLINO MICRO board to generate truly random numbers. This is particularly useful in applications requiring high levels of security, such as cryptographic operations, secure communications, or any scenario where unpredictability is crucial.

Prerequisites

  • Installed Arduino IDE.
  • CONTROLLINO MICRO board.

Example Code

Please grab the following example .ino file from Github:

Step-by-Step Guide

Step 1: Setup the Arduino Environment

  1. Connect your MICRO to your computer.
  2. Open the Arduino IDE.
  3. Ensure that the appropriate board and port are selected in the Tools menu.

Step 2: Understanding the Provided Code


#include <SPI.h>
#include <ArduinoECCX08.h>

void setup() {
  Serial.begin(115200);
  while (!Serial);
  delay(2000);

  Wire.setSDA(2);
  Wire.setSCL(3);
  
  if (!ECCX08.begin()) {
    Serial.println("Failed to communicate with ECC508/ECC608!");
    while (1);
  }

  if (!ECCX08.locked()) {
    Serial.println("The ECC508/ECC608 is not locked!");
    while (1);
  }
}

void loop() {
  Serial.print("Random number = ");
  Serial.println(ECCX08.random(65535));

  delay(1000);
}

Code Breakdown

  • Initialization: The setup() function initializes serial communication and sets up the I2C communication with specific SDA and SCL pins. It also checks if the ECC608 chip is properly communicating and locked for secure operations.
  • Generating Random Numbers: The loop() function continuously generates a random number using ECCX08.random(65535) and prints it to the Serial Monitor every second.

Step 3: Running the Code

  1. Copy the provided code into a new sketch in the Arduino IDE.
  2. Upload the sketch to your CONTROLLINO MICRO.
  3. Open the Serial Monitor (Tools > Serial Monitor) to view the random numbers being generated.

Troubleshooting

  • If the Serial Monitor displays an error related to the ECC608 chip, ensure that the chip is correctly configured and locked.
  • For any issues related to the Arduino IDE or board connections, consult the official Arduino forums or documentation.

Conclusion

By following this tutorial, you have successfully used the ECC608 Crypto Chip on your CONTROLLINO MICRO to generate truly random numbers. This functionality can be integrated into larger projects where secure random number generation is required.

Feel free to modify the code to suit your specific application needs, and explore other capabilities of the ECC608 chip to enhance the security of your projects.

]]>
https://www.controllino.com/ecc608-crypto-chip-random-number-generator/feed/ 0
ECC608 Crypto Chip: Self-signed Certificate https://www.controllino.com/ecc608-crypto-chip-self-signed-certificate/ https://www.controllino.com/ecc608-crypto-chip-self-signed-certificate/#respond Tue, 28 Nov 2023 10:18:26 +0000 https://www.controllino.com/?p=15015 Introduction

Creating a self-signed certificate using the ECC608 crypto chip involves generating a private key within the chip and then creating a certificate that is signed with this key. This tutorial demonstrates the process using CONTROLLINO MICRO and the ECC608 chip.

Prerequisites

  • Installed Arduino IDE.
  • CONTROLLINO MICRO board.

Example Code

Please grab the following example .ino file from Github:

Step-by-Step Guide

Step 1: Setup the Arduino Environment

  1. Connect your MICRO to your computer.
  2. Open the Arduino IDE.
  3. Ensure that the appropriate board and port are selected in the Tools menu.

Step 2: Understanding the Provided Code

The provided example code performs the following functions:

  • Initializes the ECC608 chip.
  • Checks if the chip is locked and prompts the user to lock it with a default TLS configuration if not.
  • Gathers input for certificate details such as issue date, expiry, and slot numbers for key storage.
  • Generates a new private key (if required) and a self-signed certificate.
  • Outputs the certificate and its SHA1 fingerprint.

Step 3: Load the Example Code

  1. Copy the provided code into a new sketch in the Arduino IDE.
  2. Review the code to understand its flow and functionality.

Step 4: Modify the Code (Optional)

You can modify the default values or add additional functionality as needed. For instance, you might want to change the default slot numbers or the default years of validity for the certificate.

Step 5: Compile and Upload the Code

  1. Click on the Verify button to compile the code.
  2. Click on the Upload button to upload the code to your Arduino MKR board.

Step 6: Interact with the Program

After uploading, open the Serial Monitor. You will see prompts asking for various details needed to generate the certificate:

  • Issue date and time of the certificate.
  • Expiry duration of the certificate.
  • Slots for storing the private key and certificate.
  • Choice to generate a new key.

Step 7: Generate the Certificate

Respond to the prompts in the Serial Monitor. The program will generate a self-signed certificate based on your responses and display it along with its SHA1 fingerprint.

Troubleshooting

  • If the Serial Monitor displays an error related to the ECC608 chip, ensure that the chip is correctly configured and locked.
  • For any issues related to the Arduino IDE or board connections, consult the official Arduino forums or documentation.

Conclusion

You now have a self-signed certificate generated by the ECC608 chip. This certificate can be used for various cryptographic purposes, enhancing the security of your projects.

]]>
https://www.controllino.com/ecc608-crypto-chip-self-signed-certificate/feed/ 0
CAN Sender https://www.controllino.com/can-sender/ https://www.controllino.com/can-sender/#respond Tue, 28 Nov 2023 10:14:00 +0000 https://www.controllino.com/?p=15013 Introduction

This tutorial will guide you through using the CAN (Controller Area Network) port on the CONTROLLINO MICRO to send data. We’ll use example code to demonstrate how to set up and send both standard and extended CAN messages.

Prerequisites

  • Installed Arduino IDE.
  • CONTROLLINO MICRO board.

Example Code

Please grab the following example .ino file from Github:

Step-by-Step Guide

Step 1: Initialization

  • Serial Begin: Initialize serial communication at 115200 baud rate to monitor the data sending process.cppCopy codeSerial.begin(115200);
  • CAN Initialization: Start the CAN bus at 500 kbps. This is a common speed for CAN networks.cppCopy codeSPI1.setRX(PIN_SPI1_MISO); SPI1.setTX(PIN_SPI1_MOSI); SPI1.setSCK(PIN_SPI1_SCK); if (!CAN.begin(500E3)) { Serial.println("Starting CAN failed!"); while (1); }

Step 2: Sending Standard CAN Packets

  • Begin Packet: Start a CAN packet with a standard ID (11 bits). In this example, 0x12 is used as the ID.cppCopy codeCAN.beginPacket(0x12);
  • Write Data: Send the data bytes. Here, we’re sending the word ‘hello’.cppCopy codeCAN.write('h'); CAN.write('e'); CAN.write('l'); CAN.write('l'); CAN.write('o');
  • End Packet: End the CAN packet transmission.cppCopy codeCAN.endPacket();

Step 3: Sending Extended CAN Packets

  • Begin Extended Packet: Start an extended CAN packet with a 29-bit ID. Example ID: 0xabcdef.cppCopy codeCAN.beginExtendedPacket(0xabcdef);
  • Write Extended Data: Similar to standard packets, but with different data. In this case, ‘world’.cppCopy codeCAN.write('w'); CAN.write('o'); CAN.write('r'); CAN.write('l'); CAN.write('d');
  • End Extended Packet: Conclude the extended packet transmission.cppCopy codeCAN.endPacket();

Step 4: Loop

The loop() function sends these packets continuously at one-second intervals.

Testing and Validation

  1. Monitor Serial Output: Open the Serial Monitor in your Arduino IDE to view the sending process and confirm successful transmission.
  2. Check CAN Network: If possible, use a CAN analyzer or another CAN device to ensure the packets are being received correctly.
  3. Troubleshooting: If there are issues in transmission, check connections, baud rate settings, and CAN IDs.

Conclusion

With this tutorial, you should be able to send both standard and extended CAN messages from your CONTROLLINO MICRO. This functionality is essential for many automotive and industrial applications using the CAN network.

]]>
https://www.controllino.com/can-sender/feed/ 0
CAN Receiver https://www.controllino.com/can-receiver/ https://www.controllino.com/can-receiver/#respond Mon, 27 Nov 2023 09:45:25 +0000 https://www.controllino.com/?p=15004 Introduction

In this tutorial, we’ll learn how to use the CAN (Controller Area Network) port on the CONTROLLINO MICRO to receive data. CAN is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other’s applications without a host computer.

Prerequisites

  • Installed Arduino IDE.
  • CONTROLLINO MICRO board.

Example Code

Please grab the following example .ino file from Github:

Overview of the Example Code

The provided example code is a simple CAN Receiver program. It initializes the CAN bus at a speed of 500 kbps and continuously checks for incoming CAN packets. When a packet is received, it prints its details and data to the Serial Monitor.

Key Functions

  • CAN.begin(speed): Initializes the CAN bus at the specified speed.
  • CAN.parsePacket(): Checks for incoming packets and returns their size.
  • CAN.packetId(): Returns the ID of the received packet.
  • CAN.packetExtended(): Checks if the packet uses an extended ID.
  • CAN.packetRtr(): Checks if the packet is a Remote Transmission Request (RTR).
  • CAN.read(): Reads a byte of data from the received packet.

Step-by-Step Guide

Step 1: Setting Up Your Environment

  1. Connect your CONTROLLINO MICRO to your computer.
  2. Open the Arduino IDE and select the correct board and port for your CONTROLLINO MICRO.

Step 2: Understanding the Code

  1. Serial Communication: The Serial.begin(115200); command starts serial communication at a baud rate of 115200. This is useful for debugging and monitoring CAN traffic.
  2. CAN Initialization: CAN.begin(500E3); initializes the CAN bus at 500 kbps. The if statement checks if the CAN bus starts successfully.
  3. Receiving CAN Packets: Inside the loop(), CAN.parsePacket(); checks for incoming packets. If a packet is received, its details (like ID, type, size) are printed to the Serial Monitor.

Step 3: Modifying the Code for Your Application

  • You can modify the loop() function to suit your application needs. For example, you might want to perform specific actions based on the packet’s ID or data.

Step 4: Uploading and Testing

  1. Copy the provided example code into a new sketch in the Arduino IDE.
  2. Upload the sketch to your CONTROLLINO MICRO.
  3. Open the Serial Monitor to view the output.

Step 5: Debugging

  • If you encounter issues, ensure your CAN bus is correctly configured and all devices are properly connected.
  • Check the baud rate and CAN bus settings.

Conclusion

You now have a basic understanding of how to use the CAN port on the CONTROLLINO MICRO to receive data. This setup can be the foundation for more complex applications involving vehicle networks, industrial automation, and more.

]]>
https://www.controllino.com/can-receiver/feed/ 0
SPS Fair 2023 https://www.controllino.com/sps-fair-2023/ https://www.controllino.com/sps-fair-2023/#respond Tue, 21 Nov 2023 12:57:26 +0000 https://www.controllino.com/?p=14910 CONTROLLINO was again an exhibitor at SPS Fair 2023. We celebrated the launch of our MICRO, showcased new products (psst, stay tuned for more!) and of course: enjoyed quite a bunch of Negronis!

Thanks for everyone who visited us! 🙂

]]>
https://www.controllino.com/sps-fair-2023/feed/ 0
Board & Library Setup with Platform.io https://www.controllino.com/board-library-setup-with-platform-io/ https://www.controllino.com/board-library-setup-with-platform-io/#respond Tue, 30 May 2023 09:21:28 +0000 https://page2023.controllino.com/?p=5080 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:

]]>
https://www.controllino.com/board-library-setup-with-platform-io/feed/ 0