[RESOLVED] trouble converting HyperTerminal commands to VB.Net
I have a program I'm trying to use to drive a scoreboard of 4 7-seg LEDs. The brand is Sure Electronics and the controller board came with code to communicate via HyperTerminal. (Commands are on p10 at http://www.sure-electronics.net/down..._Ver1.0_EN.pdf) These commands work fine and drive the digits as they're supposed to. However, I want to drive them from my VB.Net program, not from HyperTerminal. I have done this successfully with another brand, and thought I knew about what was needed, but my little demo program doesn't work. In it, I have tried to do 3 things using 3 buttons: set up the com port, send 8 as a test digit to all four digits (their addresses are 1,2,3,4), and turn off all the digits. I know the com port routine works, because I've used it before. (I have set up the com port to the same specs as what works in HyperTrminal.) I tried two slightly different approaches for the other two items, but neither works. I am confused about what needs to be ASC and what doesn't. Any help appreciated! My code is attached.
?
EDIT: From what I can understand from the reference document you need to send the characters: '$sure mseg ' followed by 2 numbers (in character representation- separated by a space character) followed by the 'enter key' (the space between the two numbers is important)
Re: trouble converting HyperTerminal commands to VB.Net
OK, thanks a lot, as that one really helped. I had to increase the time lag between successive digits, and it's working now. Many thanks for your continued interest and generosity. Here's the code snippet that's doing it:
Sub SendSecondSuggestion()
Dim q As Integer
For q = 1 To 3 'send thrice
LiveComPort.Write("$sure mseg " & a.ToString & " " & v.ToString & vbNewLine)
Threading.Thread.Sleep(75 + 25 * q)
Next q
End Sub
Re: [RESOLVED] trouble converting HyperTerminal commands to VB.Net
Interesting, glad you've got it to work. I'm slightly puzzled as to why you need to send the command 3 times, once should be enough (I am assuming that when using Hyperterminal you only need send the command once.) Also, in the Manual / Guide there's an implication that the board will send something back; "Power up the driver board. If you can see some start-up information on the PC, the connection is successful".
It's not clear whether it's gong to send an acknowledgement every time you send a command to it though. If it does, you should be reading whatever it sends, whether or not you're going to use the information, in order to keep the buffer empty, otherwise you run the risk of the buffer overflowing and you may end up with the code failing or unpredictable results. I'm personally not into .Net enough to guide you how to do that, but I suspect you'll need to create an Event Handler for receiving data. I found something regarding Serial Port comms here: http://www.dreamincode.net/forums/to...tion-in-vbnet/ which might help you further.
Good luck with the Project.
EDIT: BTW if you run into trouble and need some more help, you'd be better off posting in the Vb .NET forum (the COM in this Forum's description refers to 'Common Object Model' rather than 'Communications') I only happened on your Post by chance and there's a number of knowledgable people lurking in the .Net Fourm.
Re: [RESOLVED] trouble converting HyperTerminal commands to VB.Net
It's true that when using HyperTerminal you need send the command only once, but I've found that in VB all 4 digits won't change unless you send it more than once. I have previously used a similar but more expensive set of digits from Velleman (K8063 kit), which I think uses the same chip, and their manual instructs you to send a command more than once. They facilitate this by providing a strobe command, but the SURE people don't program that command into their chip, so I'm programming it in.
Thanks for your caution about the buffer and the advice about where to post!