![]() | ![]() | ![]() |
| | |||||||
| General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion? |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Hi guys, I face some problem on using MSComm .... I want to send a byte of data to the RS232 buffer and the data received is the Hex of the sent data. After trying for few times, I get weird Hex numbers.... Is it my program problem or the hardware ?? the following is my program..... Private Sub end_Click() MSComm1.PortOpen = False End End Sub Private Sub Form_Load() MSComm1.PortOpen = True End Sub Private Sub receive_Click() Dim InByte() As Byte Dim buf$, i% InByte = MSComm1.Input For i = LBound(InByte) To UBound(InByte) buf = buf + Hex(InByte(i)) Next i txt2.Text = buf End Sub Private Sub send_Click() Dim a As Integer Dim OutByte(1 To 1) As Byte 'For a = 1 To 100 OutByte(1) = &H1F MSComm1.Output = OutByte 'Next a End Sub | |
| |
| | (permalink) |
| Try this code: Code: Private Sub end_Click() MSComm1.PortOpen = False End End Sub Private Sub Form_Load() MSComm1.PortOpen = True End Sub Private Sub receive_Click() Dim InByte As String Dim i As Integer, buf as string InByte = MSComm1.Input For i = 1 To Len(InByte) buf = buf & Hex(asc(mid(InByte,i,1))) Next i txt2.Text = buf End Sub Private Sub send_Click() Dim a As Integer Dim OutByte As string * 1 OutByte = Chr(&H1F) MSComm1.Output = OutByte 'Next a End Sub
__________________ "There is no way to peace, peace is the way!" | |
| |
| | (permalink) |
| thanks ... I am able to send and receive back my data through RS232 buffer but after i connect all my components, the only response i received back is FFhex when I send a byte of data from the range of 70hex to 79hex. From the info i got, it said that to send data to the write buffer, I need to send 0X to 5X hex, where X represents the data I want to send while 0 to 5 represent each write buffer. And if I want to read back the data, I need to send 70,71 and 72 hex. My question is, is it true that I need to send some specific codes to be able to read and write from the buffers ? If so, why ? | |
| |
| | (permalink) |
| I am not sure I follow what you are saying. To receive data on the serial port all you really need to do is use: Code: Private Sub MSComm1_OnComm() Dim InByte() As String Dim buf$, i% InByte = MSComm1.Input For i = LBound(InByte) To UBound(InByte) buf = buf + Hex(InByte(i)) Next i txt2.Text = buf End Sub What are you trying to communicate with... or what is sending this 5X data? Ivancho | |
| |
| | (permalink) | |
| Quote:
__________________ "There is no way to peace, peace is the way!" | ||
| |
| | (permalink) |
| Hi, sorry for not writing my question clearly... Actually I'm doing a chip tester project. my hardware is connected like this : RS232 buffer <----> UART <----> Decoder <----> Buffer <----> Socket -The decoder includes input address and data decoder, Buffer includes Write and Read buffer and the socket I use is the ZIF socket. From the info I got, I need to send some hex numbers to write my data in the appropriate write buffer while to read the tested result from the read buffer, I need to send 70 to 71Hex. So, I'm wondering if it is because of the IC of the buffers? | |
| |