Results 1 to 3 of 3

Thread: Bluetooth incoming data distortion

  1. #1
    New Member
    Join Date
    Aug 12
    Posts
    2

    Bluetooth incoming data distortion

    Hi there,

    I have scales equipped with RS232 serial port and a Bluetooth transmitter. I made a program in VBA to receive data from the scales. However, lets say out of 10 incoming strings I get 3 distorted. My regular strings look like: "+001500./3 G S". This means 1500.3 grams above zero and the output is stable. But sometimes I get strings separated like "+" or "001500./3" or "G S". When I plug serial cable I have no distortions. Could you please help me out to fix it?

    Regards, Nick

  2. #2
    PowerPoster
    Join Date
    Feb 06
    Posts
    8,577

    Re: Bluetooth incoming data distortion

    You can't "make a program" using VBA since it is an embedded macro language. Most applications embedding VBA do not come with a licensed COMn: ("serial") port control or library either.

    So what application is it that you are automating? Excel? What serial port library are you using?

    Your problem stems from the "Packet Fallacy" where you assume that stream-oriented communication paths are message oriented. Correcting for this fallacy is basically the same process no matter what library you use, though the details will vary widely.

    Essentially your problem is that depending on how quickly data arrives relative to how quickly your program polls the inbound buffer for data you will grab larger or smaller pieces at a time, sometimes as little as one character at a time. You need to deblock the inbound stream into messages, either by looking for some message delimiter or by message length if messages have a known fixed length.

  3. #3
    New Member
    Join Date
    Aug 12
    Posts
    2

    Re: Bluetooth incoming data distortion

    Yes Im using Excel's VBA to create the code. Im using this COM port library: http://strokescribe.com/en/serial-port-programming.html
    I am trying to get scale's readings into excel so we could have better stock data at my work.

    What happens in my programm is:

    I have an event: incoming serial data from com port.
    Every time my scales send something the event is executed.
    The frequency of that messages is about one in every 100 ms.
    The problems is when I connect scales via cable I receive correct strings. But when Im using the bluetooth I get strange strings sometimes.
    I tried to put incoming data into a text "log" file. And I was surprised because the data was displayed in a right way. Notepad's magic haha.
    I dont get why on Incoming data event bluetooth sends me wierd strings and why they are fine in notepad. Every new received string should be stored in a new line in notepad but its not..

    My current solution is to exit sub when wierd string arrives and move to the next one. I think that communication is fast enough not to delay sent data.. But I am not shure..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •