Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by nickey

  1. Ok, that just created a new question. I measured 178ma through the relay coil when activated and so I came up with a calculated 68 ohms for a collector resistor.. but when I put it in the circuit, the relay wouldn't trip any more.. I had to drop down to a 22 ohm resistor before it would engage, and after only a few seconds the resistor (1/4 watt) gets very hot.. don't think that will work well when the pump is on for 5 or 10 minutes at a time.

  2. In examining my fish tank aerator circuit, I am uncertain about the use and value of a couple of resistors. (I acknowledge I am a tinkerer and not an EE)..


    1. What is the purpose of R2? is it needed? (I copied its use from a different relay driver circuit)


    2. Though they both seem to do the job, how would I calculate the correct values of them? (I just started with them first as is)




    water pump relay.doc

  3. Thanks for the comments, no I haven't looked at overall power consumption yet.. good idea though. My current thoughts are that since I control the on and off times that I can keep the battery drain to negligible. Might look at your suggestion in the future though.

  4. hi Mike, wow thats just what I was looking for.. My only experience with micro controllers is the TI MSP430 and so I have no knowledge of the PIC systems.. Did it take much programming on your part? Also did that chip allow you to drive a relay directly from one of the pins? My relay has a coil taking about 200ma to activate it so I had to use a transistor.

  5. RobG, thanks for the info on choices other than LM317. I looked at TI and then LT at their stepdown converters, but unless I am reading them wrong, they all seem to be packaged for surface mount. I don't have that kind of accuracy in my tinkering space and so unless they also have some with nice big pins on them I don't know if I can ever use them.

  6. Thanks zeke for the nice pointer to all the relay circuits.. I actually ended up copying one of them for my circuit (now posted in projects).


    As for mystboy and optocupler, thanks for the idea but it looks like I have found a solution with the parts I have on hand.

  7. Ok, thanks to all of the great help I've had on this forum, I have this working on my breadboard and would love to hear any comments or criticism that could help me turn it into a better circuit or better coding.

    Warn you in advance that my circuit layout and C++ structure is far from professional.


    //  Fish tank aerator
    //  final version 1.0
    //  April 2011
    //  Built with Code Composer Studio v4
    #define freq_10  BIT0		//Port 1 bit 0
    #define freq_30  BIT1		//Port 1 bit 1
    #define freq_60  BIT2		//Port 1 bit 2
    #define dur_5    BIT3		//Port 1 bit 3
    #define dur_10   BIT4		//Port 1 bit 4
    #define freq_LED BIT5		//Port 1 bit 5 -- LED indicating frequency timer is active
    #define dur_LED  BIT6		//Port 1 bit 6 -- LED indicating duration timer (pump) is on
    #define pump_relay BIT7		//Port 1 bit 7
    void clear_states(void);	//function to reset states
    void clear_timers(void);	//function to reset all timers and interrupts and setup Ports
    void set_freq_timer(void);	//function to setup frequency timer
     	int freq_state = 0;
     	int dur_state = 0;
     	int timer_state = 0;
       int freq_timer_active = 0;
       int minutes_counter = 0;
       int half_seconds_counter = 0;
       int seconds_counter = 0;		
       int timer_goal = 0;
    void main(void)
     WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer
     clear_timers();						// reset timers 
     clear_states();						// reset states
    // Poll switches loop
     for (;
    	freq_state = (P1IN & (freq_10 + freq_30 + freq_60));
     	if (freq_state == 00)
    		clear_timers();					//if frequency switch is off
    		clear_states();					// reset states
    		dur_state = (P1IN & (dur_5 + dur_10));			//get pump duration from switch
    		if (timer_state != (freq_state + dur_state))	//if switches have changed since last time
    	 			clear_timers();							//reset any old timers
    				set_freq_timer();						//setup new frequency timer
    // Clear Timers and Interrupts and Initialize Ports
    void clear_timers(void) 
    TACCTL0 = 0;						//disable interrrupts for CCR0
    freq_timer_active = 0;				//clear active timers
       minutes_counter = 0;				//clear the minutes counter
    half_seconds_counter = 0;			//clear the half/seconds counter
    seconds_counter = 0;				//reset seconds counter
    timer_goal = 0;						//clear timer goal number
    P1IE = 0;							//disable all ints port 1
    P2IE = 0;							//disable all ints port 2
    P1OUT = 0;							//clear all pins on port 1
    P1DIR = 0;							//set all port 1 pins to "input"
    P1DIR |= dur_LED + freq_LED + pump_relay;	//set port 1 LED and PUMP pins to "output"
    // Clear States
    void clear_states(void)
    freq_state = 0;
     	dur_state = 0;						//reset states
     	timer_state = 0;
    freq_timer_active = 0;
    // Setup Frequency Timer
    void set_freq_timer(void)  
    timer_state = (freq_state + dur_state);
    freq_timer_active = 1;				//indicate frequency timer active
    minutes_counter = 0;				//clear the minutes counter
    switch (freq_state)
     		case freq_10:
       	timer_goal = 10;				//set timer goal to 10 minutes
     		case freq_30:
      		timer_goal = 30;				//set timer goal to 30 minutes
     		case freq_60:
       	timer_goal = 60;				//set timer goal to 60 minutes
    P1OUT |= freq_LED;					//set frequency LED on
    P1OUT &= ~dur_LED;					//set duration (pump) LED off
    P1OUT &= ~pump_relay;				//turn pump off
    TACCR0 = 1000;					//0 through 62499 cycles
    TACTL = TASSEL_2 + ID_3 + MC_1 + TACLR;  //smclk,divider8,upmode,clrTAR
    TACCTL0 = CCIE;						//enable interrupts for CCR0
    _BIS_SR(GIE);						//enable interrupts
    //Timer Interrupt Service Routine
    //  entered every .007 seconds
    #pragma vector = TIMERA0_VECTOR
    __interrupt void CCR0_ISR (void)
    if (++half_seconds_counter >= 73)	//if one/half second is up
    	half_seconds_counter = 0;		//clear the half/seconds counter
    	P1OUT ^= freq_LED; 				//toggle the freq led
    	if (freq_timer_active == 0)		//if the duration timer is active
    		P1OUT ^= dur_LED;			//toggle the duration led
    	if (++seconds_counter >= 120)	//if one minute is up
    		seconds_counter = 0;		//reset seconds counter
    		if (++minutes_counter >= timer_goal) //and if timer is complete
    	  		minutes_counter = 0;
    			if (freq_timer_active == 1)	//and it was the frequency timer
    				freq_timer_active = 0;
    				P1OUT |= pump_relay; //turn on the pump
    				switch (dur_state)
    			 			case dur_5:
    				   		timer_goal = 5;		//set timer goal to 5 minutes
    		  			case dur_10:
    		   			timer_goal = 10;	//set timer goal to 10 minutes
    			else						//must have been duration/pump timer is now complete
    				set_freq_timer();		//start frequency timer again



    water pump circuit.doc


    water pump code.doc

  8. On my current project I am trying to get the MSP430G2211 to turn on a 12 volt pump for a certain duration. I have all the other logic and coding worked out and done, but I am at an intersection as to how to convert the 3v out signal to control the pump.

    (see diagram attached)..

    Do I use some transistor to hit a Power MOSFET (I have an IRF510) and then use that to activate the relay (not sure on how to configure that)..

    Or do I use the IRF510 or something similar instead of a relay? (never used a MOSFET for anything before)..

    Or perhaps a better idea yet?


    water pump.doc

  9. infrared, thanks for the interest.. I am making a "live-well aerator control system" for my fishing boat. When I take my boat to Minnesota each year (where I grew up) one of the more popular baits are a variety of live minnows. When I am up at a lake for a couple of weeks, the tendency is to leave the minnows in the boat's live tank overnight along with any late caught fish that I didn't want to clean that night. Rather than leave the tank pump on all night and drain my boat battery, I wanted a way to have the pump come on at selectable times and durations. I first looked at timer chips and op amps and a lot of discrete components, but someone suggested a micro-controller for the job and I looked into it and it seems like a better approach. I have it working on my breadboard except for the voltage regulator and I would like to see if I can make a simple LM117 or LM317 work for me. Going to radio shack today to see if I can find one.

  10. Thanks Geekdoc, I'm sure there are a few of us old players around. My continued amazement is how fast the industry grew and how complex computers are now in everyone's hands including 2 year olds. Its fun to have a circuit and program development environment back in my hands. I'm looking forward to finding new things to make. Before I came to micro-controllers recently, I made lighthouse (to scale) replicas out of wood and mounted on stone and then made an internal battery powered circuit with an LED to simulate a beacon light fading on and off to look like it was rotating.. Then I made a few jewlery boxes for my granddaughters that sprang to life with 8 colored LEDs inside blinking independently (used an op-amp and counter chip). Now I am completing an aerator pump working off of two 3 position rotary switches and driving a relay and LEDs with the MSP430G2211 chip. Still working on the input voltage to regulate 12v lead-acid to 3.3v, but everything else seems to work.

  11. I've already posted a few questions and have been getting some really good help back. Thanks.


    I have a long history in computers and programming (I go back to the days of paper-tape and punched card decks if any of you can comprehend that)... then I spent the last majority of my career in management, so my brain is pretty well 'fried'. I am having to learn C++ from scratch, but my logic reasoning is still intact. I also like to play with discrete circuits which is what led me to micro-controllers since you can do more with less complexity. Just a tinkerer now and making things for my own enjoyment and use.

  12. OK, I have debugged my code on the Launchpad and I like it and am ready to move the MSP430 to my own breadboard for further testing and final development. Question I have is "Is there anything different I should be doing when downloading my program to the chip?"


    When I download in debug mode I just hit the debug button and it compiles and then downloads. Is there extra and unnecessary code loaded while doing this? Is there a different method for downloading non-debug code for final use? I scanned through the help documents but couldn't find a reference to something like this.


    thanks in advance for comments.

  13. Just started to build my C program (but don't have my LaunchPad yet) and I have 2 questions please:


    1. how can I determine what the final downloadable object code is so I can be sure it will fit onto the u-cont?


    2. how do I get rid of the error "warning: last line of file ends without a newline"?



  14. I was reading a separate post about the new TI chip coming out (this forum) and the author stated


    "Three timers with 4 CCRs each (finally, enough timer to do what I want!)

    Timer C will be 32-bit and will have 8 CCRs (sweet!)"


    I am a little slow here and don't fully grasp the significance of these parameters. How does increased number of CCRs benefit me? What can I do with them for example? I'm still early in my experience with C and the MSP430 so it just hasn't sunk in yet.



  15. Thanks for the reply, and you are right, I am working on my C program right now. I haven't decided whether to poll or not, timing is not critical nor is power consumption so which ever is easiest will probably work. I have already ordered a sample of an LTC3388EMSE-1#PBF from Linear since it sounded like it would do the job good for a regulator. I have found and collected a bunch of C++ coding examples and I plan on stealing a little code from where ever I can and piece together something and then start testing. thanks again

  16. I know some of you C experts out there could whip up a sample program for my new project in probably minutes, even if not perfect I could use my limited skills to test and refine it.

    I 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 inexperienced, especially C++).. If I had some examples I could work with them and expand them I think. Its all the necessary setups and interrupts 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

  • Create New...