Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx

Ads

Discussion Groups

Discussion Groups | Piclist | Input problem

A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.

Input problem - wdavis364 - Nov 27 13:54:00 2005

I'm using pic 819 to control a stepper motor driver(mainly pulse and
direction.
RA0= ADC
RA1= forward (faster pulse rate)
RA2= reverse (faster pules rate)
Both RA1 and RA2 delivers pulse rate when pulled high.

The problem I'm having is when powered up it takes off in the fast
forward rate. When I press the buton switch it moves to adc(which it
should do without pressing any of the two button switches.
I can however, while it is running in the fast forward rate, press
the reverse button and it will run in the reverse mode. I'm not
understanding this since when either one of these button are pushed
it goes into into a continuous loop until the button is release and
if no buttons are pressed it goes into ADC mode. (or it did until I
came up this problem).
I've ran out of ideas to look for this problem and I hoping maybe
someone might give me some insight as to what might the problem may
be.
Both RA1 and RA2 are wired in the same way with same type switches.
When I power up I get neg output at Pin RA2 and pos at Pin RA1.
I'm using cc5x following is the Main function.
thanks
bill davis

void main( void)
{
TRISA = 0b00001111; //all inputs
TRISB = 0b00000000; //All outputs
PORTB = 0b00000000; //Init all as low when power on.
PORTA = 0b00000000;
OPTION = 2;
int i;
while (i){
if (PORTA.1 == 1)fastfor ();//0B00000010
else if (PORTA.2 == 1) fastrev ();//0B00000100

A2D ();

}
}




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )


Re: Input problem - rtstofer - Nov 27 15:05:00 2005


Bill,

A couple of things: First, 'i' isn't initialized. If the compiler
initializes it, it will be zero and your loop won't execute at all.

Second, if your switches are wired 'normally', you have pull up
resistors on the pins and the switch pulls the pin to ground. If
this is the case, when a switch is pressed, the input is zero. A
test like:

if (PORTA.1 == 0)
fastfor ();
else if (PORTA.2 == 0)
fastrev();

or:

if (! PORTA.1)
fastfor();
else if (! PORTA.2)
fastrev();

might be more appropriate.

Richard

--- In piclist@picl..., "wdavis364" <wdavis@g...> wrote:
>
> I'm using pic 819 to control a stepper motor driver(mainly pulse
and
> direction.
> RA0= ADC
> RA1= forward (faster pulse rate)
> RA2= reverse (faster pules rate)
> Both RA1 and RA2 delivers pulse rate when pulled high.
>
> The problem I'm having is when powered up it takes off in the fast
> forward rate. When I press the buton switch it moves to adc(which
it
> should do without pressing any of the two button switches.
> I can however, while it is running in the fast forward rate, press
> the reverse button and it will run in the reverse mode. I'm not
> understanding this since when either one of these button are
pushed
> it goes into into a continuous loop until the button is release
and
> if no buttons are pressed it goes into ADC mode. (or it did until
I
> came up this problem).
> I've ran out of ideas to look for this problem and I hoping maybe
> someone might give me some insight as to what might the problem
may
> be.
> Both RA1 and RA2 are wired in the same way with same type switches.
> When I power up I get neg output at Pin RA2 and pos at Pin RA1.
> I'm using cc5x following is the Main function.
> thanks
> bill davis
>
> void main( void)
> {
> TRISA = 0b00001111; //all inputs
> TRISB = 0b00000000; //All outputs
> PORTB = 0b00000000; //Init all as low when power on.
> PORTA = 0b00000000;
> OPTION = 2;
> int i;
> while (i){
> if (PORTA.1 == 1)fastfor ();//0B00000010
> else if (PORTA.2 == 1) fastrev ();//0B00000100
>
> A2D ();
>
> }
> }




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: Re: Input problem - Bill Davis - Nov 27 22:18:00 2005

Rick, thanks for the reply. The int i: was for something else. The while instruction did have 1, I must of changed it to i for reasons unknown to me. I must be getting too old and lame brain.
thanks for the help
bill
----- Original Message -----
From: rtstofer
To: p...@yahoogroups.com
Sent: Sunday, November 27, 2005 1:05 PM
Subject: [piclist] Re: Input problem


Bill,

A couple of things:  First, 'i' isn't initialized.  If the compiler
initializes it, it will be zero and your loop won't execute at all.

Second, if your switches are wired 'normally', you have pull up
resistors on the pins and the switch pulls the pin to ground.  If
this is the case, when a switch is pressed, the input is zero.  A
test like:

if (PORTA.1 == 0)
fastfor ();
else if (PORTA.2 == 0)
fastrev();

or:

if (! PORTA.1)
fastfor();
else if (! PORTA.2)
fastrev();

might be more appropriate.

Richard

--- In p...@yahoogroups.com, "wdavis364" <wdavis@g...> wrote:
>
> I'm using pic 819 to control a stepper motor driver(mainly pulse
and
> direction.
> RA0= ADC
> RA1= forward (faster pulse rate)
> RA2= reverse (faster pules rate)
> Both RA1 and RA2 delivers pulse rate when pulled high.
>
> The problem I'm having is when powered up it takes off in the fast
> forward rate. When I press the buton switch it moves to adc(which
it
> should do without pressing any of the two button switches.
> I can however, while it is running in the fast forward rate, press
> the reverse button and it will run in the reverse mode. I'm not
> understanding this since when either one of these button are
pushed
> it goes into into a continuous loop until the button is release
and
> if no buttons are pressed it goes into ADC mode. (or it did until
I
> came up this problem).
> I've ran out of ideas to look for this problem and I hoping maybe
> someone might give me some insight as to what might the problem
may
> be.
> Both RA1 and RA2 are wired in the same way with same type switches.
> When I power up I get neg output at Pin RA2 and pos at Pin RA1.
> I'm using cc5x following is the Main function.
> thanks
> bill davis
>
> void main( void)
> {
>  TRISA = 0b00001111; //all inputs
>  TRISB = 0b00000000; //All outputs
>   PORTB = 0b00000000; //Init all as low when power on.
>   PORTA = 0b00000000;
>    OPTION = 2;
> int i;
> while (i){
> if (PORTA.1 == 1)fastfor ();//0B00000010
> else if (PORTA.2 == 1) fastrev ();//0B00000100
>
> A2D ();
>
> }
> }




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )