This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

New project, could use experienced help

Other Parts Discussed in Thread: LM317, TPS3619

Hi all, new to the forum.  Just ordered the Launchpad and hope to make a special application board.  First of all I am much better at circuit soldering and debugging than I am at coding (very rusty, especially C++)..   If I had some examples I could work with them and expand them I think.  Its all the necessary setups and such that I need to get past.

What I want one of the 'included' msp430's to do is Read two switches, setup appropriate timers, set LED's and also drive a relay.

Switch one - 4 position, OFF, 10 Min, 30 Min, 60 Min, --- this will determine the "Frequency" of the second (duration) timer.

Switch two - toggle off or on, represents 5 Min, or 10 Min, --- this will determine the "Duration" timer

LED one - shows that the Frequency timer is active (sw one not off)

LED two - shows that the Duration timer is active (in the middle of a cycle)

When the Duration timer is running, it controls the amount of time that an external relay is set.

The primary Voltage supply is a 12 volt lead acid battery, so I know that some sort of regulator circuit or voltage divider circuit will need to be designed to get the msp430 levels down to 3 volts.

Also needed will be an external FET or power transister tied to one of the output pins as driven by the Duration timer.  This relay will be switching the original 12 volt levels to drive a pump.

Some questions come to mind such as -- should the switch positions be polled or interrupt driven?  Is the watchdog needed?  I am not too concerned about operating the msp430 at the most low levels and conserving power since I really don't think it would be a serious enough draw from the main source it it were on all the time.

Any/all ideas, coding examples, and input voltage dividing examples would be very much appreciated.  thanks

 

 

 

 

  • Dave,

    It's great to see you using the MSP430.

    A few comments. Interrupts have many many advantages and I'd recommend using them as much as possible. Make sure that you have enough I/O with interrupt capability to realize your application.

    As for the 12V to 3.3V regulator (It's a very common output voltage than 3V), you need to estimate your output current. 500mA should be plenty enough I believe, and 250mA should also be acceptable. Don't look for LDOs. Because of the large difference between input and output voltage, a standard regulator or switching regulator should be used. LM317 is one option and is quite popular. Make sure that the packaging is something you can handle. It shouldn't be an issue if you're making your own PCB. If your output power is high (above 1A or so) then switching regulators is the way to go. Make sure the power rails of the MSP430 are clean with plenty of decoupling capacitors.

    I don't know about how you'll drive the LEDs (depending on how much current), but note that many microcontrolers have limited sourcing capability. They do have better current sinking capability in which case you'd connect the LED's Cathode to the MSP430 and the Anode to Vcc. Look at the datasheet for the LED and the MSP430 to see what's possible.

    Be sure to protect the circuit from relay voltage spikes using the appropriate diode. Make sure you can successfully drive it. Some posts on adding a relay are here:
    http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/52065.aspx
    http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/90617.aspx

    There's plenty of code to go around. Look at the following file (make sure these are appropriate for your msp430 device):
    http://www.ti.com/litv/zip/slac467a

     

    Gustavo

  • Thanks for the quick reply, I have looked at a lot of the TI coding examples but they seem pretty limited in addressing the logic flow that I need.  I was hoping someone could take a rough stab at a C example for me that I could work with and tweak till I got it to work.

     

  • I'm not going to do it in C for you, but it's pretty simple. In this case, it's such a simple state machine that I'd do it all from interrupt handlers and the main loop would consist of just "go back to sleep".

    You enable interrupts on the timer and switch position change. The timer may or may not be running, and you have to reprogram the switch input edge to interrupt on every time they change.

    1. Every time you get a timer interrupt, count seconds and roll over to minutes. (Optional: If the minutes do not roll over, go back to sleep.) Then fall through to step 3.
    2. When you get a switch interrupt, read the new switch positions into an internal variable, write them to PxIES to detect the next change, and continue with step 3.
    3. If switch one is "off", disable the timer, reset the time counters to 0, disable the power switch, and go back to sleep.
    4. Enable the timer.
    5. If the minutes counter is larger than the period (what you call frequency), reset it to zero.
    6. If the minutes counter is less than the duration, enable the power switch. Otherwise, disable it.
    7. Go back to sleep.
    By reading the switch positions from an interrupt handler like this, you can disable the timer completely and minimize power consumption in the off state.

    As for the suggestion to use a standard (not LDO) regulator since you have the headroom, that's an excellent suggestion from a circuit stability point of view, if you can accept its 50 μA Iq, plus whatever your sense resistor divider draws. If you need lower, comparable to the MSP430's 1 μA, Iq is generally more heavily optimized in LDOs, like the TLV70433's 3.2 μA, or the MC78FC33's 1.1 μA. For the ultimate in power efficiency, see something like the LTC3388, a switching regulator with < 1 μA Iq.

    (Speaking of all this, why don't MSP430s exist with an on-board backup battery power switch? It sucks to spend an extra dollar and 0.5 μA for a TPS3619.) Ah, never mind, just found the 'F643x series. Not quite what I wanted, but it seems that someone has the general idea.

**Attention** This is a public forum