Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > General Electronics Chat


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?

Reply
 
LinkBack Thread Tools Display Modes
Old 7th March 2004, 08:28 AM   (permalink)
Default Interfacing RS232 buffer with MSComm

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
wingbar is offline  
Old 7th March 2004, 06:13 PM   (permalink)
Default

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
Check your baud rates properly.
__________________
"There is no way to peace, peace is the way!"
kinjalgp is offline  
Old 9th March 2004, 05:41 PM   (permalink)
Default

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 ?
wingbar is offline  
Old 9th March 2004, 06:17 PM   (permalink)
Default

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
Instead of having a button receive, when you click on it. Also all data you get is a string data...... You are sending and receiving ASCII characters. How you interpret them is upto you. You can make them the ASCII value by using the ASC(string) function, then if you like you can change that number to HEX if that is how you want to display it.

What are you trying to communicate with... or what is sending this 5X data?

Ivancho
ivancho is offline  
Old 10th March 2004, 12:45 PM   (permalink)
Default

Quote:
Originally Posted by wingbar
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 ?
Are you working with some specific device?
__________________
"There is no way to peace, peace is the way!"
kinjalgp is offline  
Old 11th March 2004, 06:30 AM   (permalink)
Default

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?
wingbar is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 11:11 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker