View Single Post
  #2   Spotlight this post!  
Unread 10-02-2007, 22:48
Stuart's Avatar
Stuart Stuart is offline
#include coffee.h
FRC #1745 (P51- Mustangs)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Dallas, TX
Posts: 414
Stuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond reputeStuart has a reputation beyond repute
Send a message via AIM to Stuart
Re: How do I program this sensor?

the first thing I would be weary about is the aluminum tape and the sensor. cause if its a magnetic sensor of any sort it wont work(aluminum is non-ferris at room temp)

as far as your code goes.

instead of counting when ever your on the tape or not youll want to count when ever you wernt on the tape and now are(I would suggest a now last variable set up, as in at the top of your code you say now = last; digital_io_04 = now;then for your if you say if (now == 1 && last ==0). otherwise youll get many counts for the same strip of tape.

youll also want to track what direction the motor is turning because if you change direction in the middle of the string youll be on tape 2 and have a count of for. for that I would do an if else for incrementing/decrementing the count based on if the pwm is > or < 127)


also for just style points you might want to but all those if elses in a switch statement.
__________________
Proud mentor of Team #1745 the P-51 Mustangs

If at first it doesn't work, use a hammer.
If that doesn't work, use a bigger hammer.