From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Solenoid Control on a Cycle

Solved!
Go to solution

Hi everyone,

 

Don't worry I searched and read all the similar questions but haven't figured out my issue yet. I'm brand new to Labview and have been tasked to create a system that will control a single solenoid connected to a piston that will run on a cycle for (x) cycles. I have no clue what to do and was hoping for some help, I understand C++ so i'm not completely lost here. Here is a list of what I have and I have been told I can buy anything else I need too.

 

-cDAQ 9171

-cDAQ 9174 Cradle

-NI 9234 Card

-24V Single Solenoid (5 port/2 way) spring return

All types of wires to connect

 

I was hoping to create a system where I could enter time on and time off, a cycle count and a cycle end number all on the front panel along with a start and stop button. I also understand the output from the card would only be 5v so I will use a relay to jump the voltage to 24v.

 

In my head this should be a simple program I just have no idea what to do in Labview. If someone could write a code close to what I need I might be able to tweak it and make it work. If not some pointer in the right direction would help.

 

Thanks in advance!

 

0 Kudos
Message 1 of 4
(3,049 Views)

Hi Asissle.  Welcome to LabVIEW!

 

What you are describing sounds like a nice beginner project, so I expect with a little bit of study you should be able to handle it.  I don't think anyone here will write it for you, but we are happy to help when you get stuck.

 

I would start by outlining (flowchart if you want, text is fine too) what you want to happen when.  For example:

  1. program start
    1. initialize connection to cDAQ
    2. put solenoid to known condition
    3. initialize user entry fields
  2. wait for user input
    1. validate user time and cycle count entries
    2. if user presses start, proceed to running cycle
  3. running cycle
    1. while cycle count < end count and user hasn't pressed stop
      1. open (close) solenoid for x time
      2. close (open) solenoid for y time
    2. put solenoid to proper end state

etc.  Once you have planned out what you want to have happen, you can start building it.

 

I think you can probably build your entire application with just a handful of your own .VIs.  Your main application can be just a while loop with a typedef enum controlling a case statement (sorry for the jargon, but these names are what you should search on).  Cases might be Initialize, Run GUI, shutdown.  Within Run GUI might be another case statement with Validate, Run test, stop test, etc. cases.  You didn't mention what version of LV you are using; if you post that I can show you.

 

Where I might start would be a .VI to control the solenoid.  Look for Action Engine in the forums, Ben Rayner has a nice post describing them.  Your control .VI could be a while loop containing a case statement where the statements are Init, open, close, shutdown.  Starting here gives you something small and immediate to start with that will be useful.

 

Check out the online tutorials, there are lots of good tutorials available.  If you are curious about a slightly more sophisticated implementation, look for the Producer/Consumer pattern.  I think it might be a very good fit for your overall application, but it is more involved that what your initial request proposes.

 

Hope that helps get you started, please post back with further questions.

 

Matt

 

Message 2 of 4
(3,006 Views)

Watched a lot of tutorial videos on Youtube that hepled a lot! It turns out that LabVIEW isn't as intimidating as I originally thought. Made a lot of progress thanks to you as well. The only issue I have come across is that it looks like I can't generate an analog output voltage with the card I have been given so that will have to be my next task to figure out before I can start testing my program. If it is possible to generate an analog output voltage with the card I have please let me know! 

 

Running Labview 2014

Card NI 9234

 

Thanks for the help again!

0 Kudos
Message 3 of 4
(2,974 Views)
Solution
Accepted by topic author Asissle

I think that is correct, you can't generate an output voltage with the hardware you listed.

 

I created a project from the State Machine sample included with LV 2014 and added a solenoid control .VI.  Not complete by any means, and I can't test it, but it should give you a good start.  The sample includes a lot of comments about what is going on.  Hope it helps.

 

Matt

Message 4 of 4
(2,964 Views)