
adccommunitymod (AutomationDirect) asked a question.
Created Date: May 19,2015
Created By: Dean
**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****
So I'm trying to get this meter/transmitter that I have been talking about working with the Do-More. The meter can be configured to output sensor values via serial on a set frequency, and I have been able to receive the entire string (208 bytes) via STREAMIN. The meter will accept ASCII commands as well, including a "GET DATA " command. I am trying to think through how I would do this. I'm thinking that a program block would be the right way to go, so that it will run asynchronously, on its own. I think it should be, STREAMOUT "Flush Input Device " first, GET DATA Command, STREAMIN, Receive Data, Parse out sensor values, Convert Strings To Real, Clear Strings. Lather, Rinse, Repeat. I though I could use a DRUM to trigger the STREAMOUT, and and STREAMIN instructions. Is this a reasonable strategy?
Created Date: May 19,2015
Created by: franji1
I would stick it in a PROGRAM code-block ReadMeter that never EXITs, and it parses the data and sticks it in a REAL. I would definitely use STAGE, not a DRUM, for the sequencing behavior (all the necessary instructions have built-in stage support).
The stage flow matches your design (this is one reason why Stage is better than RLL or Drum, the Stage IS the design, the design IS the Stage flow).
Stage (Step) 0: FLUSH Input device, On Success JMP Stage 1, On Error JMP Stage 99
Stage 1: Send GET DATA command, On Success JMP Stage 2, On Error JMP Stage 99
Stage 2: Wait for 208 bytes, then JMP to Stage 3
Stage 3: Receive Response, On Success JMP Stage 4, On Error JMP Stage 99
Stage 4: Parse Data, JMP to Stage 0
Stage 99: Report some type of error (increment a counter, set an alarm/error bit that HMI is monitoring, etc.), JMP to Stage 0
In my $tFirstScan system task, stick a RUN ReadMeter box.
Created Date: May 20,2015
Created by: plcnut
Here is a sample:
http://i761.photobucket.com/albums/xx256/plcnut/DMSerial01_zpsizr4jmel.png
http://i761.photobucket.com/albums/xx256/plcnut/DMSerial02_zpsrucze14o.png
http://i761.photobucket.com/albums/xx256/plcnut/DMSerial03_zpsjgez4gt7.png
http://i761.photobucket.com/albums/xx256/plcnut/DMSerial04_zpsh85drfws.png
Created Date: May 20,2015
Created by: Dean
Thanks everyone. I have a working prototype. For some reason the meter will not accept commands from the Do-More. I have done it in the past using a terminal application on a PC, so I know that the meter will accept and respond to commands, but its no joy so far on that front. I have a call into the meter manufacturer, so we'll see what they have to say. That said, it will spit out the entire ASCII stream automatically at a chosen interval, so my prototype is working with that. I have managed to parse out all of the actual numeric values and convert them to real data type. You guys are spot on, using stages within a program block is definitely the way to go.
Created Date: May 21,2015
Created by: plcnut
Be sure to append a $N (CRLF) to the end of your command, or your device probably won't respond.
Created Date: May 21,2015
Created by: franji1
You guys are spot on, using stages within a program block is definitely the way to go.
Have you turned on Status in the Project Browser view with your PROGRAM code-block expanded to show just the Stage rungs, so that you can tell exactly where in the protocol you are at that moment?
This is a great way to monitor your code to see "where it is hanging ", if a stage program ever "hangs ".
Created Date: May 19,2015
Created by: Dean
So I'm trying to get this meter/transmitter that I have been talking about working with the Do-More. The meter can be configured to output sensor values via serial on a set frequency, and I have been able to receive the entire string (208 bytes) via STREAMIN. The meter will accept ASCII commands as well, including a "GET DATA " command. I am trying to think through how I would do this. I'm thinking that a program block would be the right way to go, so that it will run asynchronously, on its own. I think it should be, STREAMOUT "Flush Input Device " first, GET DATA Command, STREAMIN, Receive Data, Parse out sensor values, Convert Strings To Real, Clear Strings. Lather, Rinse, Repeat. I though I could use a DRUM to trigger the STREAMOUT, and and STREAMIN instructions. Is this a reasonable strategy?