![]() |
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. |
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. |
Re: Banner Sensor Programming Problem
Quote:
2Crisis, when you printf values, make sure you do it like this: Code:
printf("dig in 1: %d", (int) rc_dig_in01); |
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. :)
|
Re: Banner Sensor Programming Problem
Thanks guys, it works now. I forgot about those unsigned chars :ahh: . 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.
|
| All times are GMT -5. The time now is 11:20. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi