LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial port read.vi

Solved!
Go to solution
I have no idea how you manage to convert a warning to an erro and stop something but you can of course remove any error/warning that you want.
Message 31 of 46
(1,454 Views)

In addition to what Dennis pointed out under Tools >> Options >> Debugging (Preferences >> Debugging on a Mac)is an item to "Show warnings in error list..."  Try changing that.

 

Lynn 

Message 32 of 46
(1,446 Views)

YESSSSSSSSSSSSSSS. ITS finally working...for now...

Thank alll of you guys for helping me on this!!Especially Dennis for walking me step by step Smiley Happy

Best regards,
Krispiekream
0 Kudos
Message 33 of 46
(1,430 Views)

Alright, all of my 4 systems are working like it should be. But I do have one last question.

My systems first read the pressure measured and saved it.

if it reads 690. and it will want to set to 730.

so it write. "setting to 730 from 690"

but looking at the pressure indicator. it was 698 for something. then when it gets to that sequence to set the pressure. it goes 698, then to 0 right away, then point something second later. it reads the presurre again. now, is that something i can fix?how do i not it let read 0? and just read the pressure?

 

Best regards,
Krispiekream
0 Kudos
Message 34 of 46
(1,405 Views)

That's got to be in some portion of code that you have not shown us to date.  You hadn't talked about setting any values, just reading.  Your code doesn't doing any writing to the serial port.

 

If I had to guess, there is either a timeout occurring, or in someway there is an instant where data is not being returned, and the default value of an empty string is getting converted to 0.  Once you get a valid value again, then you see it.

 

You may just need to have some special handling of the timeout case so that the value doesn't get written to the indicator.

Message 35 of 46
(1,401 Views)
here is where my code write to it?
Best regards,
Krispiekream
Download All
0 Kudos
Message 36 of 46
(1,387 Views)
Message Edited by krispiekream on 09-30-2008 03:37 PM
Best regards,
Krispiekream
0 Kudos
Message 37 of 46
(1,378 Views)

There is still a missing puzzle piece to this picture.  How does the code you show in Untitled1 relate to the VI you attached and the picture Untitled?

 

Where are ReadResp and Serial Error VI's?

 

Why are you keeping the VISA reference in a local variable?  Why to you write to "dup VISA resource name" as a terminal, and later to a local variable of that same terminal on a different wire branch?

 

Why do you have the semaphore structures in you Untitled1 picture?  They are doing anything the semaphore is immediately created then locked.  Then unlocked, then destroyed.  The semaphored section is never prevented from running, and it never locks out any other section of code because this is the only thread based on that semaphore.

 

If you are getting an unexpected zero for your pressure reading, it must be in the ReadResp VI that you didn't post where you aren't getting a valid response.

Message 38 of 46
(1,351 Views)

i had the readresp.vi in page 2 or something of this post. but i made some updates so here it is again.

also, about the semaphore. i used that because something suggested that if i want to get rid of the shacked sequence. i can do that using semaphore. i'll attach an image of what happened before and what i have now. "what i have now is made FALSE."

But yeah, right now, my system reads the value, then once in a while. it will read 0. I guess once it is not using pressure_query.vi. it returned the pressure to 0, till i enter pressure_query.vi again.

I do noticed that if i run pressure_query.vi by it self. I will read the pressure. But if I press stop on it. the pressure = 0. Does that help?

it seems like the value is returned to its default value.  

Best regards,
Krispiekream
Download All
0 Kudos
Message 39 of 46
(1,336 Views)

Do you have another section of code that is also using the serial port?  Your one code snippet has the global variable where you are using a boolean as a flag to lock the pressure reading.  While global variables aren't recommended, if used okay, they can be used as signal to other parts of the code.  Meanwhile the semaphore method you are using is not effectively doing anything.  Since the semaphore is being created there, there is only that semaphore reference protecting that one thread of code.  If you created another semaphore elsewhere, then it is a completely separate reference unrelated to this one.  You need to create one semphore and pass it to all instances of code that you are trying to protect from each other.  The alternative is to create a named semaphore so that each reference that is created using the same name is related.  Definitely look up semaphores in the example finder.

 

I'm not sure why you have the writing to the VISA resource in one VI (pressure query), but separate the reading of the serial port into the separate subVI (read response).  Since writing to and reading the response from the serial port are directly related operations, I would keep them grouped together in the same subVI.  I can't see how this is directly causing your problems right now as I am not seeing any obvious race conditions (like trying to read the response before you wrote out the query).  But if you are using the serial port in other parts of the code like the use of the semaphore implies, but the semaphore isn't doing its job, you could have parts of the code stepping on each other and the Read Response VI isn't reading the response it is expecting, thus failing to decode the pressure.  Also, since the writing out of the query is separated, it isn't protected by the semaphore anyway.

 

 

Message 40 of 46
(1,331 Views)