Go to Post Maybe if we get lucky [the GDC] will just say chute door. - IronicDeadBird [more]
Home
Go Back   Chief Delphi > Technical > Electrical > CAN
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-02-2010, 13:27
MikeE's Avatar
MikeE MikeE is offline
Wrecking nice beaches since 1990
no team (Volunteer)
Team Role: Engineer
 
Join Date: Nov 2008
Rookie Year: 2008
Location: New England -> Alaska
Posts: 381
MikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond repute
Speed direction in CAN?

When using quadrature encoders directly connected to the Jaguars, we noticed that the speed returned over CAN is always positive, whichever direction the wheel rotates. We see this both via our Java code and using the BDC-COMM utility.

This causes difficulty running closed loop since the signs of the PID values would depend on the wheel direction, and I'd rather not change PID values on the fly to avoid possible instability.

The most likely explanation is that we made a wiring error and are only getting a single A or B channel from all of our wheel encoders - I won't be able to check until tomorrow - but I'd like to confirm that the Jaguar firmware is working correctly.

So has anyone successfully seen a negative speed returned over CAN from a Jaguar?
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2010, 15:34
dyanoshak dyanoshak is offline
Registered User
AKA: David Yanoshak
FRC #2158 (ausTIN CANs)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Austin, TX
Posts: 189
dyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond reputedyanoshak has a reputation beyond repute
Re: Speed direction in CAN?

Quote:
Originally Posted by MikeE View Post
When using quadrature encoders directly connected to the Jaguars, we noticed that the speed returned over CAN is always positive, whichever direction the wheel rotates. We see this both via our Java code and using the BDC-COMM utility.

This causes difficulty running closed loop since the signs of the PID values would depend on the wheel direction, and I'd rather not change PID values on the fly to avoid possible instability.

The most likely explanation is that we made a wiring error and are only getting a single A or B channel from all of our wheel encoders - I won't be able to check until tomorrow - but I'd like to confirm that the Jaguar firmware is working correctly.

So has anyone successfully seen a negative speed returned over CAN from a Jaguar?
Currently you cannot get direction from the returned speed data. You can, however, configure your Jaguar to use the encoder for position measurement and monitor the position when running in speed control mode. You can determine the direction of rotation by whether or not the position is incrementing or decrementing.

In BDC-COMM you would go momentarily into position mode and click the encoder radio button. Then you would go back into speed mode and run it as normal. You should now see the position value updating.

In Labview/Java/C++ you don't have to ever leave speed mode, you will just configure the position measurement off of the encoder.

*Once you set your PID values for, lets say, forward rotation, they will act the same in reverse rotation. This is because of how speed control is implemented in the Jaguar.

The current implementation of speed control prevents cases where the output of the PID function differs in direction from the desired speed. Say your robot was driving down a steep hill. The PID is trying to maintain a certain speed, but gravity is causing the robot to accelerate. There might be a point where the output of the PID function tells your motors to start driving in reverse, aka bad for the drivetrain. Setting the output to zero and braking, for example, would be the better option. So, the speed control firmware sets output to zero whenever this "opposite sign" situation occurs.

Hope this helps,
David

Edit: *My above explanation holds true only if you're using the Jaguar in speed control mode. It looks like you are doing your own control loop, so you have two options: hope that the motor is turning the same direction you're telling it to, or get actual direction from monitoring the position.

Last edited by dyanoshak : 12-02-2010 at 15:38.
Reply With Quote
  #3   Spotlight this post!  
Unread 13-02-2010, 10:48
MikeE's Avatar
MikeE MikeE is offline
Wrecking nice beaches since 1990
no team (Volunteer)
Team Role: Engineer
 
Join Date: Nov 2008
Rookie Year: 2008
Location: New England -> Alaska
Posts: 381
MikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond repute
Re: Speed direction in CAN?

David,

Thanks for the excellent explanation. I hadn't thought through the case of an external force changing the drive direction. It's great to learn something about the implementation subtleties.

We are using the Jaguar in speed control mode (i.e. PID on the device) rather than running our own control loop, so we'll log delta position as well and rerun our tests.

[Happily we did verify correct encoder operation.]

Thanks again.
Reply With Quote
  #4   Spotlight this post!  
Unread 15-02-2010, 09:11
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: Speed direction in CAN?

Greetings!

Could either of you guys post the C++ or Java set up commands you used for you jaguar? I understand setting the thing up in speed mode (are all of the jags in speed mode or just the one with the shaft encoder?), but the initialization sequence for setting the shaft encoder and the periodic reading portion of your code would be peachy to see. Also, from what I can see in testing, the value of the position goes from 0 to 65535 as I'm going backwards if I simply print the value as a float having unpacked it. Is this what I'm supposed to see? Or, should I hack the top 2 bytes off and cast it as a singed integer to show negative position?

TIA,

Mike
Reply With Quote
  #5   Spotlight this post!  
Unread 17-02-2010, 11:31
MikeE's Avatar
MikeE MikeE is offline
Wrecking nice beaches since 1990
no team (Volunteer)
Team Role: Engineer
 
Join Date: Nov 2008
Rookie Year: 2008
Location: New England -> Alaska
Posts: 381
MikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond repute
Re: Speed direction in CAN?

Quote:
Originally Posted by taichichuan View Post
Greetings!

Could either of you guys post the C++ or Java set up commands you used for you jaguar? I understand setting the thing up in speed mode (are all of the jags in speed mode or just the one with the shaft encoder?), but the initialization sequence for setting the shaft encoder and the periodic reading portion of your code would be peachy to see. Also, from what I can see in testing, the value of the position goes from 0 to 65535 as I'm going backwards if I simply print the value as a float having unpacked it. Is this what I'm supposed to see? Or, should I hack the top 2 bytes off and cast it as a singed integer to show negative position?

TIA,

Mike
Mike,

We wrote our own Java code based on the C++ code which is posted at FirstForge, and while we were debugging our code an update to the Java code was also posted there. My suggestion would be to get a FirstForge account and check out the posted code.

Position is returned in 16.16 fixed point representation, i.e. take the 4 byte value and divide by 2^16. This is in full rotations, assuming that the "encoder line count" parameter was set up correctly. It should count correctly in both positive and negative direction when using a quadrature encoder.

Mike.
Reply With Quote
  #6   Spotlight this post!  
Unread 17-02-2010, 15:52
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
Re: Speed direction in CAN?

Hi Mike,

OK, so just so I'm clear here. The Encoder Line count isn't the number of lines from the encoder, but rather the number of pulses per revolution? And, that would mean that the number of Potentiometer turns would be 1 if we're using an encoder? You don't happen to know the units of the voltage ramp setting do you? Volts/revolution? Volts/Second? Volts/light year? I really wish the API guide was a bit more, er, fleshed out.

TIA,

Mike
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
How can you figure out robot speed?!?! gnirts Programming 7 01-04-2006 13:05
Edit- Can we connect more than one speed controller fan per breaker? DemonYawgmoth Rules/Strategy 7 03-02-2006 21:37
Can we use old Relays and Speed Controllers? thoughtful Control System 14 17-01-2005 14:55
Can we use old Relays and Speed Controllers? thoughtful Electrical 14 17-01-2005 14:55
Need direction...... archiver 2001 0 24-06-2002 02:17


All times are GMT -5. The time now is 20:25.

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