SK40C-18f4550 as RaibowBit controller

Programmer, In-Circuit Debugger, PIC Start-Up Kit, Memory Interface...

SK40C-18f4550 as RaibowBit controller

Postby zahari » Thu Aug 14, 2014 11:47 am

I have succesfully lights up a single RaibowBit and control of all color display using SK40C(PIC18f4550) with 40Mhz Crystal. However, when I try on other RaibowBit that I purchased(altogether 20 pcs), they don't light up as the first one, even all the setup is exactly the same as the first one. This is not even cascade yet. The Rainbowbit just light up bright white color only and cannot be controlled. Is there a potential that the Rainbowbit modules are defected? Here are my code, not complete because it is still a mess in original workspace, but the method i develop is like this..and it works
CODE: SELECT_ALL_CODE
void main ()
{
void putcolor2();

        TRISB = 0b00000011;               //Configure PORTB I/O direction
   TRISC = 0b00000000;
   TRISD = 0b00000000;               //Configure PORTD I/O direction
   PORTB = 0;
   PORTC = 0;
   PORTD = 0;
//sample
while(1)
{
   brtdecode(0x9A, 0xCD, 0x32); // YELLOW green
   putcolor2();
   Delay_100msX(10);
   
   brtdecode(0x55, 0x6B, 0x2F); // DARK OLIVE green..aqua or cyan
   putcolor2();
   Delay_100msX(10);
}
/********************************************************************
*       Function Name:  Single line serial Data 0                    *
*       Return Value:   void                                        *
*       Parameters:     None                                    *
*       Description:    set data logic 0 for single serial          *
*                       data transmission                           *
********************************************************************/
void SLD0()
{
   SerOne = 1;
   Nop();
   Nop();  // works 0.4 us
    Nop();
    Nop();
   SerOne = 0;
   Nop(); //.2uS works
   Nop();
   Nop();
   Nop();
    Nop();// works - 0.85 us
    Nop();
   Nop();
   Nop();
    Nop();
   Nop();
}
/********************************************************************
*       Function Name:  Single line serial Data 1                    *
*       Return Value:   void                                        *
*       Parameters:     None                                    *
*       Description:    set data logic 1 for single serial          *
*                       data transmission                           *
********************************************************************/
void SLD1()
{
   SerOne = 1;
   Nop();
   Nop();
   Nop();
   Nop();
   Nop();
   Nop();
   Nop();
    Nop(); //works 0.8

   SerOne = 0;
   
   Nop();
   Nop();
   Nop();
   Nop();
    Nop();  //works 0.45 us

}
/********************************************************************
*       Function Name:  Put color on LED 2                            *
*       Return Value:   void                                        *
*       Parameters:     None                                    *
*       Description:                            l          *
*                                                               *
********************************************************************/
void putcolor2()
{

   for(j=0;j<24;j++)
   {
      if(bitz[j]==1)
      {
         SLD1();
      }
      else
      {
         SLD0();
      }
   }
//}
SerOne = 0;
Delay10TCYx(60);

}
/********************************************************************
*       Function Name:  Brightness Decode                                 *
*       Return Value:   void                                        *
*       Parameters:     None                                    *
*       Description:                            l          *
*                                                               *
********************************************************************/
void brtdecode(int red, int grn, int blue)
{
   for(j=0;j<24;j++)
   {
      if(j<8)
      {
         bitz[j]=getBit(grn,8-j);
      }
      if((j>=8) && (j<16))
      {
         bitz[j]=getBit(red,8-j%8);
      }
      if(j>=16)
      {
         bitz[j]=getBit(blue,8-j%8);
      }
            
   }
}
zahari
Greenhorn
 
Posts: 2
Joined: Thu Aug 14, 2014 11:23 am

Re: SK40C-18f4550 as RaibowBit controller

Postby ober » Sat Aug 16, 2014 12:13 pm

The signal for individual bit might be correct, but when you use loop to check bit's logic, it takes time and calling function to output bit logic will also take times, returning after a function will takes time too.

Yes, 1 rainbowbit can works, that particular rainbowbit might have big tolerance on the signal, but not other.

Do check the 24 bits signal as a whole packet.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: SK40C-18f4550 as RaibowBit controller

Postby zahari » Sat Aug 16, 2014 3:29 pm

Hi Ober,
Thanks for your advice. I have checked my timing for writing signal. And that is very true. Rainbowbit is quite stringent on timing. I have managed to resolve the problem now. Thank you.
zahari
Greenhorn
 
Posts: 2
Joined: Thu Aug 14, 2014 11:23 am

Re: SK40C-18f4550 as RaibowBit controller

Postby ober » Sun Aug 17, 2014 8:06 am

Good! Mind sharing your project? I am sure other will benefit from it.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to PIC Development Tool

Who is online

Users browsing this forum: No registered users and 1 guest

cron