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)

billbo911 09-02-2013 00:04

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Bunniy (Post 1230296)
here

Bunniy,
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.

Ether 09-02-2013 00:36

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Bunniy (Post 1230296)
here

I would recommend you let the FPGA compute the period in hardware with its 153KHz sampling and 1MHz clock (like Mark showed), instead of doing it in software. There's no need for the IIR filter if you set the proper size for the FPGA's sample ring buffer. If you you need to avoid large current spikes at startup (perhaps to prevent Jags from cutting out), try speed-based throttle limiting instead of time-based slew rate. I would avoid using a Jag for bang-bang because of the startup current spike.



billbo911 09-02-2013 00:50

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Mark McLeod (Post 1230308)
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.

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.

Bunniy 09-02-2013 09:44

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

billbo911 09-02-2013 10:23

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Bunniy (Post 1230406)
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

Start by replacing the "360" in the left side of the periodic tasks with the number of counts you will have from a single rotation of the wheel.
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.

Mark McLeod 09-02-2013 11:05

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by billbo911 (Post 1230339)
Mark, would replacing the "Reset Counter" with a feedback loop and subtracting the previous count from the current count be a more stable option?

A feedback node and subtraction would preserve the integrity of the counter.
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.:)

Ether 09-02-2013 11:40

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.




Bunniy 09-02-2013 13:24

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?

Bunniy 09-02-2013 15:23

Re: Photosensor as encoder for bang bang.
 
where exactly is the FPGA and what does that mean

Ether 09-02-2013 15:38

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Bunniy (Post 1230563)
where exactly is the FPGA and what does that mean

If you use the LabVIEW code that Mark McLeod posted earlier it will use the FPGA.

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.



Mark McLeod 09-02-2013 15:45

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.

Bunniy 09-02-2013 18:09

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

billbo911 10-02-2013 12:38

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.

Bunniy 11-02-2013 13:33

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

Ether 11-02-2013 13:45

Re: Photosensor as encoder for bang bang.
 
Quote:

Originally Posted by Bunniy (Post 1231595)
i pluged in the Photosensor to the FPGA which is the card on the Crio

?? The sensor should be wired to a DIO on the DSC.




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