kyx101
I just started learning openPLC, which is a great open-source project. I would like to ask how to set the internal pull-up and pull-down of input pins for ESP32 and ESP8266
Reply 0 0
thiagoralves
The only way to do it currently is to edit the driver for your board and add the code in there. Drivers are located at /editor/arduino/src/hals
Reply 0 0
kyx101
The only way to do it currently is to edit the driver for your board and add the code in there. Drivers are located at /editor/arduino/src/hals
esp32引脚定义.png
It seems that this definition can also achieve built-in pull-up and pull-down input
Reply 0 0
fg71
If you use Arduino extension and Arduino API for I/O you are also updating the I/O after the main plc logic.
 
OpenPLC do things in follow order.
 
  1. update inputs
  2. update logic
  3. update output
  4. update arduino api
 
If you use location for variable you are using Arduino API to read/write that is happen in step 1 and 3
If you use Arduino extension and use Arduino API for I/O you update it in step 4
In that regard you could have a conflict there step 4 is override step 3
 
%I become pinMode(..., INPUT) and %Q become pinMode(..., OUTPUT)
 
If guess you could use if statement in board.cpp to set a specific pin to use other and OUTPUT.
 
ex.
 
You have 4 OUTPUT from %QX0.0...%QX0.3
 
You could use if statement that become true when index is the last object and set the pinMode to use other and OUTPUT
Same would apply to INPUT
You could use if statement that become true when index is the last object and set the pinMode to use other and INPUT
 
If your approach is still to use Arduino extension then you have to seperate plc logic from INPUT and OUTPUT
And use Arduino extension to be your INPUT and OUTPUT. Meaning you will not use location in your plc program.
And make sure you do not use any blocking in your loop() function.
Reply 0 0
thiagoralves
As long as you are careful with the statements on the Arduino Extension to not define as input a pin that has been defined as output on OpenPLC then you should be fine
Reply 0 0
zeloko22
This procedure stills the same for the current version of the Editor? There is any chance to introduce this option as a GUI checkbox for both pull_up or pull_down?
Reply 0 0
thiagoralves
Yes, the procedure is similar, which involves editing the driver for your board. We may add a checkbox in the future. The issue is that not all boards support this the same way.
Reply 1 0
Reply