LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Please help me modify this code to write to the correct output channels

Hello.

 

I'm backed into a corner here.  I've paid a programmer to rework the I/O section of this code and he's left me high and dry with a deliverable this week.  I'm dying here and the programming is above my head, plus Labview crashes every few edits so it's slow going.

 

This is a program we had created by an independent programmer that is no longer in business, so I can't pick his brain.  I'm left to my own devices.  A screenshot of the related code is attached with descriptions on it.

 

At one point this program ran on one SCXI chassis with 16 channel 1160 relay.  Our new application is split across four cDAQ chassis, and I need to route the conditions accordingly.  Right now this programmer attached it all to one card and essentially told me to pound salt.  I desperately need to split these local variable AND bit conditions to 1&2 to the main chassis, 3&4 to the second chassis, 5&6 to a third chassis, and 7&8 to a fourth chassis.

 

From what I can tell, the original programmer is using bit/byte count to tell each card which channels to turn on and off.  Each card only needs channel 0-3 to work, each working in pairs (the same condition that enables channel 0 enables channel 1, etc).

Example: BH1 Start Stop Test state changes, ONLY Rack 1, slot 5, channel 0 and 1 change.
BH1 Start Stop Test 2 state changes, ONLY  Rack 2, slot 5, channel 0 and 1 change.

BH2 Start Stop Test 2 state changes, ONLY  Rack 2, slot 5, channel 2 and 3 change.

Hopefully this is clear.  I've never used bit/byte/nibble to set states on cards, only typical booleans.  Thanks very much in advance.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 1 of 12
(3,112 Views)

Don't work with just one array.

 

Create other arrays and combine the signals as necessary just like you are doing now with the one array.

0 Kudos
Message 2 of 12
(3,093 Views)

I must be hung up somewhere.  The constant that's hooked to the shift register, isn't that bringing in pertinent information from another part of the program?

It can't really be as simple as reducing each array to four inputs and making more case structures, can it?

 

Or am I over complicating things?

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 3 of 12
(3,079 Views)

The constant that is hooked to the shift register is the value that intializes the shift register for the first iteration of the loop.  In this case an empty array.

 

(You've been around awhile.  I'm sure you've looked at some tutorials or taken some lessons and have learned this already.)

 

Yes.  It is that simple.

0 Kudos
Message 4 of 12
(3,068 Views)

You know, I've been doing this for a bit but it's only on a demand basis at a job that has me tasked otherwise 99% of the time.  I'm a process engineer and IT guy with literally no programming background prior to this.

 

And I'll be darned, I made a quick test program to emulate what  you suggested and it seems like it works.  The only thing I can't really figure out is the purpose of the case structures...  It seems to nullify any chance of the main program stop button actually effecting any change in state in the cases.  They go false before the program has a chance to write the zero constant to the channels.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 5 of 12
(3,052 Views)

The case structures are set up to write new values to the DAQ assistant whenever the booleans change OR the stop button is pressed.  Of course if the stop button is pressed, chances are nothing changed on the booleans.  When something changes, it only happens for that one iteration, depending on how fast the code runs, you might never see a probe on the boolean wire ever change to true., but it will have at least once.

 

What do you want to have happen when the stop button is pressed?  Often it is a desire to turn off all booleans.

 

There is no harm to writing the same data to the DAQ assistant on every iteration, so I don't know why the case structures are needed either.

0 Kudos
Message 6 of 12
(3,046 Views)

Thanks for the assist so far.

I pulled the code out into a separate VI to test.  This does almost what I want.

 

-if any individual boolean turns on or off, it should change the binary being written to the DAQ assistant.  When these booleans are TRUE, related channels in the daq should be on/high.
-if the master stop button is pressed (goes true), it should write a zero (Constant as wired) to all those DAQ assistants.  The way the previous program was written, the cases were just going false and the constant zero never got to it.

 

Using a shift register and removing the case structures, I was able to get most of the functionality I want - it sends the true to each of the switches, causing the zero constant to write to the DAQ assistant (yay!), then on the next loop iteration it sets the case structure and commands the loop to halt (yay!).

 

However, upon pressing 'start' again, it immediately shuts off as it has retained the value from the previous loop.  Not sure how to fix that.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 7 of 12
(3,004 Views)

Actually I just realized that adding a false constant to the shift register seems to have cleared that up.  Does the constant only run on the first iteration of the loop?

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 8 of 12
(2,996 Views)

As I said, there is no harm writing to the DAQ devices on every iteration, so the case structure is not needed.  And without the case structure, you don't need the shift registers and the comparisons to see if they've changed.

 

Use the boolean control terminals rather than the local variables.

0 Kudos
Message 9 of 12
(2,993 Views)

I can't use the boolean terminals, they're off in another loop.  Hence the variables.  If that's possible, I'm not sure how as most of this is beyond me.

One thing I noticed, without the case structure, when you make changes to any of the booleans, there's a brief second where the display goes to zero.  That would command an output change that I can't have.  I'm not sure what the case structure has to do with it, but I did notice it.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 10 of 12
(2,982 Views)