|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||
|
|||
|
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. ![]() |
|
#2
|
||||
|
||||
|
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 Last edited by RyanCahoon : 21-02-2010 at 18:58. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
Re: Code for Encoder isn't working
Well, when I start it all it says is watchdog not fed
|
|
#5
|
||||
|
||||
|
Re: Code for Encoder isn't working
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 |
|
#6
|
|||
|
|||
|
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.
|
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
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.
|
|
#9
|
||||
|
||||
|
Re: Code for Encoder isn't working
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 |
|
#10
|
|||||
|
|||||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |