LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling serial data

Solved!
Go to solution

I'm not sure how to handle the serial data I'm receiving from a touchscreen panel.

All I want to do is display the two sets of coordinates, which are made up of two 4 digit numbers.

What I'm struggling with, is the carriage return/line feeds (Cr/Lf).

For example I receive,

TP  CrLf                  TP = touchscreen pressed

0100 CrLf             0100 = first set X of coordinates where these values may be anything from 0000 to 4000 and like wise for all coordinates

0200 CrLf             0200 = first set Y of coordinates

TR CrLf                   TR = touchscreen released

0100 CrLf             0100 = last set of X coordinates

0200  CrLf            0200 = last set of Y coordinates

 

If the stylus is dragged on the touchscreen, then I may receive numerous TP CrLf plus the coordinates before I final get the touchscreen release set. 

If I didn't have all the CrLf's but just one CrLf' after TP nnnn nnnn it wouldn't be problem.

I've had a go using shift registers, but I'm unsure of the best way forward.

Some guidance would be most appreciated.

0 Kudos
Message 1 of 10
(3,156 Views)

Please down-convert your code to 8.2.  More eyes can see it.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 2 of 10
(3,138 Views)

I would advise to have several readouts in one iteration of the main loop:

First readout - search the received string for valid command (TP or TR).

If found: run the FOR LOOP to read 2 more times - you will get a string array of your coordinates.

If not found: skip, go to next iteration.

 

First check this: Each readout should give you one message (TP, TR, or coordinates) and properly terminates on linefeed.

You do not need string concatenations from previous iterations, all shift registers. If not, something is wrong with ViSA settings: wrong termination char, etc.

 

0 Kudos
Message 3 of 10
(3,131 Views)

Sorry saved as 8.5

0 Kudos
Message 4 of 10
(3,129 Views)

Make that 8.0

0 Kudos
Message 5 of 10
(3,128 Views)

Sorry I don't understand how I can do two more reads in the same iteration.

The problem I have, is that after I receive  a TP, the rest of code has to run before I can read again from the serial.

So unless I shift it I lose the TP.

0 Kudos
Message 6 of 10
(3,120 Views)

Put in multiple VISA reads within the same loop iteration!

Message 7 of 10
(3,115 Views)
Solution
Accepted by topic author NewWorldMan

Something like this?

Message 8 of 10
(3,111 Views)

Sorry Raven's Fan I didn't accept our answer as the solution, but Alexander had given me the answer before I just didn't realize you could use more that 1 VISA read. If I could have put you both down as the answer I would, but many thanks for your help.

Most appreciated.

 

NWM.

0 Kudos
Message 9 of 10
(3,084 Views)

That is no problem at all.  He gave you the solution, and did a good example of it.  My post  was just a comment to clarify his earlier answer since it seemed you didn't catch what he meant.  The kudoes are appreciated.Smiley Happy

0 Kudos
Message 10 of 10
(3,070 Views)