CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Timer Interrupt - not working
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Sat Aug 04, 2012 8:35 am     Reply with quote

Thanks Ttelmah

I will give it a go tomorrow.

Carl
bkamen



Joined: 07 Jan 2004
Posts: 1619
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sat Aug 04, 2012 11:25 am     Reply with quote

sseidman wrote:
Oscilloscope. A key piece of bench gear that everyone beyond novice hobbyist should have.


Amen to that.

I couldn't live without my Agilent scope. I love it.. LOVE it!
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sat Aug 04, 2012 11:52 am     Reply with quote

Many**2 years ago (1965?), I bought the Eico 460 synchronized sweep scope then later got a decent dual trace Hitachi 50mhz scope that has served well. Recently got one of the new digital scopes that are now very reasonable and fit nicely on the desk - being digital, it is nice for viewing that one-shot type thing (or short pulse that happens every 10 seconds etc). Definitely high on the list of gear that should be in any hobbyist shop. Something like the DS1102E 100 MHz 2-Channel Digital Oscilloscope can be had for around $400. Yeah, that is money, but when I bought my Eico kit, it was around $100 - and that was when I was making about $1/hour mowing lawns etc. Never regretted the investment. There are also a number of handy little "digital scopes" that plug into the USB on your PC and don't have a display of their own but use a Windows app to display waveforms and voltages etc that are worth considering.

One of my standard "testability" features I do is if I have a spare pin on anything, I set it high at the start of an ISR then low again on exit from the ISR. Tells me two things - 1) the ISR is working/getting triggered and 2) how much time the ISR is using - just bring the pin out to a test point. That has proved very helpful many times.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
Ttelmah



Joined: 11 Mar 2010
Posts: 20161

View user's profile Send private message

PostPosted: Sun Aug 05, 2012 1:55 am     Reply with quote

OK. Have re-written just the part down to where both words have been read, to show how to do this with byte I/O, and what I was suggesting about tidying the code:
Code:

//Obviously, header stuff, and ISR here

#define LATCH_ALL output_b(0b11111100)
#define RUN_ALL output_b(0b00011100)
#define TRIS_VAL (0b00000011) //Don't know what is on B0/1, setting as input

#define BLSB (2)
#define BSB (3)
#define BMSB (4)

#byte PORTB_DIRECT = getenv("SFR:PORTB")

int8 read_byte(int8 OE) {
   int8 rval;
   bit_clear(PORTB_DIRECT,OE);
   delay_us(1);
   rval=input_a();
   bit_set(PORTB_DIRECT,OE);
   return rval;
}

#define read_word(val) val.part.lsb=read_byte(BLSB);val.part.sb=read_byte(BSB);val.part.MSB=read_byte(BMSB)
#use fast_io(b)

void main(void) {

  typedef struct {
     int8 lsb;
     int8 sb;
     int8 msb;
     int8 top;
  } my_bytes; 
  union to_int32 {
     my_bytes part;
     int32 whole;
  } current, old;
  signed int32 ans;
  //setup timer etc. here

  set_tris_b(TRIS_VAL);
 
  current.part.top=old.part.top=0;
  //ensure top bytes are clear
 
  LATCH_ALL;
  read_word(old);
  RUN_ALL;
 
  while (TRUE) {
    if (tic) {
       LATCH_ALL;
       read_word(current);
       RUN_ALL;
       
       ans=current.whole-old.whole;
       old.whole=current.whole;
       
       //...........


Best Wishes
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Sun Aug 05, 2012 4:50 am     Reply with quote

Hi Ttelmah,

Thanks so much for your help.
Unfortunately though I tried it and it didn't work.

Some things I can see that I think are wrong:

Code:
#byte PORTB_DIRECT = getenv("SFR:PORTB")

int8 read_byte(int8 OE) {
   int8 rval;
   bit_clear(PORTB_DIRECT,OE);
   delay_us(1);
   rval=input_a();
   bit_set(PORTB_DIRECT,OE);
   return rval;
}

Shouldn't all the above refer to PORT_D??
because I am reading portD, and it set up for B and 'a'?

So I changed it to:
Code:
#byte PORTD_DIRECT = getenv("SFR:PORTD")

int8 read_byte(int8 OE) {
   int8 rval;
   bit_clear(PORTD_DIRECT,OE);
   delay_us(1);
   rval=input_d();
   bit_set(PORTD_DIRECT,OE);
   return rval;
}


Regarding taking the snap-shot, sorry but I dont understand the order that you are doing it in?

Your order is:
Code:
:LATCH_ALL;  //Enable Latch
  read_word(old);                        // Take reading?? - but how if the Latch output enable has not been enabled??
  RUN_ALL;                                 // Enable Latch ouput



But more importantly, the Output Enable's have_to_be Set and Read individually - so that each byte can be read. Doesn't RUN_ALL enable all the latch outputs at the same time? Only one Latch output can be on at one time.

I will have a look into further ans see if I can work it out.

Thanks
Carl
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Sun Aug 05, 2012 11:41 am     Reply with quote

Tried all day - but with no luck.

I did not manage to incorporate all of your code, but did incorporate the most imporatnt part - ensuring the Latche's were all enabled at the same time (not latch output enable though - these were still done seperately).

It made no difference.

So I thought I would try a different approach and use INT_RB - but I can't get it working. To use INT_RB, I had to change one of the Latch controls as INT_RB uses RB4_RB7. So I set my current latch enable on RB7 to E0. Then I set port b to fast_io and tris on B to (0b10000001) - therefore allowing the 'free' B7 to be wired to 2^0.

So every change on 2^0 should trigger the interrupt ISR. Any other changes on RB4_RB6 should be ignored - because this TRIS has set them up for output.

But, it doesn't work - the LCD just displays various 'fixed' values (as though the interrupt only occurs once) as the encoder is rotated.

the code is here:
Code:
/////// MASTER PROGRAM ////////
///*
#include <18F4550.H>
#fuses EC, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP, NOPBADEN, NOVREGEN
#use delay(clock=48000000)
#use standard_io(a)     
#use fast_io(b)
#use standard_io(c)     
#use standard_io(d)
#use standard_io(e)

#byte UCFG = getenv("SFR:UCFG") //USB Registors
#bit UTRDIS = UCFG.3         //USB Registors

#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1 (SPI_L_TO_H)
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)

#define SPI_SS      PIN_E2
#define TIC_CHECK   PIN_E1

#define LSB_LATCH_LE_CL3  PIN_E0
#define LSB_LATCH_OE_CL8  PIN_B2
#define SB_LATCH_LE_CL4   PIN_B6
#define SB_LATCH_OE_CL7   PIN_B3
#define MSB_LATCH_LE_CL5  PIN_B5
#define MSB_LATCH_OE_CL6  PIN_B4

#define TRIS_VAL1 (0b10000001) //BO = SPI MASTER (SDO) = INPUT. B1 = SPI MASTER (CLK) = OUTPUT
//#define TRIS_VAL2 (0b10000000)
//#define LATCH_ALL output_b(0b11111100)

//============================

signed int tic, input_lsb, input_sb, input_msb = 0;
signed int32 ans, my_bytes, pain;
int count_to_use=8;                          // NOT USED FOR NOW
static long int count=1;
signed int32 fullbyte_read_current, fullbyte_read_old;

//////#int_RTCC
//////void RTCC_isr(void)
/////{
//    if (--count==0) {
//        count=count_to_use;                                                                                                       
//////        tic = 1;
//////output_high(TIC_CHECK);           // USED FOR TIMING CHECK (SCOPE)
                        // SET INTERRUPT HAS OCCURRED FLAG                           
//    }
//    else  {                       
//        tic = 2;                                                                                         
// }
//////}

#int_RB
void RB_isr(void) {
tic = 1;
output_high(TIC_CHECK);
}

void main()
{
typedef struct {
    int8 input_lsb;
    int8 input_sb;
    int8 input_msb;
    int8 TOP;
} my_bytes;
   
union to_int32 {
    my_bytes part;
    int32 whole;
} fullbyte_read_current, fullbyte_read_old;

clear_interrupt(INT_RB);
enable_interrupts(INT_RB);
enable_interrupts(global);
set_tris_b(TRIS_VAL1);
//setup_timer_0(RTCC_INTERNAL|RTCC_8_BIT|RTCC_DIV_8);  // this should generate a 170.6uS interrupt.
//enable_interrupts(INT_TIMER0); 
UTRDIS = 1;
output_high(SPI_SS);                             // Initial Slave Select to a high level
output_low(TIC_CHECK);
setup_spi(SPI_MASTER | SPI_MODE_1 | SPI_CLK_DIV_4);
SETUP_ADC_PORTS(NO_ANALOGS);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_psp(PSP_DISABLED);
setup_ccp1(CCP_OFF);
port_b_pullups(TRUE);
output_low(LSB_LATCH_LE_CL3);                     //Disable all latch's
output_high(LSB_LATCH_OE_CL8);
output_low(SB_LATCH_LE_CL4);
output_high(SB_LATCH_OE_CL7);
output_low(MSB_LATCH_LE_CL5);
output_high(MSB_LATCH_OE_CL6);

////////////////////////////////////////INITIAL 24-BIT CATCH (OLD VALUE)//////////////////////////
//   LATCH_ALL;
   output_high(LSB_LATCH_LE_CL3);
   output_high(SB_LATCH_LE_CL4);
   output_high(MSB_LATCH_LE_CL5);

   delay_us(5);                //More than required
 
   output_low(LSB_LATCH_OE_CL8);   //LSB Latch Output Enable
   delay_us(5);                //More than required
   fullbyte_read_old.part.input_lsb=input_d();
   delay_us(1);                  //More than required???
   output_low(LSB_LATCH_LE_CL3);   //Disable Latch
   output_high(LSB_LATCH_OE_CL8);
   delay_us(1);                  //More than required

   output_low(SB_LATCH_OE_CL7);      //SB Latch Output Enable
   delay_us(5);                  //More than required
   fullbyte_read_old.part.input_sb=input_d();
   delay_us(1);                  //More than required???
   output_low(SB_LATCH_LE_CL4);      //Disable Latch
   output_high(SB_LATCH_OE_CL7);
   delay_us(1);                //More than required

   output_low(MSB_LATCH_OE_CL6);    //MSB Latch Output Enable
   delay_us(5);                  //More than required
   fullbyte_read_old.part.input_msb=input_d();
   delay_us(1);                  //More than required???
   output_low(MSB_LATCH_LE_CL5);   //Disable Latch
   output_high(MSB_LATCH_OE_CL6);
   delay_us(1);                  //More than required

fullbyte_read_old.part.TOP=fullbyte_read_current.part.TOP=0;

//////////////////////////////////////////////////////////////////////////////////////////////////
 
while(1)
  {
if (tic == 1){   ////////////////////INTERRUPT HAS OCCURRED - WE NOW HAVE 170.4uS TO DO EVERYTHING BEFORE THE NEXT INTERRUPT///////////////////////////
                               
   output_high(LSB_LATCH_LE_CL3);
   output_high(SB_LATCH_LE_CL4);
   output_high(MSB_LATCH_LE_CL5);

   delay_us(5);                //More than required
 
   output_low(LSB_LATCH_OE_CL8);   //LSB Latch Output Enable
   delay_us(5);                //More than required
   fullbyte_read_current.part.input_lsb=input_d();
   delay_us(1);                  //More than required???
   output_low(LSB_LATCH_LE_CL3);   //Disable Latch
   output_high(LSB_LATCH_OE_CL8);
   delay_us(1);                  //More than required

   output_low(SB_LATCH_OE_CL7);      //SB Latch Output Enable
   delay_us(5);                  //More than required
   fullbyte_read_current.part.input_sb=input_d();
   delay_us(1);                  //More than required???
   output_low(SB_LATCH_LE_CL4);      //Disable Latch
   output_high(SB_LATCH_OE_CL7);
   delay_us(1);                //More than required

   output_low(MSB_LATCH_OE_CL6);    //MSB Latch Output Enable
   delay_us(5);                  //More than required
   fullbyte_read_current.part.input_msb=input_d();
   delay_us(1);                  //More than required???
   output_low(MSB_LATCH_LE_CL5);   //Disable Latch
   output_high(MSB_LATCH_OE_CL6);
   delay_us(1);                  //More than required


ans=fullbyte_read_current.whole-fullbyte_read_old.whole;
fullbyte_read_old.whole=fullbyte_read_current.whole;


////////////////////////////////////CHECK IF AN ERROR HAS OCCURRED AND SEND VALUE//////////
          if ((ans==-1) || (ans==0) || (ans==1)) {
          output_low(SPI_SS);              // NO ERRORS DETECTED - SEND 24 BIT VALUE TO SLAVE
          delay_cycles(7);
          spi_write(ans); 
         delay_cycles(7);
       // spi_write(input_sb);   
         // delay_us(10);
         // spi_write(input_msb); 
         // delay_us(10);
            output_high(SPI_SS);
         //input_lsb = 0;                   //RESET
         //input_sb = 0;
         //input_msb = 0;
           delay_cycles(7);
            ans = 0;                   // RESET ANS
            tic=0;                      // RESET TIC               
         output_low(TIC_CHECK);          // USED FOR TIMING CHECK (SCOPE)
}
   
     else if ((ans <-1) || (ans >1)){
           output_low(SPI_SS);           //  ERROR DETECTED - SEND ERROR MESSAGE
          delay_cycles(7);
          spi_write(ans); 
         delay_cycles(7);
       // spi_write(input_sb);   
         // delay_us(10);
         // spi_write(input_msb); 
         // delay_us(10);
            output_high(SPI_SS);
         //input_lsb = 0;                   //RESET
         //input_sb = 0;
         //input_msb = 0;
         tic=0;                      // RESET TIC
           delay_ms(1000);}
}
   
////////////////////////////////////////////////////////////////////////////////////////////////////

                                   
//else if (tic == 2){      ////////////////////INTERRUPT HAS NOT OCCURRED - DO SOMETHING ELSE///////////////////////////
//   tic=0;
//   output_low(SPI_SS);
//   spi_write(10);
//   delay_cycles(7);
//   spi_write(0);
//   delay_us(10);
//   spi_write(0);
//   delay_us(10);
//   output_high(SPI_SS);
//   delay_cycles(7);
//   delay_ms(1000);
//}

}
}


Any further help appreciated.
Ttelmah



Joined: 11 Mar 2010
Posts: 20161

View user's profile Send private message

PostPosted: Sun Aug 05, 2012 1:04 pm     Reply with quote

Yes, typed d, not a.

If you look at the read_byte function, it lowers the selected output enable bit, waits a moment, then reads the value from port d, then raises the bit again. So the byte should be read as required.
I've probably got something like the bit numbers wrong. or the levels.

The significant point, is that the problem is I think being caused actually by having three separate latch bits. You don't need/want these. You are forming a _single_ 24bit latch, with three separate byte outputs.

Sequence needs to be:
1) A _single_ operation to latch the 24bit value.
2) Enable output on each byte in turn, and read these.

Problem is that you are not latching things at the same time.
You could simply wire all three latch bits together to a single PIC pin.

Best Wishes
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Sun Aug 05, 2012 1:33 pm     Reply with quote

Hi Ttelmah,

I'll continue again tomorrow - and will try just shorting all the Latch enables (not output enables) - simplest and surest way.

Regarding the byte_read though:
Quote:
it lowers the selected output enable bit


I can't see how it is automatically selected - all I see is 'OE' in your code.
Can you explain how this section works:
Code:
#byte PORTB_DIRECT = getenv("SFR:PORTB")

int8 read_byte(int8 OE) {
   int8 rval;
   bit_clear(PORTB_DIRECT,OE);
   delay_us(1);
   rval=input_a();
   bit_set(PORTB_DIRECT,OE);
   return rval;
}



Regarding the rest of your points - I totally agree - it would be easier to have just had one LE, and this is potentially causing the problems.

But when I implemented your 'set all the Latch enables' at the same time - it didn't work - so we will see tomorrow if it makes any difference shorting them together.

And I presume you dont thinnk much of the INT_RB plan?
My thoughts were that it_would_definetly_be_synchronised if this was used!!



Thanks
Carl
Ttelmah



Joined: 11 Mar 2010
Posts: 20161

View user's profile Send private message

PostPosted: Sun Aug 05, 2012 2:00 pm     Reply with quote

If you look at the call to byte_read, it uses:

val.part.lsb=read_byte(BLSB)

etc.,

BLSB, is #defined as the bit number of the LSB output enable bit

bit_clear(PORTB_DIRECT,OE);

then lowers this bit number, while the bit_set function, then raises it.

Best Wishes
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Mon Aug 06, 2012 2:29 am     Reply with quote

Hi Ttelmah,

OK Tried it and it was still the same. works when encoder rotated slowly, but fails when rotated faster (2^0 @ 1KHz).

I aslo tried shorting the Latch - but no difference. Its so annoying.
Your code though works well - thanks for that.

here is the final code:
Code:
/////// MASTER PROGRAM ////////
///*
#include <18F4550.H>
#fuses EC, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP, NOPBADEN, NOVREGEN
#use delay(clock=48000000)
#use standard_io(a)     
#use standard_io(c)     
#use standard_io(d)
#use standard_io(e)

#byte UCFG = getenv("SFR:UCFG") //USB Registors
#bit UTRDIS = UCFG.3         //USB Registors

#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1 (SPI_L_TO_H)
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)

#define SPI_SS      PIN_E2
#define TIC_CHECK   PIN_E1

//============================

signed int tic;
//int count_to_use=8;                             // NOT USED FOR NOW
//static long int count=1;

#int_RTCC
void RTCC_isr(void)
{
//    if (--count==0) {
//        count=count_to_use;                                                                                                       
        tic = 1;
output_high(TIC_CHECK);           // USED FOR TIMING CHECK (SCOPE)
                        // SET INTERRUPT HAS OCCURRED FLAG                           
//    }
//    else  {                       
//        tic = 2;                                                                                         
// }
}

#define LATCH_ALL output_b(0b11111100)
#define RUN_ALL output_b(0b00011100)
#define TRIS_VAL (0b00000001) //BO = SPI MASTER (SDO) = INPUT. B1 = SPI MASTER (CLK) =

#define BLSB (2)
#define BSB (3)
#define BMSB (4)

#byte PORTB_DIRECT = getenv("SFR:PORTB")

   int8 read_byte(int8 OE) {
   int8 rval;
   bit_clear(PORTB_DIRECT,OE);
   delay_us(1);
   rval=input_d();
   bit_set(PORTB_DIRECT,OE);
   return rval;
}

#define read_word(val) val.part.lsb=read_byte(BLSB);val.part.sb=read_byte(BSB);val.part.msb=read_byte(BMSB)
#use fast_io(b)

void main(void) {

  typedef struct {
     int8 lsb;
     int8 sb;
     int8 msb;
     int8 top;
  } my_bytes; 
  union to_int32 {
     my_bytes part;
     int32 whole;
  } current, old;
  signed int32 ans;

//setup timer etc. here
setup_timer_0(RTCC_INTERNAL|RTCC_8_BIT|RTCC_DIV_8);  // this should generate a 170.6uS interrupt.
enable_interrupts(INT_TIMER0);
enable_interrupts(global);
UTRDIS = 1;
output_high(SPI_SS);                             // Initial Slave Select to a high level
output_low(TIC_CHECK);
setup_spi(SPI_MASTER | SPI_MODE_1 | SPI_CLK_DIV_4);
SETUP_ADC_PORTS(NO_ANALOGS);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_psp(PSP_DISABLED);
setup_ccp1(CCP_OFF);
   

  set_tris_b(TRIS_VAL);
 
  current.part.top=old.part.top=0;
  //ensure top bytes are clear
 
  LATCH_ALL;
  read_word(old);
  RUN_ALL;
 
 
  while (TRUE) {
    if (tic) {
       LATCH_ALL;
       read_word(current);
       RUN_ALL;
       
       
       ans=current.whole-old.whole;
       old.whole=current.whole;
     
       //...........
   ////////////////////////////////////CHECK IF AN ERROR HAS OCCURRED AND SEND VALUE//////////
         if ((ans ==-1) || (ans ==0) || (ans == 1)) {
       
//         if (true){
          output_low(SPI_SS);              // NO ERRORS DETECTED - SEND 24 BIT VALUE TO SLAVE
          delay_cycles(7);
          spi_write(ans); 
         delay_cycles(7);
       // spi_write(input_sb);   
         // delay_us(10);
         // spi_write(input_msb); 
         // delay_us(10);
            output_high(SPI_SS);
         //input_lsb = 0;                   //RESET
         //input_sb = 0;
         //input_msb = 0;
           delay_cycles(7);
            ans = 0;                   // RESET ANS
            tic=0;                      // RESET TIC   
            output_low(TIC_CHECK);          // USED FOR TIMING CHECK (SCOPE)                     
}   
     else if (( ans <-1) || (ans >1)){
           output_low(SPI_SS);           //  ERROR DETECTED - SEND ERROR MESSAGE
          delay_cycles(7);
          spi_write(ans); 
         delay_cycles(7);
       // spi_write(input_sb);   
         // delay_us(10);
         // spi_write(input_msb); 
         // delay_us(10);
            output_high(SPI_SS);
         //input_lsb = 0;                   //RESET
         //input_sb = 0;
         //input_msb = 0;
            ans = 0;                   // RESET ANS
            tic=0;                      // RESET TIC   
           delay_ms(1000);
            output_low(TIC_CHECK);          // USED FOR TIMING CHECK (SCOPE)}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////

                                   
//else if (tic == 2){      ////////////////////INTERRUPT HAS NOT OCCURRED - DO SOMETHING ELSE///////////////////////////
//   tic=0;
//   output_low(SPI_SS);
//   spi_write(10);
//   delay_cycles(7);
//   spi_write(0);
//   delay_us(10);
//   spi_write(0);
//   delay_us(10);
//   output_high(SPI_SS);
//   delay_cycles(7);
//   delay_ms(1000);
//}

}
}


I'll just have to have a play around with it and see what I can come up with. Thanks for all your help.

Carl
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Mon Aug 06, 2012 1:51 pm     Reply with quote

Step back the other way. Lose the fancy interrupts, and just make sure you're getting clean encoder reads. What are the encoders? Do they require some special handling that you're missing? If you were using plain old quad encoders, I'd suggest skipping over to something like the 18f4331, which has some great handling of noisy encoder signals. This shouldn't be necessary for absolute encoders, but post some details and we can see if anything stands out.
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Mon Aug 06, 2012 2:31 pm     Reply with quote

Your right sseidman,

I was thinking on the same terms today and am going to have to to go back and check everything previous to the Latch's is good.

I did do this originally - but only statically at different absolute encoder positions. I need to carry out a 'sequential test at speed'.

I will do this tomorrow with a tried and tested 'specialised encoder testbox' (the one I am trying to replace !!!). This will ensure that the signals work correctly (or not).

There is other hardware (PLD's, other Latch's, LED's) inbetween the enocder and the Latch's - so if the test above fails, then I will start going backwards and try to find the problem. I do forsee though this being the problem.

As for the encoder - I work for an encoder manufacturer - so their is no issues or oversights with the encoder.

Thanks for your input and help Sseidman
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Tue Aug 07, 2012 5:11 am     Reply with quote

Well, I don't know if it is good news or bad news.
I removed all circuitry after the Latch's.

Then I wired the latch's up as transparent latch's (all OE to 0V and all LE to +5V).
Then I carried out a sequential test (all hardware previous to the latch's was connected up and obviously the encoder) connected on the outputs of the latch's (all 24-bits). It passed fully at speed over the complete count in both directions, several times.

So the problem cannot lie with the hardware previous to the latch's - the code input is good.

So it must be something to do with either:

1) The three separate latch reads (hardware)
2) The three separate latch reads (software)

For No 1), I have already tried wiring the three latch enables together - so I cannot improve on this.

and no 2) with Ttelmah's help looks good.

This is very strange.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group