Forum Home › Forums › Understanding the Software › Com Ports ?
- This topic has 18 replies, 4 voices, and was last updated 2 years, 5 months ago by Rich Ex.
-
AuthorPosts
-
November 5, 2021 at 8:07 am #9627Rich ExParticipant
Hi All
Is it possible for RapidScada to read data from a com port connected to the PC that is running RapidScada .
I have an old device that sends a stream of ASCII characters over the com port every 5 minutes and I want capture these with my RapidScada .
The stream is like 10/10/21 10:18 21.2 23.4 5 18 20 ( it sends date time and some measurements )
I know its not a SCADA format but any thoughts please .
Thanks as always
RichNovember 5, 2021 at 10:41 am #9630MikhailModeratorHi,
Rapid SCADA supports COM ports. But you also need a driver (dll) for Communicator that implements recognizing the data in a particular format. It’s possible to develop such driver.
November 8, 2021 at 12:43 pm #9635Rich ExParticipantHi Mikhail,
Thank you for the information .Is there an existing example to give me an idea of where to start will a dll for the COM port .
Thanks
RichardNovember 9, 2021 at 1:27 pm #9637MikhailModeratorHi,
Please check the driver development article and the existing driver as an example (link 1, link 2).
November 10, 2021 at 4:31 pm #9640Rich ExParticipantMikhail ,
Thats brilliant thank you .I have written a stand alone program that now gets the RS232 data from the device and writes it into a text file like ‘mydata.txt’, its simple the text file just shows a single number like 22.3
Could I not just write a formula to read this ‘mydata.txt’ file into RapidScada and then return this number from the file or am I going about it the wrong way?
Maybe theres a driver to read a .txt file already ?
Thanks
RichNovember 10, 2021 at 7:18 pm #9641kumajayaParticipantIf I was in your situation, since I have Mqtt broker (Mosquitto) and Node-RED installed:
Solution 1: Use python to read serial data and push it to Mqtt broker, RS as Mqtt client
Solution 2: Use Node-RED to read serial data and also set it as OPCUA server, RS as OPCUA clientNovember 11, 2021 at 6:00 am #9642manjey73Participant@rich-ex I have a driver for reading 1Wire temperature sensors on a Raspberry Pi. I didn’t manage to process 1Wire directly, so I had to write the value to txt through crontab and then process this txt from the driver. If this option is suitable, I can give you the source code of the driver.
November 11, 2021 at 10:57 am #9644MikhailModeratorHi,
and writes it into a text file like ‘mydata.txt’, its simple the text file just shows a single number like 22.3
Could I not just write a formula to read this ‘mydata.txt’ file into RapidScada and then return this number from the file
This is not optimal, however, it’s possible if the file contains only 1 number.
Create a formula and use it for an input channel of the Calculated real type.
November 11, 2021 at 10:58 am #9645MikhailModeratorThe formula would be something like:
double ReadNum() { try { string s = System.IO.File.ReadAllText(@"C:\mydata.txt"); double val; return double.TryParse(s, out val) ? val : -1; } catch { return -2; } }
November 12, 2021 at 8:36 am #9651Rich ExParticipantMikhail , manjey73 , kumajaya .
Thanks very much for you great suggestions . I will have a go and see how I get on with the different solutions … what a great forum this is ..
Kind Regards , Rich
November 12, 2021 at 4:09 pm #9654Rich ExParticipant@manjay73
Yes if you could copy your driver and paste it here that would be very interesting .
Thanks
RichNovember 12, 2021 at 7:54 pm #9655manjey73Participanthttps://cloud.mail.ru/public/rZdp/o5aELSXvM
Sensor IDs are added to the text file, and the script reads them using crontab. The driver polls the specified file and outputs a list of channels. In some places, comments in Russian may not be reflected in you.
November 15, 2021 at 11:51 am #9657Rich ExParticipantMikhail ,
You said “Rapid SCADA supports COM ports. But you also need a driver (dll) ”
So would device type be ‘ACC-RS232’ , I am struggling to find any documentation on the setting up of the device types .Sorry to be a pain but my system so far is all Scada driven which I understand , the RS232 device is turning into a pain !!
Thanks
RichNovember 15, 2021 at 12:43 pm #9658MikhailModeratorHi Rich,
RS-232 is just a communication interface. The most important is how data is encoded when transmitted.
Do you successfully write values to a text file?
Does the above formula to retrieve data from text file work?November 15, 2021 at 2:37 pm #9660Rich ExParticipantHi Mikhail ,
Yes I can write my data to a text file no problem .
I have a compiled a .exe file to do this now .I have not tried your formula yet , I don’t want to put it onto my live system incase I have issues as we use it our factory to monitor many devices .
I will have to build Rapid Scada on another machine to use as a “test rig” i think .
I will let you know .Thanks
Richard -
AuthorPosts
- You must be logged in to reply to this topic.