• Category Archives Uncategorized
  • MSP430 interrupt driven PWM

    this is the code for a PWM, using the WDT as an interval timer.

    //options for interval timer
    /* WDT is clocked by fSMCLK (assumed 1MHz)
    WDT_MDLY_32 (WDTPW+WDTTMSEL+WDTCNTCL)  32ms interval (default)
    WDT_MDLY_8 (WDTPW+WDTTMSEL+WDTCNTCL+WDTIS0)  8ms ”
    WDT_MDLY_0_5 (WDTPW+WDTTMSEL+WDTCNTCL+WDTIS1)  0.5ms ”
    WDT_MDLY_0_064 (WDTPW+WDTTMSEL+WDTCNTCL+WDTIS1+WDTIS0)  0.064ms ”
    WDT is clocked by fACLK (assumed 32KHz)
    WDT_ADLY_1000 (WDTPW+WDTTMSEL+WDTCNTCL+WDTSSEL)  1000ms ”
    WDT_ADLY_250 (WDTPW+WDTTMSEL+WDTCNTCL+WDTSSEL+WDTIS0)  250ms ”
    WDT_ADLY_16   16ms ”
    WDT_ADLY_1_9   1.9ms ”
    interval x PERIOD = period interval    .064ms x 200 = 12.8ms or 78.125hz */
    #include <msp430x20x2.h>
    #include <signal.h> //add for interrupt
    #define PERIOD 200  //defines frequency
    volatile  int timer = 0; //counts how many interrupts have been called
    //resets when it counts to PERIOD
    volatile  int duty_cycle = 0;// max = PERIOD - 1 and min = 1
    void main(void)
    {
    WDTCTL = WDT_MDLY_0_064; //interval setting
    P1DIR |= BIT0;
    P1OUT |= BIT0;
    IE1 |= WDTIE;
    eint(); //enable interrupt
    }//end main
    interrupt(WDT_VECTOR) watchdog_timer(void)
    {
    ++timer;
    if (timer == PERIOD) { timer = 0; P1OUT |= BIT0;  }
    if (timer == duty_cycle ) { P1OUT ^= BIT0; }
    }//end interrupt

    a quick demo using my rgb light

    sorry for the sound, i forgot to turn off my TV lol


  • Invintory time!!!

    While i work and try to finish a few small projects that i have started but haven’t posted about, I will be doing a small inventory of all my parts…….I have boxes and bags, and parts almost everywhere and i dont really know what i have any more. When i am finished, I may be giving away parts as long as shipping is reasonable. This wont cut to much into my programming and writing posts, i do that during work (ssshhhh!).

    I also want to thank everyone who visits my site. It means alot 🙂

    Justin


  • TI samples came in today

    ADS7841-
    12-Bit, 4-Channel Analog-to-Digital Converter
    ADS7813-
    16-Bit Sampling Analog-To-Digital Converter
    …TLC5940-
    16-Channel LED Driver w/EEprom
    TLC556-
    Dual LinCMOS(TM) Timer
    TRS232E-
    Dual RS-232 Driver/Receiver With IEC61000-4-2 Protection
    MSP430F2013-
    16-bit Ultra-Low-Power Microcontroller, 2kB Flash


  • Simple servo power source

    When I was thinking of how to run more than a few servos from my arduino, I was contemplating, the best approach to regulating the voltage for the servos. Currently I am testing my setup with 4 HS-311 Hitec servos, and a 7.2v 1.5A LiPo battery. This is a simple and easy setup, its not the most energy efficient but it works for this purpose. Currently i am not going to improve this simplistic design till i need more power or efficiency. Parts used – LM317 TO220, DC power with center pin Positive, 22o Ohm + 680 Ohm carbon film resistors, .003 micro farads Cap, .001 micro farad electrolytic Cap, Header pins and wire. The schematic i used was the first one out of the data sheet nearly on the front page. At first it was tough for me to figure out how to get the resistor values, i looked and looked and stumbled upon this site that automatically calculates the correct values for resistors per your needed voltage.

    Site needed here

    after calculating  the needed voltage and finding the needed resistors, for my 5V, I used 220 on R1 and 680 on R2, I might change them out to get the 6.5Volts I would like to have, since my servos are rated up to 6V. This extra voltage will speed up the turn speed by micro seconds and add a few more grams of torque. But that’s for a later project.

    After soldering all the connections

    I put 12V  wall wort and tested the voltage, Perfect reads about 5.18 volts, so i left it hooked up for a min to see fi any smoke fires or excesive heat build up with no load,(i thought i had accidentally bridged a connection) No sparks no fire, time for a load test. I start hooking up the Servos to the headers, 6 pairs of 3 pins, only 4 used. Then loaded up my arduino with a simple servo.write to 90 degrees and then sweep. All servos work, now to actually put a load on the servos to see if the power source can handle the load, since I don’t know what the amperage rating on these servos, nothing was stated on the box or any other info I could find.

    Video and load test still to come!