Data transfer between 3 PB programs ...
Data transfer between 3 PB programs ...
Hello (again),
My PLC <-> RS485 <-> 3D virtual simulator becomes to big as a program to control/debug.
So, I decided to split my program in to 3 separated programs.
- 1 = Simulation on PC:
The 3D simulator follows the PLC program,
I need to transfer data from PLC program to the 3D program.
Data can be Strings, and bytes, words, longs.
- 2 = Real world to PC via RS485:
The PC receives data from Sub PC's / MPU's boards via my RS485 terminal program.
The Terminal program need to send data to the PC 3D simulator.
Q)
What is the best/simplest/fast way to transfer/synchronize data between these three programs on the PC level between all PB programs ?
- Receive data from RC485 terminal program.
- Send data from PLC program to 3D simulator program.
- Answer/confirmation from 3D to PLC program.
PS: the simulator PC is connected as a slave and not as master in the RS485 bus.
I use Win10_pro and PB5.73 x64
Thanks,
marc
My PLC <-> RS485 <-> 3D virtual simulator becomes to big as a program to control/debug.
So, I decided to split my program in to 3 separated programs.
- 1 = Simulation on PC:
The 3D simulator follows the PLC program,
I need to transfer data from PLC program to the 3D program.
Data can be Strings, and bytes, words, longs.
- 2 = Real world to PC via RS485:
The PC receives data from Sub PC's / MPU's boards via my RS485 terminal program.
The Terminal program need to send data to the PC 3D simulator.
Q)
What is the best/simplest/fast way to transfer/synchronize data between these three programs on the PC level between all PB programs ?
- Receive data from RC485 terminal program.
- Send data from PLC program to 3D simulator program.
- Answer/confirmation from 3D to PLC program.
PS: the simulator PC is connected as a slave and not as master in the RS485 bus.
I use Win10_pro and PB5.73 x64
Thanks,
marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
- NicTheQuick
- Addict

- Posts: 1527
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: Data transfer between 3 PB programs ...
The easiest cross-platform way would be a local network connection. Create a network server in one application that listens on localhost and a custom port, then let the other applications connect to it and transfer data between them. You just have to think about a communication protocol to be used.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: Data transfer between 3 PB programs ...
You can use RAMDISK to store and retrieve Data at any time
Egypt my love
Re: Data transfer between 3 PB programs ...
If only for Windows, you can use messages WM_COPYDATA, it's easy and fast.
Also you can use "Named Pipes"
Also you can use "Named Pipes"
Re: Data transfer between 3 PB programs ...
SQLite supports shared memory DB's.
This way you can save to disk(periodically) and keep logs,etc. and still maintain memory disk speeds.
Create a schema that supports your 3 program communication protocol.
Then use standard SQL query read/writes.
This way you can save to disk(periodically) and keep logs,etc. and still maintain memory disk speeds.
Create a schema that supports your 3 program communication protocol.
Then use standard SQL query read/writes.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Data transfer between 3 PB programs ...
Hi everyone,
Thanks for your ideas ...
But sorry, for me (old guy), its all like chinees for me.
Maybe I forgot to say that the frequency of data transfer is high.
For example, I need refresh rates for the PLC and 3D simulator.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
- So, I had have an other idea. (I don't know it will work)
But, I already use the RS485 BUS as a communication channel between the different (Teensy 3.2 / 4.0 / 4.1) controller modules.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
- This is totally out of my comfort zone ...
What I want to try is the follow:
- I just ordered a USB-A port module (1xUSB-A to PC <--> 4x USB-A Ports)
And I bought 3x USB-A to RS485 converter.
So, there is a way to communicate via the RS485 BUS on a different COM port.
The advantages are, that I can run one of my programs on a separated MINI PC / Raspberry PI.
Q)
Is it possible to use different COM port in 3 Different PB programs at the same time ?
PC OS = Win 10 pro x64
PB = 5.73 x64
Greatings,
Marc
Thanks for your ideas ...
But sorry, for me (old guy), its all like chinees for me.
Maybe I forgot to say that the frequency of data transfer is high.
For example, I need refresh rates for the PLC and 3D simulator.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
- So, I had have an other idea. (I don't know it will work)
But, I already use the RS485 BUS as a communication channel between the different (Teensy 3.2 / 4.0 / 4.1) controller modules.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
- This is totally out of my comfort zone ...
What I want to try is the follow:
- I just ordered a USB-A port module (1xUSB-A to PC <--> 4x USB-A Ports)
And I bought 3x USB-A to RS485 converter.
So, there is a way to communicate via the RS485 BUS on a different COM port.
The advantages are, that I can run one of my programs on a separated MINI PC / Raspberry PI.
Q)
Is it possible to use different COM port in 3 Different PB programs at the same time ?
PC OS = Win 10 pro x64
PB = 5.73 x64
Greatings,
Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
Re: Data transfer between 3 PB programs ...
Ok, a hardware approach using RS485 does allow multiple devices on 1 com port. Each device has a different
"address". Your speed is limited by the baud rate and parsing of each device. LAN devices can handle even higher data rates. Usually, serial port devices are connected for low speed/low byte counts communication. Not video refresh rates.
"address". Your speed is limited by the baud rate and parsing of each device. LAN devices can handle even higher data rates. Usually, serial port devices are connected for low speed/low byte counts communication. Not video refresh rates.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Data transfer between 3 PB programs ...
There's quite a good thread suggesting UDP as a means of communication between processes, which is also advocated by Infratec in one or two posts. Setting it up is easy, especially since it's connectionless.
https://www.purebasic.fr/english/viewto ... 88#p220188
https://www.purebasic.fr/english/viewto ... 40#p590440
https://www.purebasic.fr/english/viewto ... 88#p220188
https://www.purebasic.fr/english/viewto ... 40#p590440
UDP cause of the simplicity and on a LAN you will not loose packets.
TCP has a lot of overhead. If you want transmit one packet, many others are nedeed for handshakes.
The CPU load is less, the transfer is faster, you don't need to handle connect and disconnect ...
Re: Data transfer between 3 PB programs ...
I would also have suggested pipes, but the idea of using SQLite as an in-memory database to exchange data between several programmes is really great!
I hadn't even thought of that idea yet. It saves an enormous amount of programming in terms of data handling and synchronisation.
Thank you Skywalk for this suggestion!
I hadn't even thought of that idea yet. It saves an enormous amount of programming in terms of data handling and synchronisation.
Thank you Skywalk for this suggestion!
"Daddy, I'll run faster, then it is not so far..."
Re: Data transfer between 3 PB programs ...
How to open SQLite shared memory with PB OpenDatabase?
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Data transfer between 3 PB programs ...
Think about a Modus connection! That's a industrial standard way of communication betwwen a 'PLC' and something else!
I'm working on a new Modbus implementaiton for Purebasic. Once more I guess we need the same tings!
There is a Modbus implementation for Pruebasic in the Tips and Tricks forum. But it is only a Modbus Master.
But for communication in 2 way we need a Master and a slave implementation.
A ready solution for a professional Modbus is the free library libmodbus. The problem for me with libmodus is:
it is written in C and you have to build a lib with Visual Studio C. I tried the coumminty version of Visual Stuido.
But for me it is impossible to build the libmodbus.
The next problem is: You have to create a complete dll import for Purebasic. If you are able to do the build of libmodbus
let's do!
Or if yout want to be part of the Modbus for PB implementation please tell me. Then I can provide you my very early code.
It's complete from scratch in a 'industrial way!
I'm working on a new Modbus implementaiton for Purebasic. Once more I guess we need the same tings!
There is a Modbus implementation for Pruebasic in the Tips and Tricks forum. But it is only a Modbus Master.
But for communication in 2 way we need a Master and a slave implementation.
A ready solution for a professional Modbus is the free library libmodbus. The problem for me with libmodus is:
it is written in C and you have to build a lib with Visual Studio C. I tried the coumminty version of Visual Stuido.
But for me it is impossible to build the libmodbus.
The next problem is: You have to create a complete dll import for Purebasic. If you are able to do the build of libmodbus
let's do!
Or if yout want to be part of the Modbus for PB implementation please tell me. Then I can provide you my very early code.
It's complete from scratch in a 'industrial way!
Re: Data transfer between 3 PB programs ...
If you can program a Modbus Master (TCP/IP Client) in PureBasic, it should be no problem to write a Modbus Slave (TCP/IP Server).
Everything has been done before and has been running for years.
Everything has been done before and has been running for years.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
-
DarkDragon
- Addict

- Posts: 2347
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: Data transfer between 3 PB programs ...
https://www.sqlite.org/draft/inmemorydb.html
https://stackoverflow.com/a/15720872
It's only possible within one process to have a shared cache. Or use a physical file but on a ramdisk.
bye,
Daniel
Daniel
Re: Data transfer between 3 PB programs ...
Hi,
Sorry for the late response,
I'm working on my development/prototype of my hardware for the RS485 Control modules.
Thanks again for all the ideas and help ...
I gone try to build the [MASTER] and [SLAVE] in one PC.
[MASTER] will be the PB5.73x64 / PLC program.
[SLAVE 01] the 3D simulation program.
- For the people who are interested,
I will start a post about the hardware in the [Off Topic] section.
As this is not PB related.
See https://www.purebasic.fr/english/viewtopic.php?t=85229
Thanks,
Marc,
@SMaag,
Yes, one of us is copying the other.
Sorry for the late response,
I'm working on my development/prototype of my hardware for the RS485 Control modules.
Thanks again for all the ideas and help ...
I gone try to build the [MASTER] and [SLAVE] in one PC.
[MASTER] will be the PB5.73x64 / PLC program.
[SLAVE 01] the 3D simulation program.
- For the people who are interested,
I will start a post about the hardware in the [Off Topic] section.
As this is not PB related.
See https://www.purebasic.fr/english/viewtopic.php?t=85229
Thanks,
Marc,
@SMaag,
Yes, one of us is copying the other.
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...


