Log in

View Full Version : 4 wheel pwm drive with encoders for an xbox controller


staplemonx
10-03-2014, 22:54
Does anyone have any code they could share. Our team has been trying to get CAN working on practice bot and we are running out of time so I told them to go back to PWM based code.

They pushed back by saying you can't use encoders with PWM. I think they are a little off with that statement so I am looking to give them an example of code that can do just that.

Feel free to personal message me if you want to keep it secret.
Thanks
JJ

xXhunter47Xx
10-03-2014, 23:43
I'm fairly certain that encoders can only be used in CANBus mode. I think it has to do with how PWMs are not accurate enough? I'm not sure, I know in Labview you cannot code with encoders unless you have CAN Jaguars, as far as I know.

EricH
10-03-2014, 23:50
Hunter, I hate to break it to you, but your statements ONLY apply to encoders connected directly to Jaguars.

For any encoder connected to the DSC's digital in/out ports or the Analog Breakout, the above does not apply. Of course, then the cRIO has to do all of the work associated with those particular encoders (or offboard it to a co-processor).

kylelanman
10-03-2014, 23:52
You can only use the encoders connected directly to the JAGs in CANBus mode. You can still use encoders with PWM but you have to connect them to the digital side car's digital inputs or some other input to the cRio and then setup a controller. In LabView there is a PID object and in C++ and Java in WPILib there is a PIDController class you can use.

Edit: What EricH said. I had a hunch someone might beat me to the post.

xXhunter47Xx
10-03-2014, 23:53
Ah, I see. I assumed he was talking about connecting direct to jaguars.

staplemonx
11-03-2014, 06:44
Do you have example code for either option?

Chadfrom308
11-03-2014, 08:58
We use a 4 PWM/ 4 Encoder drivetrain with our mecanums. We use talons, not jags, though