LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Everything off by a cycle? Please help!

This post is a continuation of a previous post. If you are interested, please see:

 

http://forums.ni.com/t5/LabVIEW/Program-works-when-I-STEP-but-not-when-I-RUN/m-p/1280830#M532817

 

I thought I had the complete solution, but I was wrong. Anyway, I have a multiplexer circuit and two types of sensors – voltage and temperature. I turn multiplexers ON/OFF for each type of sensor periodically but read both sensor types all the time. The result is that during a read cycle, one of the sensor types is correct and the other is incorrect. No harm really. I figured that I'll just poll the multiplexer ON/OFF value and decide which sensor value is correct and will thus display only the correct value to a couple of indicators. The VI is attached for your examination (also a JPG for convenience). The flat sequence is the "selective display" portion. I also have redundant indicators in the VI as I was trying to troubleshoot. The truth table for the circuit is as follows:

 

MUX Enable value      Voltage            Temperature

0                                 Correct              Incorrect

16                               Incorrect            Correct

 

But my logic does not work. The symptoms are:

 

1) Inside the flat sequence, when I make the comparison with 16, both "Voltage" and "Temperature" indicators show the incorrect value of the sensor reading. But when I make the comparison with 0 (zero), both "Voltage" and "Temperature" indicators show the correct value of the sensor reading. This should not happen because when MUX Enable is 16, Temperature should be correct.

 

2) When MUX Enable is 16, the "Voltage" indicator updates its value - it should be the Temperature. When MUX Enable is 0, the "Temperature" indicator updates its value - it should be Voltage.

 

3) When MUX Enable is 16, the the Raw Data indicators shows correct voltage value (should be temperature), and when MUX Enable is 0, the the Raw Data indicators shows correct temperature value (should be voltage).

 

Feels like everything is off by one cycle. Can someone please let me know where this discrepancy is coming from and more importantly – how I can solve it? Thanks.

Download All
0 Kudos
Message 1 of 10
(3,002 Views)

Run your code with Highlight to see what's really going on. You're feeding the flat sequence with a 0 or 16, 0 if 1 > Temp Measure Frequency, else 16. Might that be the problem?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 10
(2,993 Views)

 


@Yamaeda wrote:

You're feeding the flat sequence with a 0 or 16, 0 if 1 > Temp Measure Frequency, else 16. Might that be the problem?

/Y


What are you talking about??!!   Temp Measure Frequency is not being compared with anything! The code has an internal counter. If the counter goes above a certain number, then MUX Enable is set to 16 as a trigger to measure temperature. Otherwise, it's held at 0 to measure voltage.

 

0 Kudos
Message 3 of 10
(2,976 Views)

Since you can the case if more or less reversed in action i'd take a 2nd look at the 1st comparison.

forum2.PNG

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 10
(2,957 Views)

JG001,

 

Pretty sure I know how to do this but first a quick question.  How many of each sensor will you ultimately have in your application?  Just one of each?

 

 

0 Kudos
Message 5 of 10
(2,928 Views)

Yamaeda,

 

Personally, I think you are focusing on the wrong area of the code. I say this because in "Stepping" mode with Highlight, the program works like it should. So, I'm pretty sure the first comparison is OK.

 

Just to be clear, Clock Tic Counter is in a Shift Register which grows with every iteration of the code. Clock Tic Counter is being compared with a quantity = ceiling (Measurement Frequency / Temp Measure Frequency). So, let's say Measurement Frequency = 1000 Hz. Since Temp Measure Frequency is set to 2, the first comparison checks whether Clock Tic Counter > (1000/2) = 500. If Clock Tic Counter < 500, Clock Tic Counter = Clock Tic Counter + 1. When Clock Tic Counter reaches 501, it is reset to 1.

 

Hope this is clear.

 

I guess I'll be on my own for this one.

0 Kudos
Message 6 of 10
(2,926 Views)

@Wayne.C wrote:

JG001,

 

Pretty sure I know how to do this but first a quick question.  How many of each sensor will you ultimately have in your application?  Just one of each?

 

 


Wayne,

 

I will have eight voltage sensors connected to an 8-channel MUX and 2 temp sensors per voltage sensor. So, a total of 16 thermocouples connected to a 16-channel MUX. The 8-channel MUX has an inverted "Enable" pin while the 16-channel MUX has a regular "Enable" pin. I'm using a single signal for both MUXs. This is why at any given time, only one fo the sensor readings (voltage OR temp, but NOT both) is correct.

 

Hope this helps. Thanks.

0 Kudos
Message 7 of 10
(2,918 Views)

JG001,

 

So thinking in terms of your LV program, you have 8 groups of data each containing a voltage reading and two temp readings.  That means that ideally you would read the data for a particular group in sequence.  So assuming active high enable, the sequence of MUX addresses (hex) would go something like this:

 

                       

Group1 Voltage 0x00

Group1 Temp    0x10

Group1 Temp2  0x11

 

Group2 Voltage 0x01

Group2 Temp1  0x12

Group2 Temp2  0x13

 

etc

 

Is this correct?

0 Kudos
Message 8 of 10
(2,905 Views)

Wayne,

 

That would be one way to do it. Yes - you are correct about the MUX addresses.

 

My task is slightly more complicated due to the fact that the module I'm using to read the thermocouples (NI SCC-TC02) can only be updated at 2 Hz while I need to and can update the voltage channels at a much higher rate (say at 400 Hz).

 

So, the way I do it is keep the Enable signal LO for reading the voltage channels correctly in sequence at a high rate until a trigger is set (every 500 ms) when I set the Enable bit to HIGH for reading the temp channels correctly. I keep track of the channel numbers for both voltage and temp separately in shift registers.

0 Kudos
Message 9 of 10
(2,892 Views)

JG001,

 

That clarifies things a lot.  Now I understand what you're trying to do.  Back to your original problem.  You have a case statement in the sequence that controls which indicator is updated.  Swap the cases.

 

If I can find some time this afternoon, I'll try to simplify your scheme a bit.

0 Kudos
Message 10 of 10
(2,875 Views)