![]() |
Encoder for Rpm help!
Hi, i am a new programmer for my team and i am having problems with using the data from the encoder in the program. i have confirmed the encoder works with a multi-meter. the encoder is a us Digital e4p.
this is the relevant part of my code please help: class RobotOscar : public IterativeRobot { // RobotDrive myRobotDrive; // robot drive system Jaguar shooter_motor; Jaguar shooter_motor2; Encoder left_shooter; double count; public: RobotOscar(void): shooter_motor(3), shooter_motor2(4), left_shooter (3,4,false) ... ... void TeleopInit(void) { printf("Telop Init Entry\n"); left_shooter.Start(); left_shooter.Reset(); } ... ... void TeleopContinuous(void) { while(IsEnabled() && IsOperatorControl()){ count=left_shooter.Get(); printf("count= %f \n", count); } } also can you use one pwm to a digital imput to get just the A channel from the encoder for rpm only. << is the current set up |
Re: Encoder for Rpm help!
Quote:
|
Re: Encoder for Rpm help!
Quote:
You can use just one channel, but then you would need to use the Counter class, not the Encoder class, to process the signal. |
Re: Encoder for Rpm help!
If you are using a digital I/O/PWM encoder here is an example of code.
(Note: we use pointers) Code:
|
Re: Encoder for Rpm help!
We do something similar to jsmeldru...
Code:
#include <PIDSource.h>We take everything by reference since we centralize all of our sensor port data in one file. Note that that frequency is in hz. If you want rpm you can just change the 1 to a 60. |
Re: Encoder for Rpm help!
This looks nice. Now, my question is how to integrate this with a PIDController and Jaguar to make a speed-based/rpm-based PID Control. We played with modifying PIDOutput() in a super-class of Jaguar such that it 'accumulated' rather than just sending the total_error to the Jag which effectively stops the Jag when you get to an error of zero (hence a positional PID controller as it is today)...
Seems that LOTS of people would want to be able to do this, but I wasn't able to find such a thing this year and so we tried creating our own and didn't have luck. Anyone have experience here? bob |
Re: Encoder for Rpm help!
Quote:
|
Re: Encoder for Rpm help!
We have created a generic PID controller based on the WPI PID controller that, among other things, can handle speed control.
http://proj.titanrobotics.net/hg/Frc...b/TrcPIDCtrl.h |
Re: Encoder for Rpm help!
It's pretty easy actually. WPILib makes this easy for you.
We actually had two motors, so... Code:
template<class T>Code:
two_jags jags(jag1, jag2); |
Re: Encoder for Rpm help!
Quote:
|
Re: Encoder for Rpm help!
Quote:
And I haven't heard of a sync group... Anyway, what we had worked very well for us. |
Re: Encoder for Rpm help!
Quote:
sync groups only apply when using CAN. PWM is always synced. |
Re: Encoder for Rpm help!
Quote:
Code:
left_shooter(3,4,false,CounterBase.EncodingType.k1X) |
Re: Encoder for Rpm help!
Quote:
In the Counter class, you can specify either 1x or 2x decoding. I think it works this way: With 1x, it counts rising edges only. With 2x, it counts both rising and falling edges. |
| All times are GMT -5. The time now is 12:29. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi