tvmoses
Hello,
 
i'm trying to transfer a very small program on a Pi Pico but i cant.
I've connected the Pi Pico via micro USB cable but it is recognized only as a usb Drive "Rpi-RPi2".
In "Device manager" is recognized as "RP2 Boot" but with no driver installed and claiming no serial port (COM).
 
I've tried installing the driver for it using a tool called "Zadig" but with very low success. The driver and the serial port is installed but
OpenPlc Editor can't transfer the program to the Pico.
It gives me "Error during Upload: Failed uploading: uploading error: exit status 1"
 
Also i've updated OpenPlc Editor to its last version.
 
How can i resolve this problem?
Thanks in advance,
 
Best Regards
Andrew
thiagoralves
You managed to put your pico is in "bootloader" mode. The easiest way to fix this is to upload a program to it manually by dragging and dropping a UF2 firmware file to it (like copying to a flash drive). You can select "compile only" on OpenPLC, and then once it finishes compiling, grab the folder where the firmware was compiled to and copy over the UF2 file to the pico.
Reply 1 0
tvmoses
Thanks for your response,
 
i've tried your method a few minutes ago and it worked.
May i ask if i can make a Raspberry Pi Pico W as a Modbus TCP Slave ?
Because i've tried doing so in the "Transfer program to PLC" window under "Communications" tab
but as i compile the code it gives me this error:
 
Using library SPI in folder: C:\Users\Tecnico\AppData\Local\Arduino15\packages\arduino\hardware\mbed_rp2040\4.0.4\libraries\SPI (legacy)
Using library WiFiNINA at version 1.8.14 in folder: C:\Users\Tecnico\Documents\Arduino\libraries\WiFiNINA
C:\Users\Tecnico\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp: In static member function 'static void SpiDrv::begin()':
C:\Users\Tecnico\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:103:15: error: 'NINA_GPIO0' was not declared in this scope
pinMode(NINA_GPIO0, OUTPUT);
^~~~~~~~~~
C:\Users\Tecnico\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:103:15: note: suggested alternative: 'NINA_GPIOIRQ'
pinMode(NINA_GPIO0, OUTPUT);
^~~~~~~~~~
NINA_GPIOIRQ
C:\Users\Tecnico\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp: In static member function 'static int SpiDrv::available()':
C:\Users\Tecnico\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:66:25: error: 'NINA_GPIO0' was not declared in this scope
#define NINA_GPIOIRQ NINA_GPIO0
^
C:\Users\Tecnico\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:597:25: note: in expansion of macro 'NINA_GPIOIRQ'
return (digitalRead(NINA_GPIOIRQ) != LOW);
^~~~~~~~~~~~
C:\Users\Tecnico\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:66:25: note: suggested alternative: 'NINA_GPIOIRQ'
#define NINA_GPIOIRQ NINA_GPIO0
^
C:\Users\Tecnico\Documents\Arduino\libraries\WiFiNINA\src\utility\spi_drv.cpp:597:25: note: in expansion of macro 'NINA_GPIOIRQ'
return (digitalRead(NINA_GPIOIRQ) != LOW);
^~~~~~~~~~~~
 
Tell me if may i have to make another thread for this problem...
Thanks in advance,
 
Best regards
Andrew
Reply 0 0
thiagoralves
 
Update your editor and try again. I don't have a Pico W to test, but at least on my editor the code compiles now.
Reply 1 0
tvmoses
Hello,
 
I must say it worked. The Pi Pico W is connected to the router and i can ping it from the PC connected to same network via Wi-Fi.
Also Modbus TCP works both sending and receiving using RMMS Modbus Simulator. 
 
These days i might try connecting it to a S7-1200.
Thanks and have a good day!
Reply 0 0
tvmoses
Hello,
 
as i said in the previous post, Modbus on Pico W works but i've encountered a problem.
I've connected a Pi Pico W as a Modbus Server to a Siemens S7-1200 as Modbus Client using the dedicated function block "Mb_Client" and
i can write successfully the available 55 bits of the Pico W in output.
 
The problem is that after about 20 minutes the Pico W loose connection with the router.
I've tested pinging it from the PC connected to the same network and subnet and it won't find it.
The router is far from the Pico but not that much.
In the same position of the Pico i've got quite a good connection with the phone.
 
On the S7-1200 side, i've made this:
 
[203128%2F8348375%2Fmceclip0]
 
DbSystem.bSqr5 is a a squarewave clock of 500ms. Every 500 ms the datas are written.
Could be this the problem? Maybe 500ms is too fast and causes the Pico to freeze.
Have you got maybe any other ideas that may cause this problem?
 
Thanks in advance
Best Regards
 
Andrew
Reply 0 0
thiagoralves
This looks like a memory leak somewhere that could be causing the pico to freeze. Can you share your pico plc program as well?
Reply 1 0
tvmoses
Ok, thanks for your response!
Here you are the program.
It's very simple, i needed only two outputs of the Pico (Q0.0 and Q0.1) to drive two relays in order to open two electric lock of two gates.
Reply 0 0
thiagoralves
Perhaps it would be nice to have a blinking output (like the blinking example) controlled locally by the pico plc program to evaluate if the entire runtime is crashing or just the network part of it. If the led keeps blinking even after you lose Modbus connectivity, then maybe is something affecting just the network. If it stops blinking then the runtime is dead. Can you do that and let me know the result please?
Reply 1 0
tvmoses
Ok, i have tried what you've asked me to do, but maybe not in a precise way.
I've tried as so:
 
I've connected another Pi Pico W with Modbus configurated to the router.
The Pico W had loaded the blinking program without any client writing by means of Modbus to it.
Waited an hour and ...it remains connected without any problem... it's connected right now since a hour ago.
I may guess the problem come up only when data is wrote continuously to the Pico. After an amount of writings, the Pico freeze or loose connection.
 
A thing i've noticed on RMMS is that after i connect to the Pico.
it came up this text notification: "Modbus message timeout" basically every poll.
 
Immagine3.png
 
Maybe in this we can figure out the error. If you need other tests, let me know.
i've also  mounted an access point to have a stronger connection beside the Pico W and the problem persisted.
Reply 0 0
thiagoralves
Ir would be good to have this test done on the same pico to know what part of the firmware crashed
Reply 1 0
tvmoses
Ok, i might do the test as i come home this evening, might tomorrow. Thanks again
Best regards
Reply 0 0
tvmoses
Crashes only network. The led keeps blinking after the Pico closes the connection.
Reply 0 0
thiagoralves
That's interesting... it might indicate that something could be leaving open connections on the Pico. The Modbus TCP handler can only handle up to 3 (or maybe 5, I don't remember exactly) simultaneous connections. If another device is keeping the connection open - even if it is not sending any request - and it reaches the maximum limit, the pico will then prevent future connections to be opened until the previous ones are closed.
Reply 0 0
tvmoses
Ok, i understand. It could be a problem with MB_CLIENT configuration on S7-1200.
By reading you're message I guess i need to disconnect to the Pico when transfer is done. To close the connection and not leave simultaneous open connections.
I'll try so and i'll let you know if it works. (please be patient, it's the first time i use Modbus 😅😉)
Reply 0 0
Reply