Click here to Skip to main content
15,906,329 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Can anybody help to me about communication with a LCD monitor
ı post the manual about communication over tcp
thank you

CSS
MIS1 communication over TCP/IP
In order to exchange information with an LCD controller all data must be wrapped into an MIS1 frame according to the Definition of Host (DoH). The following table shows all transport layers:
#        Layer         Function
  7      Data          MIS1, DoH
  6      Data          MIS1, DoH
  5      Data          MIS1, DoH
  4      Transport     TCP
  3      Network       IP
  2      Data Link     Ethernet
  1      Physical      Ethernet


Table 1: OSI model
In the example below the required MIS1 frames for displaying a given text sequence on the display (command 0x18, see Definition of Host) are illustrated.
1. Sending the command
At first, the host sends the command to the LCD controller with slave address 1 which contains all necessary information:
>>>[19] 0x04 0x81 0x02 0x18 0x01 0x01 0x00 0x00 0x10 0x05 0x00 0x0A
0x00 0x40 0x41 0x42 0x43 0x03 0xB2
Control characters: 0x04 0x02 0x03
Slave address: 0x81 Address 0x01 OR 0x80
Code and Command ID: 0x18 0x01
Data payload: 0x01 Image number, 1
0x00 Font number, 0
0x00 0x05 Horizontal position x, 5px
0x00 0x0A Vertical position y, 10px
0x00 0x40 Text range width w, 64px
0x41 0x42 0x43 Text data, "ABC"
Escape character: 0x10
Checksum: 0xB2
As the data payload byte 0x05 is a control character (ENQ) it has to be escaped with 0x10 (DLE). The checksum is an arithmetic sum counting all bytes after 0x02 (STX) including 0x03 (ETX)  any DLE characters (0x10) must be ignored! Thus the sum can be calculated as:
0x18 + 0x01 + 0x01 +  + 0x42 + 0x43 + 0x03 = 0x0132 OR 0x80 = 0xB2
2. Receiving the acknowledgement
When a command has been sent to a slave controller it immediately replies with either an ACK (0x06, positive) or a NAK (0x15, negative) byte. This returned byte only informs the host about the MIS1 frame syntax, not about the correctness of the command itself.
<<<[1] 0x06
Status byte: 0x06 Command syntax OK
3. Requesting the status
In order to check whether a previously sent command has been accepted or an error occurred, the host can request the status of the client by sending an enquiry.
>>>[3] 0x04 0x81 0x05
Control characters: 0x04 0x05
Slave address: 0x81 Address 0x01 OR 0x80
4. Receiving the error notification
In case the command from the first step did not generate an error the slave controller will simply respond with a single NAK (0x15) byte.
<<<[1] 0x15
Status byte: 0x15 No error available
Otherwise an appropriate error notification message will be returned to the host. For example if the text range width was chosen too small for the transmitted text array the following notification would be sent:
>>>[3] 0x04 0x8C 0x01 0x18 0x01 0x03 0xA9
Control characters: 0x04 0x03
Code and Command ID: 0x8C 0x01 Command ID generating the error
Data payload: 0x18 Code generating the error
0x01 Error code, "CLIPPED"
Checksum: 0xA9
Posted
Comments
#realJSOP 29-Mar-11 8:04am    
What don't you understand? You have the manual. Read it as many times as it takes to understand it.
sabridemirel 29-Mar-11 8:17am    
ı think that ı miss something.i send the data in hex format byte by byte but it is not working.may be somebody can help me abıut the missing point
for example how can ı prepare the MIS1 package
CPallini 29-Mar-11 8:34am    
You should post your code, to get help.
sabridemirel 29-Mar-11 8:37am    
i post my code
thank you
m_socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
string szIPSelected = txtIPAddress.Text;
String szPort = txtPort.Text;
int alPort = System.Convert.ToInt16 (szPort,10);

System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse(szIPSelected);
System.Net.IPEndPoint remoteEndPoint = new System.Net.IPEndPoint(remoteIPAddress, alPort);
m_socClient.Connect(remoteEndPoint);
byte[] message = new byte[] {0x32, 0x0, 0x1 };
m_socClient.Send(message);
lukeer 29-Mar-11 8:55am    
What do you expect the lcd to do in response to the message "0x32 0x00 0x01"?

Without ever having heard of the MIS1 format, at the end of "1. ", the posted manual explains the construction of the checksum byte. From what I think having understand, every message's last byte is the checksum. Your message's checksum then would be "0x01", which might be incorrect a checksum for the rest of the message "0x32 0x00".

As OriginalGriff wrote in
http://www.codeproject.com/Questions/174392/Sending-Hex-over-TCP.aspx
get information about the hardware and protocol. You have to know how to properly construct a message that the lcd understands. Here you'll get help with programming issues.

Another quick try: go for the example messages from the manual. Send "0x04 0x81 0x02 0x18 0x01 0x01 0x00 0x00 0x10 0x05 0x00 0x0A 0x00 0x40 0x41 0x42 0x43 0x03 0xB2". Seems like lcd should display "ABC".
Try sending "0x04 0x81 0x05". Lcd should respond sending you an error message or a NAK message.

Edit: Too slow for Amund

1 solution

This example only shows how to display a text but it should give you an idea of how to extend it to cater for all messages and reading results as well:

C#
class Program
{
    // I don't know if this needs to be extended
    private static readonly byte[] ControlCharacters = new byte[]
        {
            (byte)0x05
        };

    // This escapes payload data if the data is a control character
    private static void Add(byte data, IList<byte> buffer)
    {
        if (ControlCharacters.Contains(data)) // Below 1F is control characters
            buffer.Add(0x10); // Escape
        buffer.Add(data);
    }

    private static byte CalculateCheckSum(IEnumerable<byte> buffer)
    {
        // Get everything after the first 3 bytes
        byte[] payload = buffer.Reverse().Take(buffer.Count() - 3).Reverse().ToArray();
        return (byte)((from b in payload where b != 0x10 select (int)b).Sum() | 0x80);
    }

    public static byte[] GetDisplayTextMessage(int slaveAddress, string text, int font, int x, int y, int w)
    {
        IList<byte> buffer = new List<byte>();
        buffer.Add(0x04);                           // Start
        buffer.Add((byte)(0x80 | slaveAddress));    // Slave address
        buffer.Add(0x02);                           // Control
        buffer.Add(0x18);                           // Code
        buffer.Add(0x01);                           // Command
        buffer.Add(0x01);                           // DataPayload image number
        buffer.Add((byte)font);                     // Font number
        Add(0x00, buffer); Add((byte)x, buffer);    // HPosition x
        Add(0x00, buffer); Add((byte)y, buffer);    // VPosition y
        Add(0x00, buffer); Add((byte)w, buffer);    // Text range width
        foreach (byte b in Encoding.UTF8.GetBytes(text))
            Add(b, buffer);                         // Add the text
        buffer.Add(0x03);                           // Control
        buffer.Add(CalculateCheckSum(buffer));
        return buffer.ToArray();
    }

    static void Main(string[] args)
    {
        byte[] data = GetDisplayTextMessage(1, "ABC", 0, 5, 10, 64);
        TcpClient client = new TcpClient("localhost", 4242);
        Stream stream = client.GetStream();
        stream.Write(data, 0, data.Length);
        stream.Close();
    }


Obviously you'll have to adjust for your host and port.

Hope this helps,
Fredrik Bornander
 
Share this answer
 
Comments
sabridemirel 29-Mar-11 10:11am    
ı am sorry but it is also not working.:(
Fredrik Bornander 29-Mar-11 10:35am    
How is it failing?
What error message are you getting?
sabridemirel 30-Mar-11 2:23am    
It seems working no any error.But the LCD do not show anything.
ı post another manual.it say that
Definition of Host ABSTRACT
Revision 00
Page 1 of 4
1 General
This document defines the message contents for controlling LCD devices with dot matrix dis-plays. A description of all available commands and responses is given. For data transmission purposes, these messages are to be packed into the MIS1 protocol frame.
2 Message Overview
The message content is laid down as follows:
Code
Command ID
Data
Code
Code byte, defines the type of message (see chapters below).
Command ID
Command identification for given error notifications (0x00 - 0xFE). It can be used for associating notification messages (from the controller) with command messages (from the host). An ID of 0xFF is reserved for sponta-neous notifications.
Data
Payload / user data.
Messages can have a maximum data length of 253 bytes (including code and command ID).
Message overview:
Host computer → Matrix controller
Code byte
Text messages
Group 0x10
Text to position x/y
0x18
Matrix controller → Host controller:
Code byte
Notification messages 1st group
Group 0x80
Error notification
0x8C
Definition of Host ABSTRACT
Revision 00
Page 2 of 4
3 Messages
Note:
All numbering details (image number, line number, number of gap bytes etc.) are counted from 0.
3.1 Host computer  Matrix controller
3.1.1 Write text at position x/y
This message allows a text to be freely positioned on the panel with the "normal", "flashing", and "inverse flashing" attributes. Two font types are available.
0x18
ID
1st byte, 2nd byte ...
ID: Command ID
1st byte: Image number m
2nd byte: Font number
3rd byte: Horizontal position x (high byte)
4th byte: Horizontal position x (low byte)
5th byte: Vertical position y (high byte)
6th byte: Vertical position y (low byte)
7th byte: Text range width w in pixels (high byte)
8th byte: Text range width w in pixels (low byte)
9th byte Text data or attribute information
10th byte: …
Text position:
Specified is the upper left corner of the text:
In case the given text does not fit into the specified text range width overflowing text will be cut off. Halving of letters is not supported, only entire letters are clipped. Setting a text range width of 0 writes the text on the display panel without any error checks.
Definition of Host ABSTRACT
Revision 00
Page 3 of 4
Attribute information:
Text attributes are tags for modifying the text presentation. They can be inserted anywhere in the text data stream. For attribute recognition a 0x00 byte must be sent followed by the actual attribute byte (see below).
Interpretation of the attribute byte is as follows:
Bit
7
6
5
4
3
2
1
0
MSB
LSB
Bit 0:
Value:
1
flashing
0
not flashing
Bit 3:
Value:
1
inverse flashing
0
not inversely flashing
All remaining bits:
Not used, should be set to 0 for subsequent extensions.
Inverse flashing characters are switched on when a flashing character is switched off. This en-ables characters, for instance, to jump between two positions.
Definition of Host ABSTRACT
Revision 00
Page 4 of 4
3.2 Matrix controller  Host computer
3.2.1 Error notification
0x8C
ID
1st byte, 2nd byte
ID: Command ID that is triggering the error notification
1st byte: Code that is triggering the error notification
2nd byte: Error number
Valid error numbers:
Number
ECS symbolic name
Description
1
CLIPPED
Display information shown in a clipped form
2
ECHAR_ATTRIBUTE
Invalid attribute for text output
3
ERANGE
Overflow of a command parameter
4
EOPTION
Invalid parameter in the command
5
EPAGE
Invalid image number
6
EFONTMISS
Font not defined
7
EALLOC
Memory cannot be allocated e.g. too many flow text sectors
8
EFLOWTEXT
Too many flow texts
9
EUNKNOWNCOMMAND
Unknown/unsupported command

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900