LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading and saving data from two serial ports

Solved!
Go to solution

@smercurio_fc wrote:

@Ravens Fan wrote:

EDIT:  The problem is in your ASK case.  As soon as you run the subVI with the ASK condition, your false constant keeps the subVI running forever with the infinite loop you've created.


You actually want that to be False since you want to go from the Ask state to the Recieve [SIC] state and let that state decide whether to exit out.


Yes.  You're correct.  It was a last second notice that I wanted to get in before the edit timeout expired.  I figured the action engine within an action engine was going to be a problem.  I saw the False constant, but failed to see that a Receive state was coming in next which the .pdf file didn't show that state at all.

0 Kudos
Message 11 of 20
(934 Views)

I made the changes that smercurio-fc recommended. (I did not really understand Jeff Bohrer's solution...)

I changed the shiftregiter to normal tunnels for VISA source in my RS232 VI and now I get error 1073807346 (about opening VISA source).

Here is the new RS232.

Did I missunderstand u guys? 😉

0 Kudos
Message 12 of 20
(934 Views)

Did you make any modifications to the one or two levels of VI's that use this?

 

Can you attach them?

0 Kudos
Message 13 of 20
(928 Views)
Solution
Accepted by topic author sifeet

@sifeet wrote:

I made the changes that smercurio-fc recommended. (I did not really understand Jeff Bohrer's solution...)


Jeff was suggesting copying the two sets of VIs and making multiple pairs. You'd make a "scale_1" and an "RS-232_1", where "scale_1" would call "RS-232_1". Likewise, you'd make a "scale_2" and an "RS-232_2" where "scale_2" calls "RS-232_2". Kind of a managament hassle.

 


I changed the shiftregiter to normal tunnels for VISA source in my RS232 VI and now I get error 1073807346 (about opening VISA source).

Here is the new RS232.

Did I missunderstand u guys? 😉


You also need to make the same change to the calling VI, "scale".

Message 14 of 20
(923 Views)

The init case is not using the VISA Resource in control- but the Value in the VISA cluster

 

Sorry If I was unclear-  Let me try again.

 

Your basic problem was that you had 1 shift register that was being initialized twice in the first example you posted.  (because you called the sub.vi twice with "Init" value for RS-232 state) SO! Only the last value remained on the SR. The only way to get two different values on the shift register is to have two different shift registers in memory. 

 

A vi can be executed re-enterantly and asked to use a different copy of the same vi, called a Clone, so that there are really more copies of the sub.vi in memory durring run time but- this doesn't work directly since you would have 4 copies and only the two copies with Init wired to them would have data on the SR and the Read instances would report error 1073807346- since an empty VISA session would be passed on.   A timed structure can add fleibility on when re-enterant vis allocate additional Clones since pre-allocating clones would not work.  Pretty much a potential workaround- but a large change in basic program archerecture for a solution that isn't very scaleable.

 

LV offers native OO classes -where you could create say "Class.MySensor" with Methods  "Init, close, set baud, read" and then you could create multiple copies of this object that each hold different data This is very nicely scaleable but, again a large change.

 

What you can do is let the calling VI "remember" the VISA settings for your equipment-  by using VISA in/out terminals- And this is the approach you took.  It costs some modification but lets the top level call the same "State Machine" to take simillar actions on similar equipment by mearly passing a different VISA session to the connector.


"Should be" isn't "Is" -Jay
Message 15 of 20
(921 Views)

Thanks for all the answers 😃

 

Ofcourse I made changes to "scale" and "balances" VI:s too. Unfortunately I have left my workplace now, and I'm not able to attach the VI:s now. I'll do it tomorrow. But the only changes made in those VI:s were that I replaced the old RS232 with the new RS232 in "scale"VI and saved. and then replaces the old scale with the new one in the final VI, i.e. "balances".

 

Smercurio_fc and Jeff Bohrer, thanks for your explicative answers!

0 Kudos
Message 16 of 20
(916 Views)

@smercurio_fc wrote:


Jeff was suggesting copying the two sets of VIs and making multiple pairs. You'd make a "scale_1" and an "RS-232_1", where "scale_1" would call "RS-232_1". Likewise, you'd make a "scale_2" and an "RS-232_2" where "scale_2" calls "RS-232_2". Kind of a managament hassle.

 


I tried this solution , but still I have the same problem. I only get data from one balance.

Here are the VI:s.

Download All
0 Kudos
Message 17 of 20
(897 Views)

The rest of the VI:s...

Download All
0 Kudos
Message 18 of 20
(896 Views)

Edit : I only get data from one balance at a time. For example if I stop the first scale, I start getting data from the other one and vice versa!

This has nothing to do with VISA ports, or does it? Because I CAN get data from both scales, from different ports, but not at the same time.

0 Kudos
Message 19 of 20
(892 Views)

Never mind, I solved the problem.

Thanks everyone for the help 😃

0 Kudos
Message 20 of 20
(889 Views)