OCCRA
Go to Post A good engineer will never stop learning. From his peers, technicians, and competitors. The field is just to vast for any one person to know it all. - Mr. Mike [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media  
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 04-26-2018, 11:46 AM
Jack Gillespie's Avatar
Jack Gillespie Jack Gillespie is offline
Registered User
FRC #5430 (Pirate Robolution)
Team Role: Teacher
 
Join Date: Nov 2008
Rookie Year: 2009
Location: Pittsburg California
Posts: 56
Jack Gillespie is an unknown quantity at this point
Encoder Problem

Team 5430 thought they had a really strong autonomous code for this year, but had nothing but problems and reverted to drive for time.
We have finally have both encoders reading and working but we are getting really weird responses. Sometimes the left encoder stops the left side but the right side runs continuously, but sometimes it is the right side that stops. I've uploaded an image of the specific code. I think the problem lies in the logic that stops the while loop

Thanks Jack Gillespie
Lead mentor team 5430
Attached Thumbnails
Click image for larger version

Name:	Encoder.PNG
Views:	54
Size:	37.2 KB
ID:	23364  
Reply With Quote
  #2   Spotlight this post!  
Unread 04-26-2018, 12:08 PM
AlanG's Avatar
AlanG AlanG is offline
Mentor
AKA: Alan Glaser
FRC #6829 (Ignite Robotics)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Suwanee, GA
Posts: 14
AlanG is an unknown quantity at this point
Re: Encoder Problem

Hi Jack,

Are you zeroing the encoder values at autonomous init?

Alan
Reply With Quote
  #3   Spotlight this post!  
Unread 04-26-2018, 03:08 PM
Jack Gillespie's Avatar
Jack Gillespie Jack Gillespie is offline
Registered User
FRC #5430 (Pirate Robolution)
Team Role: Teacher
 
Join Date: Nov 2008
Rookie Year: 2009
Location: Pittsburg California
Posts: 56
Jack Gillespie is an unknown quantity at this point
Re: Encoder Problem

Yes we have the Encoder Reset VI wired in just be the screen shot
Reply With Quote
  #4   Spotlight this post!  
Unread 04-27-2018, 07:32 AM
mshafer1 mshafer1 is offline
Programming Mentor
AKA: Matthew Shafer
FRC #6321 (Rouse Raiders Robotics (R^3))
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2008
Location: Texas
Posts: 96
mshafer1 is a jewel in the roughmshafer1 is a jewel in the roughmshafer1 is a jewel in the rough
Re: Encoder Problem

Quote:
Originally Posted by Jack Gillespie View Post
Team 5430 thought they had a really strong autonomous code for this year, but had nothing but problems and reverted to drive for time.
We have finally have both encoders reading and working but we are getting really weird responses. Sometimes the left encoder stops the left side but the right side runs continuously, but sometimes it is the right side that stops. I've uploaded an image of the specific code. I think the problem lies in the logic that stops the while loop

Thanks Jack Gillespie
Lead mentor team 5430
I think you have a logical error.
Yes, you need to zero the encoders before, and zero (or stop) the drive after this. But the logic to continue the loop may be wrong (see attached).

The while loop has two modes,
A stop if True mode (what you currently have it set to) - designated by the stop sign
A continue if True mode, or stop if false - designated by a green arrow

There is a Boolean rule that sais the "Not of the And is equil to the Or of the Nots" that is to say that it would be logically equivalent (as far as the loop is concerned) to invert the comparisons, and OR them (I hope this shows how you're stopping the loop in a couple of cases where you don't want to).

I think there are (at least) two correct implementations for the logic:
1. just swap the and for an OR

https://imgur.com/a/N1HD5zA

2. invert both comparisons and take the And (remove the invert you currently have) - you can use a complex for this, set the mode to AND and invert both the inputs.

https://imgur.com/a/hnfQeqX

https://imgur.com/7HzL789

There are other solutions that involve changing the loop to "Continue if True" mode; personally, I prefer to use the "Stop if True" mode primarily because it is the default (although switching context from other languages can get tricky).
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	7
Size:	9.7 KB
ID:	23365  
__________________
National Instruments Software Engineer
http://frclabviewtutorials.com Curator

Last edited by mshafer1 : 04-27-2018 at 07:38 AM.
Reply With Quote
  #5   Spotlight this post!  
Unread 04-27-2018, 08:33 AM
mshafer1 mshafer1 is offline
Programming Mentor
AKA: Matthew Shafer
FRC #6321 (Rouse Raiders Robotics (R^3))
Team Role: Mentor
 
Join Date: Jan 2015
Rookie Year: 2008
Location: Texas
Posts: 96
mshafer1 is a jewel in the roughmshafer1 is a jewel in the roughmshafer1 is a jewel in the rough
Re: Encoder Problem

I should also note that Breakaway (3937 - the team I worked with while in college in Arkansas) had better success using the gyro to drive straight (using it as the process variable on a P loop and sending the output to the arcade drive x) and just using one encoder for a P loop feeding into the Y axis of the arcade drive (although one year, we did use both encoders. We read both, negated the one that went backwards, and used the average of the two to determine the distance we had gone).
__________________
National Instruments Software Engineer
http://frclabviewtutorials.com Curator
Reply With Quote
  #6   Spotlight this post!  
Unread 04-27-2018, 11:24 AM
AlanG's Avatar
AlanG AlanG is offline
Mentor
AKA: Alan Glaser
FRC #6829 (Ignite Robotics)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2014
Location: Suwanee, GA
Posts: 14
AlanG is an unknown quantity at this point
Re: Encoder Problem

Quote:
Yes, you need to zero the encoders before, and zero (or stop) the drive after this. But the logic to continue the loop may be wrong (see attached).
Jack, I think both parts of Matthew's post here tell the story. You're exiting the while loop as soon as one side reaches its threshold, so unless you immediately follow the while loop by a command to stop both motors, in most cases one motor -- the one that didn't reach its threshold -- will continue to spin.

Quote:
I should also note that Breakaway (3937 - the team I worked with while in college in Arkansas) had better success using the gyro to drive straight (using it as the process variable on a P loop and sending the output to the arcade drive x) and just using one encoder for a P loop feeding into the Y axis of the arcade drive (although one year, we did use both encoders. We read both, negated the one that went backwards, and used the average of the two to determine the distance we had gone).
+1 to this -- this is how we code a simple straight-ahead autonomous.

Alan
Reply With Quote
  #7   Spotlight this post!  
Unread 04-27-2018, 02:29 PM
Jack Gillespie's Avatar
Jack Gillespie Jack Gillespie is offline
Registered User
FRC #5430 (Pirate Robolution)
Team Role: Teacher
 
Join Date: Nov 2008
Rookie Year: 2009
Location: Pittsburg California
Posts: 56
Jack Gillespie is an unknown quantity at this point
Re: Encoder Problem

Mshafer, AlanG, thanks to both of you.
You were absolutely right.
I took Shafer's spread sheets and created one based on what we had and it was immediately obvious what the problem was and why it was a problem.
We have changed the and to an or and have already tested it.
Once we have finished testing all of our flavors of autonomous code, we are planning on connecting a gyro and an accelerometer and experimenting with them.

Thanks again for the help
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 04:34 AM.

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


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi