|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Encoder Problemo
Help! It's not displaying the data frrom the encoders. Please any help would be appreciated asap
we checked the encoders and they are wired correctly. we are trying to print the functions which should return the values in the code. Thank you. |
|
#2
|
|||
|
|||
|
Re: Encoder Problemo
Are you sure you followed all the steps in the encoder readme for enabling the encoders? I.E. uncommenting the #defines in encoders.h to enable the encoders?
|
|
#3
|
||||
|
||||
|
Re: Encoder Problemo
Yes we followed the readme and are still getting zero
Yes I am on cgront's team |
|
#4
|
||||
|
||||
|
Re: Encoder Problemo
Do we have to call an encoder function after initialization?
if so Where? |
|
#5
|
||||
|
||||
|
Re: Encoder Problemo
somebody please respond to this please
![]() |
|
#6
|
||||
|
||||
|
Re: Encoder Problemo
We need help!
![]() |
|
#7
|
|||
|
|||
|
Re: Encoder Problemo
posting the code that isn't working is always a good way to get help.
|
|
#8
|
||||
|
||||
|
Re: Encoder Problemo
we can not because its the whole project.
|
|
#9
|
|||
|
|||
|
Re: Encoder Problemo
How are you getting the data out of Kevin's variables? Do you just have a printf grabbing it out? Or do you hand it to one of your variables and then printf? How do you know it's really zero? Did you do the printf right? I messed up and spent two days futzing with encoders when the problem was in a printf call once.
Can you try to show me the parts of the code where the Encoders are dealt with? Forget Kevin's code, show me what you did? Ari. |
|
#10
|
||||
|
||||
|
Re: Encoder Problemo
first of all did you make that function or did you add an exsiting function to the program your making are you getting an linking error or what maybe the globals are wrong
(are you using easyc) |
|
#11
|
|||
|
|||
|
Re: Encoder Problemo
Did you remember to #include <stdio> ? Did you do something like:
int myVar = 0; printf("This is %d",myVar); ? |
|
#12
|
||||
|
||||
|
Re: Encoder Problemo
In encoder.h, we modified it to have the digital imputs 12 and 13 for encoders 1 and 2.
From encoder.h: Code:
#ifndef _encoder_h #define _encoder_h #define ENABLE_ENCODER_1 //right #define ENABLE_ENCODER_2 //left #define ENCODER_1_PHASE_B_PIN rc_dig_in12 //right #define ENCODER_2_PHASE_B_PIN rc_dig_in13 //left #define ENCODER_1_TICK_DELTA 1 #define ENCODER_2_TICK_DELTA 1 Code:
#pragma code
//#pragma interruptlow InterruptHandlerLow save=PROD,section(".tmpdata")
#pragma interruptlow InterruptHandlerLow save=PROD //encoder
void InterruptHandlerLow (void)
{
unsigned char int_byte;
unsigned char Port_B;//encoder
unsigned char Port_B_Delta;//encoder
if (PIR1bits.RC1IF && PIE1bits.RC1IE) // rx1 interrupt?
{
#ifdef ENABLE_SERIAL_PORT_ONE_RX
Rx_1_Int_Handler(); // call the rx1 interrupt handler (in serial_ports.c)
#endif
}
else if (PIR3bits.RC2IF && PIE3bits.RC2IE) // rx2 interrupt?
{
#ifdef ENABLE_SERIAL_PORT_TWO_RX
Rx_2_Int_Handler(); // call the rx2 interrupt handler (in serial_ports.c)
#endif
}
else if (PIR1bits.TX1IF && PIE1bits.TX1IE) // tx1 interrupt?
{
#ifdef ENABLE_SERIAL_PORT_ONE_TX
Tx_1_Int_Handler(); // call the tx1 interrupt handler (in serial_ports.c)
#endif
}
else if (PIR3bits.TX2IF && PIE3bits.TX2IE) // tx2 interrupt?
{
#ifdef ENABLE_SERIAL_PORT_TWO_TX
Tx_2_Int_Handler(); // call the tx2 interrupt handler (in serial_ports.c)
#endif
}
else if(PIR1bits.TMR2IF && PIE1bits.TMR2IE) // timer 2 interrupt?
{
PIR1bits.TMR2IF = 0; // clear the timer 2 interrupt flag [92]
Timer_2_Int_Handler(); // call the timer 2 interrupt handler (in adc.c)
}
else if(PIR1bits.ADIF && PIE1bits.ADIE) // ADC interrupt
{
PIR1bits.ADIF = 0; // clear the ADC interrupt flag
ADC_Int_Handler(); // call the ADC interrupt handler (in adc.c)
}
else if(INTCON3bits.INT2IF && INTCON3bits.INT2IE) /* The INT2 pin is RB2/DIG I/O 1. */
{
INTCON3bits.INT2IF = 0;
// printf("Left Interrupt hit\r");
// Left_Encoder_Int_Handler();
}
else if(INTCON3bits.INT3IF && INTCON3bits.INT3IE) /* The INT3 pin is RB3/DIG I/O 2. */
{
INTCON3bits.INT3IF = 0;
// printf("Right Interrupt hit\r");
// Right_Encoder_Int_Handler();
}
else if (INTCONbits.RBIF && INTCONbits.RBIE) // encoder 3-6 interrupt?
{
Port_B = PORTB; // remove the "mismatch condition" by reading port b
INTCONbits.RBIF = 0; // clear the interrupt flag
Port_B_Delta = Port_B ^ Old_Port_B; // determine which bits have changed
Old_Port_B = Port_B; // save a copy of port b for next time around
if(Port_B_Delta & 0x10) // did external interrupt 3 change state?
{
#ifdef ENABLE_ENCODER_3
Encoder_3_Int_Handler(Port_B & 0x10 ? 1 : 0); // call the encoder 3 interrupt handler (in encoder.c)
#endif
}
if(Port_B_Delta & 0x20) // did external interrupt 4 change state?
{
#ifdef ENABLE_ENCODER_4
Encoder_4_Int_Handler(Port_B & 0x20 ? 1 : 0); // call the encoder 4 interrupt handler (in encoder.c)
#endif
}
if(Port_B_Delta & 0x40) // did external interrupt 5 change state?
{
#ifdef ENABLE_ENCODER_5
// Encoder_5_Int_Handler(Port_B & 0x40 ? 1 : 0); // call the encoder 5 interrupt handler (in encoder.c)
#endif
}
if(Port_B_Delta & 0x80) // did external interrupt 6 change state?
{
#ifdef ENABLE_ENCODER_6
// Encoder_6_Int_Handler(Port_B & 0x80 ? 1 : 0); // call the encoder 6 interrupt handler (in encoder.c)
#endif
}
}
}
We would like some suggestions about checking the wires incase the code is properly set up. |
|
#13
|
|||
|
|||
|
Re: Encoder Problemo
Hey Cgront, Its Randell if your reading this I need you to get my memstick and give it to me tomorrow at robotics
|
|
#14
|
|||
|
|||
|
Re: Encoder Problemo
You said you have encoders 1 & 2 for 12 & 13?
Those are phase B from what I see in the code. Have you edited the phase A digitial i/o's?? Are they still getting 1 & 2? |
|
#15
|
|||||
|
|||||
|
Re: Encoder Problemo
Quote:
Also, here's my standard question for problems of this type: what exactly does "wired correctly" mean? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Encoder Problems | bjimster1 | Programming | 2 | 10-02-2007 08:04 |
| Encoder Error | Anime-niac_2.9 | Programming | 1 | 27-01-2007 16:23 |
| Encoder Problem | DustinB_3 | Programming | 22 | 03-01-2007 20:42 |
| Encoder help | Windward | Programming | 21 | 14-01-2006 15:10 |
| encoder.c | Gary Bonner | Programming | 2 | 14-01-2005 13:41 |