01-28-2011 04:35 AM
I am working with bluetooth to send my four signals from my circuit to the computer. So, I am using VISA to acquire the data in labview. Since as you know its not possible to use DAQ while using bluetooth.
anyway after getting the signal I need to filter ir for analysis part and I am using filter express VI from signal processing's functions. However, I am getting error, since I dont have the sampling frequency set and I am not able to set it in my filter function either.
I was wondering If there is a way of making labview recognize the clock-timer as the sampling rate or any other way to set the sampling frequency somewhere before the filters.
here is the program, you can take a look at it.
01-30-2011 12:05 PM
Clock timer of what? You don't even have a Wait function inside your loop. If you have an A/D running on the instrument and are sending a waveform, then obviously the program has no way to know the sample rate unless you send and read that. If the instruments sends a single sample each time, then your sample rate is your while loop's iteration time. Try using a timed loop.
p.s. Your code is very sloppy and hard to read. Neatness does count, It seems overly complicated and your use of the Replace Substring inside a for loop is just wrong. Have you looked at the output of that?
01-30-2011 01:56 PM
I have found so many mistakes in my program as well. I am so new in labview and this is my project. anyway I changed abit, however, I still have a problem in the very beginning of my program, and its that I need to read 8 bytes from the visa and then I need to seperate then into 8 different 1-byte arrays(so it will give me my four signals). I still dont know how to do that, whatever I do it doesnt work, could you please look at this new file and see if its a correct way of doing or not? and how can I get those 8 bytes sepererated. I was using string to byte array function to convert them before but then I found out that the output is not 8 one-byte arrays but more. in addition, later on I need to pack 300 samples of 2 of my signals for later analysis. I am thinking that after getting the 8 bytes I should swap the byte for big endian first. But after that shall I pack in the shape of arrays or change the type of the data again? I would be garteful if you could answer my questions , I am really confused.
01-30-2011 02:12 PM
The for loops are completey wrong. If you read 8 bytes, you just need to directly wire the string to byte array function. You would get a single 1D array that you would inex.
A major problem is how do you know the order of bytes? It's asynchronous with the sender so the byte order is random. In other words, the first byte you read can be any byte sent between 1 and 8. With your current design, I don't see any way it would ever work. This is something that would have to be fixed on the sender side. Typically, the sender would not write anything until a specific request is received.
01-30-2011 02:26 PM
Sender side is sendng 2 bytes of FF in the begining of the loop and 2 bytes of zeros between each signal, I am attaching the code as ICCV8 file (I will also attach it as a notepad file), so you can see what I mean. I had written some solutions for that as well in my program before but not sure if it was correct or not. I tried to search for FF bytes as a string, after getting each 18 bytes. But apparently it doesnt find the FF, I reckon because of wrong conversions beforehand, so it stops the programm there. Im attaching the that program now as well. could you please take a look?
01-30-2011 02:35 PM
I am thinking when I find the FF bytes and they are in the middle of an array, the program should save the data coming after FFs. after that the program should read a new 18 bytes and try to add the lacking data in the end of the previously saved FF array, so it will be complete. That is why I tried to use 3 VISA read functions in different sequences. However, all of them are getting the data from one source, I mean from one while loop. Is that a correct idea? I am not sure about it either.
01-30-2011 02:52 PM - edited 01-30-2011 02:54 PM
What I have done is read 1 byte at a time and simply compare it to FF. You don't even have to convert it to a numeric. Just right click on a string constant and select 'Hex Display'. This would be done in a while loop. Exit when the FF is read and from then on, you would be in sync. This all assumes that your data never includes FF. I don't see anywhere in your C code where you replace an FF in the data with something else.
Get RID of those for loops. Your conversion with them is completely wrong.
01-30-2011 03:02 PM
oommgggg, yes, your so right. Thank you sooo much,I have a deadline tomorrow, so I am so stressed that my brain has stopped working :X I am correcting it right now. But one more question, what do you think about my idea of using VISA read fucntions as I explained before, is that correct? will it work?
01-30-2011 03:15 PM
I don't think you really don't need separate VISA Reads. Once synched, you can do a single read of x number of bytes, convert that to a single byte array and index the elements (single Index Array) you need.
01-30-2011 03:58 PM
I corrected the way you said, thank you so much. Could you see if the VISA read part is ok? But one more thing I am still having doubt on it and its while I am packing the 300 samples for analyzing. Shall I use concatenate string? or shall I pack it as arrays?