LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serail port visa read

Hi all,
I'm using Labview 8 and communicating with the serial port and GPIB.
I'm receiving string "d" continuously in Visa read and want to compare it, as can be seen in my code. Whenever I read string "d" I want to initiate the structure for GPIB loop. Unfortunately I'm able to see a line of "ddddddddddddddddddddddddddddddddddd..." in my read string indicator but when I compare it with "d" using boolean eual to operator, I get FALSE!Smiley Surprised
Can anyone figure what is the problem,
Looking for help,
Regards
0 Kudos
Message 1 of 8
(2,767 Views)
That's because "ddddd...." does not equal "d"!

How do you know that you actually only got one "d"? You don't, since you're reading as many bytes as are available on the serial port. You could have gotten "ddddd", "dd", "dddddddddddddddd", or "dddddddd", none of which are equal to "d".

What is this "d" response supposed to mean? Are you only supposed to get one?
0 Kudos
Message 2 of 8
(2,755 Views)
Oh ok,
Actually I've interfaced my PIC microcontroller to the Serial port and after if finishes off it's task it send a status message "d". I can change the status message if you want, to anything.
Every time I get a "d" I need to trigger the Structure loop, so that corresponding data of network analyser can get stored in the file. The delay kept inside the while loop can be adjusted so that structure loop executes fully before next "d" comes in.
Waiting for reply,

Rohit


0 Kudos
Message 3 of 8
(2,749 Views)
You can use the "Match Pattern" function, although looking at your VI again my guess is that another possibility is that the problem is that the PIC is sending "d" followed by a linefeed or something else. You've got the serial port set up to not use the termination character to end a read. Does the PIC end its messages with a linefeed? Set the string indicator to '\' Codes Display mode. Do you see "d\nd\nd\n"? The "\n" is a linefeed character. This means that you're trying to compare "d\n" to "d", which is not equal. You can either strip the linefeed before comparing, or just use the "Match Pattern".

Note for others reading this: This is another in a series of threads. Others: this thread and this thread.
0 Kudos
Message 4 of 8
(2,744 Views)
I'm getting series of ds , there is no line feed character. And when I use the match patter pallete...the offset past match goes to it's maximum value immediately...i.e 65536 if I connect it to a control(unsigned 16 bit).
Whearas what I want is everytime I get a d I want to trigger the structure for GPIB( I mean get some YES/NO) which can trigger the structure.
As when the PIC is idle it doesnt send anything and the read string indicator is empty, which is true as in idle mode PIC doesnt send anything.

0 Kudos
Message 5 of 8
(2,738 Views)
The output of the Match Pattern is a signed integer. If what you're looking for is not found the "offset past match" is -1. The documentation states this. In general, you would use it as shown in the attached image.

That said, just so I get this straight, since I've noticed in your posts you tend to only give partial information which negate previous suggestions. You have a big while loop set up in which you're building a bunch of commands and you send them out to the PIC. The last one you send is "s". You then read from the serial port. I'm assuming you're expecting to see a "d" there to indicate that the PIC is done with the set of commands that you've sent? Regardless of what's on the serial port, you then go around the loop again and do the same thing. What happens if you don't receive anything on the serial port from the first iteration? You would merrily go around the loop a second time sending out the commands as before. Presumably this means the PIC goes through another processing phase, at which point you may get the "d" from the first set of commands. Don't you want to wait until you get a "d"? Why issue the commands again if you have not verified the PIC has completed its task?

You said "The delay kept inside the while loop can be adjusted so that structure loop executes fully before next "d" comes in." What delay? Are you talking about the 4.333 wired to the "Wait" function? If that's what you're referring to, that's not going to give you the delay you want, because that can execute at any time since you have no data dependency on it. In fact, it can execute while you're creating your commands. When is this delay supposed to happen?

Message Edited by smercurio_fc on 06-01-2007 03:58 PM

0 Kudos
Message 6 of 8
(2,731 Views)
Hi,
The Start and Stop buttons are of type Latch when released, so the set of commands is given to PIC only once i.e. on  a click of a mouse. Rest of the time since the controls remain in False conditon no Visa Write occurs and I'm just trying to read from Visa Write. Whenever I read a d means Task of PIC is over and in that iteration the structure needs to execute.
An "s" character is read to PIC only when I press Stop and it's an interrupt to the PIC, which makes PIC go in IDLE state, in which case it doesn't transmit any charater back.
0 Kudos
Message 7 of 8
(2,723 Views)
Hi,
It's working now....the idea of using match pattern is working

Thanks a lot
0 Kudos
Message 8 of 8
(2,712 Views)