LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communication only working while in Highlighted Execution

Hi, there.

 

I'm having some issues while trying to communicate via serial port, it is only working in Highlighted Execution mode. The thing is, I do 2 communications in every loop iteration, in the first one I send the device the power I need (this is something like p50789f), then, it sends me what it got, if the answer is correct i send the device a "correct" (this is "of") message and we go on with the rest of the program.

 

This communication never gives me any problem, the problem is the next one.

 

In the next one I start the communication by asking the device how much power it is consuming (w1f), we do that 'Echo Routine' (not sure how it's called) again, and everything works fine.

The problem starts when it wants to tell me how much power it's consuming, I expect something like (w50760f) but I get nothing at all.

 

I've tried adding delays, but it won't work. Any Ideas?

 

Thanks a lot, I'll add pics of the program in a hour, I'm waiting for my laptop's battery to recharge 🙂

0 Kudos
Message 1 of 5
(2,550 Views)

skelzer,

 

Apologies to a new member for all the spam hitting the Board today.  This is highly unusual.

 

Usually when a program works with Highlight Execution on and it fails without it, the problem is one of timing. Something in your program is running too fast for the external device to keep up.  Do you have any delays between writes and reads?  Are you getting any errors? If so, what are the error codes? 

 

It can be difficult to trouble shoot a picture.  It is better if you can post your VI with typical data saved as default.

 

Lynn

0 Kudos
Message 2 of 5
(2,539 Views)

No problem with the spam, and thanks for the reply 🙂

 

I was quite busy today, so I couldn't upload the VI, I'll upload it by tomorrow morning.

 

 

Thanks again, Cheerio! 🙂

0 Kudos
Message 3 of 5
(2,533 Views)

Ok, here it is, this one is the "bad" communication.

 

Potencia.vi is the "master" (Don't know if that's the word) VI. It works fine until third frame's second frame's 'Lee Modulo.vi' in that VI, I get nothing when I try to run it in normal mode. When I run it in Highlighted Execution mode I always get the word I'm waiting for (w5xxxxf).

 

Hope you can help, it's my final year project, and everything's working like a charm, but I'm hitting my head against a wall with this issue.

 

 

Cheerio! 🙂

0 Kudos
Message 4 of 5
(2,529 Views)

skelzer,

 

1. Use of sequence structures tends to make program very inflexible.  Except around the Wait(ms) functions they are completely unnecessary in your program.  LabvIEW is a dataflow language.  The data determines the order of execution.

2. You are not looking at any errors.  Wiring the error clusters can give you a lot of information when things do not work.

3. You do not show where you initialize the serial port (or close it).  Do you have termination characters enabled?  Your LEE M.vi stops immediately if no byte is present at the port.  Typically the usage puts a small delay in the True case and stops after a complete message is received.

 

4. A better architecture for many cases is to do the reads and writes in one VI and pass messages, (possibly via Queues), to a parallel loop where the messages are decoded and decisions made about what to do next.  This is called the Producer/Consumer Design Pattern.

 

Lynn

0 Kudos
Message 5 of 5
(2,516 Views)