Go to Post The best way to win an award is to not try to win an award. - MrTechCenter [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 19-03-2008, 21:49
Aerex Aerex is offline
Registered User
FRC #1369 (Minotaur)
Team Role: Programmer
 
Join Date: Mar 2008
Rookie Year: 2004
Location: Tampa
Posts: 9
Aerex is an unknown quantity at this point
Vex Light Sensor on FRC Bot

We tried to use a vex sensor onto our FRC robot to be used to count revolutions by counting a series of alternating black and white tape on a motor. However there is something wrong with my code.

Code:
#include "Main.h"

void Autonomous ( void )
{
      int c = 1; 
      unsigned char light; 
      int a = 0; 
      int b = 0; 
      int value = 0; 

      while ( value <= 5 ) //the transition of White to Black five times
      {
            SetPWM ( 10 , 190 ) ; //
            SetPWM ( 11 , 190 ) ;
            light = GetAnalogInput ( 1 ) ;
            if ( light >= 0 && light <= 99 ) //interval of white (Bright)
            {
                  a = 1 ;
                  PrintToScreen ( "a: %d\n" , (int)a ) ;
                  PrintToScreen ( "Light: %d\n" , (int)light ) ;
            }
            if ( light > 99 ) //interval of black (Dark)
            {
                  b = 1 ;
            }
            if ( a == 1 && b == 1 )
            {
                  value++ ; //problem starts here
                  a =0 ;
                  b = 0 ;
            }
      }
      SetPWM ( 10 , 127 ) ;
      SetPWM ( 11 , 127 ) ;
}
At the incremental of the variable value the RC begins to count continously up to five at the first instance and then it stops. I want it to only increment the variable value one at a time so that I can see a smooth transition. I started to believe that the vex light sensor is not capable to be used for FRC. Anyone know the problem or should I just use at gear tooth sensor. I appreciate the response.
  #2   Spotlight this post!  
Unread 20-03-2008, 09:20
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Vex Light Sensor on FRC Bot

Did you look at the analog output in the online window? Are you using the light sensor or the line following sensor? I believe the line following sensor would work better for the task you are looking for. Both work with FRC as they are just analog sensors.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #3   Spotlight this post!  
Unread 20-03-2008, 13:21
Dad1279 Dad1279 is offline
Registered User
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: NJ
Posts: 511
Dad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud of
Re: Vex Light Sensor on FRC Bot

I think you would find that a sensor using uses digital inputs and interrupt routines, like the gear-tooth sensor, more reliable.

I am not familiar with the vex light sensor, however we had success in the past with a Banner light sensor (digital output) that was included in the prior year KOP. (2004/5?)
  #4   Spotlight this post!  
Unread 20-03-2008, 14:10
Aerex Aerex is offline
Registered User
FRC #1369 (Minotaur)
Team Role: Programmer
 
Join Date: Mar 2008
Rookie Year: 2004
Location: Tampa
Posts: 9
Aerex is an unknown quantity at this point
Re: Vex Light Sensor on FRC Bot

Yes it is the line following sensor and yes I did look at the terminal window however, I feel that the transition between bright to dark can not be accurately be determined with the vex line following sensor. I believe our banner light sensor from years past cannot be located so it won't do me any good as of now.
__________________
Myspace/Facebook + Academics = NoobsHelp.com
  #5   Spotlight this post!  
Unread 20-03-2008, 15:46
Dad1279 Dad1279 is offline
Registered User
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: NJ
Posts: 511
Dad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud of
Re: Vex Light Sensor on FRC Bot

Looking at the specs for the Vex line following sensor: http://www.vexlabs.com/docs/inventor...wer-5-1-06.pdf

It uses IR, probably not desirable to use this year, considering all of the potential interference from remote controls and lap counters.

Can you describe the motor or mechanism you want to count RPMs?

Edit: I also notice that the sensor should be very close to the tape. 1/8" and from the spec sheet:
Because the line follower uses an infrared LED to illuminate its target
and an infrared sensor to detect the reflected light, it will actually
work in low-light conditions or even in the dark! However, this
also means that it can easily become saturated — in other words,
everything will look white to it, like an over-exposed photograph — in
environments where there is a lot of infrared radiation. You’ll find
environments like this in competition settings where tungsten lights are
used for illumination. To avoid saturating the infrared sensor,
consider mounting it underneath the robot or adding a cardboard
shield to block ambient radiation.

Last edited by Dad1279 : 20-03-2008 at 15:51.
  #6   Spotlight this post!  
Unread 20-03-2008, 22:18
Aerex Aerex is offline
Registered User
FRC #1369 (Minotaur)
Team Role: Programmer
 
Join Date: Mar 2008
Rookie Year: 2004
Location: Tampa
Posts: 9
Aerex is an unknown quantity at this point
Re: Vex Light Sensor on FRC Bot

I apprecitate I just realized today that the sensor uses IR, so I will consider using some sort of border like the cardboard to protect it from other IR frequencies from reaching it. Today I figured out the problem with my code and it seems that I had to nest an if statement to compensate with the transition between a dark to bright color (black to white).

Code:
if ( light >= 1 && light <= 99 ) //interval of white (Bright)
            {
        light = getAnalogInput(1);
     if (light > 99){
a = 1;
}
                  PrintToScreen ( "a: %d\n" , (int)a ) ;
                  PrintToScreen ( "Light: %d\n" , (int)light ) ;
            }
            if ( light > 99 ) //interval of black (Dark)
            {
 light = getAnalogInput(1);
if (light <= 1 && light <= 99){
                  b = 1 ;
            }
}
            if ( a == 1 || b == 1 )
            {
                  value++ ;
                  a =0 ;
                  b = 0 ;
            }
Now instead of counting RPM, I made so that a certain distance equals one count. Take for example that it takes 10 inches for one round of spins of the motor. If I want to go 20 inches all I would need to do is execute this process twice. I want to know if this idea is pratical to use. I plan on getting the correct measurements at competition.
__________________
Myspace/Facebook + Academics = NoobsHelp.com
  #7   Spotlight this post!  
Unread 20-03-2008, 22:31
thefro526's Avatar
thefro526 thefro526 is offline
Mentor for Hire.
AKA: Dustin Benedict
no team (EWCP, MAR, FRC 708)
Team Role: Mentor
 
Join Date: Aug 2006
Rookie Year: 2005
Location: New Jersey
Posts: 2,599
thefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond repute
Send a message via AIM to thefro526 Send a message via MSN to thefro526
Re: Vex Light Sensor on FRC Bot

We found that when using a Vex Line Following Sensor on An FRC bot it is much easier to use it as a digital input. Assuming you are using Black and White you will either get a 0 for black and a 1 for white or vice versa.

On another note if the IR sensor is about 3 inches away form our lap counter how much interference will it receive? I think I might just put some cardboard around it on all sides to be safe.
__________________
-Dustin Benedict
2005-2012 - Student & Mentor FRC 816
2012-2014 - Technical Mentor, 2014 Drive Coach FRC 341
Current - Mentor FRC 2729, FRC 708
  #8   Spotlight this post!  
Unread 20-03-2008, 22:49
thefro526's Avatar
thefro526 thefro526 is offline
Mentor for Hire.
AKA: Dustin Benedict
no team (EWCP, MAR, FRC 708)
Team Role: Mentor
 
Join Date: Aug 2006
Rookie Year: 2005
Location: New Jersey
Posts: 2,599
thefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond reputethefro526 has a reputation beyond repute
Send a message via AIM to thefro526 Send a message via MSN to thefro526
Re: Vex Light Sensor on FRC Bot

I just tested some Vex Sensors with some remotes and found that if used as a digital input the number will fluctuate rapidly between 1 and 0 when directly exposed. this goes away after about 2 feet or so. When used as an analog input the number still changes but not as rapidly.

Btw I used a universal remote setup for a magnavox, a samsung remote, and a comcast remote
__________________
-Dustin Benedict
2005-2012 - Student & Mentor FRC 816
2012-2014 - Technical Mentor, 2014 Drive Coach FRC 341
Current - Mentor FRC 2729, FRC 708
  #9   Spotlight this post!  
Unread 20-03-2008, 23:00
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 7,019
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Vex Light Sensor on FRC Bot

Quote:
Originally Posted by Aerex View Post
Take for example that it takes 10 inches for one round of spins of the motor. If I want to go 20 inches all I would need to do is execute this process twice. I want to know if this idea is pratical to use. I plan on getting the correct measurements at competition.
That will work, but everything has to be in increments of (10"), so if you wanted to go 155 inches, you need to choose 150 or 160. This may or may not be a problem for you.

In our robot, we use a gear tooth sensor and can count to a fraction of an inch instead of a fraction of a foot.

Don
__________________

I am N2IRZ - What's your callsign?
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Light Sensor Filter dasmoenator Programming 2 21-11-2007 23:49
Moving bot once targeted on the light bronxbomber92 Programming 10 30-01-2007 12:33
Vex Light Sensor Robots_R_Us Technical Discussion 2 11-08-2006 18:24
Light Sensor Type, Please Help! Alexander McGee Electrical 7 20-11-2004 21:48
How do light sensor(Banner) work? roberthan Programming 9 25-02-2004 14:05


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

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