Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Receiving data from comport !!

Status
Not open for further replies.
hi,

You are trying to capture data while you are displaying to the text box.

Capture the data in an array, say 15 bytes of raw data, dont try to display while you are capturing.

The Sync byte of you data file is attached, the oximeter says its waiting too long.
 

Attachments

  • 000esp09.gif
    000esp09.gif
    14.1 KB · Views: 151
hi,
I am logging off for the day, I will modify and post a new VB program for you tomorrow.
 
hi,
I am logging off for the day, I will modify and post a new VB program for you tomorrow.

hi,
This simple program works with a test string equivalent to the output of the Oximeter.

I have decoded/masked some of the data, you should do the remainder.:)

Code:
Option Explicit
Dim X, Z As Byte
Dim BitStr, BitStr2 As Variant
Dim arry(15)


Private Sub Form_Load()

MSComm1.CommPort = "2"

MSComm1.Settings = "4800,O,8,1"

MSComm1.InputLen = 0

MSComm1.PortOpen = True

End Sub

 
Private Sub lblBar_Click()

End Sub

Private Sub lblSignal_Click()
End Sub

Private Static Sub MSComm1_OnComm()
Dim Data
Dim strchr As String
Dim strlen, valchr, X, Z, Y As Byte

On Error GoTo fail1

   Select Case MSComm1.CommEvent
        
        Case comEvReceive
            
            Dim Buffer As Variant
            Buffer = MSComm1.Input
         
            Data = (StrConv(Buffer, vbUnicode))
            strlen = Len(Data)
            ''Text1.SelText = strlen & vbCrLf
            
            For X = 1 To strlen
            strchr = Mid$(Data, X, 1)
            valchr = Asc(strchr)
            
            Next X
            

            If valchr > 127 Then
            Z = 0
            arry(Z) = valchr
            '''Text1.SelText = Right$("00" + Hex$(arry(0)), 2) & ","
            Else
            Z = Z + 1
                If Z > 14 Then Z = 0
            arry(Z) = valchr
            '''Text1.SelText = Right$("00" + Hex$(arry(Z)), 2) & ","
            End If
 
    End Select
    
     
         
If Z > 3 Then
MSComm1.PortOpen = False
Decode
End If

Exit Sub

fail1:
MSComm1.PortOpen = False
Z = 0
valchr = 0
MSComm1.PortOpen = True


End Sub


Private Sub Decode()

Dim S, X As Byte
        
        Text1.Text = ""
        
        For X = 0 To 4
        Text1.SelText = Right$("00" + Hex$(arry(X)), 2) & ","
        Label1(X).Caption = Right$("00" + Hex$(arry(X)), 2) & " "
        Next X
        
        Label3(0).Caption = arry(0) And &H7
        Label3(1).Caption = arry(1) And &H7F
        Label3(2).Caption = arry(2) And &H7
        Label3(3).Caption = arry(3) And &H7F
        Label3(4).Caption = arry(4) And &H7F
        
        
    'check for bit 6 in arry(2)
    If arry(2) And &H40 = 1 Then
    Label3(3).Caption = (arry(3) And &H7F) Or &H80
    End If
                       
        Z = 0
        
        MSComm1.PortOpen = True
            
End Sub
Static Function Bin2BinStr(PrtVal As Integer)
'converts a 8 bit string value to 8 bits

Dim binmask, p As Integer

BitStr = String(8, "0")

 If PrtVal > 127 Then
    Mid$(BitStr, 1, 1) = "1"
    Else
    Mid$(BitStr, 1, 1) = "0"
 End If
 
    If PrtVal < 0 Then
     Mid$(BitStr, 1, 1) = "1"
    End If
 
 binmask = &H40
 
 For p = 2 To 8
    If PrtVal And binmask Then
    Mid$(BitStr, p, 1) = "1"
    End If
    
    binmask = binmask \ 2
 
 Next p
 
BitStr2 = BitStr

End Function

[I]**broken link removed**[/I]
 

Attachments

  • 000esp05.gif
    000esp05.gif
    6.4 KB · Views: 160
  • oximV1.txt
    2.7 KB · Views: 191
hi salem,
Ref your PM, I would prefer to work on the problem using the Forums, other members may find our posts useful.

I will continue to work on this with you until its working or we decide to shelve the project. OK.:)
.
I have used the original protocol and formatting pdf to create a test string of 5 bytes via a UART transmission program from another PC into that program I posted and it does what I expect.

Tell and show me the results you are getting with the program I posted yesterday
 
Ok,

i got freezing all the time when i open the comport ( but the input data shows in the TextBox ) and can't press any thing at all in the app !! till i unplug the device from the PC

then a message will appear ( normal msg about the device is not open ... )

at that time i only see the decoded of the bytes be in lables to show the data as u did

till now i am not sure about the data i need which are ( Pulse , Heart Rate ,, etc )

Thank u very much Eric
 
B8,3F,3F,3F,3F,

theses what i got in the text box
mm not appear in the labels till i unplug the device from the pc then show up

when i put my finger on the device to check the result will be like the following :

C0,3F,3F,3F,3F,
CA,3F,3F,3F,3F,
93,3F,3F,3F,3F,
95,3F,3F,3F,3F,
BE,3F,3F,3F,3F,
BD,3F,3F,3F,3F,
C9,3F,3F,3F,3F,

Notice that only the 1st byte changes
 

Attachments

  • oxyerr.jpg
    oxyerr.jpg
    134.8 KB · Views: 142
hi,
Your results suggest that the signal strength is erratic, the sync byte/bit 7 seems to be detected correctly.
Do you have any more technical info on the oximeter.??

I cannot explain the string of 3F's.???
C0,3F,3F,3F,3F,
CA,3F,3F,3F,3F,
93,3F,3F,3F,3F,
95,3F,3F,3F,3F,
BE,3F,3F,3F,3F,
BD,3F,3F,3F,3F,
C9,3F,3F,3F,3F,


C0 1=sync, 1=beep, 0=drop SpO2,=search, 0000=signal for Pulsate.
CA 1=sync, 1=beep, ....................................1101= 10
93 ................................................................0011=3
95 ................................................................0101=5
BE ...............................................................1110=14
BD ...............................................................1101=13
C9 ................................................................1001=9
 
no i just have the PDF only

btw the USB device shows in device manager as a virtual comport but it works fine as a real comport when talk to it using VB or its exe app ....

Thanks Eric
 
no i just have the PDF only

btw the USB device shows in device manager as a virtual comport but it works fine as a real comport when talk to it using VB or its exe app ....

Thanks Eric

Hi,
If I post a binary test file, do you have a another PC that you could use to transmit the test string, via the RS232 [USB] cable link to the PC with my VB5 ONCOMMs test program.???
 
i do have another PC with RS232 for both

but the cable should i use not exist between them i think i have to have RS232 cable ( Female with both sides )

but what can we get if we test that program ? is it useful for our issue with Oximeter !!!

Thanks Eric ,,,
 
i do have another PC with RS232 for both

but the cable should i use not exist between them i think i have to have RS232 cable ( Female with both sides )

but what can we get if we test that program ? is it useful for our issue with Oximeter !!!

Thanks Eric ,,,

hi,
I think by checking with a known data pattern we will be able to confirm that the VB5 receive program is working as expected.
At the moment we are not 100% sure if its the oximeter, usb/rs232 or the vb5 program.:)

Attached two images, the AA image is the transmitting PC and the 000 image is the receiving PC, showing the data as valid.

also there is a repetitive hex file for transmit tests.
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    13.5 KB · Views: 157
  • 000esp04.gif
    000esp04.gif
    14.1 KB · Views: 147
  • OxiTestTx1.hex
    240 bytes · Views: 117
hi,
Changed the text box to a rich text box to allow longer file display.

This image is that test file hex being received, all OK
Note: I have made the byte 5 either 35 or 3F, so that you see the text changing.
 

Attachments

  • 000esp05.gif
    000esp05.gif
    10.3 KB · Views: 244
  • oxim2.bas
    2.6 KB · Views: 156
i tried to change the text box to be Rich one

NO LUCK !!!

i will go crazy now :)

the app is freezing and can't even stop the project from VB

something wrong with code made it to hang up
 
i tried to change the text box to be Rich one

NO LUCK !!!

i will go crazy now :)

the app is freezing and can't even stop the project from VB

something wrong with code made it to hang up

hi,
I dont believe there is a problem with my code, I have checked every which way without a problem.

The next step I would suggest is to download from the web a free PC comms program and use that connected to the Oximeter.
Let me know what you see.
free comms software - Pesquisa Google

Eric

BTW: do you have a model/type number for your Oximeter hardware.???

EDIT:
Using a free-ware RS232/UART data-logger program, I get this attached hex file, which confirms that my transmit and receive VB5's are OK.
Use a HEX viewer program to see the hex data.
 

Attachments

  • OxiTestTx1.hex
    240 bytes · Views: 105
Last edited:
there is no part number for it ... its common from many manufacturers

its USB to Comport actually as I described before here how it looks in Device Manager : Silicon Labs CP210x USB to UART Bridge

Thanks Eric ,,,
 
there is no part number for it ... its common from many manufacturers

its USB to Comport actually as I described before here how it looks in Device Manager : Silicon Labs CP210x USB to UART Bridge

Thanks Eric ,,,

hi.
I looked at the Silicon Labs CP210x USB to UART Bridge, but its just a driver for usb/uart usage.

I would recommend that you try the Oximeter and VB5 programs with a regular PC/RS232 connection.
 
yeah i know its a driver to make a virtual comport

but do u mean try another Oximeter with comport !! ?? not mine ??

Thanks
 
yeah i know its a driver to make a virtual comport

but do u mean try another Oximeter with comport !! ?? not mine ??

Thanks

I mean get a PC that has a standard Serial [RS232] port and try the Oximeter you already have and use the VbB5 programs.

Did you download a free RS232 comms program and try that with the Oximeter.?
 
Status
Not open for further replies.

Latest threads

Back
Top