LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I keep getting error 1 when trying to write data to file? How do I solve this? I have attached my code.

Please bear with my code. I have attached my code and subVIs. Code called "Main Code" is my main code, the rest are just subvis that belong to the main code. 

Read instructions on the front panel to be able to run the code. 

I just can't see what I am doing wrong. Can someone please help?

Note: To avoid broken VI, put all the code in one folder. 

 

Thanks for your help!

 

INSTRUCTIONS how my code works

 

1. Create a file you would like to save the data.
2. Pick a time to start data logging
3. Create how often you want to create new file (every 2, 3, 4, etc.. minutes, sec, hour)
4. Click start test to start the program

 

0 Kudos
Message 1 of 8
(1,341 Views)
  • It would be better to zip you pile of files up instead of attach each individually.
  • Your shift register is initialized with a control (should be a diagram constant!) that has state=end by default, so the loop will end after one iteration, no matter what the other controls are. The log state is never encountered.
  • Please clean up your front panels (reasonable fonts, logical arrangements of controls, not maximized to the screen, etc.)
  • Please clean up your code and avoid all these overlapping wires and structures.
  • I would strongly recommend to avoid these gigantic convoluted, non-scalable data structures. This entire thing could probably be done with 20% of the current code.
  • If you want to append to the current existing file, the mode should be "open or create".
  • ...
0 Kudos
Message 2 of 8
(1,324 Views)

I'm not sure I understood your code, however I notice that after writing to the file you close it, so Log Ref becomes invalid. Maybe you are trying to use this reference for another write.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 3 of 8
(1,299 Views)

Yes, I saw that too but I assumed that the "build acq array" will execute again before the next write. It is too tedious to figure out the entire state diagram, but it seems that he is actually trying to reuse the closed reference. Still, that's only the tip of the iceberg!

Message 4 of 8
(1,296 Views)

@pinkpanther and Mr. Altenbach, 

Yes, I think that may be the reason I'm getting error 1, trying to reuse the close reference.

I created a code, playing with it, trying to generate code 1 on purpose. The only time, I would generate error code 1 is if my code looks like this below.

GRCK5000_0-1677177086634.png

 

 

0 Kudos
Message 5 of 8
(1,279 Views)

@GRCK5000 wrote:

The only time, I would generate error code 1 is if my code looks like this below.


I can probably come up with dozens of other code alternatives to generate the same error code. 😄

0 Kudos
Message 6 of 8
(1,260 Views)

Haha.. sometimes LabVIEW can be complicated. one error can be caused by multiple things.😩 I think I found the solution for this problem, but I have a different question. I'll make a post for it. 

0 Kudos
Message 7 of 8
(1,245 Views)

@GRCK5000 wrote:

Haha.. sometimes LabVIEW can be complicated. one error can be caused by multiple things.😩 I think I found the solution for this problem, but I have a different question. I'll make a post for it. 


I really think you are digging yourself into a deeper and deeper hole with that completely misguided and not scalable overall architecture, applying band-aid solutions. I recommend to start from scratch.

0 Kudos
Message 8 of 8
(1,237 Views)