LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed with RS232-bluetooth

Dear all,

I would first like to thank you for taking your time and reading my message.

I am using two rs232-bluetooth dongles to communicate wirelessly with two PCs.
I am trying to send two waveforms from one PC to the other. I am doing this using flatten to string and unflatten from string.

The company states that the rs232-bluetooth dongles are a direct cable replacement.

I am doing this having adapted the Advanced Serial Read-Write example that LV provides.

My problem is that on the receiving PC when unflattening from string i cant find and wire a '1-d array of DBL waveform' to the type of the unflatten vi.

I have used hyperterminal and i know that these dongles work at distances exceeding 400m.
I have also managed to send just one waveform wirelessly but i then sometimes get 'junk' data(either +some huge number or -some huge number). I am using the 'bytes at port vi' and it seems to me that i might have a problem with processing the data in the right way.

I would thus like to know if there is a way to process the 'bytes at port' a few at time.

I am no Labview expert so i would greatly apprecieate any help, preferably in some example vi's or changes on my vi's.

I have read all the knowledge base on rs232 and have looked at a huge number of other peoples questions on rs232 but to no avain.

I am using LV8 and both PCs have reasanoble CPU and RAM memory.

Thanks

Alex
0 Kudos
Message 1 of 25
(4,551 Views)
First of all I would recommend testing your program with a direct cable connection first, to ensure that no problems are arising from the bluetooth devices. 

To answer your other questions:

1. Normally you would use a constant on the block diagram as the source for the type you wire into the Unflatten From String function.  This is not an option with waveforms, so just place an array shell on the front panel, and place a waveform control inside of it.  You can then use this control as the type for your Unflatten operation, and you can hide the control on the front panel if desired.

2. Using the "Bytes at Port" property does not force you to read all of those bytes.  All you need to do is to specify a smaller number for your VISA Read.  As long as you specify a number smaller than the number of available bytes, those bytes will be read and everything else will be left in the read buffer.


-tuba
Message 2 of 25
(4,539 Views)

Hi tuba,

Thanks for your reply.

I tried using a waveform control (constant) inside a array shell, but although i am getting data in binary, the unflatten array does not peoduce anything.

Do you have any ideas?

I would greatly appreciate any help!

May be i should do away with the flatten and unflatten string and try and do it string to number conversions directly into the Read VISA?

Thanks

Alex

0 Kudos
Message 3 of 25
(4,525 Views)


@bogiasac wrote:
Dear all,

I would first like to thank you for taking your time and reading my message.

I am using two rs232-bluetooth dongles to communicate wirelessly with two PCs.
I am trying to send two waveforms from one PC to the other. I am doing this using flatten to string and unflatten from string.

The company states that the rs232-bluetooth dongles are a direct cable replacement.

I am doing this having adapted the Advanced Serial Read-Write example that LV provides.

My problem is that on the receiving PC when unflattening from string i cant find and wire a '1-d array of DBL waveform' to the type of the unflatten vi.

I have used hyperterminal and i know that these dongles work at distances exceeding 400m.
I have also managed to send just one waveform wirelessly but i then sometimes get 'junk' data(either +some huge number or -some huge number). I am using the 'bytes at port vi' and it seems to me that i might have a problem with processing the data in the right way.

I would thus like to know if there is a way to process the 'bytes at port' a few at time.

I am no Labview expert so i would greatly apprecieate any help, preferably in some example vi's or changes on my vi's.

I have read all the knowledge base on rs232 and have looked at a huge number of other peoples questions on rs232 but to no avain.

I am using LV8 and both PCs have reasanoble CPU and RAM memory.

Thanks

Alex

Bluetooth and >400m. That sounds VERY strange!

First you should do some protocol. The problem you are running in is that on the receiver side you are just reading how many data there is and then reading it. LabVIEW is very fast so it is likely to read the number of bytes at serial port long before the entire flattened string has arrived so you end up with an incomplete flattened string and the unflatten function will recognize that the data can't be complete and refuses to attempt to unflatten the chunk.

A good solution would be to first send the length of the flattened string by Flattening that number which will result in a 4 byte string. Then send the actual flattened string. On the receiver side wait until you have at least 4 bytes at the serial port, unflatten those 4 bytes to an integer and then read the actual string using this number as the number of bytes to read. If you have very large flattened data and the serial communication baudrate is slow you may first have to wait again until the amount of bytes the flattened string should consist of has (almost) arrived before trying to attempt to read it since the read timeout might kick in before all data has arrived.

Even better would be to read in a loop every 10 seconds or whatever depending on your baudrate, whatever data is present at the serial port appending it to an internal shift register until you have read the amount of bytes you have firstly received. Then take out the indicated amount of bytes putting a possible rest back into the shift register for the next loop to use (if it is already there it would contain at the beginning four bytes being the next size of flattened data to follow) and pass the extracted data now to the Unflatten from string function.

This last apporach if done correctly is indeed a little more complicated but it does make the difference between an application that will work sometimes and one that will work continuesly for long amounts of time. If you need to run this for very long times such as days it would be a good idea to have the receiver send an acknowledgement after each flattened string indicating if everything went smoothly and have the sender only send the next flattened string AFTER an acknowledgement has been received.

Rolf Kalbermatter

Message Edited by rolfk on 04-13-2006 11:29 AM

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 4 of 25
(4,508 Views)

Thanks for your reply rolfk.

As far as the bluetooth is concerned i am using a 'class 1' device which is rated at 100m and the derectional antennas which i added, increase the range to 400m. You can actually get them to transmit at a range of 1000m!!! if you use better antennas. 

The rs232-bleutooth dongel is called promi-sd 202 by a company called Initium (korean).

I will try and implement your suggestion but my experience with labview is quite limited.

Do you by any chance have any example code you could give me? I would really be grateful, since i have been straggling with this for a while now.

Thanks

Alex

0 Kudos
Message 5 of 25
(4,491 Views)
Open the example finder (Help>>Find Examples) and search for serial or TCP where you can see examples for how this is normally implemented in LV. You can also search the site for TCP or the term "messaging protocol" and you should find a tutorial which will demonstrate this as well.

___________________
Try to take over the world!
Message 6 of 25
(4,473 Views)
Thanks for the reply tst.

I have looked throught all the serial examples and literally scoured the discussion forums for my answers but have found very little!!!

However, the TCP examples look extremlly promising. Possibly exactly what i am looking for. I know that i am going to have problems adapting the code to my needs, but the TCP examples will be of extreme help to me.

If i have any problems i will publish my vi's on the discussion room. Please take just 2 minutes of your time to go through them!!!

Thanks for the responce!!!


0 Kudos
Message 7 of 25
(4,464 Views)

Hi tst. I am back with more problems.

 

I took your advise and went through the tcp examples. I tried using the code in tcp for my serial application but i came up with an error. When ever i seem to run my vi's, i get 'Not enough memory to complete this operation' error on the receiver side and labview crashes.

I looked through the discussion forum to find some answer, and they blame Win NT for it. However, i am using Win XP Pro on both PC's.

I am becoming preaty desperate for a solution to what should be a simple program. Can some PLSSSS look at my vi's and help.

Thanks

0 Kudos
Message 8 of 25
(4,439 Views)
Sorry forgot VIs
Download All
0 Kudos
Message 9 of 25
(4,438 Views)
I don't have 8, so I can't look at your code but it sounds like you're doing something LV really doesn't like. I would expect you to be able to use VISA functions on both sides to read the data, just as the TCP functions can be used on both sides. If you post it as 7.1 I might have time to look at it. Otherwise, I hope someone else will check it out.

___________________
Try to take over the world!
Message 10 of 25
(4,408 Views)