Jump to content
43oh

RobG

Members
  • Content Count

    3,117
  • Joined

  • Last visited

  • Days Won

    248

Everything posted by RobG

  1. 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.
  2. 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.
  3. Here's my take on controlling RC servos with LaunchPad. Again, I am using my favorite shift register, 74HC595 (later I will be adding another example which will use 74HC164.) Since the voltage may be different in your application and the default DCO is used, you will have to work out the timing. If you need only 4ch, look at this post. Here is another 4ch example with ADC The simplest single channel ADC -> Servo example is here And finally, 2ch version is here Besides LP you will need 74HC595 and 8 10k pull down resistors. #include unsigned int counter = 5;
  4. Yes I am Next week I will do another one, controlling up to 8 servos using 74HC164
  5. 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
  6. 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.
  7. ******************* Also checkout this post ******************* In this example, I am demonstrating how to connect switches using parallel-serial shift register 74HC165. You can daisy chain as many 165s as you want. In my example I have 2 of them, which allowes me to connect up to 16 switches. In the video, I am using small 6 position DIP switch and all unused inputs are grounded and do not have pull-up resistors. Also, the state of switches is displayed on a 7 segment display (see my other post for how to connect 7 segment display.) De-bouncing is accomplished by comparing previous
  8. 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.
  9. Last weekend I was doing a little photo shoot and I was in need of extra flash source. I have an old Nikon SB-28 laying around so I figured I could use it if I had a slave trigger. Sure I can buy one from Amazon for <$10 (dumb one) or build one using 555 (which would ignore TTL pre-flash,) but why not go one step further and use LaunchPad. Step 1, build strobe light. This is pretty simple, just add opto-isolator and write short program. FL1 connects to the center pin of the hot shoe, FL2 to the side. If you need a hot shoe, you can get one cheap from BHPhotoVideo.com, just search for
  10. 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.
  11. **************** For the latest, see this post **************** In this example, I have replaced LEDs with four 7 segment displays. Note: I am using HC series, not HCT. LaunchPad provides 3.6V, HCT needs 5V. #include unsigned int counter = 0; // Counter variable unsigned int digitCounter = 0; // Digit counter unsigned char digit = 0; // Single digit to be displayed unsigned char bcd7digit[10] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; // BCD to 7 digit map unsigned char digitSelector[4] = {0x01, 0x02, 0x04, 0x08}; // Digit selecto
  12. This is schematic for Part 2: Moved to another post
  13. 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 |= U
×
×
  • Create New...