![]() |
Photosensor as encoder for bang bang.
Hello folks,
Helping my programmer do a bit of research. How would we go about pulling the period of time between rotations of a flywheel using a photosensor and tape to use with a bang bang in Labview. |
Re: Photosensor as encoder for bang bang.
Here's one way to do a tach with a photosensor:
![]() |
Re: Photosensor as encoder for bang bang.
what is and where do i find the 'Dig Scr' thingy between the DIO open and the COUNTER open
|
Re: Photosensor as encoder for bang bang.
It's in
WPI Robotics Library -> I/O -> DigitalInput |
Re: Photosensor as encoder for bang bang.
1 Attachment(s)
Quote:
Is the Counter/ConfigTimer (blue arrow) where the FGPA sampling size is configured? If so, does the "5" (green arrow) mean FPGA sample average is set to 5? Does Counter/Get (red arrow) return the same thing as the GetPeriod() method in the Counter class in C++ and Java (i.e. period, in seconds, of the tooth count, based on the last 5 samples) ? Thanks. |
Re: Photosensor as encoder for bang bang.
In a word, Yes.
The 5 there is just an example for # samples to average. (For the OP's programmers, e.g., Bunniy) For example, if you have multiple pieces of reflective tape around the wheel to increase your resolution, then averaging removes any displacement errors in positioning the individual pieces of tape. You know, if the pieces of tape aren't perfectly spaced, perfectly sized, perfectly oriented. If you just use 1 piece of tape then I'd probably take the LabVIEW default of 1. That Get wire is the average Period (in seconds) between pulses. |
Re: Photosensor as encoder for bang bang.
Quote:
I have a more general LabVIEW question if I may. Before I posted the above question, I tried for about half an hour to find the answer on the internet. Do you (or does anyone reading) know of a site where you could type, say, "Counter Config Timer" into a search box and it would display the LabVIEW help screen for that icon? I had no success with Google. |
Re: Photosensor as encoder for bang bang.
Thank you mark for telling me that it should be set to 1. No wonder my wheel was spinning so fast!
|
Re: Photosensor as encoder for bang bang.
im still having trouble. my motor keeps spinning as fast as possible even when i set the rpm to even 200.
|
Re: Photosensor as encoder for bang bang.
Show a snippet of the code you're using.
I may be a little slow responding, I'm shoveling snow. P.S. If you don't know what a number in the example means, ask. You don't want the 99 for example, because you only have 1 tick per revolution. |
Re: Photosensor as encoder for bang bang.
Ether, I don't know of a site that does that, but the editor will. If you click on search in the palettes, type Counter Config, it will have only one item in the list. Hover and the Context help window will show that item's help. There is also a function called QuickDrop that some folks just love. You hit Ctl-Space and type some of the name and it does the same sort of list and you click and drop the node. It doesn't look like the help updates until you drop the node.
Greg McKaskle |
Re: Photosensor as encoder for bang bang.
1 Attachment(s)
here
|
Re: Photosensor as encoder for bang bang.
1 Attachment(s)
and this is the rest of it. The first picture us what is in the periodic task vi
|
Re: Photosensor as encoder for bang bang.
So you're taking the total revs since the last time you checked the counter.
Dividing by a time constant, filtering the result, and applying a slew rate limiter? I'm not a fan of the Counter reset applied that way. There's a window to drop counts. Seems a bit much for flywheel. Is the slew rate limiter to avoid extended stall time at full power for the flywheel? P.S. I overlooked that the slew rate is probably bypassed with the False Case. Is that really 360 counts per revolution? I thought you only had 1? I don't think you want that 60 or 360 applied there, but maybe I haven't grasped what you are calculating. |
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
Quote:
The first thing I would check is if you are actually getting an RPM reading by placing a "probe" just before the ">= " comparitor. Also, make sure the other input to the comparitor is seeing the desired RPM value. If you are not seeing either at that point, then you will know where to start digging further. |
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
Quote:
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. |
Re: Photosensor as encoder for bang bang.
my buttons are in teleop and send the numeric values to the global variable which is then sent to the bang bang controller in the periodic tasks.I downloaded the bang bang and did not change it except for the global variable. Now i dont know what most of the numbers mean but tell me what you think i shouild change.
P.S. sorry for my little kid posts and all, i just got my license yesterday, and a flat the same day, lost and found our pneumatic wheel at homedepot, and had a long day of course :P |
Re: Photosensor as encoder for bang bang.
Quote:
Make sure the filter level is set to "0", and lastly that the Boolean for the slew rate filter is set to "False". Does your Begine.vi have the correct configurations for the counter? (That was also included in the .zip version of the Bang-Bang control. The separate versions of the Bang_Bang I uploaded just added extra features.) If it is not there, then you will not be getting any input to the control and it will always be full on. |
Re: Photosensor as encoder for bang bang.
Quote:
You do have to be aware of how high the Counter can count and provide for wraparound if resolution makes that a potential problem. Counter Reset can be used when the shooter is turned off or first turned on, i.e., before or after the count integrity matters. Also, it should be made clear that a crude filter and a loss of resolution is being applied by converting the Counter to RPMs before doing the tests. My preference is to do all processing and comparisons in native units and only convert to RPMs for the human display. Bunniy, your Counter initialization in Begin.vi looks fine. See, you get your license and immediately you're doing errands.:) |
Re: Photosensor as encoder for bang bang.
The OP didn't mention the shooter speed(s) or the execution rate. So I'll pick some numbers. At 4500 rpm true wheel speed, sampling the counts of a one-per-rev sensor at a 20ms rate will give you 1 count 50% of the time and 2 counts 50% of the time. So if you compute speed by dividing counts by elapsed time, your measured rpm will be 3000 half the time and 6000 the other half, and that's assuming perfect 20ms scheduling of your control algorithm. That's a lot of noise. I wonder if the shooter inertia would be large enough to allow bang-bang to work with a signal like that. Maybe some inquisitive team will try it and report their results. If it doesn't work, let the FPGA do the sampling (at 153KHz) and timing (with its 1MHz timer). You'll see +/-3 rpm, and your 20ms scheduling doesn't need to be tightly held. |
Re: Photosensor as encoder for bang bang.
Thank you. That seems to have helped. Also i am using a pneumatic wheel and a painted a small white line of paint about 1/3 of an inch in diameter. Should i make it bigger. I am looking at my rpm calculator and it was only showing me 30 at full power. My thought is that it is not registering fast enough. Any suggestions?
|
Re: Photosensor as encoder for bang bang.
where exactly is the FPGA and what does that mean
|
Re: Photosensor as encoder for bang bang.
Quote:
FPGA stands for Field Programmable Gate Array. You can Google it for all the hairy details if you like. In a nutshell, it's a programmable piece of hardware that is in the cRIO (separate from the CPU that is running your program). The FPGA processes all the digital signals coming into the DSC. It polls those signals at 153KHz and has a 1MHz timer to timestamp events (like ticks from a sensor). The FPGA makes its information available to your program running in the cRIO CPU. It relieves the CPU from having to do the high-speed polling. |
Re: Photosensor as encoder for bang bang.
1 Attachment(s)
Ether means get the Period the way I showed how earlier.
That comes from the FPGA which is the chip that processes all the inputs and outputs on the cRIO. FPGA stands for Field Programmable Gate Array. P.S. Boy am I slow today. But I did just finish moving 1500 cubic feet of snow, shovel-full by shovel-full. |
Re: Photosensor as encoder for bang bang.
3 Attachment(s)
I still have no luck. Here are is my current project. I have the rpm value sent to my driver station which is named "Cim". Like i said i just have an photosensor and a little piece of the wheel white. It always runs at full speed when i press different desired RPM values. I dont know if it is a problem with the begin or even my global variable. Please look over it for me
|
Re: Photosensor as encoder for bang bang.
3 Attachment(s)
Mark,
I created a "Count only" version of the Bang-Bang control. Does this look correct? If so, I'll add it to my "White Paper" options. The only modifications needed are to replace the counter and motor names with the actual names. If actual RPM is needed, that can be added here or elsewhere. I also put a version together that uses the period approach you described earlier. |
Re: Photosensor as encoder for bang bang.
so i have tried to use it and i pluged in the Photosensor to the FPGA which is the card on the Crio. Now in the begin do i have to set it up a certain way or something? Because i tried using the robot with your new code and it is not even spinning the motor now
|
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
And can you also check my global variable
|
Re: Photosensor as encoder for bang bang.
The DSC is?
|
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
Haha is it the digital side cart i should wire the Photosensor to or the blue thingy on the crio
|
Re: Photosensor as encoder for bang bang.
Quote:
You want to wire your sensor to a DIO on the Digital Side Car. |
Re: Photosensor as encoder for bang bang.
haha thank you. I will try it.
|
Re: Photosensor as encoder for bang bang.
Just a caveat about the Photosensor.
What model are you using? If it's this Kit one: ![]() Then the power wiring gets a bit unusual. The signal connects to the Digital Sidecar, but it can be unwise to take power for this particular sensor from there. It doesn't handle voltage dips well. We can describe what to do, but I don't want to clutter the thread if you're using some other model. P.S. I'll take a look at your revision Bill. I just have had only snippets of time over the past couple of days. I know a lot of new names for snow now, but not in polite company... |
Re: Photosensor as encoder for bang bang.
Yes i am using that kind. I have it powered by the power distribution board
|
Re: Photosensor as encoder for bang bang.
I used what you gave me and now my motor wont even spin at all
|
Re: Photosensor as encoder for bang bang.
Quote:
http://www.chiefdelphi.com/forums/sh...6&postcount=22 |
Re: Photosensor as encoder for bang bang.
I fixed the spinning part. I wired it wrong. But still the motor is still spinning as fast as possible
|
Re: Photosensor as encoder for bang bang.
It is still making my motor spin as fast as possible
|
Re: Photosensor as encoder for bang bang.
Quote:
With a fresh battery and early in a match without pushing contests and not a lot of motors powered all at once, that's probably fine. The danger is when the robot battery voltage drops below 10.8v (because it's towards the end of a match full of pushing defensive robots or the battery gives out early) the feedback from the sensor can become random. It won 't count correctly. There is an alternate source of guaranteed stable power if you are using a 24v Solenoid Breakout. The sensor can be wired just to an available power pin. |
Re: Photosensor as encoder for bang bang.
can you show or tell me where or what that is that i have to wire it to
|
Re: Photosensor as encoder for bang bang.
For now I'd leave it where it is until you get the code figured out and working correctly.
Are you using solenoids this year? If you are, then are you using 24v solenoid came in the Kit the past couple of years. This year they were offered in FIRST Choice. |
Re: Photosensor as encoder for bang bang.
i have it hooked up and i had just hooked it up to the solenoid breakout card. but not there is no power to the photosensor
|
Re: Photosensor as encoder for bang bang.
NOw i got it to work at 24 volts. Now i need the code to work
|
Re: Photosensor as encoder for bang bang.
I am getting a reeding now of Rpms between 500 to about 3000. But still my motor keeps going very fast
|
Re: Photosensor as encoder for bang bang.
1 Attachment(s)
Quote:
With a 20ms execution rate using counts to read a one-per-rev sensor on a wheel spinning at 2000 rpm, you're going to see a *lot* of noise. |
Re: Photosensor as encoder for bang bang.
The value (10) you put underneath the indicator, what does that number mean exactly.
|
Re: Photosensor as encoder for bang bang.
1 Attachment(s)
here
|
Re: Photosensor as encoder for bang bang.
Quote:
@ Bunniy: Many folks don't use the threaded display and can't tell who you are talking to if you just use the pronoun "you". |
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
@ Ether: Thank you, im new to chief delphi so i dont know this
|
Re: Photosensor as encoder for bang bang.
Quote:
That will provide sufficient context. |
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
2 Attachment(s)
Quote:
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 360CPR 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. |
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
Quote:
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. |
Re: Photosensor as encoder for bang bang.
Quote:
|
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. |
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
1 Attachment(s)
Quote:
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. |
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? |
Re: Photosensor as encoder for bang bang.
Quote:
|
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 |
Re: Photosensor as encoder for bang bang.
1 Attachment(s)
Quote:
|
Re: Photosensor as encoder for bang bang.
Quote:
Quote:
|
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
OMG i finally got it. The encoder reset was my problem. Everything works Perfectly. Thank you everyone
|
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. |
Re: Photosensor as encoder for bang bang.
Quote:
So, is there a chance you can post the final version of the code you are using? Both Begin.vi and the control loop? |
Re: Photosensor as encoder for bang bang.
Quote:
|
Re: Photosensor as encoder for bang bang.
To be sure you should ask Q & A.
Past permissions are not present rules. I don't see any restriction other than R70 Quote:
R66 is a weird one. It says we can't pump 12v into the Breakouts except through the Wago power ports. I wonder who tried to do what? |
| 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