LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview control Metal Plating Line

Solved!
Go to solution

Hi,

 

I need help.

 

I am a chemist and I have developed metal plating process. Chrome, Nickel, copper and copper alloy. Just decorative finishing. Everything was ok in the lab and I decided to build simple prototype line. 9pcs 100liters tanks, rails, chain, motor with reductors and etc. Find attached few pics.

 

I have to note that I do all alone: chemical process, design, TIG welding, lathe, electrical wiring. Probably it could be better if I find specialists but I cannot afford it at the moment.

I decided to use labview and Arduino Mega. I draw the program and everything was ok till I switched the power 220V to the relays. The input signals from the proximity sensors started playing. Even without wiring. It would be a problem and I bought USB 6501 (only digital). The problem is the DAQmx is a little bit different than Arduino program.

 

I cannot run the automatic mode. Please find attached the code. I will really appreciate if somebody show me where and what is wrong to my code.

 

0 Kudos
Message 1 of 10
(3,907 Views)

I'm not clear on what you are saying your problems are.

 

You say "input signals from the proximity sensors started playing.  What does that sentence mean?

 

You have some weird constructs in your code.  Comparing a boolean to False is the same thing as using a Not! prmitive.   Likewise feeding a boolean through a select node where you have False on top and True on the bottom.  Again, that is a Not!  Comparing a boolean to True, you should just be using the original boolean wire.

 

Some places, you write a digital output then read it, but don't actually doing anything with the boolean you are reading in.

 

Are you having electrical problems with using 220V?  Are you having programming problems?

 

It looks like you have a state machine going on.  Good.  But you have some while loops buried in the case structure that may never end.  Take for instance the first one in the 1-Tank Case.  You are looking at the Sensor Down indicator.  And after a confusion of effective Not!s, it will either stop the loop or continue the loop.  But the only way that value will change is if the value of Sensor Down changes.  The only way it can change is if the digital input is read differently outside the case structure.  But it can't be read again until your while loop completes.  Catch 22!

 

Don't bury while loops inside of a state machine.  If you need to go back and check on digital inputs, make sure your state machine allows you to go back and check them again.

 

 

 

Message 2 of 10
(3,887 Views)

When I used Arduino I registered input signals but the sensors were not wired. Some noise probably. This uncertainty is not allowed even with prototype.
I use this construction because the input signal is GND (0) and the input line is permanent 5V (1).


No problem with 220V. I tried few times to drive the code manual and the plating line works / move very well. I think my problem is the code especially when I use sequences and local variables. Probably the logic I use is not appropriate.


For example: Tank 1- the motor is running down till the sensor down switch. The while loop will run till the sensor down is off and stop when it is on and go to the next flat seq. This is my problem. It does not work. Such code works with Arduino but with daq it just wait and when I switch the sensor manual nothing happens. No light, no motor, nothing. I thing my logic is wrong but manual works: motor is working, sensor register the postition (light on led) etc. Please find attached picture of tank 1 code.

0 Kudos
Message 3 of 10
(3,878 Views)

Read what I wrote before.

 

You are relying on a local variable.  Not good, but not the problem.  That local variable won't change until you read the digtial output and write the value to the terminal which is happening outside that loop.  It gets read once, and won't be read again until everyhting in the larger while loop finishes (a key principle of data flow).  That outer while loop can't finish until the inner while loop (the one you are stuck in) finishes.  But it can't.

 

Turn on highlight execution and watch the flow.........

 

Then I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 4 of 10
(3,863 Views)

Thank you, RavensFan!

I am following the link (6 hours course). There are things which can be learn only with practice.

If I understand correctly the inner and outer loop wait each other and this waiting will never end.

I have to tell to the first case of the flat seq to run the motor and wait until the vertical rail reach the lower level (sensor down).

Find attached what I did with Arduino. It works. Do I have to do similar now? It is different now with daq.  Do you have link to similar VI? I tried to find but there are many for Arduino and not too much for daq. Or I cannot recognize it.

I know it takes time to learn labview but I have to do all alone. I have to finish the line with successful testing in few weeks. I will really appreciate if you give me a clue or link to similar code. How to wait (local variables) until something is happen without while loop? Or?

0 Kudos
Message 5 of 10
(3,841 Views)

Highlight execution shows the execution stuck into the inner while loop (attached). Because it is local variable it cannot make the connection with “its origin“ before the loop is not finished.

 

What approach is appropriate for such case?  

 

P.S. I apologies if I do not use the right words. I hope you understand my English.

0 Kudos
Message 6 of 10
(3,835 Views)
Solution
Accepted by Bozhidar4o

You will be better off using the code where you have the writes and reads of the device within the loop like you show in the Arduino Program.jpg  (I can't tell if you have things wired up correctly.  I think you have wires running backwards because it looks like the Arduino Read has no output, but it might be running backwards out the left side of the subVI.)

 

You have two things you could do to improve the code.

 

1.  Anything that involves reading from your hardware, put it in a separate while loop that runs in parallel to any other loop.  Since it seems like you would only care about the most recent value read, then using local variables to get that data won't be so bad.

2.  Redesign your state machine to get rid of any while loops buried within the while loops.  Don't have 3 major states where within each state there are multiple loops and multiple activities taking place.  Break those master states down into smaller states and have you state machine proceed through each smaller state in turn.  You want each state to take place quickly.  Then you can check hardware within the state, or before the case structure  of the loop.  If you find you haven't reach the condition to change state, then you repeat that state.  (Where it will check the hardware again and do another decision.)  If you've reached the condition to move on, then you put the new next state into the shift register and run that the next loop iteration.

Message 7 of 10
(3,805 Views)

I followed your advice and broke those master states to smaller states and removed all flat sequences. I think I have breakthrough. Thank you for your help. I will try to optimize the code these days and post the results.

Message 8 of 10
(3,791 Views)

Link to the progress: https://www.youtube.com/watch?v=mK_YscX53Dg

I had a lot of problems with unexpected errors which were caused by electric field of close mounted old sparky relays. Fixed.

The code is still not optimized but it works. I use while loops as time counter but it will be changed. The program wait to finish the loop and there is no other action until it is done.

0 Kudos
Message 9 of 10
(3,623 Views)

Very cool.  Thanks for sharing the video.  I think that is part of the fun in using LabVIEW when you go from starting out to making it do things for you in the real world.

0 Kudos
Message 10 of 10
(3,597 Views)