Jump to content
43oh

spreng37

Members
  • Content Count

    33
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    spreng37 reacted to RobG in Help porting code from TLC5916 to TLC5940   
    Here's one example, 12bit GS.
    I am using bit banging instead of USI module to make it work with my TLC5940 board, which was designed to be used with 2553/USCI.
     

    #include #define SCLK_PIN BIT5 #define MOSI_PIN BIT7 #define GSCLK_PIN BIT4 #define BLANK_PIN BIT2 #define XLAT_PIN BIT1 #define DCPRG_PIN BIT7 //P2 #define VPRG_PIN BIT0 typedef unsigned char u_char; typedef unsigned int u_int; #define NUMBER_OF_LEDS 16 u_int leds[NUMBER_OF_LEDS] = { 0, }; u_char timerCounter = 0; void updateTLC(); void sendData(u_int data); void main(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT DCOCTL |= DCO0 + DCO1; // DCO = 15.25MHz BCSCTL1 |= RSEL0 + RSEL1 + RSEL2 + RSEL3; // as above BCSCTL2 |= DIVS_3; // divide clock by 8 P1OUT &= ~(VPRG_PIN + BLANK_PIN + XLAT_PIN + SCLK_PIN + MOSI_PIN); P1DIR |= VPRG_PIN + BLANK_PIN + XLAT_PIN + SCLK_PIN + MOSI_PIN; P1DIR |= GSCLK_PIN; // port 1.4 configured as SMCLK out P1SEL |= GSCLK_PIN; P2SEL &= ~(BIT6 | BIT7); P2OUT &= ~DCPRG_PIN; P2DIR |= DCPRG_PIN; // setup timer CCR0 = 0xFFF; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 CCTL0 = CCIE; // CCR0 interrupt enabled updateTLC(); P1OUT |= XLAT_PIN; P1OUT &= ~XLAT_PIN; _bis_SR_register(GIE); leds[0] = 0x0F; u_char counter = 0; u_char direction = 0; u_char first = 0; u_char firstDirection = 0; u_int brightness = 0xFFF; while (1) { // if (direction) { counter--; leds[counter] = brightness; leds[counter + 1] = 0; if (counter == first) { direction = 0; // first if (firstDirection) { first--; if (first == 0) firstDirection = 0; } else { leds[first - 1] = brightness; first++; if (first == (NUMBER_OF_LEDS - 2)) firstDirection = 1; } } } else { counter++; leds[counter] = brightness; leds[counter - 1] = 0; if (counter == (NUMBER_OF_LEDS - 1)) { direction = 1; } } //update all leds u_char c = 0; while(c < NUMBER_OF_LEDS) { if(leds[c] > 0) leds[c] = brightness; c++; } //update brightness brightness -= 0x02; // sleep _bis_SR_register(LPM0_bits); } } void updateTLC() { u_char ledCounter = NUMBER_OF_LEDS >> 1; while (ledCounter-- > 0) { u_char i = ledCounter << 1; sendData(leds[i + 1]); sendData(leds[i]); } } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { P1OUT |= BLANK_PIN; P1OUT |= XLAT_PIN; P1OUT &= ~XLAT_PIN; P1OUT &= ~BLANK_PIN; timerCounter++; if (timerCounter == 0x08) { // 0x08 - 2ms * 8 = 16.384ms, ~61Hz updateTLC(); timerCounter = 0; _bic_SR_register_on_exit(LPM0_bits); } } void sendData(u_int data) { u_char c = 0; while (c < 12) { (data & 0x0800) ? (P1OUT |= MOSI_PIN) : (P1OUT &= ~MOSI_PIN); P1OUT |= SCLK_PIN; P1OUT &= ~SCLK_PIN; data <<= 1; c++; } }
     
     
    And here's the code that works just like the TLC5916 one (12bit GS instead of 8bit.)
     

    #include #include "pattern.h" #define SCLK_PIN BIT5 #define MOSI_PIN BIT7 #define GSCLK_PIN BIT4 #define BLANK_PIN BIT2 #define XLAT_PIN BIT1 #define DCPRG_PIN BIT7 //P2 #define VPRG_PIN BIT0 typedef unsigned char u_char; typedef unsigned int u_int; #define NUMBER_OF_LEDS 16 u_char timerCounter = 0; // 16 levels of brightness const u_int lut[16] = { 0, 30, 60, 100, 200, 300, 400, 600, 800, 1000, 1200, 1500, 1800, 2100, 3600, 4095 }; // range is 0-4095 (12bit) u_char patternIndex = 0; u_char patternCounter = 0; void updateTLC(); void sendData(u_int data); void main(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT DCOCTL |= DCO0 + DCO1; // DCO = 15.25MHz BCSCTL1 |= RSEL0 + RSEL1 + RSEL2 + RSEL3; // as above BCSCTL2 |= DIVS_3; // divide clock by 8 P1OUT &= ~(VPRG_PIN + BLANK_PIN + XLAT_PIN + SCLK_PIN + MOSI_PIN); P1DIR |= VPRG_PIN + BLANK_PIN + XLAT_PIN + SCLK_PIN + MOSI_PIN; P1DIR |= GSCLK_PIN; // port 1.4 configured as SMCLK out P1SEL |= GSCLK_PIN; P2SEL &= ~(BIT6 | BIT7); P2OUT &= ~DCPRG_PIN; P2DIR |= DCPRG_PIN; // setup timer CCR0 = 0xFFF; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 CCTL0 = CCIE; // CCR0 interrupt enabled updateTLC(); P1OUT |= XLAT_PIN; P1OUT &= ~XLAT_PIN; _bis_SR_register(GIE); while (1) { // // logic goes here // patternIndex is used for pattern selection // patternCounter is used for timeline if(patternCounter < 16) { patternIndex++; patternCounter++; } else { patternIndex--; patternCounter++; } // sleep _bis_SR_register(LPM0_bits); } } void updateTLC() { u_char ledCounter = NUMBER_OF_LEDS >> 1; while (ledCounter-- > 0) { u_char i = ledCounter << 1; sendData(lut[pattern[patternIndex][i + 1]]); sendData(lut[pattern[patternIndex][i]]); } } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { P1OUT |= BLANK_PIN; P1OUT |= XLAT_PIN; P1OUT &= ~XLAT_PIN; P1OUT &= ~BLANK_PIN; patternIndex &= 0x0F; // mask patternCounter to get 0-15 range timerCounter++; if (timerCounter == 0x08) { // 0x08 - 2ms * 8 = 16.384ms, ~61Hz updateTLC(); timerCounter = 0; _bic_SR_register_on_exit(LPM0_bits); } } void sendData(u_int data) { u_char c = 0; while (c < 12) { (data & 0x0800) ? (P1OUT |= MOSI_PIN) : (P1OUT &= ~MOSI_PIN); P1OUT |= SCLK_PIN; P1OUT &= ~SCLK_PIN; data <<= 1; c++; } }
  2. Like
    spreng37 reacted to RobG in Help porting code from TLC5916 to TLC5940   
    SCLK_PIN P1.5
    MOSI_PIN P1.7 (SIN)
    GSCLK_PIN P1.4
    BLANK_PIN P1.2
    XLAT_PIN P1.1
    DCPRG_PIN P2.7
    VPRG_PIN P1.0
     
    2231 has two P2 pins, P2.6 and P2.7 (pins 13 & 12.)
    SOUT and XERR should be left floating, those are outputs.
     
    You can re-arrange pins as you like, just make sure when you set/reset them, you use appropriate port number
    P1OUT |= XLAT_PIN, etc.
    The only pin that has to stay as it is is GSCLK P1.4.
  3. Like
    spreng37 reacted to rockets4kids in Strange breadboarding issue (MSP430G2231 + TLC5940)   
    It's a really good idea to have a 10 uF on the power rails.
     
    Also, double check all of your ground and power connections for breadboard faults.
  4. Like
    spreng37 reacted to RobG in Strange breadboarding issue (MSP430G2231 + TLC5940)   
    Besides 100nF cap mentioned by SirZ, 47k RST resistor should be connected to Vcc, not GND.
  5. Like
    spreng37 reacted to SirZusa in Strange breadboarding issue (MSP430G2231 + TLC5940)   
    Where's your capacitor (100nF) between Vcc and GND (Pins 21 and 22) on the TLC5940-side?
     
    Have a look at TLC5940 Datasheet page 21
  6. Like
    spreng37 got a reaction from oPossum in PWM with MSP430G2231 + TLC5916   
    Here's the end result:
     


     
    80 Osram PointLEDs, MSP430G2231, 2 x TLC5916. Still want to try the the 5940 to reduce components.
  7. Like
    spreng37 got a reaction from bluehash in PWM with MSP430G2231 + TLC5916   
    Here's the end result:
     


     
    80 Osram PointLEDs, MSP430G2231, 2 x TLC5916. Still want to try the the 5940 to reduce components.
  8. Like
    spreng37 got a reaction from RobG in PWM with MSP430G2231 + TLC5916   
    Here's the end result:
     


     
    80 Osram PointLEDs, MSP430G2231, 2 x TLC5916. Still want to try the the 5940 to reduce components.
  9. Like
    spreng37 reacted to RobG in Testing boards   
    If you don't know what to do with that 5.25" drive cable, here's an idea, use it to test booster packs
     
    To our younger users: 5.25" drive is something your dad used to store data on (the data was actually stored an a 5.25" floppy disk.)
     




  10. Like
    spreng37 reacted to RobG in PWM with MSP430G2231 + TLC5916   
    You can donate to Tesla Museum
  11. Like
    spreng37 got a reaction from RobG in PWM with MSP430G2231 + TLC5916   
    Here's what I ended up with:
     


  12. Like
    spreng37 reacted to 32xan in New guy needs advice on protection circuit and code   
    Capacitor is missing on the Reset pin of MSP430.
     
    Also, the TLC5916 has min 0.6V on the Vo for 26 mA (from datasheet). With only 0.4V on the Vo of the TLC5914 I kind of curios how stable/predictable it would sink 10mA (or whatever you would programm TLC5914 to sink)?
  13. Like
    spreng37 reacted to dkedr in New guy needs advice on protection circuit and code   
    Here is a click able link to the schematic from the first post.
    http://www.acmewebpages.com/leds/chmsl/uc_schematic.jpg
    Is there a particular reason you are using the PTN78000?
     
    The TLC5916 is actually rated up to 20V on the LED output pins, so you could use the 13.8V input to drive the LEDs directly. However depending on the current you might want to add some series resistors.
     
    The amount of regulators in your design is actually unnecessary. The first regulator is actually capable of producing the 3.3V for the MSP/TLC.
     
    Also, all your regulators are rated at 1A, which would mean a large chunk of their capacity is unused as you're just powering the logic inside the TLC5916 and the MSP430 is a very low power device so it doesn't draw much current.
     
    The way you have arranged those diodes is incorrect. The diodes are there to prevent negative voltages from destroying whatever electronics come after it, in your design however the diodes don't serve a purpose, and also don't allow the capacitors to do their job. If you look at the datasheets of the parts you used, you'll notice that there are no diodes in the example circuits, especially on the output. Diodes are normally used at the very start of the design, to protect the circuit from reverse polarity(the user reversing the + and - terminals). The diode should be connected with the arrow pointing into your circuit, so it should be in between the 13.8V and the input of your first regulator.
     
    The capacitors are there to smooth out any noise that might be superimposed(added) to the regulated signal. Noise comes from pretty much anything that has current flowing through it, so we filter it to prevent it getting into our circuits(you've done more of this with the .1uF caps next to the MSP and the TLC chips). Now the way you have the capacitors connected now, they will only charge up once, when you power on your circuit and will not discharge because the diodes are blocking the discharge path. To allow the capacitor to work you will need to take out the diodes and put a connection across the place where they used to be. It's also good practice to have capacitors close to the input of the regulators as well as the outputs. This makes the output they produce smoother(less noise).
     
    EDIT: Found a simple circuit with a well known regulator:

×
×
  • Create New...