Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Interrupts, limit switches, and IR board (http://www.chiefdelphi.com/forums/showthread.php?t=63005)

Neurovirus 31-01-2008 21:35

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

DonRotolo 31-01-2008 22:12

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

GRS 31-01-2008 22:59

Re: Interrupts, limit switches, and IR board
 
Quote:

Originally Posted by Neurovirus (Post 689855)
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?

EricWilliams 14-02-2008 20:06

Re: Interrupts, limit switches, and IR board
 
Quote:

Originally Posted by Don Rotolo (Post 689891)
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.

dcbrown 15-02-2008 11:56

Re: Interrupts, limit switches, and IR board
 
1 Attachment(s)
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.


All times are GMT -5. The time now is 23:51.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi