Go to Post (i would watch out for those jag's if i were you) - Scott Bahl [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-03-2015, 15:35
bacarpenter bacarpenter is offline
Lead programmer (2 years)
AKA: Baylee Carpenter
FRC #2197 (Las Pumas)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Indiana
Posts: 19
bacarpenter is an unknown quantity at this point
Exclamation Need help with logic

I'm trying to make a program that will make three motors turn until the lifts they are controlling hit the limit switch we have at the bottom of the lifts. I need the lifts to go in order from the lowest to the highest lift (we have encoders) As of currently I've been putting logic into periodic tasks but I can't seem to get it to work. Anyone have any ideas?
I posted the code that I'm currently using, this is a vi I made that is inside of periodic tasks
Attached Thumbnails
Click image for larger version

Name:	Program.png
Views:	76
Size:	180.3 KB
ID:	18581  

Last edited by bacarpenter : 09-03-2015 at 15:48.
Reply With Quote
  #2   Spotlight this post!  
Unread 09-03-2015, 15:55
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Need help with logic

A loop does not produce an output until it ends. Your VI will execute until the limit switch is activated, then end and output a value of zero.

I don't understand the description of what you want to do. Can you give some more detail, and maybe include a picture or diagram of what you're controlling?
Reply With Quote
  #3   Spotlight this post!  
Unread 09-03-2015, 16:31
bacarpenter bacarpenter is offline
Lead programmer (2 years)
AKA: Baylee Carpenter
FRC #2197 (Las Pumas)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Indiana
Posts: 19
bacarpenter is an unknown quantity at this point
Re: Need help with logic

Quote:
Originally Posted by Alan Anderson View Post
A loop does not produce an output until it ends. Your VI will execute until the limit switch is activated, then end and output a value of zero.

I don't understand the description of what you want to do. Can you give some more detail, and maybe include a picture or diagram of what you're controlling?
We have three lifts with an attachment connected to them to pick up crates and there are limit switches at the bottom of the lift so I'm trying to make logic that when a button is pressed on the joystick the corresponding lift will go down till it hits the switch
Attached Thumbnails
Click image for larger version

Name:	image.jpg
Views:	42
Size:	1.23 MB
ID:	18582  
Reply With Quote
  #4   Spotlight this post!  
Unread 09-03-2015, 17:12
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Need help with logic

I'm not quite sure what the picture is supposed to show me, but I'll take a guess. Is each lift a lead screw driven by a belt from a motor?

Are all three lifts independent, or do they need to coordinate with each other somehow? I will assume that each lift works on its own.

Once the button is pressed, do you want the lift motor to continue running until the limit switch is activated, or do you want the motor to stop when the button is released? I will assume that you want the button to start the motor, and only the limit switch will stop it. (That's dangerous, but it sounds like what you asked for.)

The simple way to do it is to use a flat sequence inside a neverending while loop in Periodic Tasks. The first frame of the sequence waits for the joystick button to be pressed. The second frame sets the motor to run the lift downward. The third frame waits for the limit switch to be activated. The fourth frame stops the motor. If that's not enough of a hint, ask for more help about what you don't understand.

There should also be a failsafe in the part that waits for the limit switch. I suggest an "abort" button on the joystick that stops the lift motor on command, and also a timer that stops it if too much time has elapsed. You could also stop driving the motor if the encoder indicates that the lift has moved too far, or if it has stopped.
Reply With Quote
  #5   Spotlight this post!  
Unread 09-03-2015, 18:04
bacarpenter bacarpenter is offline
Lead programmer (2 years)
AKA: Baylee Carpenter
FRC #2197 (Las Pumas)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Indiana
Posts: 19
bacarpenter is an unknown quantity at this point
Re: Need help with logic

All your assumptions are correct. The only problem is that I've never used flat sequences outside of auto so how exactly does one flat sequence?
Reply With Quote
  #6   Spotlight this post!  
Unread 09-03-2015, 18:20
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Need help with logic

Just put the flat sequence inside a while loop in Periodic Tasks. Right-click on the edge and add frames as needed.

Each of the "wait until" steps should be implemented as a while loop inside one of the frames. Put the code to read a joystick button or limit switch inside the loop, with the logic set up to stop the loop when the desired condition occurs. Also add a 5-20 millisecond Wait inside the loop, to keep it from running as fast as possible and starving other tasks of CPU time.
Reply With Quote
  #7   Spotlight this post!  
Unread 09-03-2015, 18:23
bacarpenter bacarpenter is offline
Lead programmer (2 years)
AKA: Baylee Carpenter
FRC #2197 (Las Pumas)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Indiana
Posts: 19
bacarpenter is an unknown quantity at this point
Smile Re: Need help with logic

That's really simple thanks!
Reply With Quote
  #8   Spotlight this post!  
Unread 10-03-2015, 15:38
bacarpenter bacarpenter is offline
Lead programmer (2 years)
AKA: Baylee Carpenter
FRC #2197 (Las Pumas)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Indiana
Posts: 19
bacarpenter is an unknown quantity at this point
Exclamation Re: Need help with logic

Quote:
Originally Posted by Alan Anderson View Post
Just put the flat sequence inside a while loop in Periodic Tasks. Right-click on the edge and add frames as needed.

Each of the "wait until" steps should be implemented as a while loop inside one of the frames. Put the code to read a joystick button or limit switch inside the loop, with the logic set up to stop the loop when the desired condition occurs. Also add a 5-20 millisecond Wait inside the loop, to keep it from running as fast as possible and starving other tasks of CPU time.
I tried to do what you said but the while loop inside of the flat sequence runs and the outside loops isn't executed. I posted a picture of what I currently have
Attached Thumbnails
Click image for larger version

Name:	Program.png
Views:	31
Size:	22.8 KB
ID:	18590  
Reply With Quote
  #9   Spotlight this post!  
Unread 10-03-2015, 16:25
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Need help with logic

Quote:
Originally Posted by bacarpenter View Post
I tried to do what you said but the while loop inside of the flat sequence runs and the outside loops isn't executed. I posted a picture of what I currently have
With that code, you're essentially taking a snapshot of the joystick button and the limit switch before the flat sequence begins, and not reading them again until it has ended.

You need to put the Joystick Get and the Switch Get Value functions inside their respective loops, so that you're repeatedly reading their current value.

Last edited by Alan Anderson : 10-03-2015 at 16:30.
Reply With Quote
  #10   Spotlight this post!  
Unread 10-03-2015, 18:04
bacarpenter bacarpenter is offline
Lead programmer (2 years)
AKA: Baylee Carpenter
FRC #2197 (Las Pumas)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Indiana
Posts: 19
bacarpenter is an unknown quantity at this point
Re: Need help with logic

Quote:
Originally Posted by Alan Anderson View Post
With that code, you're essentially taking a snapshot of the joystick button and the limit switch before the flat sequence begins, and not reading them again until it has ended.

You need to put the Joystick Get and the Switch Get Value functions inside their respective loops, so that you're repeatedly reading their current value.
Okay so I put it inside of the while loop and it works but it'll only work once.
Attached Thumbnails
Click image for larger version

Name:	Program.png
Views:	29
Size:	209.1 KB
ID:	18592  
Reply With Quote
  #11   Spotlight this post!  
Unread 10-03-2015, 18:21
Kevin Phan's Avatar
Kevin Phan Kevin Phan is offline
College Student
FRC #0357 (Royal Assault)
Team Role: Alumni
 
Join Date: Apr 2013
Rookie Year: 2010
Location: PA, United States
Posts: 95
Kevin Phan will become famous soon enoughKevin Phan will become famous soon enough
Re: Need help with logic

I would suggest combining the first frames of your program, just to clean it up. It doesn't change any thing, but makes it neater. By once, do you mean it runs until it hits the limit switch?
__________________
VEX & FRC Student Team Member #357 Royal Assault 2010-2014 "Dare Mighty Things"
2014-2019 Attending Drexel University Major:Electrical Enginnering
Reply With Quote
  #12   Spotlight this post!  
Unread 10-03-2015, 19:27
bacarpenter bacarpenter is offline
Lead programmer (2 years)
AKA: Baylee Carpenter
FRC #2197 (Las Pumas)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Indiana
Posts: 19
bacarpenter is an unknown quantity at this point
Re: Need help with logic

Quote:
Originally Posted by Kevin Phan View Post
I would suggest combining the first frames of your program, just to clean it up. It doesn't change any thing, but makes it neater. By once, do you mean it runs until it hits the limit switch?
It runs once it'll stop when the limit switch is pressed but if you press the button again it won't work it says its not executed
Reply With Quote
  #13   Spotlight this post!  
Unread 10-03-2015, 19:40
Kevin Phan's Avatar
Kevin Phan Kevin Phan is offline
College Student
FRC #0357 (Royal Assault)
Team Role: Alumni
 
Join Date: Apr 2013
Rookie Year: 2010
Location: PA, United States
Posts: 95
Kevin Phan will become famous soon enoughKevin Phan will become famous soon enough
Re: Need help with logic

Well since the limit switch is pressed, the loop will continue seeing true. What you need to do is to create a case structure that checks the button being pressed and when the limit is pressed. I suggest creating a truth table as you have 2 Boolean elements. There is a Boolean array to number express vi that will change the default case structure into a numeric structure. I have an examination to how to do this in a guide I made. Here's the link to it. This guide does not cover any new vis or changes made to LabVIEW for this season. LabVIEW's mechanics have not changed significantly and the examples shown will work. If you want to pursue this path, be attentive to the changes you made. Be aware of the states of your sensors before, during and after the action your robot will make after the button is pressed.
__________________
VEX & FRC Student Team Member #357 Royal Assault 2010-2014 "Dare Mighty Things"
2014-2019 Attending Drexel University Major:Electrical Enginnering
Reply With Quote
  #14   Spotlight this post!  
Unread 10-03-2015, 22:52
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Need help with logic

Quote:
Originally Posted by bacarpenter View Post
Okay so I put it inside of the while loop and it works but it'll only work once.
In order for the outer While to run again, everything inside it has to complete. You have three Flat Sequences there, each waiting for a joystick button and then a limit switch before they will finish. By putting all of those sequences in the same While, you have made it necessary to run all three of the lifts to the bottom before you can run any of them to the bottom again.

If your lifts are truly independent, put the code for each of them in its own While loop.
Reply With Quote
  #15   Spotlight this post!  
Unread 11-03-2015, 11:44
bacarpenter bacarpenter is offline
Lead programmer (2 years)
AKA: Baylee Carpenter
FRC #2197 (Las Pumas)
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Indiana
Posts: 19
bacarpenter is an unknown quantity at this point
Talking Re: Need help with logic

Thanks for the help! I got it to work after putting the flat sequence inside of a case structure that executes whenever the button is pressed
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:29.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi