• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8595
  • Last Modified:

how to program with Pole display / customer display?

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
yolip
Asked:
yolip
  • 6
  • 4
1 Solution
 
Bob LearnedCommented:
What kind of device are you talking about?

Bob
0
 
yolipAuthor Commented:
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
 
Bob LearnedCommented:
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
yolipAuthor Commented:
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
 
Bob LearnedCommented:
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
 
Bob LearnedCommented:
That would be:

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

Bob
0
 
yolipAuthor Commented:
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
 
Bob LearnedCommented:
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
 
yolipAuthor Commented:
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
 
Bob LearnedCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now