Go to Post No matter what happens to the robot we learned our lesson and we had fun. That's what matters. - David Guzman [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 01-04-2013, 23:37
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Consistent Encoder RPM Issues

Hi all. I am trying to figure out how to get encoders to read consistent values for speed. We have 250 count encoder (e4p) on there and using getRate() they read correctly at low RPMs but once it starts hitting 6000 rpm then we start seeing variations of around 15 revolutions per second. These are mounted on a mini cim. I don't really know what to do at this point. I have tried varying them from k4X to k1X with no real difference. My other thought was doing some kind of

reset
wait
get elapsed ticks
get elapsed time
calculate rpms

as I am under the impression that the variation could be due to the miniscule time frame between ticks that WPIlib uses to calculate the rate? I couldn't figure out how to spawn a new task to do this is and I do not want to block my code. Essentially I have run out of experience and I couldn't find much in the way of code examples or a clear solution to my problem.

So here is my goal:
Get a clean rpm reading useable in PID or other algorithm to ramp up a frisbee shooter to the desired speed.

My problem:
Highly variable readings at higher wheel speeds.

Thanks,
Team 4302
Reply With Quote
  #2   Spotlight this post!  
Unread 01-04-2013, 23:41
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Consistent Encoder RPM Issues

Use a lower CPR encoder. We were running into resolution issues with the timer once the square wave's period got extremely small. Less ticks = bigger period = more resolution.

We get fairly good results with a retro reflective optical sensor pointed at a piece of tape on the shooter wheel. We got terrible results with a 32 CPR encoder. We are calculating RPM with Counter::getPeriod().

Last edited by Tom Bottiglieri : 01-04-2013 at 23:45.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-04-2013, 23:48
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

So the problem is that the Crio is randomly dropping ticks or is it that the timer is trying to measure immensely small time periods and failing to do so accurately?
Reply With Quote
  #4   Spotlight this post!  
Unread 01-04-2013, 23:50
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Consistent Encoder RPM Issues

Quote:
Originally Posted by meltbox360 View Post
So the problem is that the Crio is randomly dropping ticks or is it that the timer is trying to measure immensely small time periods and failing to do so accurately?
The second one. Once the period of the ticks gets sufficiently small, you may only be able to measure in buckets of 5-10% of your RPM.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-04-2013, 23:55
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

Well that is encouraging. In that case is there a way to start another thread as I have not been able to with startTask. Function pointers in classes are beyond me as of right now which made it impossible for me to use startTask properly. I then wanted to use

(tickGet() * 1000) / sysClkRateGet())

To calculate time however "tickLib.h" doesn't want to compile either.

Ideally I do not want to impact responsiveness. I do not think we will be able to modify to a different encoder at this point. If you think it is worth switching encoders could you link to the one you have purchased. I am not familiar with retro-reflective encoders. Thanks.

EDIT: The idea is to create another thread, sleep in it for some time, then measure the rpm. That way I should allow the other thread to run while getting reasonably accurate speed. I think this is correct.

Last edited by meltbox360 : 02-04-2013 at 00:01.
Reply With Quote
  #6   Spotlight this post!  
Unread 02-04-2013, 00:01
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Consistent Encoder RPM Issues

Quote:
Originally Posted by meltbox360 View Post
Hi all. I am trying to figure out how to get encoders to read consistent values for speed. We have 250 count encoder (e4p) on there and using getRate() they read correctly at low RPMs but once it starts hitting 6000 rpm then we start seeing variations of around 15 revolutions per second. These are mounted on a mini cim. I don't really know what to do at this point. I have tried varying them from k4X to k1X with no real difference.
A 250 count encoder should work if you set it up properly.

- Physically disconnect Channel B. Don't use it. Use Channel A only

- Create an up/down Counter object (not encoder) on the Channel A signal, and set it to count rising edges only

- Set the FPGA sample ring buffer to 125 samples1.

- Use Counter getPeriod() method. RPM = 60/(250*getPeriod())


Can you provide some more detail about your shooter design?

- what motor controller(s) are you using?

- what motor(s) are you using?

- how are those motor(s) connected to the wheel(s)?

- where and how is your encoder mounted?

Depending on the answers, you may be able to use the very simple bang-bang speed controller algorithm.


1if you don't know what this means, ask


Reply With Quote
  #7   Spotlight this post!  
Unread 02-04-2013, 00:10
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

Oh oh. It is wired to use channel B. I will disconnect that then and try as you say. The encoders are mounted on a shaft extension coming out of a cim in one case and a mini cim in another. The wheels are on this same shaft. It is supported at two points. The encoder is right over the end of the shaft extension. I saw mention of bang-bang but never really delved too much into it as the readings were a little iffy.

So essentially wheels, encoder, motor all spin same speed. The encoder is mounted with screws and sits on the end of the shaft. We are using Victor 888 speed controllers.

I will post back shortly with results.

EDIT: Is it really necessary to disconnect the B channel or can it remain plugged in some arbitrary spot? The ground and power are wired to separate wires unfortunately so unplugging it entirely is not really an option without modifying the wires.

EDIT 2: I do not know how to set the FPGA sample ring buffer. I think that in order to set the rest up I need to make the counter and do the following

SetUpSource([channel A]);
SetUpSourceEdge(true, false);

Except then I don't know what channel I drop in when I am making the instance of the Counter class. Also channel A?

Last edited by meltbox360 : 02-04-2013 at 00:18.
Reply With Quote
  #8   Spotlight this post!  
Unread 02-04-2013, 00:14
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Consistent Encoder RPM Issues

Quote:
Originally Posted by meltbox360 View Post
The encoders are mounted on a shaft extension coming out of a cim in one case and a mini cim in another. The wheels are on this same shaft. The encoder is mounted with screws and sits on the end of the shaft.
Could you post a picture? I'm concerned about vibration.


Reply With Quote
  #9   Spotlight this post!  
Unread 02-04-2013, 00:17
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Consistent Encoder RPM Issues

Quote:
Originally Posted by meltbox360 View Post
EDIT: Is it really necessary to disconnect the B channel or can it remain plugged in some arbitrary spot? The ground and power are wired to separate wires unfortunately so unplugging it entirely is not really an option without modifying the wires.
Can you post a simple hand-drawn sketch? I'm not sure I follow you.


Reply With Quote
  #10   Spotlight this post!  
Unread 02-04-2013, 00:18
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Consistent Encoder RPM Issues

Quote:
Originally Posted by meltbox360 View Post
I will post back shortly with results.
What programming language are you using?


Reply With Quote
  #11   Spotlight this post!  
Unread 02-04-2013, 00:30
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

I am using c++

Here are the pictures.
Attached Thumbnails
Click image for larger version

Name:	IMG_00000043.jpg
Views:	57
Size:	1.01 MB
ID:	14503  Click image for larger version

Name:	IMG_00000044.jpg
Views:	36
Size:	993.0 KB
ID:	14504  
Reply With Quote
  #12   Spotlight this post!  
Unread 02-04-2013, 00:31
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Consistent Encoder RPM Issues

Quote:
Originally Posted by meltbox360 View Post
Here are the pictures.

Does your camera have a macro setting?


Reply With Quote
  #13   Spotlight this post!  
Unread 02-04-2013, 00:36
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

Using my phone. First time was me being too quick.
Attached Thumbnails
Click image for larger version

Name:	IMG_00000045.jpg
Views:	48
Size:	1.15 MB
ID:	14505  
Reply With Quote
  #14   Spotlight this post!  
Unread 02-04-2013, 00:36
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,043
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: Consistent Encoder RPM Issues

Quote:
Originally Posted by meltbox360 View Post
I am using c++
Since you didn't ask, I assume you already know what this means and how to do it:

Quote:
Originally Posted by Ether View Post
- Set the FPGA sample ring buffer to 125 samples1.

1if you don't know what this means, ask

Reply With Quote
  #15   Spotlight this post!  
Unread 02-04-2013, 00:38
meltbox360 meltbox360 is offline
Registered User
FRC #4302
 
Join Date: Jan 2012
Location: Chicago, Il
Posts: 32
meltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of lightmeltbox360 is a glorious beacon of light
Re: Consistent Encoder RPM Issues

Quote:
Originally Posted by Ether View Post
Since you didn't ask, I assume you already know what this means and how to do it:




I asked in a second edit earlier. Not sure at all. Sorry I checked the docs and then I realized I have no idea how to do this stuff correctly without some experimentation.
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


All times are GMT -5. The time now is 12:42.

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