Go to Post I just got pwned by Dave...how awesome is that?! - Tetraman [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-02-2004, 19:02
2Crisis's Avatar
2Crisis 2Crisis is offline
Blaarg
AKA: Dave L
#1343
Team Role: Webmaster
 
Join Date: Jan 2004
Location: Phoenix, Az
Posts: 7
2Crisis is an unknown quantity at this point
Send a message via AIM to 2Crisis
Question Banner Sensor Programming Problem

I am having some trouble with the Banner Sensors (for detecting the white reflective line). We have the Banner Sensors wired up as I have read here in the forums (white OR black for Data on RC, blue for ground, brown for +). We currently have 2 Sensors: Sensor #1 is plugged into RC Digital IO port 1, and Sensor #2 is plugged into RC Digital IO port 18 (we have to use port 1 and 18 because our pin-wire connector is too fat on one side). When we power on the robot (and neither banner sensor detects anything), rc_dig_in01 broadcasts 257, and rc_dig_in18 broadcasts 0. If Sensor #1 detects something, rc_dig_in01 accordingly broadcasts 1. However, if Sensor #2 detects something, instead of changing rc_dig_in18 to 1, it changes rc_dig_in01 to 256, and rc_dig_in18 stays at 0. rc_dig_in18 is ALWAYS broadcasting zero! If both sensors detect something, then rc_dig_in01 broadcasts 0. I'm fairly certain this is a programming problem, but I am lost. I have 'rc_dig_in18 = INPUT' set in the User_Initialization() function, but can rc_dig_in18 not be programmed for Input? In the default_routine, it reads

relay8_fwd = !rc_dig_in18; /* Power pump only if pressure switch is off. */

So, what's going on? Can rc_dig_in18 only be used for some kind of pressure switch? I'm lost.
  #2   Spotlight this post!  
Unread 23-02-2004, 19:16
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: Banner Sensor Programming Problem

Im more lost than you are - a digital input should only be able to give a value of 1 or 0

I have no idea how you are getting 256 or all those other values from a single bit pin

try searching your code on the variable names - maybe there is a stray equation someplace that is setting the bit variables to something else?

this is really strange.
  #3   Spotlight this post!  
Unread 23-02-2004, 21:08
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Banner Sensor Programming Problem

Quote:
Originally Posted by KenWittlief
Im more lost than you are - a digital input should only be able to give a value of 1 or 0

I have no idea how you are getting 256 or all those other values from a single bit pin

try searching your code on the variable names - maybe there is a stray equation someplace that is setting the bit variables to something else?

this is really strange.
the input you he's getting on rc_dig_in01 is actually 0 and 1, but it's being printf'd without being cast to an int - thus, the unsigned char value is being taken along with a second byte of padding, thus 0 + 256 = 256, and 1 + 256 = 257.

2Crisis, when you printf values, make sure you do it like this:

Code:
printf("dig in 1: %d", (int) rc_dig_in01);
make sure you have the banners wired correctly - the blue and brown wires for both sensors should be hooked up to a 20 amp fuse on your fuse panel, and either the white or the black wire (the same color for both sensors) should be hooked up to the SIG pin of the digital input port.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #4   Spotlight this post!  
Unread 23-02-2004, 21:37
ZZII 527's Avatar
ZZII 527 ZZII 527 is offline
"Scale Electric Vehicle"
AKA: Shane Colton
FRC #0097
Team Role: College Student
 
Join Date: Feb 2004
Rookie Year: 2003
Location: Cambridge, MA
Posts: 366
ZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond repute
Send a message via AIM to ZZII 527
Re: Banner Sensor Programming Problem

We had a similar problem...in fact, it was exactly the same. We were getting 257 also and wondering how that was possible. Well, turns out the sensors were working fine, it was just printing the wrong numbers, if that is possible. Try printf-ing one at a time. I'm sure there is an explanation, I just have no idea what it is.
__________________
MIT Mechanical Engineering
>> College Mentor, Team 97: Cambridge Rindge and Latin School with The Edgerton Center, MIT Mechanical Engineering, Bluefin Robotics, and Draper Laboratory
>> Alumnus, Team 527: Plainedge HS
  #5   Spotlight this post!  
Unread 24-02-2004, 13:40
2Crisis's Avatar
2Crisis 2Crisis is offline
Blaarg
AKA: Dave L
#1343
Team Role: Webmaster
 
Join Date: Jan 2004
Location: Phoenix, Az
Posts: 7
2Crisis is an unknown quantity at this point
Send a message via AIM to 2Crisis
Re: Banner Sensor Programming Problem

Thanks guys, it works now. I forgot about those unsigned chars . When the #2 Sensor was plugged into rc_dig_in18, it still broadcasted a constant zero no matter what I did, so we soldered on new ends, and moved it to a different IO port... it now works correctly.
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
Victor problem Andy Baker Electrical 15 24-06-2003 09:49
Ok one problem cantwell03 Programming 3 13-02-2003 07:28
The problem with scouting... archiver 2001 10 23-06-2002 23:49
joystick problem archiver 2000 12 23-06-2002 23:08
Major problem with chipphua motors aka Scott White Motors 18 19-03-2002 19:44


All times are GMT -5. The time now is 11:20.

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