Go to Post You should take in to consideration who you are putting on to the field, not what. - NorviewsVeteran [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 18-02-2007, 23:19
magical hands magical hands is offline
Jigar Patel
AKA: Jigar Patel
FRC #2185 (Etobicoke CI)
Team Role: Mentor
 
Join Date: Dec 2003
Rookie Year: 2004
Location: TORONTO
Posts: 93
magical hands is on a distinguished road
Gear Tooth Code

Can someone tell me why this code wouldn't work for Gear Tooth Sensor. To me it makes sense because its connected to digital input and it only gives 0 or 1 based on the voltage (5v).

int i = 0;

If (rc_dig_in01 == 1) //Gear Tooth Attached to dig_input 1
{
i++; // Gear Counter
printf("Gear counter=%d\r\n", i);
}
  #2   Spotlight this post!  
Unread 19-02-2007, 00:05
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,112
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: Gear Tooth Code

That code continuously increments a value whenever the Gear Tooth Sensor is high. It won't work because it doesn't count the number of times the signal from the Gear Tooth Sensor goes high.

If the signal is slow enough, you can poll it and count low-to-high transitions. Just remember the previous state of the pin, and if it was a zero last time but is a one this time, increment the counter. However, if the signal changes so quickly that you can't guarantee you'll be reading it often enough, you'll need to use the hardware interrupt feature of the RC's first few digital input pins.
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
Gear Tooth Sensor Zoom Programming 46 22-01-2008 08:05
24 Tooth Gear Sprocket daviamp General Forum 4 29-01-2007 00:04
Gear Tooth Sensor nukem Programming 9 04-02-2006 20:21
Gear Tooth Sensor Talha Electrical 1 23-01-2006 21:29
LabView Gear Tooth Sensor Code SkiRacer LabView and Data Acquisition 2 17-01-2006 03:53


All times are GMT -5. The time now is 13:15.

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