Jump to content

RobG

Members
  • Content Count

    3,117
  • Joined

  • Last visited

  • Days Won

    247

Everything posted by RobG

  1. RobG

    LaunchPad controlling up to 8 RC Servos

    I was thinking that not many of us will ever need to use 8 servos so I have updated my code and here it is. The new version controls up to 4 servos and does not require additional parts. Just connect your servo to pins P1.4-P1.7 and voila. #include unsigned int counter = 0;
  2. RobG

    LaunchScope

    Logic analyzer? Something simple, maybe 4 inputs, or 8 using external shift register.
  3. RobG

    LaunchPad controlling up to 8 RC Servos

    That would be the case if we fed latch (storage clock) with inverted shift clock (register clock) as per specs.
  4. RobG

    PWM codes and TimerA

    TBCCR0 = 512 - 1; // PWM Period TBCCTL2 = OUTMOD_7; // TBCCR2 reset/set TBCTL = TBSSEL_2 + MC_1; // SMCLK, up mode the above lines are redundant in your interrupt routine (plus they only need to be executed once) and I am not sure but they may affect the timer. I would remove them from interrupt and put the just before __bis_SR...
  5. RobG

    LaunchPad controlling up to 8 RC Servos

    Sure, we need 595 to shift just one 1, so before first shift, we have to set input to 1, after that it's all zeros. Every clock, we move that 1 to the next out. Output is active when clock is 0. When clock is 1, output is disabled (Hi-Z.) We have to set 1 on the input one clock earlier, because shift registers are one ahead of the latches when both clocks are connected together.
  6. RobG

    PWM codes and TimerA

    Why don't you just toggle it in the interrupt? This part should be executed only once, put it in the main TBCCR0 = 512 - 1; // PWM Period TBCCTL2 = OUTMOD_7; // TBCCR2 reset/set TBCTL = TBSSEL_2 + MC_1; // SMCLK, up mode Get rid of for, then in the interrupt routine, use if statement to toggle duty cycle if(toggle ^= 1) { TBCCR2 = DUTY_1; } else { TBCCR2 = DUTY_2; } One more question, why are you using two timers? You have interrupt for timer A, but changing CCR on timer B.
  7. RobG

    LaunchPad, 74HC165, Switches

    Yes I am Next week I will do another one, controlling up to 8 servos using 74HC164
  8. RobG

    Debouncing in external interrupts

    The way I am doing it for multiple switches is by using shift register to read the position and the timer to control frequency at which they are read. Also, I have two variables, one to store position information and one to store information about position changes. After getting information from the register, I am XORing it with the positions from previous read and storing it in change variable. Then I am updating position variable. If the bit in the change variable is set, it means switch is not stable and should not be used at this time. When the bit is clear, it means switch did not change it's position since the last time we read it and could be considered stable. One thing about this solution is that you need a wake up switch if you want to preserve power. Example, let's say we have one 165 with 8 switches, first var is change var, second is position, switches are off. 00000000 00000000 Now we flip one switch 00000001 00000001 00000001 Then on the next interrupt 00000000 00000001 Now we switch it off 00000000 00000001 00000000 And next interrupt 00000000 00000000 Just my $0.02
  9. RobG

    Quick and dirty 74HC595 shift register demo

    The only problem is that 164 doesn't have output latch which means your data will be shifting each time you send it to 164 and your output will be unreliable. This might be fine if you are using it for display purposes and you are shifting fast enough, but if you are planning to control relays for example, 164 is a bad choice.
  10. Posted the video. BTW, my schematic shows 4 single digit displays, but on my video, I am using one 4 digit display from Futurlec. I chose that one because it requires less connections. Also, I am using 74HC595 instead of 74HCT595 which is listed on the diagram. Resistors are 220 ohms.
  11. RobG

    MSP430 LaunchPad, 74HC595, 16 LEDs

    Hi, I am powering it directly from LaunchPad, so it's about 3.6V. I am using 330ohm resistors to limit the current to about 5mA. 74HCT595 can source/sink up to 35mA. One more thing, I am using HC series, not HCT, sorry for the confusion. Rob.
  12. What is it? 4 digit BCD counter using LaunchPad and two 74HC595 shift registers. Note: One important thing that I forgot to add is that since I am powering this from LP, I am using here 74HC595 and not HCT. LP provides 3.6V, HCT needs 5V. See it in action: #include unsigned int counter = 0; // Counter variable void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1OUT |= 0x01; // Port P1.0 will be used to latch P1DIR |= 0x01; USICTL0 |= USIPE6 + USIPE5 + USIMST + USIOE; // Out & clk enable, SPI Master USICTL1 |= USICKPH + USIIE; // Counter interrupt USICKCTL = USIDIV_7 + USISSEL_2; // /2 SMCLK USICTL0 &= ~USISWRST; // Enable USI USICNT = USI16B; // Enable 16 bit CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 10000; // Duration TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK, upmode _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { counter = _bcd_add_short(counter, 0x01); // Decimally increase counter's value USISR = counter; USICNT |= 16; // Start USI } // USI interrupt service routine #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { USICTL1 &= ~USIIFG; // Clear pending flag P1OUT &= ~0x01; // Latch data P1OUT |= 0x01; } In the coming parts, I will be increasing the number of digits to 8 and changing LEDs to 7-segment displays, maybe throw in a keyboard.
  13. RobG

    MSP430 LaunchPad, 74HC595, 16 LEDs

    EAGLE for Mac
  14. RobG

    MSP430 LaunchPad, 74HC595, 16 LEDs

    This is schematic for Part 2: Moved to another post
×