Go to Post We can't be afraid to critique the existing system. If we don't, how will it ever get better? - Jaine Perotti [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-02-2013, 10:59
Invictus3593's Avatar
Invictus3593 Invictus3593 is offline
time you like wasting is not wasted
FRC #3593 (Team Invictus)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Tulsa, OK
Posts: 318
Invictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really nice
Robot "twitching?"

Our robot is almost fully programmed but we've run into a problem, the robot's drive motors and some other motors run themselves for a fraction of a second with no joystick input every now and then. It only happens when the robot is enabled in teleop and the only error messages we get are that the loop that robotdrive and one other motor are in is running to slowly.

I did fix half of the problem yesterday when a digital I/O port on the sidecar was being read by both the compressor and a digital read at the same time, that caused it to twitch a TON.

I would like to add that I tried a completely new project with just drive and it worked fine so it's not the hardware or wiring.

Is this caused by the slow loop or is it something wrong with my teleop code?
Attached Files
File Type: vi Teleop.vi (40.2 KB, 33 views)
File Type: vi Firing project.vi (72.0 KB, 25 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2013, 11:23
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
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: Robot "twitching?"

FIRE is inappropriate for use in Teleop because of the delays embedded inside.
This code that calls it should be moved to a loop in Periodic Tasks.vi where such things belong.

The reason you're seeing the behavior that you are, is because you are losing control when Teleop essentially freezes up while processing your FIRE sequence. The last commands sent to Tank Drive will stick until the FIRE sequence completes.
Susequent joystick movements (like going to neutral) won't be processed by Teleop until the FIRE sequence is finished 3+ seconds later.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 09-02-2013 at 11:25.
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2013, 11:28
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: Robot "twitching?"

The problem is that Fire has a number of large delays.

If the safety feature is active and the motors aren't updated by that deadline, the motors will be set to speed zero. This is primarily to keep the robot safer when you hit a breakpoint in the code or get into an infinite loop, etc.

The other reason you don't really want large delays in teleop is that it will cause the code to ignore the joystick for several seconds. Depending on what the robot and driver are doing at the time, this could be fine. In that rare case, simply turn off the safety config in Begin. Typically, the better solution is to move the delayed code out of teleop and run it in parallel, or make it into a state machine that performs the operations a little at a time over a number of teleop calls.

Both of these are valid approaches, but the easier of the two is probably to take the Safety code and place it into a loop in Periodic Tasks. Have the periodic loop read a global that tells it to fire, and in teleop, set the global instead of calling the function. Be sure to reset the global. You can also look at using a notifier if you feel up to it.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2013, 12:48
Invictus3593's Avatar
Invictus3593 Invictus3593 is offline
time you like wasting is not wasted
FRC #3593 (Team Invictus)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Tulsa, OK
Posts: 318
Invictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really nice
Re: Robot "twitching?"

Quote:
Originally Posted by Greg McKaskle View Post
Typically, the better solution is to move the delayed code out of teleop and run it in parallel, or make it into a state machine that performs the operations a little at a time over a number of teleop calls.

I'm not sure what you guys mean by "run it in parallel." How do I run the fire sequence when a button is pushed in teleop? We made "FIRE" so that multiple things would happen in sequence to shoot the Frisbees without many joystick inputs having to be received at a time. We want to run this sequence in teleop to shoot one frisbee after another until any discs loaded will fire.

Is this delay problem the reason the two motors (motor 1 & 2) don't stay on when the sequence moves to the next frame?
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2013, 12:54
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
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: Robot "twitching?"

All the stuff that feeds into FIRE including the joystick gets for axes and buttons, can all be copied and pasted into clear space in Periodic Tasks.vi.

Then put a While loop around it that never ends, and put a 10ms Wait in there so it doesn't suck all the life out of the cRIO.

There's nothing special about Teleop that gives it exclusive access to the Joystick controls. They can be read in Teleop and in Periodic Tasks, or other places, too.
The advantage of Teleop is that it only gets called whenever there are new joystick values to process, so it's more efficient.
Run the loop in Periodic Tasks a little faster than the 20ms communication packet rate and it won't matter that you're sometimes reading joystick info twice sometimes. The duplicate info won't be the the signal telling you to FIRE.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 09-02-2013 at 12:58.
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2013, 13:13
Invictus3593's Avatar
Invictus3593 Invictus3593 is offline
time you like wasting is not wasted
FRC #3593 (Team Invictus)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Tulsa, OK
Posts: 318
Invictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really nice
Re: Robot "twitching?"

Quote:
Originally Posted by Mark McLeod View Post
Run the loop in Periodic Tasks a little faster than the 20ms communication packet rate and it won't matter that you're sometimes reading joystick info twice sometimes.
How do I do that? Just change the delay in the loop I made?

And thank you guys for all the quick responses!!

Last edited by Invictus3593 : 09-02-2013 at 13:28.
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2013, 14:17
vic burg's Avatar
vic burg vic burg is offline
Alumni, Mentor, & AmeriCorps VISTA
AKA: Captain Obvious
no team
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Florida
Posts: 544
vic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to behold
Re: Robot "twitching?"

We were having the same problem and tried your safety solution but it didn't fix it. Now it's not responding at all.
__________________
RoboColts--Hallandale Elementary
--Thanks goes out to Cody C for making me ^^this^^ user bar!!!!
Nuts and Bolts help the world go 'round.... They also keep us all together. Including the Robots we build. -vic burg
I have been dubbed an honorary member of 1902 and 744 (by the members).
And yes, I am in the habit of collecting team t-shirts.
Reply With Quote
  #8   Spotlight this post!  
Unread 09-02-2013, 14:21
Invictus3593's Avatar
Invictus3593 Invictus3593 is offline
time you like wasting is not wasted
FRC #3593 (Team Invictus)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Tulsa, OK
Posts: 318
Invictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really nice
Re: Robot "twitching?"

I got the robot to stop twitching! Not by disabling the safety, but by moving the code I had running delays to periodic tasks. But now the joystick values don't ever get updated. Without the compressor, the sequence runs perfect, just how i wanted it

Last edited by Invictus3593 : 09-02-2013 at 14:36.
Reply With Quote
  #9   Spotlight this post!  
Unread 09-02-2013, 14:37
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: Robot "twitching?"

Quote:
but it didn't fix it. Now it's not responding at all.
All you did was disable the safety in Begin? And if you turn it back on?

Are there messages being sent to the diagnostics?

Greg McKaskle
Reply With Quote
  #10   Spotlight this post!  
Unread 09-02-2013, 14:41
vic burg's Avatar
vic burg vic burg is offline
Alumni, Mentor, & AmeriCorps VISTA
AKA: Captain Obvious
no team
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Florida
Posts: 544
vic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to beholdvic burg is a splendid one to behold
Re: Robot "twitching?"

Quote:
Originally Posted by Greg McKaskle View Post
All you did was disable the safety in Begin? And if you turn it back on?

Are there messages being sent to the diagnostics?

Greg McKaskle
Yes, yes and yes. More details here: http://www.chiefdelphi.com/forums/sh...d.php?t=113119
I don't want to thread jack.
__________________
RoboColts--Hallandale Elementary
--Thanks goes out to Cody C for making me ^^this^^ user bar!!!!
Nuts and Bolts help the world go 'round.... They also keep us all together. Including the Robots we build. -vic burg
I have been dubbed an honorary member of 1902 and 744 (by the members).
And yes, I am in the habit of collecting team t-shirts.
Reply With Quote
  #11   Spotlight this post!  
Unread 09-02-2013, 15:32
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
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: Robot "twitching?"

Quote:
Originally Posted by Invictus3593 View Post
But now the joystick values don't ever get updated.
That probably means the Joystick Gets are misplaced.
Post the code you have now and we'll help troubleshoot that.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #12   Spotlight this post!  
Unread 11-02-2013, 16:05
Invictus3593's Avatar
Invictus3593 Invictus3593 is offline
time you like wasting is not wasted
FRC #3593 (Team Invictus)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Tulsa, OK
Posts: 318
Invictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really nice
Re: Robot "twitching?"

Here are both Teleop and Periodic Tasks. Do you need begin for the compressor's start?

The sequence in periodic works great, but no relay fired.

EDIT: It gave me an code of "-44027" when I put a probe on the error line in Begin.vi. I'm not sure what that means, but it told me it's an unidentified error.
Attached Files
File Type: vi Teleop.vi (37.5 KB, 7 views)
File Type: vi Periodic Tasks.vi (33.3 KB, 4 views)

Last edited by Invictus3593 : 11-02-2013 at 16:23.
Reply With Quote
  #13   Spotlight this post!  
Unread 11-02-2013, 16:20
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
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: Robot "twitching?"

No Relays were harmed in the running of this code, because those are solenoids.

What kind of solenoid are you using?
The code assumes it is a single solenoid (one physical set of wires).
the solenoids we've goten in the kit the past couple of years have been double solenoids (two sets of physical wires).

Post your Begin so we can check that out too.

P.S. to your edit.
A -44027 error is "FRC: The DIO channel has already been allocated."
That means you've specified the same DIO more than once in Begin.vi. Probably the default DIO 1 came up twice.
You can get info on the mysterious error numbers by going to Help->Explain Error... and typing in the error number (remember to include the negative sign if appropriate).
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 11-02-2013 at 16:25.
Reply With Quote
  #14   Spotlight this post!  
Unread 11-02-2013, 16:26
Invictus3593's Avatar
Invictus3593 Invictus3593 is offline
time you like wasting is not wasted
FRC #3593 (Team Invictus)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Tulsa, OK
Posts: 318
Invictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really nice
Re: Robot "twitching?"

Quote:
Originally Posted by Mark McLeod View Post
What kind of solenoid are you using?
Single, it's the one from the kit, but we only connected one set of wires from the double solenoid, it works great *thumbs up!*

Here's begin for ya!
Attached Files
File Type: vi Begin.vi (54.6 KB, 6 views)
Reply With Quote
  #15   Spotlight this post!  
Unread 11-02-2013, 16:29
Invictus3593's Avatar
Invictus3593 Invictus3593 is offline
time you like wasting is not wasted
FRC #3593 (Team Invictus)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Tulsa, OK
Posts: 318
Invictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really nice
Re: Robot "twitching?"

You're right, I was opening DIO1 twice instead of both 1 & 2! It works perfectly now! Thanks for all your help man!
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 22:51.

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