|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Strange gear tooth sensor port issue
After a battle with a broken gear tooth sensor, we finally have two sensors working. Good.
We're using MPLab and WPILib, which is nice. However, the problem is that the GetGTSensor code doesn't seem to work as advertised. The sensors are on ports 1 and 2 of the digital inputs. StartGTSensor(1,0) and StartGTSensor(2,0) work. However (and this is the weird bit), the values for GT 1 must be retrieved with GetGTSensor(2) and the values for GT 2 must be retrieved with GetGTSensor(4). Even odder, if StartGTSensor is used with an invert value of 1, GetGTSensor(1) will return -1 once the gear on port 1 starts moving, and GetGTSensor(3) will return -1 once the gear on port 2 starts moving. What's going on here? Regards, -scott |
|
#2
|
||||
|
||||
|
Re: Strange gear tooth sensor port issue
When you say get GTsensor code, is that kevin's code, or your own?
What project are you using? If it is your code, can you show us it? |
|
#3
|
||||
|
||||
|
Re: Strange gear tooth sensor port issue
WPILib's "GetGTSensor" routine, from the latest release of WPILib.
The code is simply this: void main(void) { StartGTSensor(1, 0); StartGTSensor(2, 0); while (1) { printf("1: %d 2: %d 3: %d 4: %d\n", GetGTSensor(1), GetGTSensor(2), GetGTSensor(3), GetGTSensor(4)); } } The gear tooth sensors are plugged into ports 1 and 2. Output: 1: 0 2: <port 1 output> 3: 0 4: <port 2 output> ... If I invert instead: StartGTSensor(1, -1); StartGTSensor(2, -1); then I see this: 1: -1 2: <port 1 output> 3: -1 4: <port 2 output> ... Regards, -scott |
|
#4
|
|||||
|
|||||
|
Re: Strange gear tooth sensor port issue
Quote:
If this is the case, you can correct the problem either by printing the values using %ld, or by casting them as (int). |
|
#5
|
||||
|
||||
|
Re: Strange gear tooth sensor port issue
Oh, jeez. For some reason I thought that function returned int.
Yes, that probably explains it. Thanks. Regards, -scott, who apparently has been programming in Java for far too long. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Gear Tooth Sensor | marco_alchemy | Electrical | 7 | 06-02-2008 09:54 |
| Gear Tooth Sensor | Nathan | Programming | 4 | 12-01-2008 15:09 |
| Gear Tooth Sensor? | Raikon | Kit & Additional Hardware | 3 | 09-02-2007 16:40 |
| Gear Tooth Sensor | nukem | Programming | 9 | 04-02-2006 20:21 |
| Gear Tooth Sensor | Talha | Electrical | 1 | 23-01-2006 21:29 |