LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

File overwrite

Hy guys!

I am working on a lap counter hobby projekt. I have two cars, one is controlled by the user (player) what is an input, and one with a myDAQ, this is the output. I also have two digital optical sensors, these are the lap counters. 

Sensor.PNGThe problem what I can't resolve is that if the user laptimer reach earlier the 10 laps, so the player has a better lap time as the myDAQ, then the myDAQ should automatically learn the better laptime (The program should overwrite the file what is already used in the program).input_output.PNG

Could you please help me out?

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

Hi Dombi,

 

why is there an additional wait in the case structures when you already have a wait in the main loop?

Why do you need to add 0?

Why is there a generic IO constant in the false case of the AO case structure?

Why do you initialize and cleanup two of your DAQmx tasks, but two other tasks not?

There is no error handling in your VI…

References should be kept in shift registers…

 

if the user laptimer reach earlier the 10 laps, so the player has a better lap time as the myDAQ, then the myDAQ should automatically learn the better laptime

IF "usertime" < "myDAQ time" THEN use "user time"

Seems like a simple comparison with a Select  node…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(2,254 Views)

Hi GerdW!

Firts of all I am really thankful for your fast answer. 
why is there an additional wait in the case structures when you already have a wait in the main loop?

Because the myDAQ is checking too fast the lines and beause this the counter was too fast so I must use there an additional wait.

 

Why is there a generic IO constant in the false case of the AO case structure?

I can't answer this correctly. I use there a generic IO constant because I didn't know what I should use there, and with that VI the program worked. 
I wanted to use just the TRUE part of that CASE, but if I don't wire something in the FALSE part for the output then the "RUN" button will be broken. Do you know what should I do in these cases?

kerdes.PNG

 

IF "usertime" < "myDAQ time" THEN use "user time"

I know the logic, I understand it. The problem is that I don't know how to build up in LabVIEW and how to wire it.

Could you help me in these problems? 

 

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

@Dombi_Kristóf wrote:

I wanted to use just the TRUE part of that CASE, but if I don't wire something in the FALSE part for the output then the "RUN" button will be broken. Do you know what should I do in these cases?

kerdes.PNG 


Just wire the reference through.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(2,219 Views)

A couple of additional points:

  • The Principle of Data Flow means that the While Loop won't run (again) until everything inside the Loop has run.  This means that which takes the longest time determines the Loop speed.  The minimum loop time is 50 ms.  If either optical sensor "fires", the minimum increases to 300 ms.  And depending on the sampling speed/timing of the Ai/AO functions and any processing relevant to those samples, the minimum time might be even longer.
  • Time is an important concept in LabVIEW, and in DAQ, in general.  Having a loop with uncertain and "variable" time is often a Bad Idea (the exception is when you want to run "as fast as possible", i.e. without any Wait or DAQ functions).
  • Many LabVIEW functions have Error In and Error Out lines.  In addition to the important function of spotting Run Time Errors, they also define the "order" for function execution.  In particular, a function that is not on an Error Line (like the Wait functions) can execute any time in the loop.
  • The I/O line in the AO False Loop that comes in on the left just gets "wired through" and brought out on the right.  This line "defines" the DAQmx Task, and is usually carried in a Shift Register (so that it "has the latest state").
  • You might want to sit down with Pencil and Paper and think "What do I really want to do?".  It occurs to me that you might have two independent Tasks (and maybe more than two ...). 
    • One is to monitor two sensors that record Laps and figure out when one (or both) reach 10 laps.  This is a simple task, one that should have a single timing that defines the timing resolution you need.  I think I know why you have two timings -- you are looking at levels, i.e. T or F, and don't want to measure two Trues in a row (because your pulse is high while you make two successive measurements).  Can you think of a better way to know that this is the first T measurement?  [Hint -- learn about Shift Registers and While Loops].
    • There may be a Task to output something to a Measurement file.  When should this start?  How often should it take place?  For how long?  Why are you doing this?  What is being measured?
    • You may want to do something with these data.  What?  When?  Why?
    • It's especially important to ask how these varying sub-Tasks relate to each other.  Does one depend on the other?  Must they run at the same rate at the same time?  Note that because of the Principle of Data Flow, LabVIEW can easily have two Tasks run at the same time, but independently of each other (this is often called "Parallel Processing").

Bob Schor

Message 5 of 5
(2,218 Views)