Go to Post Also, if Beatty fielded a refrigerator we'd still pick them; how can you not - "all they ever do is win". - Gary Dillard [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 17-02-2004, 16:01
tml240's Avatar
tml240 tml240 is offline
bahh
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: Ann Arbor, MI
Posts: 63
tml240 is on a distinguished road
sample limit switch code???

anyone got one???
we need it to program our arm
__________________

OHL 2004- ultimate NHL 2004 MOD
  #2   Spotlight this post!  
Unread 17-02-2004, 16:09
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: sample limit switch code???

Im pretty sure the default code already has PWMs and relay outputs that are programmed to stop if certain digital input pins are pulled low by an external switch.

From the top of my head, I think relay out 8 is tied to digital input 16? intended to be used with the compressor and the pressure limit switch? - that would be a good example of how to start.
  #3   Spotlight this post!  
Unread 17-02-2004, 16:17
tml240's Avatar
tml240 tml240 is offline
bahh
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: Ann Arbor, MI
Posts: 63
tml240 is on a distinguished road
Re: sample limit switch code???

we are trying to use limit switch as interrupts... and when the arm hits the switch, it will stop moving, that's our plan
__________________

OHL 2004- ultimate NHL 2004 MOD
  #4   Spotlight this post!  
Unread 17-02-2004, 16:26
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: sample limit switch code???

then you would probably need a single-edge based interrupt pin to determine when the circuit goes from open to closed.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #5   Spotlight this post!  
Unread 17-02-2004, 17:10
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: sample limit switch code???

it would be much simpler to have the line of code that is controlling the motor also look at the limit switch on a digital input pin, instead of using interrupts

this is not really an interrupt application, because you are controlling the motor output on every loop of your code anyway, there is no reason to interrupt the loop when the switch closes - the victors and spikes dont respond that fast.

besides, contact switches bounce when they open and close - which means, instead of simply going from 0 to 1, they go 0000111110011011010101111111111 - so for every switch closure you will see maybe 20 to 100 interrupts within several milliseconds.
  #6   Spotlight this post!  
Unread 17-02-2004, 17:13
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,825
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: sample limit switch code???

Quote:
Originally Posted by tml240
we are trying to use limit switch as interrupts... and when the arm hits the switch, it will stop moving, that's our plan
As Ken mentioned, this section from the FRC default code, user_routines.c, Default_Routine() does what you want. Each of the pwm outputs are stopped by a limit switch in either direction (min, max).
Code:
  /*---------- PWM outputs Limited by Limit Switches  ------------------------*/
  
  Limit_Switch_Max(rc_dig_in05, &pwm03);
  Limit_Switch_Min(rc_dig_in06, &pwm03);
  Limit_Switch_Max(rc_dig_in07, &pwm04);
  Limit_Switch_Min(rc_dig_in08, &pwm04);
  Limit_Switch_Max(rc_dig_in09, &pwm09);
  Limit_Switch_Min(rc_dig_in10, &pwm09);
  Limit_Switch_Max(rc_dig_in11, &pwm10);
  Limit_Switch_Min(rc_dig_in12, &pwm10);
  Limit_Switch_Max(rc_dig_in13, &pwm11);
  Limit_Switch_Min(rc_dig_in14, &pwm11);
  Limit_Switch_Max(rc_dig_in15, &pwm12);
  Limit_Switch_Min(rc_dig_in16, &pwm12);
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
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
Inserting Naviagation code into Default code? actorindp Programming 3 28-01-2004 18:12
Some EDURobotics Problems squide Robotics Education and Curriculum 9 20-01-2004 10:27
I am wondering........... geo Technical Discussion 10 15-04-2002 13:17
Need help with 255 Variable Joseph F Programming 18 26-02-2002 14:49
Error found in programming for the pump and pressure switch sjharobotics Programming 4 06-02-2002 17:46


All times are GMT -5. The time now is 10:38.

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