October 2010


AzeoTech

Recommended Posts

DAQFactory training coming soon

By popular request, starting in February, AzeoTech will be offering training classes for DAQFactory here in Ashland Oregon. Several classes will be offered including basic DAQFactory and more advanced topics. If you are interested, please email us at support@azeotech.com with your name and what sort of topics you'd be interested in. We'll put you on a list and you'll be the first we'll contact when the course dates are finalized. If you have a large group and would prefer training at your site, please email us as well.

Tips and tricks

We can't have a newsletter without a tips or trick. For more information, or if you have questions, please visit the DAQFactory forum at www.azeotech.com/board.

Outputting to a dot matrix printer:

There are lots of applications where you need a printed log of events happening, where a line is printed as soon as the event occurs. Laser and ink jet printers only print when the page is full, so there is still a strong need for dot matrix printers. Fortunately writing a single line to a dot matrix printer on the printer port is really easy in DAQFactory:

private h = file.Open("lpt1",0,1,1,1)
file.Write(h, "Alert!  Something happened!")
file.Close(h)

Now, you'll probably want to put this code into a sequence function so you can call it from anywhere. To do this, just create a sequence, call it something like "PrintLine" and put script like this:

function PrintLine(string out)
   private h = file.Open("lpt1",0,1,1,1)
   file.Write(h, out)
   file.Close(h)

Or, since you usually want a time stamp as well:

function PrintLine(string out)
   private h = file.Open("lpt1",0,1,1,1)
   file.Write(h, formatDateTime("%c", systime()) + ": " + out
   file.Close(h)

Then to print a line to the printer just do this:

PrintLine("Alert! Something happened!")

How does it work? Well, operating systems have, pretty much since the beginning, treated printers, screen output and files on disk as files. As such, you can use the standard file functions on all three. Nowadays, screen output is covered up by the Windows graphical user interface, but its still there when you have a command prompt. Printers are typically hidden behind their graphical driver, but Windows has still kept its direct connection to these devices when they are plugged into the printer port (and I'd imagine the com port). In DOS, the name of the printer port is "lptx" where x is the printer port number. So, to open a connection to a printer plugged into the first printer port, you simply open a file called "lpt1" for writing. Then you can output to it by writing to the "file". This actually would work with a laser or inkjet printer if you could find one that had an old style printer port instead of a USB or Ethernet connection, but with those types of printers, the data is buffered until the end of the page is reached, so its much less useful than the old fashion dot matrix printer.

Link to comment
Share on other sites

  • 3 months later...

i want to thank you very much about previous information and i already use sequence to make print using lptx port but i tried to make print using com port RS232 and the printer bagan to respond but it print unmeaningful letters ,how can i set the specified por to prin correctly

thank you again

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.