1

Hey all, i am trying to turn on a A/V Reciever with a RS232 command using the VB6 comm32. To turn it on it says to use:

 Command code   Parameter code  CR    Code set example
 PW           ON              <CR>  PWON<CR>

And this is my VB6 code i am currently using that doesnt seem to work...

MSComm.CommPort = 2
MSComm.Settings = "9600,n,8,1"
MSComm.PortOpen = True

If Not MSComm.PortOpen Then
    MsgBox "not opened"
Else
    MSComm.Output = "PWON" & Chr(13)

    Do While MSComm.InBufferCount > 0
         Text1.Text = Text1.Text & MSComm.Input
    Loop
End If

The reciever never turns on. What could i be doing incorrectly? I checked to make sure the com port was 2 and it is.

David

StealthRT
  • 10,108
  • 40
  • 183
  • 342
  • What model of A/V receiver are you using? Can we take a look at the specification? – PleaseStand Nov 21 '10 at 03:46
  • The A/V is a Marantz sr7005. The PDF i am using is this: http://www.filefactory.com/file/b45ce8b/n/Marantz_New_RS232C_Command_List-Receiver_All.pdf – StealthRT Nov 21 '10 at 03:58
  • Is it sitting in the output buffer? I don't remember the exact name of the property to check... outputbuffercount or something? Also, you've turned off flow control, yes? As others have suggested, get this working in Hyperterminal first. – Brad Nov 21 '10 at 05:03
  • Well for some reason i got it to work finally. I guess i needed to turn the unit on first then control it there after. Thanks! – StealthRT Nov 22 '10 at 01:41

1 Answers1

3

You are just sending the characters <CR> rather than a real carriage return (ASCII code 13). Documentation for serial peripherals often puts the names of control characters in brackets (see Wikipedia for a list of them). You need the line:

MSComm.Output = "PWON" & Chr(13)

It also seems that the code that follows to read data from the serial port should be changed because if the data has not arrived in the serial port's buffer yet, it will read nothing. Take a look at Microsoft's example for how to do so. You could decide to stop reading once a particular substring in the input has been found, once a certain number of bytes have been read (Len function), etc.

PleaseStand
  • 31,641
  • 6
  • 68
  • 95
  • Hey thanks for the reply idealmachine but that doesn't seem to turn it on, either :o( – StealthRT Nov 21 '10 at 03:42
  • I also just posted the link above to the PDF of the commands.. maybe i am just doing this wrong? – StealthRT Nov 21 '10 at 04:02
  • @StealthRT: After making that change, your code should be correct. Can you manually turn on the receiver with HyperTerminal using the "Direct to COM2" option and typing "PWON" followed by the Return key? (For Windows 7, use another terminal program like PuTTY instead.) – PleaseStand Nov 21 '10 at 04:33
  • I connect to it using HyperTerminal but i am unable to type anything in the window?? http://i52.tinypic.com/2zqbew7.jpg & http://i52.tinypic.com/1ihjj5.jpg – StealthRT Nov 21 '10 at 04:47
  • @StealthRT: What you're typing is still sent, but in order to see it on your screen, you need to turn on the "Echo typed characters locally" option: http://technet.microsoft.com/en-us/library/cc786584%28WS.10%29.aspx#BKMK_5 – PleaseStand Nov 21 '10 at 04:49