LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What am I doing wrong with my code?

Solved!
Go to solution

I'm sure there are a number of things I'm doing wrong, but if I can just get this to "work" that would be great for now.

 

Goal: Data log Tc's every 60sec as well as "fuel weight".

  • Be able to turn "pumps" on manually with switch, "pumps" turn off when fuel weight reaches a certain numeric value.

So I've made an even bigger mess now. I've got the "pumps" to turn on and off with the switch manually, but not turn off based on the numeric value.

The indicator for "fuel weight" Turns on/off at the appropriate time based on the numeric, but only when it's outside of the event structure.

The system wont data log unless there is a timeout value for the event structure, or it will only log when some event occurs inside the structure.

Need a little help sorting things out, Thanks Smiley Happy

LabView 2014sp1, with fieldpoint drivers V15.0

0 Kudos
Message 1 of 13
(3,465 Views)

Your loop only spins when the event fires.

 

Have a look at the tutorials and example templates. I would recommend a simple state machine. Also your array gymnastics seem overly complicated. A table is just a 2D array of strings so built that in a shift register. No need for the express table and dynamic data there. Just use "built array" to concatenate the two 1D arrays and the scalar into a longer 1D array.

0 Kudos
Message 2 of 13
(3,460 Views)

In a word "everything"...

 

You need to break your task down into steps, make a flowchart if that helps. Then you will see that "one big loop" is never going to work. A simple state machine would be a far better approach with each "state" being a "step" from your breakdown of steps.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 13
(3,456 Views)

Hey there!

 

I don't actually see any place where you control your pumps based on a numeric value...  I see the event structure and how it'll run when you see a change in value to FUEL WEIGHT and to PUMPS, so it makes sense that it works when you manually change it.  But I don't see you modifying this anywhere else, so I don't see why it would change anything based on a numeric.  Am I missing something here?

 

Also, you have FUEL WEIGHT set to change value inside an event structure that's going to run when FUEL WEIGHT's value changes.  But FUEL WEIGHT's value isn't going to change until the event structure runs!  So, it's never going to get run.

 

I'm not sure about the datalogging issue... I'm not too familiar with FieldPoint, but that part of the code looks good to me.

 

I would highly recommend you switch up your architecture slightly and make this a state machine.  It'd make the whole thing cleaner and easier to work with. It seems like you're getting caught up in some event structure logic issues here and you could put those to rest.  It's not all that different from what you've got now. Here's a tutorial: http://www.ni.com/tutorial/7595/en/

0 Kudos
Message 4 of 13
(3,446 Views)

For the numeric value controlling the pumps. There is a "weight" value coming from one of the FieldPoint(FP) modules(Red pen), that value goes into the data logger and also when they value is less than 0.05 it needs to turn the pumps off. Part of the problem might be that the value is not a control, but how do I get it to be just an indication of the weight value and a control for the pump at the same time?

 

I'm going to look into this "state machine" thing and see what I can learn, it's what everyone is recommending for this.

 

Thanks for your help

0 Kudos
Message 5 of 13
(3,431 Views)

It is a data source. You branch the wire to the indicator and pump control. Don't use an event structure. You also have a blatant race condition, because you are writing to a local variable of a Boolean control while the terminal ha most likely already been read. The pump control belongs after the case, eliminating the local.

 

You have some very fundamental misconceptions about data flow, so you really should go back to the tutorials

0 Kudos
Message 6 of 13
(3,422 Views)
Solution
Accepted by topic author LabNoob14

OK, your requirements need better descriptions.

 

You have a control for the pump but you also have a comparison that controls the pump. How are you sorting out the two inputs? There are several possibilities, e.g.:

 

  1. The pump can be operated manually, irrespective of the comparison result?
  2. Whenever the comparison is true, the pumps should come on irrespective of the switch state.
  3. Only if both (the switch is on AND the comparison) is true, the pump should go on?
  4. When should the pump go off again?
  5. etc.

Here's a very simple draft how you would combine the table data and switch the pump whenever the comparison value changes. This is just a very rough sketch to give you some ideas. (sorry, I don't have your driver subVIs). You need to incorporate the manual pump switch after answering the question above. We don't know the solution until you tell us how it should function.

 

pumper.png

 

Some comments to your original code: Wiring from the output of the wait statement and multiplying with [i] makes no sense. That value is random and only has meaning in relation to a similar value taken earlier. The wait takes milliseconds, so multiplying a "sec" value with 100 does not give you ms, just bs. If you want to be able to enter fractional seconds, the control needs to be orange, else make it U32 to avoid the coercion. How long will this be running? Building a table of infinite size might get you into memory problems.

Message 7 of 13
(3,403 Views)

3.Only if both (the switch is on AND the comparison) is true, the pump should go on.

The pump should go OFF when the value from FP AI-110 is less than 0.05 (the value will start somewhere around 20 and gradually reduce over time)

 

Would I still be able to manually switch the pump OFF even if the AI-110 value is greater than 0.05?

 

How long will this be running.  2000, 60 second readings is a number I could use for now, but eventually I want to stop taking readings when a temperature value is met.

 

Thanks, this really helps simplify things. I'm still very unfamiliar with LabView, but a learn a little bit everyday

0 Kudos
Message 8 of 13
(3,342 Views)

@LabNoob14 wrote:

3.Only if both (the switch is on AND the comparison) is true, the pump should go on.

 


You already said the magic word "AND", so simply insert this function into the vertical wire branch right after the comparison and wire the pump switch to the other input of the function and remove the local variable. 😄

 

That's all! See how far you get.

0 Kudos
Message 9 of 13
(3,329 Views)

What kind of array and conversion to the table is that?

Also what are these two things?aliensymbols.PNG

0 Kudos
Message 10 of 13
(3,311 Views)