LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Code debugging with Phidgets

To start, I am using Phidgets as my sensors, which is why some of the VIs may appear missing if you don't have the libraries downloaded.  My code was working fine the other day, but since then I've added a few things, which caused it to stop working properly.  Now, even when I delete the newly added code and go back to when the code was working properly, it won't work.  I'm really not sure what could be going wrong.  It becomes really "laggy" after I click on my start button to get into the "Temp Check" part of my code.  Once it hits the correct temperature and goes into the "Main Program" part of my code, nothing seems to be taking any measurements.  I have noticed though that when I click on the power button to my channel 0 for my solenoids, it seems to advance the readings (the temp changes and the chart plots).  Every time I click the button this happens, but it doesn't repeatedly happen.

 

I know my code is kind of a mess (this is my first time writing code of this size), but I was hoping someone could find something that I may be doing wrong.  

 

I've attached the Program and then also the project.

Download All
0 Kudos
Message 1 of 5
(2,639 Views)

Your temperature check of the code seems to run as fast as the computer allows, and it is constantly opening and closing four different devices, (In addition to the temperature read). Openeing a device needs to be done only once before the main program starts. Then you close at the end, also once.

In the "main program" case, you have to event structures running in parallel. The lower has nothing wired to the timeout, thus it will never timeout and stall the entire inner loop unless a "solenoid power" event is fired constantly.

 

Your code design is way too constipated. Try to run all the UI stuff in a seperate loop instead.

 

You also have serious race conditions where you write to a terminal and read from a local varaible of same in parallel (puller motor, oscillator, etc.). There is no way to tell if you get a current or stale value at the local variable. Use a wire!

0 Kudos
Message 2 of 5
(2,626 Views)

I took out the inside while loop and also one of the event structures (so there is only one now).  I also moved all of the opens/closes to the outside of the state machine so they only open and close once.  I put a wait clock in each state to slow things down a bit too.  I got rid of all the local variables in the same loop by just wiring them together.  

 

I'm not sure what you mean by "all of the UI stuff"?  I still am having trouble with my encoders.  Two things are going wrong.  The first thing is that they aren't indexing properly.  I have it in input 0 and its reading in input 2 for example.  I also can't figure out what I'm doing wrong with my conversions to ft/min.  I'm using the 3530 encoder which outputs 1440 pulses/revolution (360 counts and 1 count=4 pulses).  I think my problem lies in the way I have the feedback.  I want to take the change in each of time and position, but I don't think that is what I'm doing.

 

I've attached the project and program again to show you my changes.

Download All
0 Kudos
Message 3 of 5
(2,568 Views)

I'm not sure if you can see my "Velocity Conversion" so I've attached it in this message.  I also have realized that no matter which port I plug the encoder into, it always only reads in the Chopper output.  All 4 ports read to Chopper and I'm not sure what I can do to change this

0 Kudos
Message 4 of 5
(2,524 Views)

The problem with the encoders is that they all need to be opened individually.  At the moment, you are only opening one and taking all of your readings from that one.

 

Also, you are correct in saying that you're not quite calculating delta t and delta position correctly.  You only need the one subtraction node and the feedback node; ditch the second subtraction.

 

forum_code_encoders.png

-Jim B
Applications Engineer, National Instruments
CLD, CTD
0 Kudos
Message 5 of 5
(2,503 Views)