1 Attachment(s)
[RESOLVED] Serial Port Coms and External LED Display
Hi all
I hope this is the correct place to post this, if not, I apologise.
I'm trying to write a VB2005 app that will communicate via serial port with two external LED displays. While I can do the VB side of things, I'm completely stumped by the communications protocols used to talk with the displays :(
Can anyone help me out and try and decipher the protocols so that I know what strings to send to the displays? (pdf attached).
The company in question (Polycomp) will quiet happily write me something for an extortionate price, but that's as far as they will go :eek:
Thanks in advance
Andy
Re: Serial Port Coms and External LED Display
The PDF had a sample program(s). So what exactly are you trying to do with the sign?
Re: Serial Port Coms and External LED Display
But apart from that.
If you want to sned receive data u will use the io namespace.
P.E. you want a 9600 connection with com1, so:
Dim p As New System.IO.Ports.SerialPort("COM1:", 9600)
After that try checking the p values see if you can progress
Re: Serial Port Coms and External LED Display
It does have an example program, but I'm confused about what most of the sections of the string which is submitted to the display does.
What I'm trying to do is write a program that has full control over not only the message content, but the format / effects of the message on the display.
It's not visible to me what string / format of string to throw at the signs to get the relevant output.
For example, what string would I send to the signs to display a 'Hello World' message that scrolled from left to right?
Hope that explains a bit better.
Andy
Re: Serial Port Coms and External LED Display
Re: Serial Port Coms and External LED Display
Geez D, sorry. Let me try again.
Code:
Dim myMSG() As Byte = New Byte() {}
Dim testMSG As String = "dbasnett is the best :-)!!" 'humor
Dim theHdr() As Byte = New Byte() {0, 1, 0, 3, CByte((2 ^ 7) + (2 ^ 6)), Asc("0"), Asc("0"), Asc("1")}
Dim theSched() As Byte = New Byte() {} 'New Byte(17) {}
Dim theTempo As Byte = 225
Dim theFunc As Byte = 15
Dim thePageStat As Byte = 128
Dim theTrl() As Byte = New Byte() {4, 0}
Dim msgSiz As Integer, msgPOS As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
msgSiz = theHdr.Length + theSched.Length + 3 + testMSG.Length + theTrl.Length 'calc size of message
Array.Resize(myMSG, msgSiz)
msgPOS = 0
Array.Copy(theHdr, 0, myMSG, msgPOS, theHdr.Length) 'copy the header to msg
msgPOS += theHdr.Length
Array.Copy(theSched, 0, myMSG, msgPOS, theSched.Length)
msgPOS += theSched.Length
myMSG(msgPOS) = theTempo
msgPOS += 1
myMSG(msgPOS) = theFunc
msgPOS += 1
myMSG(msgPOS) = thePageStat
msgPOS += 1
Encoding.ASCII.GetBytes(testMSG, 0, testMSG.Length, myMSG, msgPOS) 'convert string to bytes
msgPOS += testMSG.Length
Array.Copy(theTrl, 0, myMSG, msgPOS, theTrl.Length) 'copy trailer
For x As Integer = 0 To myMSG.Length - 2 'calc checksum
myMSG(myMSG.Length - 1) = myMSG(myMSG.Length - 1) Xor myMSG(x)
Next
'SP.Write(myMSG, 0, myMSG.Length)
Re: Serial Port Coms and External LED Display
That certainly gets a response. Unfortunately it's just gobledy gook on the display. No matter what the message is, the display shows exactly the same garbled message, so there's probably something wrong with the header format / length?
:(
Re: Serial Port Coms and External LED Display
have you checked the serial port settings? the web site says :
BAUD RATE : 1200 – available up to 19,200
START BIT : 8
STOP BITS : 1
PARITY : NONE
the pdf says
BAUD RATE : 9600
START BIT : 1
STOP BITS : 2
PARITY : NONE
Re: Serial Port Coms and External LED Display
Yup. I've taken the display cover off and checked the dip switch settings from the website (http://www.polycomp.co.za/Dipswitch.html)
The displays are running at
Baud : 9600
Start bits : 8
Stop bits : 1
Parity : None
I'll have a play with the dip switch settings tomorrow to make sure, but it doesn't look like that :(
Re: Serial Port Coms and External LED Display
I edited post 6 to get rid of the schedule business. Try again.
I have to say that is some bad documentation.
Re: Serial Port Coms and External LED Display
I'll try that in the morning :thumb:
Yeah, the documentation is confusing as hell. Well, certainly to me ;)
Oh, btw, thanks for the help so far:)
Re: Serial Port Coms and External LED Display
Re: Serial Port Coms and External LED Display
Ok, here's the wierd results of todays testing.
All COM port settings are correct, so we can rule that one out.
Pairing the code back to the following gets a static message on the screen :-
Code:
Dim myMSG() As Byte = New Byte() {}
Dim testMSG As String = "Message "
Dim theHdr() As Byte = New Byte() {0, 1, 0, 3}
Dim theTrl() As Byte = New Byte() {4, 0}
Dim msgSiz As Integer, msgPOS As Integer
Dim WithEvents serialPort As New IO.Ports.SerialPort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
msgSiz = theHdr.Length + testMSG.Length + theTrl.Length 'calc size of message
Array.Resize(myMSG, msgSiz)
msgPOS = 0
Array.Copy(theHdr, 0, myMSG, msgPOS, theHdr.Length) 'copy the header to msg
msgPOS += theHdr.Length
Encoding.ASCII.GetBytes(testMSG, 0, testMSG.Length, myMSG, msgPOS) 'convert string to bytes
msgPOS += testMSG.Length
Array.Copy(theTrl, 0, myMSG, msgPOS, theTrl.Length) 'copy trailer
For x As Integer = 0 To myMSG.Length - 2 'calc checksum
myMSG(myMSG.Length - 1) = myMSG(myMSG.Length - 1) Xor myMSG(x)
Next
serialPort.Write(myMSG, 0, myMSG.Length)
This results in a static message a max of 8 chars long (the size of the display). But if I then send a message 5 chars long (for example), the last 3 chars are not overwritten and any message longer than 8 chars is chopped off.
Why reducing the header from
Code:
Dim theHdr() As Byte = New Byte() {0, 1, 0, 3, CByte((2 ^ 7) + (2 ^ 6)), 0, 0, 1}
to
Code:
Dim theHdr() As Byte = New Byte() {0, 1, 0, 3}
works I don't know. This obviously seems to remove any possibility of effects for the message (ie scrolling etc). Including any more in this string just produces rubbish on the display, but every rubbish character on the display can be changed by changing the
Code:
CByte((2 ^ 7) + (2 ^ 6)), 0, 0, 1
portion of the string (ie changing CByte((2 ^ 7) + (2 ^ 6)) changes the first char on the screen, changing the first '0' changes the second char etc)
This suggests that the display is incapable of special effects, but I know for a fact that it does them because I already have a piece of software (no source code unfortunately) that scrolls the text from right left and copes with a message larger than the screen (1 line of 8 chars).
So, to roundup. I can display an 8 char message, but as a bare minimum, I must be able to scroll the message from right to left.
Any ideas?
Andy
Re: Serial Port Coms and External LED Display
I have quickly read this thread and their documentation. From what I can understand, you need to send your entire message to the display in one "short burst" (less than 40 seconds). So you need to send multiple 8 character strings as per their protocol, and it (the display) should handle the rest assuming you've sent the correct strings to it (you should get the ACK?).
I'm not really able to help you with the technical side but perhaps understand what it is you need to achieve, would be a great place to start!
vb Code:
Do Until DesiredResultAchieved
AskMyself_WhyDoINeedToDo()
FigureOut_WhatINeedToDoInOrderToDoThat()
Loop
OMG I just solved all the problems of the world ;-)
Re: Serial Port Coms and External LED Display
What model of sign do you have?
You could get a Hex editor and have a look at the program you have, if you know the message it puts on the screen.
You could also email Polycomp and tell them what you think the byte sequence is generically and ask them if that is correct.
It is confusing.
Re: Serial Port Coms and External LED Display
Copy paste post 6 again. The page number business wants ascii.
1 Attachment(s)
Re: Serial Port Coms and External LED Display
Ok. So I've been in touch with Polycomp UK, who were happy enough to help out.
It seems that I've been given the wrong protocols for these displays! :blush:
(correct protocols attached)
Sorry, guys, it seems I've unwittingly led you up the garden path :(
These correct protocols explain why only the first part of the header worked. In these protocols there is no more to the header! It turns out that this display is an older version with limited functionality. The display is also incapable of special effects (apart from flashing and enlarged text). However, you can specify where on the display the message starts.
As a result, I've knocked together some code that gives the 'illusion' of scrolling by incrementing the message start location and re-sending the message multiple times.
Thanks for all the help guys. Without your code it would have been a very steep uphill struggle for me to get this far :thumb:
I will certainly be coming back here the next time I have a problem ;)
Cheers
Andy