Serial COMS

This is the main technical forum for discussing problems that were encountered by users while developing PROMOTIC applications, and their possible solutions.

Serial COMS

Postby PaulW » Thu 07. Mar 2013 11:52:03

Good morning, I have a question regaring serial communications with legacy devices - I am presently researching available software for my HMI project and one device I need to recover data from is a serial device which requires a poll & response type communication. In trying other software I have been able to create a simple serial connection to the device and then write a script that retrieves the data and parses into data points which can then be logged, graphed, displayed etc. Is this possible with Promotic and if not can this be something that could be added? I could do this through OPC and a serial data logger however much simpler if it can be done through the HMI software.
PaulW
 
Posts: 6
Joined: Thu 07. Mar 2013 11:36:05

Re: Serial COMS

Postby Petr Návrat » Fri 08. Mar 2013 18:58:12

Hello,
The issue described in your post can be easily solved by PROMOTIC software.
The most important step is to identify the communication protocol used by your device.
There are two possible options:
    - The device uses some standardized communication protocol that is covered by one of the PROMOTIC communication drivers, see (except PmChar)
    http://www.promotic.eu/en/pmdoc/Subsystems/Comm/PmDrivers/Group.htm
    - The device does not use any of the listed standardized protocols, but you know detailed protocol description.
    If so, you can use the “user defined communication driver” – PmChar and define your own communication protocol/messages, see
    http://www.promotic.eu/en/pmdoc/Subsystems/Comm/PmDrivers/kCHAR.htm
The PROMOTIC documentation covers the communication topic in detail, including examples.
Feel free to download the PROMOTIC software from our web. In freeware mode, the software is fully functional, including all communication drivers
(the only limitation is the number of variables used in your project).
For more details see http://www.promotic.eu/en/pmdoc/PriceList/PmFree.htm
Petr Návrat
Administrátor
 
Posts: 79
Joined: Thu 13. Dec 2012 14:32:08

Re: Serial COMS

Postby PaulW » Mon 11. Mar 2013 16:05:32

hi, thanks for the pointers to the documentation and I have made some progress.. what i have got so far is PmComm object and in that i have created a PmCommMsg. In the Data-sent tab I have created two data items, the first is a string that contains the word 'login' and the second data item is the integer 13. What I am trying to do is send login followed by cr-lf. I added a button to a graphic and call the run method of PmCommMsg from the button down event. Is this the right approach for a poll/respose type serial communication? [update] just figured out to use expression vbcrlf in second data item to send cr-lf, however still not seeing any receive data.
PaulW
 
Posts: 6
Joined: Thu 07. Mar 2013 11:36:05

Re: Serial COMS

Postby Petr Návrat » Wed 13. Mar 2013 14:20:53

I think that the error may be in Data-Send.
There you have an integer containing the value 13. The integer is 2-bytes long!!
It is better to create three individual variables:
1st: String (that is OK for "login")
2nd: Byte (with Value 13 = CR)
3rd: Byte (with Value 10 = LF)
(or a single String that you fill with expression "login" & vbCrLf), see http://www.promotic.eu/en/pmdoc/ScriptLangs/VBScript/Const.htm

Then you must create variable in Data-Receive, for example one String and set for 100 characters (you must tell the driver how many characters to expect in reply).

Then you call Run method (Button is OK – but it is better to call it in onButtonUp event).

You can see all communication in the INFO system (button "Info" in toolbar) in item: "COMM/PmChar" and if you go to "Monitor" page, you can see all sent and received bytes.
See http://www.promotic.eu/en/pmdoc/Subsystems/Info/Info.htm
Petr Návrat
Administrátor
 
Posts: 79
Joined: Thu 13. Dec 2012 14:32:08


Return to I don't know how to...

Who is online

Users browsing this forum: No registered users and 5 guests