Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Glenn on September 17, 2012, 10:08:53 AM

Title: Serial Printing
Post by: Glenn on September 17, 2012, 10:08:53 AM
What is Do-More's equivalent to the 'VPRINT' instruction?
Title: Re: Serial Printing
Post by: BobO on September 17, 2012, 11:30:53 AM
STRPRINT is a full featured print-to-string function...sort-of a PLC version of 'printf' (from C).

STREAMOUT is how you send a string or buffer out a serial port.
Title: Re: Serial Printing
Post by: Glenn on September 18, 2012, 09:23:17 AM
Thanks Bob.
Currently (260 CPU) I use port 1 to connect to the HMI and port 2 to the printer. How do I do that with the Do-More?
Title: Re: Serial Printing
Post by: franji1 on September 18, 2012, 09:49:38 AM
1. PLC->System Configuration
2. the Serial Port mode on the CPU Configuration is Do-more Programming by default.  You need to change it to General Purpose.  I assume you are using Ethernet or USB for programming, otherwise, make sure you have that comm link working before changing this.  Hit the Device Settings button to set the baud rate, etc.
3. Use the STRPRINT to generate the message within a STRING element like SS0 (up to 64 characters), or SL0 (up to 256 characters).  If you need an even longer string, Do-more supports up to 1024 in one STRING element.  Let us know.
4. STREAMOUT SS0 or SL0 (or whatever) out the @IntSerial port Device.

STRPRINT utilizes a very rich formatting script language.  You can intermix elements like V10 R22 with string literals, similar to VPRINT
"V10 equals" V10
But there is a bunch of formatting functions for STRPRINT (and EMAIL) instruction.  Look for the String Scripting Language Reference in the Help.  Just search for DMD0168 which is the topic number.

Or even better, here's a link to an online version of the Help topic:
String Scripting Language Reference (http://forum.hosteng.com/wndm/HTMLHelp1/instruction_set/Scripting_Language_Reference.htm)
All Help Topic links are active, so you can click on them to browse to related subject matter within your Internet browser.
Title: Re: Serial Printing
Post by: franji1 on September 18, 2012, 09:56:10 AM
I did not address your HMI issue.  You may need to get an H2-SERIO module for a 2nd serial port (actually, there are 3 ports on an H2-SERIO), or use the local Ethernet port for your HMI, if your HMI supports Modbus/TCP.  If you have to use serial for the Printer and for the HMI, you will have to get a H2-SERIO module.  They're only $176 for 3 ports, and you can use the remaining two for Programming, another Printer, another HMI, Modbus/RTU, etc.

http://www.automationdirect.com/pn/H2-SERIO
Title: Re: Serial Printing
Post by: MikeS on September 18, 2012, 10:05:57 AM
the DM1 and DM1e cpus only have a single serial port, so to connect the HMI and the printer to serial ports you will need to add a SERIO module to your system -- OR -- if the HMI can connect over Ethernet, the DM1e has an onboard Ethernet port that it could use .

under System Configuration, set the serial port for 'General Purpose', click Device settings to set the port's parity, baud rate, etc. to match the printer

assuming that you are sending ascii data to the printer, use a STRPRINT instruction to place the text you want to send to the printer into a String. the STRPRINT has a lot of options when it comes to generating the data to send. You can include any mix of literal text (characters in double quotes), control characters, plc variables, number formatting functions, date and time, and math functions.

use a STREAMOUT instruction to send that String of text to the Serial port
Title: Re: Serial Printing
Post by: Glenn on September 18, 2012, 03:13:16 PM
Got it. Thanks everyone for the replies.
Title: Re: Serial Printing
Post by: rlp122 on September 19, 2012, 09:09:41 AM
If you are using a Cmore HMI (http://support.automationdirect.com/products/cmore.html), it now supports DoMore natively with version 2.76