LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help to optimize my code and reduce 50% processing on my core i7

This is my first time working with labview and I am trying to learn more. I have read free online guides etc and came up with my setup.  

 

Goal:

If I have a square signal coming then 1 square or beginning of the square will equal one change. I need to record change/revolution of a wheel hence the coding seems like that.

 

Problem:

I can see the change but I have few problems with my code:

 

  • If i stop the code then the revolution does not disappear but keeps on counting from there on (If I press run again). I want it to reset.
  • It does not record data after every 30 mins to a file. I have tried with one of the channel but it ends up saving as one file without having the "time stamp" which I did choose from the advance section. I just need it to record revolution every 30 mins to a file. 
  • My coding is apparently not optimized hence 56% of my processing power is used of my core i7 which is alot. I need to know what part of it is causing this problem. I can guess that I have the same loop for each channel hence its more demanding but I will appreciate if someone can optimize it further or give me a clue to what I should do.
  • Once I made the exe file out of it. The button to turn on/off did not work anymore while it worked fine during the labview program.
I am looking forward to hearing from you. I will like to thank you in advance for reading this and helping me out. 
Future plan:
  • I am going to try to stop it when a certain amount of revolutions has been reached. I will try that in the future though. If you can give me some advice on that, it would be appreciated. 

 

0 Kudos
Message 1 of 6
(2,447 Views)

Instead of umpteen different loops and DAQ Assistants, use one loop and one DAQ Assistant that reads all of the channels.

 

That program does not save anything since you do not have anything wired to the 'Signals' input. Even if you did, there is no timestamp information in the data being read from the DAQ Assistant. It's just a Boolean array as you can see. I have no idea how the Write to Measurement File handles an input of Booleans but you will have to use one of the functions on the timing palette to get current time and include that with the Boolean.

 

You do not initialize your shift registers so they maintain the last data when the VI is run again.

Message 2 of 6
(2,428 Views)

A few more comments:

 

 

  • I don't have DAQ installed, so I cannot look at your DAQ express VIs. How much data do they read with each iteration?
  • What determines the loop rates of the loops? Do they need to run this fast?
  • Why do you index out the first elements twice to get the same value twice? Once is enough.
  • All you ever look at in the array inside the shift register is the first element. Why not simply only keep the first element in the shift register as a scalar? Now you would only need one "index array" instead of four.
  • As Dennis said, one loop is enough. Right now you need to press 24 buttons to stop the VI.
  • Once a loop stops, it cannot be restarted. Think "state machine" instead.
  • Don't confuse the operator. Your switches are green in one state and have a green LED in the other state. Make it more intuitive!
  • initialize your shift registers
  • You are counting, thus the numeric should be an integer (blue).
  • Instead of piles of similar controls and indicators, use arrays.
  • ...
  • ...

 

0 Kudos
Message 3 of 6
(2,418 Views)

 


@Taz labview wrote:

 

  • My coding is apparently not optimized hence 56% of my processing power is used of my core i7 which is alot. I need to know what part of it is causing this problem. I can guess that I have the same loop for each channel hence its more demanding but I will appreciate if someone can optimize it further or give me a clue to what I should do.

Since the I7 is most likely a quad core processor, it means you are saturating two cores. This also means that the loop rate is CPU limited. That's never a good idea!

 

0 Kudos
Message 4 of 6
(2,404 Views)

Thanks. Now I know how to initialize the shift register. 

0 Kudos
Message 5 of 6
(2,363 Views)

 


  • @altenbach wrote:

    A few more comments:

     

     

    • I don't have DAQ installed, so I cannot look at your DAQ express VIs. How much data do they read with each iteration?
    • What determines the loop rates of the loops? Do they need to run this fast?
    • Why do you index out the first elements twice to get the same value twice? Once is enough.
    • All you ever look at in the array inside the shift register is the first element. Why not simply only keep the first element in the shift register as a scalar? Now you would only need one "index array" instead of four.
    • As Dennis said, one loop is enough. Right now you need to press 24 buttons to stop the VI.
    • Once a loop stops, it cannot be restarted. Think "state machine" instead.
    • Don't confuse the operator. Your switches are green in one state and have a green LED in the other state. Make it more intuitive!
    • initialize your shift registers
    • You are counting, thus the numeric should be an integer (blue).
    • Instead of piles of similar controls and indicators, use arrays.
    • ...
    • ...

     



  • 1 sample on Demand
  • As you have said that it depends on the 2 cores being saturated. I do not know how to determine the loop rate. I will be glad if you can tell me what to look for here.
  • Indexing twice is true. I will take that away.
  • I know that one loop is probably enough but how to do that is the problem. I have 16 signals which are generated by mice running on a wheel. I want to see the revolution for each wheel and want to stop recording revolution for some wheels when pressing the button. I will also try to put in later to stop after reaching certain amount of revolution. (Any idea how I can do that? Should I change to another type of loop)
  • How do I make it so it stops and starts?
  • It was the opposite here that when the operator small light was green that meant it isnt on while blank meant on. I did not know how to switch small light hence I changed the color of the whole button.
  • I know the colors represents different thing in labview but does it really matter if its blue or orange? I mean it still works. 
  • Each control is for different cage where you can turn it off or on and we need to know how many revolutions each mice has made. Unless you meant I can do this in another way then please show me a simple code. 

 

0 Kudos
Message 6 of 6
(2,354 Views)