Member #65077

Member Since: March 24, 2009

Country: United States

  • The feature list is nice but a $3 MCU can do most of it. If it was an open source project the cost would be 1/10 …

  • [SOLVED - restarted tablet] Help? RN-52 worked fine, audio and serial, then suddenly audio output stopped working. I ordered a new RN-52 (assuming I burned the audio output stage) but I get the same result: Serial connection works well, my Android tablet detects the audio connection and reroutes output to the RN-52 but no audio comes out. The Red LED on the breakout board keeps flashing 3 times. Earlier when it worked it was mostly on with occasional flashes. Any ideas? Also - did anyone find a solution how to convert the speaker output to line-out? Issues like common ground to both channels, protecting both sides of the link, load matching…? Thanks!!!!

  • There is a useful trick I found for controlling the LEDs! Outputting the exact bit waveform is hard (100ns accuracy - duh?) but I found that if I run a Microchip PIC (or equivalent) MCU on 64MHz internal oscillator I can cause the UART to output the bit waveform. The trick is in the UART setup: * INVERT the output of the UART (normally low) * bit rate of 8MHz or 125ns * No stop bit (8 data bits, no parity) Then there are the MAGIC NUMBERS: Sending byte 192 (0xC0) sends a 1 code. Sending byte 252 (0xFC) sends a 0 code. Those BYTE values create a BIT waveform for the LEDs. This trick could be useful for the high-end machines (ARM based for example) to support the accurate bit timing requirements.

    Here is a sample C code (CCS C) : #include <18LF46K22.h>

    #fuses INTRC_IO,NOPROTECT,NOPLLEN,NOBROWNOUT,NOLVP,NOWDT                      
    
    #use delay(clock=64000000)
    #use rs232(stream=LED_STREAM, baud=8000000, xmit=PIN_C6, rcv=PIN_C7,bits=8,parity=N,stop=0,ERRORS,INVERT)
    
    #define NUM_LEDS 24
    
    #define HI_BIT  192 // 0b11000000
    #define LOW_BIT 252 // 0b11111100
    
    
    //==========global  variables:===========
    
    byte grn [NUM_LEDS];
    byte blu [NUM_LEDS];
    byte red [NUM_LEDS];
    
    ///////////////////////////////////////////////
    #INLINE
    void SendByte (byte b) {
        byte i;
    
        // send 8 bits, MSB first.
        // for each bit send a CHAR that creates the bit's waveform
        for(i=0;i<8;i++) {
            if(bit_test(b,7)) fputc(HI_BIT,LED_STREAM);
            else fputc(LOW_BIT,LED_STREAM);
            b<<=1;
        }
    }
    ////////////////////////////////////
    
    void Draw (){
        unsigned int8 i;
    
        // send all data to LEDs
        // data order to transmit is G,R,B, 8 bits each.
    
        for (i=0;i<NUM_LEDS;i++){
            SendByte(grn[i]);
            SendByte(red[i]);
            SendByte(blu[i]);
        }
    }
    
    /////////////////////////////////////
    void initArray() {
        byte i;
    
        // assuming 24 LEDs:
        for(i=0;i<NUM_LEDS;i++) {
            // red channel:
            if(i<6) red[i]=i*51;
            else if(i<12) red[i]=(11-i)*51;
            else red[i]=0;
            // grn channel:
            if(i<8) grn[i]=0;
            else if(i<14) grn[i]=(i-8)*51;
            else if(i<20) grn[i]=(19-i)*51;
            else grn[i]=0;
            // blu channel:
            if(i<4) blu[i]=(3-i)*51;
            else if(i<16) blu[i]=0;
            else if(i<22) blu[i]=(i-16)*51;
            else blu[i]=(27-i)*51;
        }
    }
    ///////////////////////////////////////
    void Rotate() {
        byte r,g,b,i;
    
        // rotate colors in array. This is only for demo.
        r=red[0];
        g=grn[0];
        b=blu[0];
        for(i=1;i<NUM_LEDS;i++) {
            red[i-1]=red[i];
            grn[i-1]=grn[i];
            blu[i-1]=blu[i];
        }
        red[NUM_LEDS-1]=r;
        grn[NUM_LEDS-1]=g;
        blu[NUM_LEDS-1]=b;
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    
    
    void main(){
    
        setup_oscillator(OSC_64MHZ);
        initArray();
        delay_ms(100);
    
        while(true){
          Draw();
          delay_ms(60);
          Rotate();
       }
    }
    

No public wish lists :(