Go to Post There are few times I sleep so soundly as I do after an FRC build season and regional. - JamesCH95 [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 10-02-2007, 23:24
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,721
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: How do I program this sensor?

To clarify, this is a continuous loop of rope and you're only ever running the motor in one direction, correct? There's a few problems in your code. It will compile, but probably won't do what you think. I can't comment on whether it will work in your application cause I can't quite decipher what your apparatus is doing. Here's what I've noticed:

1. You mean rc_dig_in04, NOT, digital_io_04. You use digital_io_04 to define port 4 as an output or input. once you've defined it as an input, you read its value from rc_dig_in04.
2. I think you're going to want to wrap your entire bit of code there in an if(pwm03 != 127) statement. If you don't, your code will be counting up as long as rc_dig_in04 is 1. Even if the motor isn't running and just sitting there.
3. I don't think you want this in Process_Data_From_Local_IO. Unless you're pretty certain about the output of the sensor, you might have to deal with a "bouncing" issue where the input value bounces between 0 and 1 as the sensor decides whether it sees something or not. Process_Data_From_Local_IO loops fast enough that it might get confused. Aside from which, changing the pwm03 value won't have any effect until the next time your Default_Routine runs anyways, so I'd put all of this in there.
4. After you set pwm03 to 127, the tape is still sitting in the sensor, and the sensor is still reading 1. So when you start up the motor again, the sensor will still say 1, and you'll instantly stop. You should add in code that waits until rc_dig_in04 goes back to 0 before you start checking for it to be 1 again.
5. Finally, your giant if-else chain for count is really tailor made for for a switch-case statement. You might want to change it to that to simplify your code a bit.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
 


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
Vex line follower sensor kit program jbill30 Programming 5 12-05-2006 14:43
What's happening to this program??? Weightmn General Forum 22 04-04-2005 15:40
TI Pressure Sensor this year? kmcclary Pneumatics 1 20-01-2005 20:53
This board is quiet-- so how bout this election?!?!? archiver 2000 19 24-06-2002 00:23
How do you connect optical sensor? archiver 2001 1 23-06-2002 23:05


All times are GMT -5. The time now is 00:20.

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