hi i am new to the msp430 launchpad and i am trying desperately how to use it as a timer that controls a relay i need it to be on for 10 seconds and off for 50 seconds and repeat please please help me
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.
hi i am new to the msp430 launchpad and i am trying desperately how to use it as a timer that controls a relay i need it to be on for 10 seconds and off for 50 seconds and repeat please please help me
david soderbloom said:hi i am new to the msp430 launchpad and i am trying desperately how to use it as a timer that controls a relay i need it to be on for 10 seconds and off for 50 seconds and repeat please please help me
Hi David, sorry if this answer appear bad to you, but timer are for uS precision timing, are you able to do C programming? Which processor on socket or application? If so use a software loop or change an example led flashing to suit your need then specify if you wish to use calibrated DCO constant with 1% error on timing or a better stable 32KHz LF xtal.
Regards
Roberto
ext xtal how to set up and two a nice example of how to do the code for a 10 second on 50 second off loop
You didn't clarify whether you are already proficient in 'C' programming - in particular, 'C' programming for small microcontrollers.
Clearly, that is a prerequisite to this task.
Have you spent time reviewing the support material available for the MSP430: www.ti.com/msp430 - in particular the 'Training' tab.
Note also the 'Tech Docs' tab - which lists all the available supporting documentation.
Example code is available under the 'Tools & Software' tab.
In addition to the given suggestions for material, here a simple outline of how to do it:
set up the clock system for a known frequency. (you may work with the default, which is app. 1.05MHz)
Set up a timer to count this frequency. Simples case is free running in cont mode.
On every timer overflow, a certain time has passed. (on 1.05MHz, 43,7ms).
Write a interrupt service routine (ISR) for the timer interrupt.
Each time this function is called, 43,7ms have passed, so simply sum them up and when your 10s have passed, take an action.
It can be refined, by using low-power modes, calibrated base frequency and maybe an adjustment for a 'rounder' timing (e.g. 50ms, so 20 interrupts are one second, 400 are 20 seconds).
if everyone has the answers, then riddle me this batman... , i was wandering about a code example, i want one of you to get off your high horse and show us a code example of a timer that is on for 10 seconds and off for 50 seconds, 1/6 duty cycle i want to see how running the two timers is accomplished i have programmed c++ for years, i dont want to read a bunch of crap, i love how everyone is so awe inspired by this damn msp 430 i think it is useful yes but i have seen everyone with an arduino have a finished product within minutes i can accomplish this with my arduino mega in two damn minutes how is it done so fast and simply with msp 430 help me keep faith in this devolopement platform
david soderbloom said:i can accomplish this with my arduino mega in two damn minutes
So do that, then!
The thing with the Arduino (and its ilk) is that you get a bunch of libraries that do all this low-level fine-detail stuff for you; if that's the way you want to work, that's fine - stick with it.
The MSP430 is just a microcontroller, so you do have to do all this low-level fine-detail "bare metal" stuff - "crap", as you call it - yourself.
Clearly, this is not for everyone - that's why platforms like Arduino exist!
Do you want finished code for nothing? Ok goto arduino site and don't stress us again here.
This is a microcontroller help forum. We don't have time to serve people saying arduino is simple or laying about years of c++ programming.
From what are you asking us I hope You are NOT able to perform a simple two line program!
Regards
Hi Andy, I am tired of this burden on forum, how can we reduce? Is more annoying than spam. This guy say it is a c++ programming for years.. Ok what is asking us I was able to do near 40 year ago when I started my first assembly program.
I am sure this guy never can't do with arduino in days not two minutes.
Regards
Roberto
Roberto Romano said:This guy say it is a c++ programming for years.. Ok what is asking us I was able to do near 40 year ago when I started my first assembly program
Now, Now! It is perfectly possible that he is, indeed, a thoroughly competent "high level" C++ programmer without ever having done any of this really low-level, bare-metal microcontroller stuff. There are plenty of platforms that provide all that for you.
I don't know about Arduino, but I recently tried an mbed, and I was able to get something up & running on that far quicker than would be possible on a "bare-metal" microcontroller: http://twitpic.com/81uzja
Again, this is precisely because the mbed comes with a whole bunch of libraries which do all that low-level "crap" (sic) for you - so you don't have to understand, do, or even think about it yourself.
hahaha once again i rest my case not one of you can produce a code example, i just want to know whats the best method of applying this to my application there seems to be multiple ways to accomplish this i want short, simple, reliable, job done i have yet to find someone that can show me an example if your all so enlightened than show me how its done if its so "simple for you elite advanced super users"
oh yeah and all the crap i am talking about is if somebody did it better than why reinvent the wheel go ahead and feel so self satisfied with your insanely vast dorkness of fully understanding every facet and fundamental of the msp 430 that's great! but i get laid, and get *** done one way or another, i don't have the never ending time frame because i am not a forty year old virgin!!! to learn everything about it i just need it to serve a simple purpose and i would greatly appreciate anybody who is competent enough to present an example come on i have given tons of help to others on c++ coding forums and they have helped me, srry i cannot afford to give as much as much help as i would like.
I am not sure why would want to use 2 timers but a timer that uses a 32 kHz souce like XT1CLK, which is usually the ACLK outside of the clock system can be used to count seconds.
Timer0 is initialized by
//capture/compare unit 0 is used
//32Khz crystall therefore let it count to 32767 till it generates the interrupt
TA0CCR0 = 32768 - 1;
//enable interrupt
TA0CCTL0 |= CCIE;
//use aclk, continous/compare mode clear the counter
TA0CTL |= TASSEL0 + MC1 + TACLR;
//set the relay on
The timer generates an interrupt every second now.
All you have to do is to count the seconds:
static enum{
On,
Off
}RelayState = On;
#pragma vector = TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void)
{
static u8 secondsCounter = 0;
secondsCounter++;
switch (RelayState)
{
case On:
if( secondsCounter == 10 )
{
RelayState = Off;
secondsCounter = 0
//set relay off flag, wake mcu up
}
}
break;
case Off:
if( secondsCounter == 50 )
{
RelayState = On;
secondsCounter = 0;
//set relay on flag, wake mcu up
}
break;
}
}
And less ranting please, helping doesnt mean that someone does your work. The timers are well described in the CC430 user guide and a state machine shouldnt be a problem for an experienced c++ programmer.
mark sonn said:And less ranting please, helping doesnt mean that someone does your work. The timers are well described in the CC430 user guide and a state machine shouldnt be a problem for an experienced c++ programmer.
Hi Mark, please cross check this short circuit loop and no more word about have to be spent about.
Take care from volatile race behavior on your code.
Regards
Taking you tone into account, It's a matter of 'want' rather than a matter of 'can'.david soderbloom said:not one of you can produce a code example
Even then, an at least partially competent C programmer should be able to figure out how to count seconds and act on certain counts, once a timer is set up for a certain delay. Even when using the .NET libs under VC++ for timers, this would be a task to accomplish. A simple one, still more than just call for a timer.Andy Neil said:It is perfectly possible that he is, indeed, a thoroughly competent "high level" C++ programmer without ever having done any of this really low-level, bare-metal microcontroller stuff
That depends on your application (the 'whole picture'), which nobody knows except you.david soderbloom said:i just want to know whats the best method of applying this to my application
And nobody wants to do the job for you, for free, in his spare time.david soderbloom said:i want short, simple, reliable, job done
Take a look at gadgeteer. It is called a microcontroller environment, but the specs rather look like a PC with pentium processor. With .NET available. Argh!Andy Neil said:I don't know about Arduino, but I recently tried an mbed
**Attention** This is a public forum