i have to comunicate from vb to control a nec vt480 and I have not much idea how to send the instructions correctly .
Acording to the information given by nec, this are the codes to control projector:
001. POWER ON 02H 00H 00H 00H 00H 02H
002. POWER OFF 02H 01H 00H 00H 00H 03H
003. INPUT SELECT RGB(*5) 02H 03H 00H 00H 02H 01H <DATA> CKS
004. INPUT SELECT VIDEO 02H 03H 00H 00H 02H 01H 06H 0EH
005. INPUT SELECT S-VIDEO 02H 03H 00H 00H 02H 01H 0BH 13H
006. PICTURE MUTE ON 02H 10H 00H 00H 00H 12H
007. PICTURE MUTE OFF 02H 11H 00H 00H 00H 13H
008. SOUND MUTE ON 02H 12H 00H 00H 00H 14H
009. SOUND MUTE OFF 02H 13H 00H 00H 00H 15H
010. ONSCREEN MUTE ON 02H 14H 00H 00H 00H 16H
011. LAMP INFORMATION REQUEST 03H 8CH 00H 00H 00H 8FH
012. MUTE CONTROL 02H 1AH 00H 00H 02H <DATA> CKS
013. VOLUME ADJUST 03H 10H 00H 00H 05H 05H <DATA> CKS
014. BASE MODEL TYPE REQUEST 00H BFH 00H 00H 01H 00H CKS
015. PROJECTOR INFORMATION REQUEST 00H BFH 00H 00H 01H 02H CKS
And also here you got the communication settings:
Baud rate: 19200 bps
Data length: 8 bits
Parity bit: No parity
Stop bits: 1 bit
Communications mode: Full duplex
For the moment I've wroten a few orders:

mscomm1.commport = 1
mscomm1.settings = "19200,n,8,1"
mscomm1.portopen = true
mscomm1.output = "h03 8C 00 00 00 8F"

I don't really know much from vb6, I just started with this project, also controling AOI (automatical optical inspection), few weeks ago with no idea about vb6, neither others.
Can someone help me?

Dani AI

Generated

Short summary and practical tips (builds on and )

The projector protocol uses binary frames — not ASCII hex text. The final byte marked CKS is simply the 8‑bit sum of all preceding bytes (i.e. CKS = (sum of bytes) AND &HFF). That is why sending the characters "038C..." fails: you were sending ASCII characters, not the raw byte values. was right to send raw bytes; ’s confirmation shows that approach works.

A small VB6 helper that converts space‑separated hex values into a raw command and appends the checksum:

' hexString example: "02 0A 00"
Function HexToCmd(hexString As String) As String
    Dim parts() As String, i As Long, v As Long, s As String, sum As Long
    parts = Split(Trim(hexString), " ")
    For i = LBound(parts) To UBound(parts)
        v = CLng("&H" & parts(i))
        s = s & Chr$(v)
        sum = (sum + v) And &HFF
    Next i
    s = s & Chr$(sum)
    HexToCmd = s
End Function

Send with MSComm (after setting 19200,n,8,1 and opening the port):

MSComm1.Output = HexToCmd("02 01 00 00 00")

Quick receive/debug helper (prints incoming bytes as hex):

Function ToHexString(txt As String) As String
    Dim i As Long, out As String
    For i = 1 To LenB(txt)
        out = out & Right$("0" & Hex(AscB(MidB(txt, i, 1))), 2) & " "
    Next
    ToHexString = Trim(out)
End Function
' In MSComm1_OnComm use Debug.Print ToHexString(MSComm1.Input)

Troubleshooting checklist

  • Verify physical wiring and RS‑232 voltage levels (projector expects RS‑232 ±V, not TTL).
  • Confirm straight vs null‑modem wiring (Tx↔Rx).
  • Disable hardware handshaking (full‑duplex, no flow unless specified).
  • Test first from a terminal (HyperTerminal / PuTTY) to isolate VB code.
  • If using a USB‑serial adapter, try another adapter/driver or check COM number.
  • Open the port from a user action (button) if you hit timing/thread issues in XP, and set MSComm.RThreshold low enough to get data events.

This explains why raw bytes solved the problem and gives compact, reusable helpers to build commands, append CKS, and inspect responses.

Recommended Answers

All 6 Replies

Does no one can helpe me? I hope someone with serial port communication knowledge could help me.

Is this in XP (there has a been a few threads going around about problems with reading/writing serial ports in XP with VB). Also, I'm not sure if the output is supposed to be a string, or if it's supposed to be those values in hex.....

Yes it is in windows XP professional
I've tried more things in the while I have no answer and I've sent the message in different ways

MSComm1.Output = "038C0000008F"
MSComm1.Output = "000000111000110000000000000000000000000010001111"
MSComm1.Output = &H038C0000008F"

but none of them have worked.
Is there anyway to check my port is working properly?

Hi,

Give this a try. Call the PowerOff function from a button_onlclick instead of onload.

mscomm1.RThreshold = 34
mscomm1.commport = 1
mscomm1.settings = "19200,n,8,1"
mscomm1.portopen = true


Public Sub PowerOff()
On Error Resume Next

Dim bytes(5) As Byte

bytes(0) = "&H" & 02
bytes(1) = "&H" & 01
bytes(2) = "&H" & 00
bytes(3) = "&H" & 00
bytes(4) = "&H" & 00
bytes(5) = "&H" & 03

MSComm1.Output = bytes


End Sub

Private Sub MSComm1_OnComm()

On Error Resume Next

If MSComm1.CommEvent = comEvReceive Then

msgbox MSComm1.Input

End If

End Sub

Try using this software to monitor the port "http://www.hhdsoftware.com/Family/serial-monitor.html"


Regards
Marikanna

commented: Well Done +5

SUCCESS. It has worked out. Thanks a lot Marikanna. What is the code alone itself is working propperly, at least the output, with the input doesn't work as I want but I'll make some other tryes to improve it. I think the rest is just working on development and go on, so if I have no other relevant problems I think soon it will be perfectly solved. Thanks once again Marikanna.

Neil

I've tried some other things in my old code and I realise that the clue was just the byte sending.

dim array(n) as byte
 
array (0) = &HXX
array (1) = &HXX
....
array (n-1) = &HXX
array (n) = &HXX
 
MSComm1.Output = array

thanks to anyone that has read and think about my problem, I'm not the best to do it but if someone needs my help I'll be pleased to serve.

Neil

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.