Go to Post Ok maybe you cant stop them, but you can utilize that pretty flashing LED pretty darn well! - Andy Grady [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 31-01-2008, 21:35
Neurovirus Neurovirus is offline
Registered User
FRC #0224
 
Join Date: Jan 2008
Location: Piscataway
Posts: 13
Neurovirus is an unknown quantity at this point
Red face Interrupts, limit switches, and IR board

For easyC Pro,

how can u get it, so that when the limit switch is pressed and outputting a 1 to the microcontroller, to stop the motor?
Right now I have

Set PWM3 to 195

Get Interrupt

Set PWM3 to 127

which doesn't even make the motor move, at all....

Also, I would like to know how to use the IR board. I'm guessing you'll have to use the interrupt block, which i don't even know how to use.

In the end, I need someone to explain the following:

-limit switch, implementing it with easyC
-the whole Interrupt block, what it exactly does, how can i make it to control a PWM output
- IR board, tho I think if i know how the interrupt block works, I could figure this out on my own
  #2   Spotlight this post!  
Unread 31-01-2008, 22:12
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 7,011
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Interrupts, limit switches, and IR board

An interrupt is just what it says: The processor interrupts what it was doing and does whatever the interrupt routine says until the interrupt is cleared. So, interrupts are usually saved for stuff that happens so quick a normal loop might miss it.

For a limit switch, you don't usually need an interrupt.

Same for the IR board. Your loop is something like 26 milliseconds, the IR board puts out a 100 millisecond pulse, that means you can see the IR board signal at least three times before it goes away.

If the limit switch is being pressed for less than 26 mSec, maybe use an interrupt, but if not...


Just use a digital input, but remember that the input pin is pulled high (+5v weakly inside the RC, so what you need to do is connect the switch to ground on one side and the digital input pin on the other side. Also make sure the digital pin you use is really set up as an INPUT, not an output. (I also read that you need to enable the pull-up resistor, but I don't know enough to explain how, or if).

Don
__________________

I am N2IRZ - What's your callsign?
  #3   Spotlight this post!  
Unread 31-01-2008, 22:59
GRS GRS is offline
Registered User
FRC #1764
 
Join Date: Jan 2008
Location: KC, MO
Posts: 34
GRS is an unknown quantity at this point
Re: Interrupts, limit switches, and IR board

Quote:
Originally Posted by Neurovirus View Post
For easyC Pro,

how can u get it, so that when the limit switch is pressed and outputting a 1 to the microcontroller, to stop the motor?
Right now I have

Set PWM3 to 195

Get Interrupt

Set PWM3 to 127

which doesn't even make the motor move, at all....

Also, I would like to know how to use the IR board. I'm guessing you'll have to use the interrupt block, which i don't even know how to use.

In the end, I need someone to explain the following:

-limit switch, implementing it with easyC
-the whole Interrupt block, what it exactly does, how can i make it to control a PWM output
- IR board, tho I think if i know how the interrupt block works, I could figure this out on my own
Are you sure that the limit switch is giving its signal to the RC?
  #4   Spotlight this post!  
Unread 14-02-2008, 20:06
EricWilliams EricWilliams is offline
Registered User
FRC #2039 (Rockford Robotics)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2001
Location: Rockford, IL
Posts: 103
EricWilliams is a glorious beacon of lightEricWilliams is a glorious beacon of lightEricWilliams is a glorious beacon of lightEricWilliams is a glorious beacon of lightEricWilliams is a glorious beacon of lightEricWilliams is a glorious beacon of light
Re: Interrupts, limit switches, and IR board

Quote:
Originally Posted by Don Rotolo View Post
Just use a digital input, but remember that the input pin is pulled high (+5v weakly inside the RC, so what you need to do is connect the switch to ground on one side and the digital input pin on the other side. Also make sure the digital pin you use is really set up as an INPUT, not an output. (I also read that you need to enable the pull-up resistor, but I don't know enough to explain how, or if).

Don
If the input pin is pulled high internally, the circuit inside the RC already HAS a pull-up resistor.
  #5   Spotlight this post!  
Unread 15-02-2008, 11:56
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: Interrupts, limit switches, and IR board

There are two sources of the pullups - one inside the chip for PORTB pins (digital inputs 1-6), and the other within the IFI black robot controller case for digital inputs 7-18.

See IFI diagram for controller pullup information.

Code:
PORTB is a bidirectional I/O port. PORTB can be software
programmed for internal weak pull-ups on all inputs.
DS39646B-page 15


bit 7 RBPU: PORTB Pull-up Enable bit
1 = All PORTB pull-ups are disabled
0 = PORTB pull-ups are enabled by individual port latch values

DS39646B-page 122
So if !RPBU is asserted (0) AND the PORTB input pin is configured as input, then a weak pullup resistor to +5V is enabled on-chip for the robot controller's digital inputs 1-6.

The other digital lines 7-18 always have a 100k pullup supplied by IFI whether input or output.

The internal PORTB pullups are enabled within the code build environments by default. In IFI file ifi_library.c:

Code:
Initialize_Registers()
:
.
  TRISH = 0xFF;
  ADCON1 = 0x00;          /*all analog inputs; no digital*/
  INTCON2bits.NOT_RBPU = 0;  /*enable PORTB pull-ups (for bootloader interrupt)*/
  PSPCONbits.PSPMODE = 0;
  MEMCONbits.EBDIS = 1;   /*use PORTD for I/Os, not for external memory interface*/
The other resistors/capcitors shown; 1k/0.001uf on 1-6 and 680/0.01uf on lines 7-18 are passive RC networks to help reduce/eliminate input glitches seen on these lines due to noise and make/break actions of mechanical switches (i.e. to de-bounce inputs).

RC Networks effectively act as a time delay for the signal/signal change.

Attached is a schematic of a typical limit switch input into the robot controller.
Attached Thumbnails
Click image for larger version

Name:	limitswitch.JPG
Views:	56
Size:	26.1 KB
ID:	6274  

Last edited by dcbrown : 15-02-2008 at 12:12.
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
Limit Switches ChrisR_522 Programming 2 25-01-2008 08:04
Limit Switches help Ianuser Programming 7 12-02-2007 23:36
limit switches stephenthe1 Programming 28 11-05-2005 16:37
Limit switches Team168 Programming 8 10-02-2003 16:22
Limit Switches/Pots Brett W Technical Discussion 3 28-01-2003 14:25


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

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