View Single Post
  #11   Spotlight this post!  
Unread 03-05-2008, 21:56
Generalx5's Avatar
Generalx5 Generalx5 is offline
Hard Core Inventor
AKA: Jun(John) Zheng
FRC #1346 (Trobotics)
Team Role: Student
 
Join Date: Nov 2005
Rookie Year: 2004
Location: CANADA
Posts: 94
Generalx5 will become famous soon enough
Re: Automatic counter-Encoder

Part I:

Woah there! Plenty of help, thanks!

As for Kevins code: count = (count + ((dig_in ^ old_dig_in)?1:0))%30;
old_dig_in = dig_in;

Do I simply replace dig_in with rc_dig_in05 for example if im using digital 05 as my input. Will I have to replace old_dig_in with anything or leave it as is....

So everytime I need to call back to find where the count is, I have to refer to using "count"? right? so in the case that count = 25 is true, do this etc etc...if count is 26 do this and so on. Would it be possible to start the count when the switch is either a 0 or a 1? For example, I always want the first number 1 to be when the switch is 1, and then when the switch is 0, that would become 2, if I had to reset, and the current switch is sitting at 0, it would not start the count unless the switch is at 1.

So can someone run this through with me? When the system boots up, what is it doing initially? It has no count to begin with? Does it start counting as soon as it detects that a change has occured?

Could it be made so that initially, if the switch is 0, it would count it as a 1, and when the switch starts with a 1, it would count is as an automatic 2. This way, each 0 that comes back from the switch becomes an odd number, while each 1, is an even number.

If you are wondering what this wheel is, it is actually a motor that I've been making in the shop. its made to track distance covered by the rotations.

Part II:

How do I print the current count in a printf format?

Last edited by Generalx5 : 03-05-2008 at 21:59. Reason: Added part II