01-24-2012 12:16 PM
Hi John,
I think I can help with that, too! Do you know about the online LabVIEW introduction courses?
There's a 3 hour course and a 6 hour course. They're really great for people who are getting started with LabVIEW. Have a look!
You're doing well already, but I think the courses will just speed things along that much more.
And, of course, we on the forum are always here too!
Diane
01-25-2012 07:31 AM
Hi DianeS
Thanks for the information. I will definitely look into it. I also have set up a meeting with a local rep here in relation to the Core 1 course. I think between both I should get a better understanding.
Can i ask one more question/favour from you. I have attached the complete VI which i am using to drive a stepper motor.
The top Digital output is used to create a pulse with the pulse timings dictated by the Time delay just below this. The Digital inoput is connected to a limit switch. This VI will work on its own
The bottom section is the section whihc you helped us with and will output a signal for a specific period after recieving the input signal. This also works on its own.
I can also open up two VI's and it will work although the bottom section will not stop the first VI which is obvious as it is not connected but acting independently.
What I would like is for the top section to stay running as I enter the true/false structure and jump out/stop as I finish the true case structure.
Any help appreciated 🙂
01-25-2012 01:20 PM
Hi John,
Let me see if I have interpreted your question correctly:
You want the stepper motor pulse section to continue to run during the time your other signal is high. In other words, you want your stepper motor pulse operations to run continuously, regardless of what the other part is doing.
Is that right?
If so, you will need to put them in separate loops. A loop cannot finish its current iteration until everything inside it has finished executing.
Have a look at the attached. Run it and see if it works the way you want. I encourage you to look at the LabVIEW help files for any functions you don't understand.
If this application is ever going to grow, you will need to rethink your architecture.
Taking the Core classes will help you a lot. I would definitely encourage it!
Hope some of this helps!
Diane
01-26-2012 05:58 AM
Hi Diane
THANK you very much for everything you have done we really appreciate it. We are using LV 8.5 so when we got your program converted to this version type it gave an error. We decided to make your LV program up exaclty as you had it using our 8,5 LV which gave no errors, so maybe something in the conversion resulted in an error.
As for the program this behaved exceptionally well however is it possible for the stepper motor pulse to stop (or maybe even the program to stop) after the bottom loop completes it cycle of x number of seconds. The idea behind this is that when the limit switch is flicked the stepper motor reverses for x secs then turns off/ stops which is what we want, else the motor would stay in the loop (going back and forth) between the limit switch and the distance of x sec's which we dont want.
We have tried a number of things but with no luck.
Thanks
John
01-26-2012 01:18 PM
Hi John,
Well, you came pretty close to duplicating my code, anyway...why all the extra "merge error" functions after the loops stop? And what did I tell you about straightening out your wires? It's important. My head aches when I look at your code. Minimizing wire bends and having everything in straight lines makes the block diagram a lot more readable. Every time I modify your code, I have to spend several minutes going through and straightening everything, out, removing empty space so that the block diagram fits on the screen without having to scroll, etc.
The block diagram shouldn't exceed the screen size...or, at worst, you should only have to scroll in one direction. You're probably going, "ok, ok, quit harping on this and solve my problem", but it really does matter, especially when someone else is trying to read your code.
Merely a small scolding.
Ok. On to the code.
To be honest, I cannot tell from your description exactly what you want your "stop" condition to be.
Here is what I think you want:
1. Start both operations. Both loops running.
2. Input signal in bottom loop goes T. Top loop continues to run.
3. After x seconds, input signal in bottom loop goes F. Both loops stop (or top loop essentially goes idle).
3a. Input signal in top loop goes T. Both loops stop.
3b. "Stop" button pressed. Both loops stop.
3c. Error occurs in either loop. Both loops stop.
Have I interpreted this correctly? If the top loop goes idle, what starts it running again? A button press? An input signal? Does the bottom loop ever go idle?
You should really start thinking about converting this to a state machine. It will tidy up the code and allow for much greater flexibility for future modifications. Search the forum for "state machine". You will get a LOT of hits. Look up event structures, too.
In fact, I think it would be good for you to sit down and write out precisely what you want this program to do, step by step (like I did in my first response). I feel like the specifications keep changing, which makes it very difficult to steer you in the proper direction. You want to wind up with a good, maintainable program. To get there with a minimum of fuss, you need to start by outlining everything you want it to do.
01-27-2012 04:41 AM
Hi Diane
Sorry for the layout, no excuses from my side as its not fair on somebody else to have to go thru that. Also as i look at it now i myself am confused where as yesterday i understood it. SO i take your point about making things clear.
Here is what i want to do
1 User turns on device, motor rotates in cw direction *****complete****
2 Motor continues until it hits the limit switch (port in top loop), then stops *****Complete****
3 User flicks manual direction switch to make motor go in ccw motion. turns on app ****Complete***
4 Motor contiues in ccw motion until it hits the upper limit switch ***Complete***
5 When limit switch is pressed motor rotates in cw direction for x secs ****Complete*****
6 After x seconds the Program stops
After this the op can flick the manual direction switch to the cw direction agin turn on the app and do the whole Process again.
The overall goal about this project is for us to check stepper motors (torque, current etc) and to see how the new design will affect them.
This will be used for a batch of 20-30 various stepper motors approx
Thanks for the feedback (neg or positive is much appreciated) as its hard to learn the correct way to program when i am the only one in the company who is willing to learn labview.
I have attached the tidied up version of the code.
Regards
John
01-27-2012 11:39 AM
01-30-2012 09:29 AM
Hey Diane
Finally i got that Vi finished and doing what we wanted. Tens of hrs for 3/4 extra icons :smileyfrustrated I am sure it is not written correctly (if that is what you can say about labview "written" ) but it works. Anyways i want to thanks you for everything you have done for me over the last few days, you really helped a newbie get a better understanding of labview.
I have attached the vi for your information.
Thanks for everything
Regards
John
01-30-2012 12:51 PM
Hi John,
There are other, more flexible ways you can do things, but if this is working for you, go with it. It might be kind of a pain if you ever want to expand it, but you can always start another thread for that.
Your use of a local variable is fine in this case since you only have one place where you write to it (I'm not sure why you write to a local and then read from the terminal instead of writing to the terminal and reading from the local, but that's really neither here nor there), but I would encourage you to use locals sparingly and with caution. Search "race conditions" on this forum to find out why I say that.
If you are serious about wanting to really learn LabVIEW, then do spend some time going through the introduction courses I directed you to earlier in this thread, and look at different architectures like state machines, producer/consumer, etc. I think you have good potential so I'd like to see you getting into good programming habits early! That, and you'll wind up with much better code.
You've done a good job and I'm glad I was able to help.
Diane