Go to Post FIRST is like pizza--you and I might prefer different toppings, but there's no wrong way to do it. - Billfred [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 21-02-2010, 17:41
Michael Fadaie Michael Fadaie is offline
Registered User
FRC #3393
 
Join Date: Feb 2010
Location: Edgewood
Posts: 10
Michael Fadaie is an unknown quantity at this point
Code for Encoder isn't working

I need help programming the encoders. I provided some pictures of my code and I am hoping you can solve the problem. I am not really going to explain it that much because you already are going to understand it. But, code.jpg the VI called speed controller encoder contains the code fromthe picture below which I couldn't fit in an attachment. The Michael Fadaie PID VI is just like the PID loop you find under the VI that are already made for you. But, it was condenced. Also, I am opening two encoders in the begin VI for the right and left motors.

If you have any questions feel free you ask. Thanks.

Attached Thumbnails
Click image for larger version

Name:	code4.jpg
Views:	32
Size:	90.1 KB
ID:	8740  Click image for larger version

Name:	Code.jpg
Views:	34
Size:	133.0 KB
ID:	8741  Click image for larger version

Name:	code3.jpg
Views:	29
Size:	80.3 KB
ID:	8742  
Reply With Quote
  #2   Spotlight this post!  
Unread 21-02-2010, 18:55
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Code for Encoder isn't working

While we can probably understand your code, it will take us a long time if we have to try to figure out what's going wrong. Let us know what it's doing wrong/what it's not doing and we'll be able to help you better and more expediently.

One thing I've noticed initially, though, is that in the code pasted into your post, the wires going between the loops probably won't do what you want, as values will only be propagated along them once, after the source (top) loop finishes. This also means that the bottom loop won't run until the top loop has been stopped, but then since the value wired to the stop terminal on the bottom loop will already be true, the bottom loop will only run once.

--Ryan
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor

Last edited by RyanCahoon : 21-02-2010 at 18:58.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-02-2010, 19:02
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,751
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: Code for Encoder isn't working

The wire means that the bottom loop will not begin until the top loop is stopped.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 21-02-2010, 19:09
Michael Fadaie Michael Fadaie is offline
Registered User
FRC #3393
 
Join Date: Feb 2010
Location: Edgewood
Posts: 10
Michael Fadaie is an unknown quantity at this point
Re: Code for Encoder isn't working

Well, when I start it all it says is watchdog not fed
Reply With Quote
  #5   Spotlight this post!  
Unread 21-02-2010, 19:15
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: Code for Encoder isn't working

Quote:
Originally Posted by Michael Fadaie View Post
Well, when I start it all it says is watchdog not fed
When running a program on the cRIO, you need to "feed" the watchdog timer periodically, otherwise the cRIO assumes your program has hung up somewhere. Since you code includes a loop in the drive part of your program (where the watchdog is usually fed) that will repeat longer for a second or so (unless you click the stop button) without feeding the watchdog, you'll get the watchdog not fed error. Either rework your code so the loop only runs a certain number of times (or, alternatively, remove the loop), or add a watchdog feed to the loop (for an example of a watchdog feed, see the teleop.vi in the framework).

--Ryan
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
Reply With Quote
  #6   Spotlight this post!  
Unread 21-02-2010, 19:16
Michael Fadaie Michael Fadaie is offline
Registered User
FRC #3393
 
Join Date: Feb 2010
Location: Edgewood
Posts: 10
Michael Fadaie is an unknown quantity at this point
Re: Code for Encoder isn't working

Do I need to open two encoders in the begin VI because the open encoder VI has channel A and Channel B.
Reply With Quote
  #7   Spotlight this post!  
Unread 21-02-2010, 19:16
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,751
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: Code for Encoder isn't working

Where do you think the watchdog is being fed? And there is no indication as to where the code you attached is from. If you are in teleop and the teleop doesn't feed the watchdog or doesn't feed often enough, you get the watchdog going off.

Greg McKaskle
Reply With Quote
  #8   Spotlight this post!  
Unread 21-02-2010, 20:24
Michael Fadaie Michael Fadaie is offline
Registered User
FRC #3393
 
Join Date: Feb 2010
Location: Edgewood
Posts: 10
Michael Fadaie is an unknown quantity at this point
Re: Code for Encoder isn't working

Does any one have a sample of code that makes the encoders work and change the motor speed a contant. I know you have to use a PID loop.
Reply With Quote
  #9   Spotlight this post!  
Unread 21-02-2010, 21:31
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Code for Encoder isn't working

Quote:
Originally Posted by Michael Fadaie View Post
I know you have to use a PID loop.
Not necessarily. If you are using Jaguars and CAN bus, you can just plug the encoder into the Jag and let it close the loop for you. At least that's what the Jag manual implies; we haven't tried it yet.


~

Last edited by Ether : 21-02-2010 at 21:44. Reason: grammar
Reply With Quote
  #10   Spotlight this post!  
Unread 22-02-2010, 08:07
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,112
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: Code for Encoder isn't working

If that pair of while loops is the "Speed Control Encoder" SubVI, and you're using it in Teleop.vi, you will get a Watchdog error. The first loop never finishes, so the SubVI never returns a result, so anything that depends on it will not run. The code effectively halts at that point, doing nothing but reading the encoders.

Without a description of what you expect from the code I can't be sure, but I think if you just take out the While loops everything should work much better.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
encoder code for 18f8520 cau.denny General Forum 2 17-03-2009 12:51
Help! Autonomous isn't working... DotCom Programming 1 09-02-2007 21:09
Camera isn't working Idaman323 Programming 13 15-02-2006 23:18
PERL isn't working... Joe Ross CD Forum Support 1 19-06-2001 10:14


All times are GMT -5. The time now is 11:12.

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