Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Code for Encoder isn't working (http://www.chiefdelphi.com/forums/showthread.php?t=83307)

Michael Fadaie 21-02-2010 17:41

Code for Encoder isn't working
 
3 Attachment(s)
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.


RyanCahoon 21-02-2010 18:55

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

Greg McKaskle 21-02-2010 19:02

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

Michael Fadaie 21-02-2010 19:09

Re: Code for Encoder isn't working
 
Well, when I start it all it says is watchdog not fed

RyanCahoon 21-02-2010 19:15

Re: Code for Encoder isn't working
 
Quote:

Originally Posted by Michael Fadaie (Post 925547)
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

Michael Fadaie 21-02-2010 19:16

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.

Greg McKaskle 21-02-2010 19:16

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

Michael Fadaie 21-02-2010 20:24

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.

Ether 21-02-2010 21:31

Re: Code for Encoder isn't working
 
Quote:

Originally Posted by Michael Fadaie (Post 925598)
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.


~

Alan Anderson 22-02-2010 08:07

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.


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

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