?
Solved

how to program with Pole display / customer display?

Posted on 2007-08-06
13
Medium Priority
?
8,125 Views
Last Modified: 2013-11-07
Hi,

I use the code below to display message to the pole display (customer display), but i don't know how to clear the display screen before new message is display. and how display the message from the beginning of the screen?  Please help.

Thanks

private void btnSendMessage_Click(object sender, EventArgs e)
        {
            SerialPort sp = new SerialPort();

            sp.PortName = "COM1";
            sp.BaudRate = 9600;
            sp.Parity = Parity.None;
            sp.DataBits = 8;
            sp.StopBits = StopBits.One;            
            sp.Open();
           
             sp.WriteLine(txtMessage.Text);
           
             sp.Close();
            sp.Dispose();
            sp = null;
        }
0
Comment
Question by:yolip
  • 6
  • 4
10 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19637982
What kind of device are you talking about?

Bob
0
 
LVL 2

Author Comment

by:yolip
ID: 19638002
thanks for you quick reply. I am working with VFD-650 Customer display. I have the user manual, but i don't understand it at all. I have an example here, hopefully can help you get some idea.
Thanks

Clear display range:
COMMAND: C
COMPUTER: EOT SOH 'C'  'START'   'END'  ETB
          ASCII (04H)(01H)(43H)(31H~58H)(17H)
            Byte 1         1        1             1          1
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19638275
This is how I would read that (since I haven't used that device):

Special control characters:

EOT - End of Transmission
SOH - Start of Heading
ETB - End of Transmission Block

The display has a range of blocks that can contains characters.  The start is Hex 31, and the end is Hex 58.  You can clear the entire range of a specific range.

Here is an example of what I mean:

using System;
using System.IO.Ports;

public class Vfd650Display : SerialPort
{
    private SerialPort _port = null;

    // Constructor
    public Vfd650Display()
    {
        _port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
        _port.Open();
    }

    /// <summary>
    /// Destructor
    /// </summary>
    ~Vfd650Display()
    {
        _port.Close();
    }

    // COMMAND: C
    // COMPUTER:  EOT   SOH 'C'  'START'   'END'      ETB
    //      ASCII (04H)(01H)(43H)(31H~58H) (31H~58H)  (17H)
    //       Byte 1   1   1        1         1        1
    public void ClearDisplay()
    {
        byte[] data = new byte[] {0x4, 0x1, 0x43, 0x31, 0x58, 0x17} ;
        _port.Write(data, 0, data.Length);
    }

    public void SendText(string text)
    {
        _port.WriteLine(text);
    }

}

Bob


0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
LVL 2

Author Comment

by:yolip
ID: 19644623
Thank you very much, it is working perfect. Beside that, could you please teach me how to display the message in different line (have 2 lines). I have this set cursor position, i tried to do it similar to your way, but it did not works. I really appreciate if you can help me too.

Thanks

Set cursor position:
COMMAND: P
COMPUTER: EOT     SOH     'P'         'POSITION'   ETB
          ASCII (04H)   (01H)  (050H)  (31H~58H)   (17)
        BYTE:   1           1          1             1                1

NOTE: THE CURSOR CAN BE SET TO THE POSITION FROM 1 TO 40
           POSITION 1 MEANS THE UPPER LEFT CORNER POSITION..
           POSITION 20 MEANS THE UPPER RIGHT CORNER POSITION..
           POSITION 21 MEANS THE LOWER LEFT CORNER POSITION..
           POSITION 40 MEANS THE LOWER RIGHT CORNER POSITION..

   byte[] data2 = new byte[] {0x4, 0x20, 0x50, 0x39, 0x17};
            sp.Write(data2, 0, data2.Length);
            sp.WriteLine(txtMessage.Text + "$100.00");
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 200 total points
ID: 19645697
Update:

using System;
using System.IO.Ports;

public class Vfd650Display : SerialPort
{
    private SerialPort _port = null;

    // Constructor
    public Vfd650Display()
    {
        _port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
        _port.Open();
    }

    /// <summary>
    /// Destructor
    /// </summary>
    ~Vfd650Display()
    {
        _port.Close();
    }

    // COMMAND: C
    // COMPUTER:  EOT   SOH 'C'  'START'   'END'      ETB
    //      ASCII (04H)(01H)(43H)(31H~58H) (31H~58H)  (17H)
    //       Byte 1   1   1        1         1        1
    public void ClearDisplay()
    {
        byte[] data = new byte[] { 0x4, 0x1, 0x43, 0x31, 0x58, 0x17 };
        _port.Write(data, 0, data.Length);
    }

    //Set cursor position:
    //COMMAND: P
    //COMPUTER: EOT     SOH     'P'         'POSITION'   ETB
    //          ASCII (04H)   (01H)  (050H)  (31H~58H)   (17)
    //        BYTE:   1           1          1             1                1

    //NOTE: THE CURSOR CAN BE SET TO THE POSITION FROM 1 TO 40
    //           POSITION 1 MEANS THE UPPER LEFT CORNER POSITION..
    //           POSITION 20 MEANS THE UPPER RIGHT CORNER POSITION..
    //           POSITION 21 MEANS THE LOWER LEFT CORNER POSITION..
    //           POSITION 40 MEANS THE LOWER RIGHT CORNER POSITION..
    public void SetCursorPosition(short position)
    {
        if (position < 1 || position > 40)
            throw new ArgumentOutOfRangeException("Cursor position must be 1 to 40");

        byte[] data = new byte[] { 0x4, 0x1, 0x50, (byte)(0x31 + position), 0x17 };
        _port.Write(data, 0, data.Length);
    }

    public void SendText(string text)
    {
        _port.WriteLine(text);
    }

}
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19645727
That would be:

SetCursorPosition(1);
SendText(this.txtMessage.Text + " $100.00");

Bob
0
 
LVL 2

Author Comment

by:yolip
ID: 19652990
Thanks for that Bob, but i tried the following code with your code, it looks doesn't work properly. sometime just show the first character of the message, sometimes overlap/mess up the words. but about 1/10 will get the correct display. do you know why?

           vdisplay.ClearDisplay();
            vdisplay.SetCursorPosition(1);

            vdisplay.SendText("Total:");
            vdisplay.SetCursorPosition(13);
            vdisplay.SendText(txtMessage.Text);

            vdisplay.SetCursorPosition(21);
            vdisplay.SendText("Balance:");    

            vdisplay.SetCursorPosition(34);
            vdisplay.SendText(txtMessage.Text);
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19653977
What happens if you just do this (without the other lines)?

 vdisplay.SetCursorPosition(13);
 vdisplay.SendText(txtMessage.Text);

Does it display in the correct position?

Bob
0
 
LVL 2

Author Comment

by:yolip
ID: 19658773
not always... if i execute it multiple times with the same text, then it sometimes just display the first character, then display all in next execution. is there any trick need to be aware?

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19659149
You could use System.Threading.Thread.Sleep(1000) between the SetCursorPosition and SendText.  There is probably a better way, but I am curious if that will work.

Bob
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question