From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unusually high data value being read (serially, UART) at launch

Hi,

 

I'm experiencing an issue upon startup with unexpectedly high sample values being read serially.

 

The data is being fed from a PIC (18F2550) 10-bit ADC sampled at 1kHz and it is sending the samples out through the UART protocol (19,200 baud rate). We expect values between 0-1023 to be coming from the UART. When these high values occur (up to 2^16-1), a little wiggle on the potentiometer ADC fixes this issue and the data plots as expected.

 

My main.vi illustrates my main applications initial flow, it is preconfigured through the Serial Configure block, it is just not shown there.

The serialreadtointeger.vi also expects 2 bytes at the com port. High byte has 6 MSb's equal to 0 with the last two LSb's being equal to the MSb's of the data sample with the remaining low byte containing the 8 LSb's of the sample adding up to 10 bits.

This youtube video we made shows the issue in more context: http://www.youtube.com/watch?v=2NZDPYPlSZI

 

Are the values being concatenated from the previous application's run or is something else happening?

Download All
0 Kudos
Message 1 of 4
(2,274 Views)
How do you know which byte is which when you read? Since the communication it's asynchronous, you have no idea of the byte order unless you are appending a termination character at the end of the second byte. Randomly reading bytes will not work.
0 Kudos
Message 2 of 4
(2,243 Views)

Alright, that's fair. The values coming in agree with what we are receiving on RealTerm and Putty, so I'm confused why the values would correct (stay within the desired range of 0 to 1023) once we toggled the potentionemeter [refer to youtube video]?

 

Thanks for your help by the way.

0 Kudos
Message 3 of 4
(2,217 Views)

@afdasfdasfadsfdafadfdsf3 wrote:

Alright, that's fair. The values coming in agree with what we are receiving on RealTerm and Putty, so I'm confused why the values would correct (stay within the desired range of 0 to 1023) once we toggled the potentionemeter [refer to youtube video]?


That is sounding like you have a bug in the pic code.

 

To me, this looks very much like you data is getting out of sync.  You really should add something (a sync word, termination character, and/or checksum) to make sure you are getting the data in the proper format.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(2,185 Views)