Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Photosensor as encoder for bang bang. (http://www.chiefdelphi.com/forums/showthread.php?t=113029)

Bunniy 11-02-2013 18:48

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Ether (Post 1231853)
To understand why, you have to do the math.

Using the "period" method, like Mark posted earlier in this thread, the FPGA samples the sensor at 153KHz and records the elapsed time between pulses with a 1MHz clock. For a one-per-rev sensor (like yours) on a wheel spinning at, say, 2000 rpm, that gives you a very accurate and hi resolution signal. See attachment.

The "count" method is very accurate for high speeds with high counts-per-rev sensors like a 360CP encoder. But for a one-per-rev sensor like yours, it's not very good. At a wheel speed of 2000 rpm and sampling every 20ms, you don't get enough counts to accurately determine what the speed is. Sometimes you'll get 1 count, and sometimes you'll get *no* counts. You can't convert that into a useable speed signal.
See attachment.



Do you have a good method to use the period method with desired rpm

Ether 11-02-2013 18:53

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Bunniy (Post 1231854)
Do you have a good method to use the period method with desired rpm

I would recommend the method suggested in posts 17, 25, 26, 53, 58, and 60. Hopefully Mark can help you with the details. I am not a LabVIEW guru.

The only thing I'd change in what Mark posted is to set the FPGA samples to "1" instead of "5" for a one-per-rev sensor.




Bunniy 11-02-2013 19:16

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Ether (Post 1231857)
I would recommend the method suggested in posts 17, 25, 26, 53, 58, and 60. Hopefully Mark can help you with the details. I am not a LabVIEW guru.

The only thing I'd change in what Mark posted is to set the FPGA samples to "1" instead of "5" for a one-per-rev sensor.




Its just that i have tried multiple times and i really want someone to tell me how the entire periodic task and begin should look. Considering im using a photosensor and only one tick per rev. Because i just want to get my wheel to be at a certain rpm with a push of a button and i have been trying to do this for 5 days now and no luck.

MysterE 11-02-2013 19:45

Re: Photosensor as encoder for bang bang.
 
Hi everyone,

I just wanted to say thank you for all of the help that you all have been giving our programmer. He is working solo on this and is learning much of it without local support. We are slowly making progress and appreciate all of your efforts.

Bunniy 11-02-2013 20:54

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by billbo911 (Post 1230339)
When I first saw the code I was surprised at how familiar it looked, then I realized, I posted it last year.

Mark, would replacing the "Reset Counter" with a feedback loop and subtracting the previous count from the current count be a more stable option?

Both the IIR filter and the slew rate limiter were placed in this code as ways to compensate for other issues.

The slew rate limiter really is only needed when using a Jaguar. The current limiting circuit in the Jag can trip if the start up current is too high. If using a Talon or Victor, this entire block of code can be bypassed or completely removed.

Honestly, the IIR filter shouldn't be used. It introduces lag into the control. I put it in there as a way to smooth out the RPM signal. I believe the main reason the signal was noisy was due to the use of a "wait" loop instead of a timed loop in the original version. In addition, we were using "Get Rate" in the original version. "Get Rate" is an instantaneous measurement that is inherently noisy. This version uses a count divided by time to determine RPM, which is a much cleaner approach. This filter can be bypassed by setting the filter strength to "0", or just deleting that section of code.

The "360" is the number of ticks per revolution of the encoder it was designed to be used with. If the encoder is just a couple of lines on a wheel and an optical sensor, the this value needs to reflect the number of lines.

Bang-Bang is a simple control system. A comparison of the current RPM to the desired RPM. If the current is at or above the desired value, then turn off the motor. If it is below, turn the motor on at full power. Anything else in the loop just clutters the process.

Question can you tell me or show me a code which uses a photosensor with a bang bang when it only has one tick per revolution

billbo911 12-02-2013 01:43

Re: Photosensor as encoder for bang bang.
 
1 Attachment(s)
Quote:

Originally Posted by Bunniy (Post 1231898)
Question can you tell me or show me a code which uses a photosensor with a bang bang when it only has one tick per revolution

I'll do my best. Sorry to have been away all day, it's build season and I was mentoring two teams today. Barely had time for lunch and got home an hour ago.

OK, 1 tick per revolution is REALLY LOW, so expect it to yield less than optimal results, though not unmanageable.
I searched the thread, but couldn't find any mention of the motor you are using, nor the wheel type. So, I'm going to make an assumption here that it will be a CIM driven direct drive shooter.

Let's assume you are getting a maximum of 5000 RPM. That means 83.3 RPS. If you gather a count sample 10 times a second, you will only see a maximum of 8.33 counts. So, 8, or 9. Miss just one count and your error is +- 625 RPM.
Therefore, you can only adjust your RPM in 625 RPM steps as well. That is not very much control.

So, that tells us using the period approach should be quite a bit better. With only 1 cycle per revolution, you don't need to worry about inaccuracies in the pulse positioning caused in manufacturing.

So, looking at the example Mark gave in post #2, the "Begin.vi" sets up the timer to average 5 counts. With the "Period" example I gave previously, it reads the samples every 20+ ms. If you use his "Begin.vi" and my Period.vi in your periodic tasks, you would only need to set the average to 2 counts. (Ether pointed out in a PM, there is no need to average with a single count encoder, so leave it at the default of 1.) Now when you feed a value into the control, it needs to be in the form of the period desired.

For example:
3000 RPM = (3000/60) = 50 RPS, therefore the period desired is 1/50 or .02 seconds.

Below is a picture of the "Period" control.

Bunniy 12-02-2013 18:27

Re: Photosensor as encoder for bang bang.
 
I do have the mini cim attached directly to the wheel. I am using a wheel like this http://www.andymark.com/product-p/am-0970.htm

Now i was able to make a small part of the wheel white so the photosensor has something to recognize. My question is how big should the mark actually be on the wheel for the photosensor to recognize it in a well fashioned time?

Ether 12-02-2013 18:30

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Bunniy (Post 1232342)
I do have the mini cim attached directly to the wheel. I am using a wheel like this http://www.andymark.com/product-p/am-0970.htm

Now i was able to make a small part of the wheel white so the photosensor has something to recognize. My question is how big should the mark actually be on the wheel for the photosensor to recognize it in a well fashioned time?

Please post a picture of the wheel showing the white mark. The shape and sharpness of the mark is important.



Bunniy 12-02-2013 18:33

Re: Photosensor as encoder for bang bang.
 
I'll do my best. Sorry to have been away all day, it's build season and I was mentoring two teams today. Barely had time for lunch and got home an hour ago.

OK, 1 tick per revolution is REALLY LOW, so expect it to yield less than optimal results, though not unmanageable.
I searched the thread, but couldn't find any mention of the motor you are using, nor the wheel type. So, I'm going to make an assumption here that it will be a CIM driven direct drive shooter.

Let's assume you are getting a maximum of 5000 RPM. That means 83.3 RPS. If you gather a count sample 10 times a second, you will only see a maximum of 8.33 counts. So, 8, or 9. Miss just one count and your error is +- 625 RPM.
Therefore, you can only adjust your RPM in 625 RPM steps as well. That is not very much control.

So, that tells us using the period approach should be quite a bit better. With only 1 cycle per revolution, you don't need to worry about inaccuracies in the pulse positioning caused in manufacturing.

So, looking at the example Mark gave in post #2, the "Begin.vi" sets up the timer to average 5 counts. With the "Period" example I gave previously, it reads the samples every 20+ ms. If you use his "Begin.vi" and my Period.vi in your periodic tasks, you would only need to set the average to 2 counts. (Ether pointed out in a PM, there is no need to average with a single count encoder, so leave it at the default of 1.) Now when you feed a value into the control, it needs to be in the form of the period desired.

For example:
3000 RPM = (3000/60) = 50 RPS, therefore the period desired is 1/50 or .02 seconds.


I am having trouble. I am using what you told me but my motor is not getting any value except for 0

Bunniy 12-02-2013 18:47

Re: Photosensor as encoder for bang bang.
 
1 Attachment(s)
Quote:

Originally Posted by Ether (Post 1232343)
Please post a picture of the wheel showing the white mark. The shape and sharpness of the mark is important.



Here is what it mainly looks like but with tape. i cant get the angle wuth the way our shootter is

Ether 12-02-2013 20:08

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Bunniy (Post 1232345)
I am using what you told me

Did you read the post very carefully? Specifically, did you follow these instructions:
Quote:

So, looking at the example Mark gave in post #2, the "Begin.vi" sets up the timer to average 5 counts. With the "Period" example I gave previously, it reads the samples every 20+ ms. If you use his "Begin.vi" and my Period.vi


Bunniy 12-02-2013 20:43

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Ether (Post 1232387)
Did you read the post very carefully? Specifically, did you follow these instructions:




yes so i should set the number of samples to average as 1 with a 1 tick per revolution

Ether 12-02-2013 20:56

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Bunniy (Post 1232409)
yes

Post your code.



Bunniy 12-02-2013 22:45

Re: Photosensor as encoder for bang bang.
 
OMG i finally got it. The encoder reset was my problem. Everything works Perfectly. Thank you everyone

MysterE 12-02-2013 23:51

Re: Photosensor as encoder for bang bang.
 
Nothing better than watching a student finally 'getting it'. Thanks, Ether, Billbo, and anyone else for their help.

Gotta love CD.


All times are GMT -5. The time now is 22:48.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi