11-13-2007 01:33 PM
Dear all,
Thank you for reading my post.
I am using Labview 8.0 on Pentium D 3.4Ghz, 2GB of RAM.
I am using a microcontroller PIC24 (on the Explorer 16 development board), which I have programmed to acquire an AC signal at a rate of about 4 kHz. The PIC24 has a 10bit ADC and the acquire value is then padded to16bits in total (format: 0-0-0-0-0-0-d9-d8-d7-d6-d5-d4-d3-d2-d1-d0) as an unsigned int.
The serial setting for the pic and my Labview program are 115200, 8 data bits, no parity, 1 stop bit.
In order to send the acquired value to my PCs serial port (Remember UART = 8-bits of data only) I divide the 16 bit word into MSB and LSB. I then send the MSB and LSB 8-bit value one after the other.
The format I use is:
ADC_High = 0-0-1-d9-d8-d7-d6-d5
ADC_LOW = 1-0-1-d4-d3-d2-d1-d0
The total data rate for this communication is about 64kbps.
After the VISA Read VI has read and outputted the data (in string format), I am trying to remove the 3-MSB from both ADC_HIGH and ADC_LOW.
Once the 3-MSB have been removed, I want to concatenate the two strings (ADC_HIGH and ADC_LOW).
After that I want to type cast the concatenated string back to unsigned int and normalize the value.
As I am however, new to
Would some one be as kind as to check the attached VI and give me some advice of what I might be doing wrong?
Regards
Alex11-13-2007 02:13 PM - edited 11-13-2007 02:18 PM
11-13-2007 04:47 PM - edited 11-13-2007 04:55 PM
11-16-2007 01:18 PM
Thanks for both your replies.
Both of your solution work fine.
Before I start I should first say that I made a mistake when decalring the data type format. The correct is: d1-d2-d3-d4-d5-d6-d7-d8-d9-d10-0-0-0-0-0-0.
First to answer Spex’s question on coding the data differently:
I had been coding the data exactly as you suggested; however, I have changed the way of doing this for a number for reasons.
However, know I am interested in adding the validity check to verify and distinguish between the two data stream.
The function I am looking to implement would require I compare only the first 3 bits of every word (e.g. a1-a2-a3-x-x-x-x-x). Then, I would load the two 5 LSB into an array as per your examples.
The attached example seems to work (in LV 8.0). I was just wondering whether there is a better solution to the problem (more efficient, simpler, etc…)?
Regards
Alex
11-16-2007 02:18 PM - edited 11-16-2007 02:22 PM
11-16-2007 03:57 PM - edited 11-16-2007 03:57 PM
11-20-2007 10:05 AM
Thanks for your reply altenbach.
You are 100% right that the use of the sequence structure was pointless.
I should have also combined the MSB and LSB checking to just one case structure, as you point out.
You suggest: "I clip the first char from thethe input array if the framing is not right."
Would you be as kind as to ellaborate on this? How would I clip one char if the pattern does not much?
Regards
Alex
11-20-2007 12:10 PM
Let's ssume you have a long string, alternating between MSB and LSB. If we get them pairware and process as above, and the pattern does not match, it means that the original string starts with the wrong byte. If you would take the substring starting with element 1 (instead of zero) before processing, the framing for the rest of the data should be correct.
bogiasac wrote:
You suggest: "I clip the first char from thethe input array if the framing is not right."
Would you be as kind as to ellaborate on this? How would I clip one char if the pattern does not much?
11-20-2007 01:21 PM
I am assuming you are referring to the String Subset VI.
By removing element one, I understand that I would have to 9 string characters (8 characters + end of line).
Please remember that the correct data type format is: d1-d2-d3-d4-d5-d6-d7-d8-d9-d10-0-0-0-0-0-0.
Also I have changed the values that represent MSB and LSB. Now 000 represent MSB and the bytes that start with 100 represent LSB. This was simply done so that only one bit changes at a time.
However, I am not getting any results. I have attached the modified VI.
I would be grateful if you could advise me on it.
Regards
Alex
11-20-2007 02:40 PM
bogiasac wrote:
I am assuming you are referring to the String Subset VI.
By removing element one, I understand that I would have to 9 string characters (8 characters + end of line).
Please remember that the correct data type format is: d1-d2-d3-d4-d5-d6-d7-d8-d9-d10-0-0-0-0-0-0.
Also I have changed the values that represent MSB and LSB. Now 000 represent MSB and the bytes that start with 100 represent LSB. This was simply done so that only one bit changes at a time.
OK, put a typcal string into your control and make it the default, save the VI. Then attach it again. Let's see what you have. 🙂