06-15-2010 05:45 PM
Hi all,
I need to receive data from a bluetooth module with virtual serial port. Then send those data to do the FFT every 30 seconds. I tried tow different ways as shown in the attachements, however, I failed to get it work.
The first way is to use Instrument I/O assistant as Dennis suggested; After connected to the Bluetooth module and set the port number, the instrument I/O module says no response from instrument.
Then I tried the advanced serial write and read VI, the bluetooth module reading works fine in the example (advanced serial write and read.vi).However, I dont know how to connect the string and danamic data together as shown in the attachment.
So all I want is to obtain the data from bluetooth serial port for 30 seconds, then send off to the FFT. Could you please help me? Thank you very much.
Baicy
06-15-2010 08:32 PM
06-15-2010 08:52 PM
I can't believe you did nothing with the Instrument I/O Assistant. You didn't really expect to have me write anything for it, did you? I told you it was a dummy function since you did seem it important enough to provide any details. You could have at least made an effort. You could at least take one of the tutorials. You could at least put your VISA Read inside a loop to get multiple samples.
p.s. You are selling LabVIEW code to clients?
06-16-2010 07:03 PM
06-16-2010 07:21 PM
Your VISA version is going the wrong way. It is getting worse rather than better.
The intialization doesn't belong in the while loop. The stop button does. Right now it will either run once or forever because the stop button only gets read at the very beginning of the programming.
I don't know why you are wiring the purple VISA resource wire to your Hex string conversion function. You don't actually use the string coming out of the VISA read at all. And you are trying to read 5000 bytes. Whatever value you actually get out of the hex conversion function, you are building a single element of an array and passing that out. So whatever meaningless number that is, you actuallly only wind up with a 1-element array. But you only get that if you have th stop button presses before the VI runs. Otherwise you get nothing because you would be force to abort the VI to get it to stop.
As for the Instrument I/O assistant, you haven't done anything with that yet. You are writing a *IDN? command to it. That command tells instruments that might understand it to identify itself. It doesn't give you any real data, assuming it gives you something at all. Then your Read and Parse step doesn't seem to have anything associated with it.
As for your error message, that is "Could not perform operation because of I/O error." Are you sure you have Hyperterminal closed when you run your VI? Are you sure it is Com20?
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
06-16-2010 09:32 PM
baicy,
You don't have to be an engineer to use LabVIEW. You do have to take the time to take those tutorials and use Help (i.e. the button in the I/O Assistant). The *IDN? command is just the default when you create a new assistant and you should have been able to do something like in your DASYLab (is it really yours?) program which is just run a query.
Hex String to Number is the wrong function. You are not getting ASCII strings where that function is used.
06-17-2010 09:27 PM
Thank you very much,Ravens.
I have completed the turorial and modified the VI, I can get some reading from the Bluetooth module, however, it is not entirely correct.
The bluetooth is sending Hex string "1FF" constinuouly, which can be verrified by hyper terminal, however, the readings from the VI is lossing data. For example, the string is something like: 1, 1FF,1FF,1FF,FF,1FF,1FF. Could you please help me? Again, many thanks.
Dennis, the Hexadecimal String To Number Function can convert the Hex string to the right number I want. For example, 1FF is 511. Why do you think that it is the wrong function? Thank you.
Baicy
06-17-2010 09:50 PM
As I said before, get the serial port initialization out of the loops. And also the input buffer setting that you have added since then. When you initialize the serial port, (and now set the buffer size also) on every loop iteration, you are causing bytes to get thrown away that may have arrived in the buffer since the last read.
Dennis probably thought you were getting bytes of values like 01 and FF (two bytes of those values in hex) as opposed to 3 ASCII characters of "1" "F" and "F". If you are getting "1FF" that is human readable in hyperterminal, then you are using the correct function to convert it to a number that you can work with in the calculations.
06-17-2010 10:01 PM
Thank you very much for your quick replay!
I get the serial port initialization out of the loops as you segguested.
However, it doesn't improve anything. There are still missing bit. what do you think problem is?
Baicy
06-17-2010 10:19 PM - edited 06-17-2010 10:21 PM
NO NO NO!
All you did was move the controls out of the inner most loop. You need to take the entire initialization function out of all loops. You really don't need to set the buffer size. And you need to close your VISA resource at the end and wire up all error wires.