Config.txt - Configuration Guide for GPIO and Serial Port Usage
The Config.txt file, located inside the Project folder, is crucial for configuring GPIO and serial port usage. When Soft PLC files are saved, this file is created empty. An empty Config.txt file means that Soft PLC will not perform any operations. However, once edited, Soft PLC will follow the instructions contained within
Steps to Create and Transfer Config.txt
- Create Config.txt on Your Computer:
- Create the Config.txt file on your computer and transfer the file via FTP or create it directly through the terminal on your Raspberry Pi.
-
Sample Config.txt File:
Config.txt
Shutdown Detect:29U;
Digital Inputs:33D;35U;36;37U;
Digital Outputs:38;40;
Hardware PWM:Pin=12;Clock=100000;Range=100;
Software PWM:Pin=16;Range=100;
Serial Port:Name=/dev/ttyS1;BaudRate=9600;Parity=None;StopBits=2;DataBits=8;FlowControl=None;EnablePin=32;
Serial Port:Name=/dev/ttyS2;BaudRate=9600;Parity=None;StopBits=2;DataBits=8;FlowControl=None;EnablePin=7;
-
- This example is prepared according to the WiringPi library.
- Physical pin numbers should be used.
- Do not create lines for unused features. For example, if there are no DI, do not add that line.
- List Hardware PWM, Software PWM, and serial ports one below the other as many as needed.
- Don’t forget to adjust the GPIO pin numbers according to your hardware.
- Run the “gpio readall” command in the terminal to view the pin table for your device.
- To use GPIOs, you also need to reserve these addresses in the IO Addresses tab for Soft PLC in Fulmatic SOFT.
Detailed Configuration Instructions
Shutdown Detect
- The pin to be used for your closure detection circuit. Below is an example of a closure detection circuit (SD Detect) in the image provided. You can also examine it here.
- Soft PLC has 256 kB of memory. Only the used part of the memory is saved to the disk, reducing the capacitor size needed for the shutdown circuit.
- When the program is closed with Ctrl + C, the required shutdown time is displayed on the terminal screen: “PLC_Code.bin saving time: 70 ms.” This time depends on the hardware speed and the size of the written PLC code.
- If the shutdown time is insufficient, add additional capacitors. We recommend starting with 3300uf.
Shutdown Detect
Shutdown Detect:29U;
Digital Inputs
-
Specification:
-
List pins sequentially with optional U for Pull Up or D for Pull Down.
-
Digital Inputs
Digital Inputs:33D;35U;36;37U;
-
- 33D – I 0.0 – Low
- 35U – I 0.1 – High
- 36 – I 0.2 – Low
- 37U – I 0.3 – High
-
Notes:
- U and D may not work on some systems. Set manually or use external resistors.
- The first pin number represents the first bit of the digital input start address in Soft PLC.
- Each pin number listed represents the subsequent bits starting from the start address.
Digital Outputs
- Specification:
- Specify the pin numbers to be used as digital outputs.
- Pins should be listed sequentially, and U, D notation cannot be used.
Digital Outputs
Digital Outputs:38;40;
-
- 38 – Q 0.0
- 40 – Q 0.1
-
Notes:
- The first pin number represents the first bit of the digital output start address in Soft PLC.
- Each pin number listed represents the subsequent bits starting from the start address.
PWM Configuration
- In PWM, Clock and Period are written as constants in the Config.txt file.
- The analog output address in Fulmatic SOFT is the output value of the first PWM. This value should be between 0 and the set Period.
- PWM range should be written as a maximum of 1024.
- If you set the analog output address to 100, the first PWM will be UINT16 type QW 100. The other PWMs will be QW 102, QW 104, and so on.
- Hardware PWMs are addressed first, followed by Software PWMs.
- No fractional numbers are used.
Hardware PWM
- By using Hardware PWM, you can generate PWM signals at specific frequencies and ranges and use these signals in different applications.
- Each device may have different pin numbers for hardware PWM. Here we show an example usage.
Hardware Pwm
Hardware PWM:Pin=12;Clock=100000;Range=100;
-
- Pin= Hardware PWM pin number 12 (GPIO18-PWM0)
- Clock= PWM frequency
- Range= PWM range (between 0 and 1024)
- Pin= Hardware PWM pin number 12 (GPIO18-PWM0)
Software PWM
- Using Software PWM, you can generate PWM signals on an idle GPIO pin.
Software Pwm
Software PWM:Pin=16;Range=100;
-
- Pin= Software PWM pin number
- Range= PWM range
- Frequency formula: Frequency Hz. = 1,000,000 / (PWM Range x 100us)
- Range 100: Frequency Hz. = 1,000,000 / (100 x 100us) = 100 Hz
- Pin= Software PWM pin number
Serial Port Configuration
- Specification:
- Communicate with other devices using the serial port.
Serial Port
Serial Port:Name=/dev/ttyS1;BaudRate=115200;Parity=None;StopBits=1;DataBits=8;FlowControl=None;EnablePin=32;
Serial Port:Name=/dev/ttyS2;BaudRate=115200;Parity=None;StopBits=1;DataBits=8;FlowControl=None;EnablePin=7;
- Parameters:
- Name – Should be written according to your hardware.
- BaudRate – Communication speed
- Parity – None, Even, Odd, Mark, Space
- StopBits – 0, 1, 2
- DataBits – 7, 8, 9 (8 for Modbus)
- FlowControl – None, RequestToSend, RequestToSendXOnXOff, XOnXOff
- EnablePin – If serial port communication is to be provided via an RS485 integrated circuit, one of the GPIO pins is used as the Enable pin.
Note: If you are communicating over a serial port using a USB converter or an RS232 chip, you do not need to specify the EnablePin parameter. This parameter is only necessary when using an RS485 integrated circuit.
Serial Port
Serial Port:Name=/dev/ttyS1;BaudRate=115200;Parity=None;StopBits=1;DataBits=8;FlowControl=None;