View Single Post
  #2   Spotlight this post!  
Unread 23-01-2006, 14:06
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: G.T.S ..... (problem)

I assume you're referring to the Gear Tooth Sensor. It sounds like you're having two conceptual difficulties with printing its value.

First, its output is a very short high-going pulse whenever a gear tooth passes the sensor. It's on the order of 40-80 microseconds long. Unless you get extremely lucky, your code is not very likely to read anything other than a 0.

Second, it sounds like you might be trying to use printf with a char. For a couple of technical reasons, that doesn't work exactly the way you want it to. You'll need to cast the value to an int like this:
Code:
  char value = 1;
  ...
  printf ( "value = %d\r", (int)value );
The proper way to read the gear tooth sensor is to have it create an interrupt whenever it emits a pulse, and to use the interrupt service routine to count the pulses.