Go to Post Looks very well designed. Now where is the "export to reality" button in the CAD software? (I have been looking for it for weeks). - sanddrag [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 16-01-2014, 22:35
joecloud joecloud is offline
Registered User
FRC #2805
Team Role: Programmer
 
Join Date: Apr 2013
Rookie Year: 2013
Location: Texas
Posts: 22
joecloud is an unknown quantity at this point
Teleop move motor forward and backwards timed

My goal is that when button 7 is pressed, that the motor will move forward at full speed for 1 second, then stop. wait .5 seconds, then move in reverse at half speed for 1.5 seconds. I just wanted to get some feedback on the code and what I could do to make it less cluttered, and possibly more effective (I haven't had a chance to upload it to the bot yet, I will Saturday. )

Click image for larger version

Name:	teleop.PNG
Views:	67
Size:	20.5 KB
ID:	15851

Button 7 is supposed to toggle on/off and start the sequence structure, am I doing it right?
Thanks!

Also, build team mentioned that they're going to throw another motor on the gearbox that this motor is currently on, so 2 motors will be working together for more power!
I was wondering what would be the best way to add a second motor to the sequence? Should I set up an 'Open2Motor' so that they only need one block? Or should I just add the 2nd motor to the case structure (Have separate motor get for the 2 motors)?

Thanks a ton,
__________________
--
Joe,
Programming: Team #2805

Last edited by joecloud : 16-01-2014 at 22:50.
Reply With Quote
  #2   Spotlight this post!  
Unread 16-01-2014, 22:55
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Teleop move motor forward and backwards timed

The sequence looks okay, but has a few problems.

The Joystick button will never change, because the Get is outside the While loop. You'll keep using the value of the button at the time the loop first started.
Just add another Joystick Get inside the While loop.

The cimtest RefNum Get would be better outside the While loop and wired in to Motor Set Output. The RefNum is something that doesn't change, so you don't have to keep retrieving it everytime.

I'd increase the Timer to 20ms, because that's as fast as the button can possibly change.

The button 7 check looks good, but since the wires are on top of one another it's hard to be positive.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 16-01-2014 at 22:58.
Reply With Quote
  #3   Spotlight this post!  
Unread 16-01-2014, 23:06
Cecil's Avatar
Cecil Cecil is offline
Registered User
AKA: Alex Hummel
FRC #2010 (Lightning Bots)
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2006
Location: Champion
Posts: 343
Cecil is a splendid one to beholdCecil is a splendid one to beholdCecil is a splendid one to beholdCecil is a splendid one to beholdCecil is a splendid one to beholdCecil is a splendid one to beholdCecil is a splendid one to behold
Re: Teleop move motor forward and backwards timed

Wouldn't having a while loop in Teleop slow the entire Teleop loop down to the point it would start cutting out? I thought that all loops had to go in Periodic Tasks to run correctly.

Other than the other things that Mark pointed out, it looks good to me.
__________________
I'm right 90% of the time, so why worry about the other 3%?
Reply With Quote
  #4   Spotlight this post!  
Unread 16-01-2014, 23:15
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Teleop move motor forward and backwards timed

That's true.
Everything looks good if you drop that as is (with corrections) into the Periodic Tasks.vi
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #5   Spotlight this post!  
Unread 17-01-2014, 08:22
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Teleop move motor forward and backwards timed

I think you'll also discover that you will want a fourth step, to stop the motor after the 1.5 seconds. And as Mark said, if you take the motor reference out of each sequence and wire it across, the code will be smaller and cleaner.

By the way, putting this into teleop wouldn't simply slow it down. If you place an infinite loop into a function, the function becomes, ... , ...? Yep, it becomes infinite as well. So by placing an infinite loop in teleop, you would only call telop once and your teleop portion of your program would pretty much lock up waiting for the loop to finish.

Greg McKaskle
Reply With Quote
  #6   Spotlight this post!  
Unread 17-01-2014, 13:44
joecloud joecloud is offline
Registered User
FRC #2805
Team Role: Programmer
 
Join Date: Apr 2013
Rookie Year: 2013
Location: Texas
Posts: 22
joecloud is an unknown quantity at this point
Re: Teleop move motor forward and backwards timed

Alright thank you all for all the help. Making the edits right now. Just wanted to confirm one thing, since we are adding a second motor should i set up an open 2 motor for the 2 motors instead of adding another single motor get to the loop? The second motor is supposed to function just like cimtest.

Thanks again,
__________________
--
Joe,
Programming: Team #2805
Reply With Quote
  #7   Spotlight this post!  
Unread 17-01-2014, 14:29
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,579
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Teleop move motor forward and backwards timed

Quote:
Originally Posted by joecloud View Post
Alright thank you all for all the help. Making the edits right now. Just wanted to confirm one thing, since we are adding a second motor should i set up an open 2 motor for the 2 motors instead of adding another single motor get to the loop? The second motor is supposed to function just like cimtest.
Open 2 motors is part of the robot drive palette for controlling drivetrains, where both sides of the drivetrain get different commands. It isn't appropriate for use for two motors that need the exact same command. Just open a second motor and send it the same command.
Reply With Quote
  #8   Spotlight this post!  
Unread 17-01-2014, 14:30
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Teleop move motor forward and backwards timed

I believe your choices are to open a second motor and set it to the same values in each sequence, or you can send out one signal and duplicate it using a Y cable.

Greg McKaskle
Reply With Quote
  #9   Spotlight this post!  
Unread 17-01-2014, 16:53
joecloud joecloud is offline
Registered User
FRC #2805
Team Role: Programmer
 
Join Date: Apr 2013
Rookie Year: 2013
Location: Texas
Posts: 22
joecloud is an unknown quantity at this point
Re: Teleop move motor forward and backwards timed

I'll look into the Y-cable, we may or may not already have one.
Here is the code after the suggested modifications.
If I understand this correctly, because the code was originally in teleop it would have kept auto repeating whatever was in the loop forever?

Click image for larger version

Name:	periodictasks.PNG
Views:	27
Size:	74.6 KB
ID:	15855

This is the updated code in Periodic tasks, are there any global variables etc.. of the sort that I need to setup for it to function right? Or does periodic tasks work seamlessly in teleop mode (haven't done much periodic tasks code)


Thanks,
__________________
--
Joe,
Programming: Team #2805
Reply With Quote
  #10   Spotlight this post!  
Unread 17-01-2014, 18:18
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Teleop move motor forward and backwards timed

Looks good.
The last 500 ms Timer isn't necessary. There's nothing to wait for by that point. It'll just prevent the button from working again right away.

Periodic Tasks runs all the time. While Teleop is running, while Disabled even (but the motor outputs are what get disabled, so you won't see any motor move).

Don't try to use cimtest anywhere else now, since it's always going to be in use waiting for that button press.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 17-01-2014 at 18:21.
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:03.

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