Go to Post That wheel appears to have been forged deep within the fires of Mount Awesome. - viking1902 [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 26-12-2013, 22:11
DavisDad's Avatar
DavisDad DavisDad is offline
MechE
AKA: Craig Rochester
FTC #8470 (Team Technado)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Boston
Posts: 317
DavisDad will become famous soon enoughDavisDad will become famous soon enough
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by Joe Ross View Post
This thread shows the required calls for setting up a CAN Jaguar in position mode. http://www.chiefdelphi.com/forums/sh...d.php?t=102909 You also need to using the imaging tool to set the appropriate CAN Jaguar plugin (Serial or 2CAN).
Hi Joe,

Thanks for the link and info in previous post. I work with industrial control systems (not programming) and I like distributed control over a network. My bias from work makes me lean toward using the Jaguar's controller for the feedback control and send setting over the BUS.

I really appreciate the real-world experience with the FRC electronics.

Last edited by DavisDad : 26-12-2013 at 22:11. Reason: typo
  #17   Spotlight this post!  
Unread 27-12-2013, 16:26
nuttle nuttle is offline
Registered User
AKA: Allen Nuttle
FRC #4080
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: United States
Posts: 104
nuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud of
Re: Jaguar Speed & Position Control with Encoders

I spent a fair amount of time using CAN and the Jags and this architecture has a lot of potential -- in my opinion, the problems were all in the implementation and the current Jags seem to have addressed the most severe problems. I also designed and built my own smart motor controllers that used different silicon and was very happy with how these turned out. I'm really looking forward to seeing a second-generation motor controller with these capabilities generally available -- and therefore legal for competition use.

I'd second the points about watching the serial bandwidth if you go this way and about using the 2CAN to open up this potential bottleneck. There at least used to be a source (eStop robotics, IIRC) for pre-made serial-to-CAN converters and terminators, as well as cables. Some teams have trouble with these, particularly the terminators. You'll need a serial converter for using BDC-COMM with a PC anyway. And BTW, making sure things work under BDC-COMM is a good first step and troubleshooting tool.

I've also seen people tripped up because the encoder connector on the Jag has a different pinout than the standard one used by US Digital, so pre-made cables at least need to be modified. Also, the space around the pins is very tight and so you have to have the right connector for this.


I sent this for a fix to the problem where the index signal messes up position control, AFAIK, it never made it into official firmware, but I haven't tried to use this in the past couple of seasons (this refers to a source file for the Jag firmware):


Note that this is in the ControllerPositionMode() function in controller.c.

Briefly, the problem was that when using PID position-based control with an indexed encoder, things don't go well when the index is hit and the position count wraps.




static void
ControllerPositionMode(void)
{
long lTemp;
//
// Get the motor position.
//
[...]
//
// Compute the error between the target position and the motor position.
//
lTemp = g_lPositionTarget - lTemp;
[
The preceding line is deriving the position error, but neglects that there are really two errors and this code need to evaluate both of these and pick the smaller of the two. The second error crosses through zero and when this is the smaller of the two, the existing code does not do the right thing.

This shows up especially when using an indexed encoder where the count gets set to zero when the index is encountered. Note that if using a pot, you really don't want to move through zero, so the logic change only applies when dealing with an encoder!

One possible fix is to leave the preceding line as-is, but add this code:

// When using an encoder, handle the case where the most direct way to reach the
// desired position crosses through zero. If the encoder lines global has not been set,
// this will be zero, meaning the count wraps at QEI_MAXPOS_M. If the position
// error is more than halfway through a full revolution, going through zero is the shorter
// distance. If the error is exactly half-way around, it would make sense to keep going
// in the current direction, but PID behavior should adequately cover this case.
// This code should really be gone over to be sure there are no issues mixing signed and
// unsigned 32-bit integers. Also, it might make sense to use QEI_MAXPOS_M in the
// case where the encoder lines global has not been set (but this is more a usage problem).

if (HWREGBITW(&g_ulFlags, FLAG_POS_SRC_ENCODER) == 1 && g_ulEncoderLines != 0)
{
if (lTemp > g_ulEncoderLines / 2)
{
lTemp = lTemp - g_ulEncoderLines;
}
else if (lTemp < -(g_ulEncoderLines / 2))
{
lTemp = lTemp + g_ulEncoderLines;
}
}
]
//
// Run the PID controller, with the output being the output voltage that
// should be driven to the motor.
//
[...]

Last edited by nuttle : 27-12-2013 at 23:45.
  #18   Spotlight this post!  
Unread 27-12-2013, 16:34
nuttle nuttle is offline
Registered User
AKA: Allen Nuttle
FRC #4080
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: United States
Posts: 104
nuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud of
Re: Jaguar Speed & Position Control with Encoders

Another thing that can trip people up is if the controller resets for any reason (power brown-out, bug?, bandwidth saturates on serial link and something bad happens?). Or maybe the cRIO resets but the Jaguar does not, or maybe something bad happens around losing the safety heartbeat, ...

Anyway, there is a possibility that the configuration parameters will all be lost and things will revert to the defaults. You want to have some sort of error handler in the cRIO code and probably also to periodically read at least something from the Jag to be sure things seem good.

There are some old threads on this topic and also that go into more detail on some of the issues in my prior post.
  #19   Spotlight this post!  
Unread 28-12-2013, 04:52
DavisDad's Avatar
DavisDad DavisDad is offline
MechE
AKA: Craig Rochester
FTC #8470 (Team Technado)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Boston
Posts: 317
DavisDad will become famous soon enoughDavisDad will become famous soon enough
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by Joe Ross View Post
...One option would be to invest in the 2CAN. Another option would be to limit the amount of CAN traffic. Setting a setpoint every few seconds isn't a problem. Changing setpoints at 50hz to multiple jaguars and requesting lots of status can be a problem.
Hi Joe,

I've read about the 2CAN but the price scared me away. I'll put that on my list to investigate.

Thanks!
  #20   Spotlight this post!  
Unread 28-12-2013, 05:09
DavisDad's Avatar
DavisDad DavisDad is offline
MechE
AKA: Craig Rochester
FTC #8470 (Team Technado)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Boston
Posts: 317
DavisDad will become famous soon enoughDavisDad will become famous soon enough
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by Ether View Post
The point Joe was making is that the built-in PID in the Jag's firmware closes the loop at 1000 Hz. You can't do that with cRIO. You can't do that with Victor or Talon.



Victors will accept 200 Hz input PWM frequency.




Other systems might.


Hi Ether,

First- I've read many of your posts and want to compliment you on your contributions to the teams. Your to-the-point, thorough, and expert responses are a pleasure to read. Thank you!

I've begun following your links and have a lot of studying to do...
  #21   Spotlight this post!  
Unread 28-12-2013, 05:17
DavisDad's Avatar
DavisDad DavisDad is offline
MechE
AKA: Craig Rochester
FTC #8470 (Team Technado)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Boston
Posts: 317
DavisDad will become famous soon enoughDavisDad will become famous soon enough
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by Jared View Post
The PID functionality of the Jaguars does work, but adding CAN can be expensive depending on which adapter you use.

The PID on the cRIO is just as fast and as powerful as the one on the jaguar, but works with all types of speed controllers and sensors. If you're looking for basic getting started examples, there are plenty for PID on the cRIO.
Jared,

By "adapter", do you mean something like 2CAN? Isn't the CAN system intended to be done directly from the cRIO? My understanding is that using a device like 2CAN improves CAN speed and has some improved functionality, right?

Thanks for the imput
  #22   Spotlight this post!  
Unread 28-12-2013, 05:26
DavisDad's Avatar
DavisDad DavisDad is offline
MechE
AKA: Craig Rochester
FTC #8470 (Team Technado)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Boston
Posts: 317
DavisDad will become famous soon enoughDavisDad will become famous soon enough
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by nuttle View Post
Another thing that can trip people up is if the controller resets for any reason (power brown-out, bug?, bandwidth saturates on serial link and something bad happens?). Or maybe the cRIO resets but the Jaguar does not, or maybe something bad happens around losing the safety heartbeat, ...

Anyway, there is a possibility that the configuration parameters will all be lost and things will revert to the defaults. You want to have some sort of error handler in the cRIO code and probably also to periodically read at least something from the Jag to be sure things seem good.

There are some old threads on this topic and also that go into more detail on some of the issues in my prior post.
Hi nuttle,

Thanks so much for the thorough response and links. The "picture that is emerging" seems to be that CAN architecture with the Jaguar is finicky but powerful if devilish details are worked out.

Last edited by DavisDad : 28-12-2013 at 16:47. Reason: typo
  #23   Spotlight this post!  
Unread 28-12-2013, 14:47
nuttle nuttle is offline
Registered User
AKA: Allen Nuttle
FRC #4080
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: United States
Posts: 104
nuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud ofnuttle has much to be proud of
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by DavisDad View Post
The "picture that is emerging" seems to be that CAN architecture with the Jaguar is finicky bur powerful if devilish details are worked out.
Yeah, this is a good way to put it. You can get things working without too much trouble, but if you don't leave enough time to test everything very well, you run some risk of having something go wrong at an inopportune time. Could be a transient glitch you barely notice or could be worse...

I've personally had pretty good results, but things like the position control with an index not working (a couple of years back but maybe still not fixed?) are limiting and cost and reliability made it so that it was really only worth the trouble if you could gain an advantage by using the CAN function. It is nice to be able to read the current and even temp, but few teams do anything with this, so closed-loop PID control seems to be the main feature that gets used. It is also nice to have another way to interface encoders, particularly since the cRIO is only set up to handle a limited number of these.

There's a lot more that could be done with this type of architecture. I put some thoughts on this in this post: <http://www.chiefdelphi.com/forums/sh...2&postcount=74>.
  #24   Spotlight this post!  
Unread 28-12-2013, 15:17
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Jaguar Speed & Position Control with Encoders

Isn't position and speed control what the analog interface is for? just hook up something like a pot or a limit switch (or even a hall-effect sensor if you are sly like that) to control speed, etc.!
  #25   Spotlight this post!  
Unread 28-12-2013, 15:27
EricH's Avatar
EricH EricH is online now
New year, new team
FRC #1197 (Torbots)
Team Role: Engineer
 
Join Date: Jan 2005
Rookie Year: 2003
Location: SoCal
Posts: 19,779
EricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond repute
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by yash101 View Post
Isn't position and speed control what the analog interface is for? just hook up something like a pot or a limit switch (or even a hall-effect sensor if you are sly like that) to control speed, etc.!
Actually, a pot or a limit switch will be rather useless for controlling speed. Pots are good for position, maybe you can get speed but only for a short time. Limit switches are good for telling you that you need to stop right before your code ignores that and manages to destroy them! (OK, I'm mostly joking--you have to mount them so that they don't get destroyed if the thing that's moving hits the hard stops. Past experience.)

For speed, encoders are the way to go, generally speaking, and seeing as the Jags have the capability to handle them and run PID, that can be a lot more useful than just using the analog interface.
__________________
Past teams:
2003-2007: FRC0330 BeachBots
2008: FRC1135 Shmoebotics
2012: FRC4046 Schroedinger's Dragons

"Rockets are tricky..."--Elon Musk

  #26   Spotlight this post!  
Unread 28-12-2013, 17:17
magnets's Avatar
magnets magnets is offline
Registered User
no team
 
Join Date: Jun 2013
Rookie Year: 2012
Location: United States
Posts: 748
magnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond repute
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by Ether View Post
Victors will accept 200 Hz input PWM frequency.
Yeah, but the point Jared was making was that the pulse width coming from the sidecar is about 20 ms, so you still can't get better than about 50 hz.

Also, I'm having a really hard time thinking of an FRC application where you need to update 1000 times per second over 100 or 200. It seems to me that in a single millisecond, a negligible amount of change can be done to the speed of a motor, and that some sensors won't show a change over 1/1000 of a second.

Has anybody really seen a benefit from really fast PID loops?
  #27   Spotlight this post!  
Unread 28-12-2013, 17:30
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,067
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by Ether View Post
Victors will accept 200 Hz input PWM frequency
Quote:
Originally Posted by magnets View Post
Yeah, but the point Jared was making was that the pulse width coming from the sidecar is about 20 ms, so you still can't get better than about 50 hz.
The pulse width is not 20ms. The period is 20ms. The pulse width varies from roughly 1ms (full reverse) to 1.5ms (zero command) to 2ms (full forward.

You can change the PWM period coming from the sidecar, so you can send commands at a higher frequency.


  #28   Spotlight this post!  
Unread 28-12-2013, 17:39
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,563
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by magnets View Post
Yeah, but the point Jared was making was that the pulse width coming from the sidecar is about 20 ms, so you still can't get better than about 50 hz.
The PWM pulse repeat rate can be as high as 200hz. By default, it is 200hz for Jaguars, 100hz for Victors and Talons, and 50hz for Servos.
  #29   Spotlight this post!  
Unread 28-12-2013, 18:54
magnets's Avatar
magnets magnets is offline
Registered User
no team
 
Join Date: Jun 2013
Rookie Year: 2012
Location: United States
Posts: 748
magnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond reputemagnets has a reputation beyond repute
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by Joe Ross View Post
The PWM pulse repeat rate can be as high as 200hz. By default, it is 200hz for Jaguars, 100hz for Victors and Talons, and 50hz for Servos.
I was unaware that this works. A while back (2009 or 2010) I looked at the signal with a scope, the pulse width was somewhere between 1-2.5 ms, and the delay in between was 20 ms, no matter what speed controller was selected (in LabVIEW).
  #30   Spotlight this post!  
Unread 28-12-2013, 19:20
DavisDad's Avatar
DavisDad DavisDad is offline
MechE
AKA: Craig Rochester
FTC #8470 (Team Technado)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Boston
Posts: 317
DavisDad will become famous soon enoughDavisDad will become famous soon enough
Re: Jaguar Speed & Position Control with Encoders

Quote:
Originally Posted by yash101 View Post
Isn't position and speed control what the analog interface is for? just hook up something like a pot or a limit switch (or even a hall-effect sensor if you are sly like that) to control speed, etc.!
Hi yash,

My son and I have implemented speed control on a FTC design using Matrix motors (~120 rpm, planetary 27:1, hall effect encoder 757 lines) controlled by LEGO NXT. You can see our progress here: Modular Drive System

Our prototype works well as follows:
  • The pain for getting the motor controllers configured was relatively small (~ 8 hrs).
  • PID control of encoder speed tracked well with little control oscillations
  • The mecanum omni directional control scheme went together smoothly
  • The prototype controlled smoothly from the game controllers
  • Power was good
  • The bot tracked straight with a small amont of drift to the left

We're planning to make a video tomorrow to show the driving performance. We were delighted scooting around the kitchen, pushing around chairs. Sending the desired speed to the motor controller and letting it do the "local maintenance" is a solid architecture.

Last edited by DavisDad : 29-12-2013 at 04:42. Reason: typo
Closed Thread


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


All times are GMT -5. The time now is 17:27.

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