Jump to content
43oh

[ ENDED ] June 2011 - 43oh Project of the Month Contest


The May-June 2011 - 43oh Project of the Month Contest  

27 members have voted

You do not have permission to vote in this poll, or see the poll results. Please sign in or register to vote in this poll.

Recommended Posts

HI

well i finally made a video on my project but it didnt come out very good, the sound is off a little. The project is

controlling a dc motor with pwm.

 

here is the code again i am using grace for the program so all the initalization code is not there but the main program

should be ok i think.

 

Edit */*/* I added the full .zip of the project with all the grace files.

 

*
Chris Mansfield *** Pwm Dc motor control for msp430
*/


/*
* ======== Standard MSP430 includes ========
*/
#include 
#include 
/*
* ======== Grace related includes ========
*/
#include 

/*
*  ======== main ========
*/

int pwm=200;
int max;

#define MaxPwm 250
#define PWMStep 5

void main(void)
{
   CSL_init();                     // Activate Grace-generated configuration
   __enable_interrupt();           // Set global interrupt enable

   WDTCTL = WDTPW + WDTHOLD;

   int i=0;				// Jump start for motor requires more current to get 
   for(i=0;i<10000;i++)    // started.
   P1OUT= BIT0; 

   P1IFG=0; // clear the interrupt flag

 while(1)
 {
 	if(pwm != MaxPwm)
 	{
 for(max=0;max<=MaxPwm;max+=PWMStep)
 	 {
 		if(max < pwm)
 		 P1OUT = BIT0;//output on
 		else
 		P1OUT = 0;// output 0 off 	
    }
 	}
    else
    P1OUT = BIT6 | BIT0; // max output

 }

}

volatile int pin;
volatile char depin;

void port1(void)
{
P1OUT=0;
pin=P1IN;

if(pin & BIT3)
{
 P1IFG&= ~BIT3; // clear p1.3 flag
 pwm+=PWMStep; //increase pwm
	if(pwm >= MaxPwm)
	pwm=MaxPwm; // limit max pwm 100%


  P1IE &= ~BIT3;	// debouce
  depin=1;
  TACTL = TASSEL_1 + ID_0 + MC_1 + TACLR;
  TACCR0 = 3500;
}

 if(pin& BIT1)
    {	
  P1IFG&= ~BIT1 ; // clear p1.1 flag
  pwm-=PWMStep; //	decrease pwm
	if(pwm <= 0)
	pwm=0; // limit min pwm 0%

  P1IE &= ~BIT1;	// debouce
  depin=1;
  TACTL = TASSEL_1 + ID_0 + MC_1 + TACLR;
  TACCR0 = 3500;
 }

 if(P1IFG) //clears any other flags
 P1IFG=0;
}

void WTD_ISR()
{

}

void TA_ISR()
{
if(depin == 1) // re-enable pin interuppt	
{
 P1IE |= BIT3;
 P1IE |= BIT1;
 depin=0;
}

TACTL  = MC_0;// disable clock
TACCR0 = 0;  // zero counter
}

 

here is the video ....sorry on the quality..

 

post-2410-135135500685_thumb.jpg

Motor.zip

Link to post
Share on other sites
  • Replies 66
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

To measure the CIR carrier frequency, each individual pulse of IR must be detected. Common IR demodulator modules can not do this - they respond to a burst of IR, not each pulse.   There are parts m

As this was suggested to me last month, I will try and submit my color matching game. As it is a beginner's first project, I am not sure if it is really worthy to be featured in a contest but you neve

Here's my project, don't have any pics or videos of it in action yet, will post some ASAP. I am using some of RobG's LCD code:http://www.43oh.com/forum/viewtopic.php?f=9&t=540 I found a 35-bit l

Posted Images

I have not worked on Grace, but is it possible for you to save your Grace Project directory.

 

Sure, i added it to the post. Also there is a typo on the name... MOtor, changing all the names is hard ...so i left it that way. :roll:

Link to post
Share on other sites

Unfortunately no.

 

See the rules;

A few simple rules to follow:

- You must be a member of the 43oh forum at least a week before your submission.

- One entry from each member will be permitted.

- Your project can be anything based around the MSP430. You may interface the MSP430 to another controller.

- You may reuse code from anywhere as long as you give credit to the original author.

- You must submit code and schematics of your project with a proper description.

- You can submit your MSP430 project, if it was created before the annoucement of the contest.

- You must have at least 5 posts in the forums, for your entry to be considered when the voting begins.

- A member is free to modify his/her code to perfection, till the closing date, as long as the original entry is not change.

For eg: If a member submits "Launchpad controlled Space Shuttle", he/she can modify code, schematics and hardware and improve upon it till the closing date. But a change in project to "Launchpad controlled Robot" will not be allowed. Hopefully this will encourage members to post their projects early and not play the waiting game.

Link to post
Share on other sites
- You can submit your MSP430 project, if it was created before the annoucement of the contest.

 

So if I don't have a project ready when I see the announcement, I can't enter any?

 

- You must have at least 5 posts in the forums, for your entry to be considered when the voting begins.

 

Comments or threads?

Link to post
Share on other sites
So if I don't have a project ready when I see the announcement, I can't enter any?

You can, but you have to specify what your project is. You may improve upon your project until the closing date, but you can not change the project.

 

This means that when POM opens, you may pledge "I am building a rocket silo control panel. So far I have two buttons and int main(){}, but stay tuned!", and this qualifies as your entry to the contest. You have to finish this by POM deadline. You have to finish this by POM deadline, ie. you can not say "Well, at the end of the day it turned out to be a marine wildlife exploration vessel" and expect to stay.

 

- You must have at least 5 posts in the forums, for your entry to be considered when the voting begins.
Comments or threads?

Comments.

Link to post
Share on other sites
  • 2 weeks later...

Here's my project, don't have any pics or videos of it in action yet, will post some ASAP.

I am using some of RobG's LCD code:http://www.43oh.com/forum/viewtopic.php?f=9&t=540

I found a 35-bit led driver/shift register, so I thought I'd use it in something. What came out was pretty neat, so I decided to enter it in the contest.

 

The micro sends a 36-bit word serially, with one start bit. A "one" turns on an LED.

[Build Thread]

M5451B7.PDF

 

post-2374-13513550165_thumb.png

//***************************************************************************************
// MSP430 Driver for 2 Shift Registers
//
// Description; Drives 35 LEDs and an LCD with 4 digital pins of the MSP430, via two shift registers
//
// MSP430x2xx
//http://processors.wiki.ti.com/index.php/MSP430_Launchpad_Shift_Register
//***************************************************************************************
#include 

   #define sendLCDData(data) send(data, 1);
   #define sendLCDcmd(data) send(data, 0);
   #define clearDisplay(); sendLCDcmd(0x01); __delay_cycles(2000)
   #define initDisplay(); sendLCDcmd(0x38); sendLCDcmd(0x0C); clearDisplay(); sendLCDcmd(0x06);

//Define our pins
   #define DATAPIN BIT7 //for both
   #define CLOCKPIN BIT6 //for LCD
   #define ENABLEPIN BIT5 //for LCD
   #define LEDCLOCKPIN BIT4 //for LEDs

// Declare functions
void delay ( unsigned int );
void pulseClock ( void );
void shiftOut1 ( long);
void shiftOut2 ( long);
void shiftOut3 ( long);

void pinWrite (unsigned int, long);

   char bitCounter = 0;
   void send(char data, char RegisterSelect);
   void PrintStr(char *Text);
   void send1(long long data);


int main( void )
{
 // Stop watchdog timer to prevent time out reset
 WDTCTL = WDTPW + WDTHOLD;
 P1DIR |= (DATAPIN + CLOCKPIN + ENABLEPIN + LEDCLOCKPIN);  // Setup pins as outputs
       __delay_cycles(10000);

       initDisplay();
       sendLCDcmd(0x80);
       PrintStr("Hello, 43oh.com!");
       sendLCDcmd(0xC0);
       PrintStr("This is a 35LED ");
       __delay_cycles(3000000);
       sendLCDcmd(0x80);
       PrintStr("ping-pong, with ");
       sendLCDcmd(0xC0);
       PrintStr("an LCD display. ");
       __delay_cycles(3000000);
 int i;
 //Do a "ping-pong" effect back and forth
 for(;{
    for ( i = 0 ; i < 16 ; i++ ){ //first 16, up
     shiftOut1(1 << i);
     delay(200);
   }

    for ( i = 0 ; i < 16 ; i++ ){ //second 16, up, after 16 NULL bits
     shiftOut2(1 << i);
     delay(200);
   }
    for ( i = 0 ; i < 3 ; i++ ){ //three last, up, after 32 NULL bits
     shiftOut3(1 << i);
     delay(300);
   }
    for ( i = 2 ; i > -1 ; i-- ){ //three last, down, after 32 NULL bits
     shiftOut3(1 << i);
     delay(300);
   }

    for ( i = 15 ; i > -1 ; i-- ){ //second 16 down, after 16 NULL bits
     shiftOut2(1 << i);
     delay(200);
   }

    for ( i = 15 ; i > 0 ; i-- ){ //first 16, down
     shiftOut1(1 << i);
     delay(200);
   }
     //and back up again...

 }
}
   void send(char data, char RegisterSelect) {   //For LCD
      bitCounter = 0;
      while(bitCounter < 8) {
           (data & BIT7) ? (P1OUT |= DATAPIN) : (P1OUT &= ~DATAPIN);
           data <<= 1;
           P1OUT |= CLOCKPIN;
           P1OUT &= ~CLOCKPIN;
           bitCounter++;
        }
        RegisterSelect ? (P1OUT |= DATAPIN) : (P1OUT &= ~DATAPIN);
        P1OUT |= ENABLEPIN;
        __delay_cycles(10);
        P1OUT &= ~ENABLEPIN;
   }
   void send1(long long data) {   //For testing
      bitCounter = 0;
      while(bitCounter < 16) {
           (data & BIT7) ? (P1OUT |= DATAPIN) : (P1OUT &= ~DATAPIN);
           data <<= 1;
           pulseClock();
           bitCounter++;
        }
   }

   void PrintStr(char *Text) {   //For LCD
   char *c;
   c = Text;
   while ((c != 0) && (*c != 0))
   {
       sendLCDData(*c);
       c++;
   }
}

// Delays by the specified Milliseconds
// thanks to:
// http://www.threadabort.com/archive/2010/09/05/msp430-delay-function-like-the-arduino.aspx
void delay(unsigned int ms)
{
while (ms--)
   {
       __delay_cycles(1000); // set for 16Mhz change it to 1000 for 1 Mhz
   }
}

// Writes a value to the specified bitmask/pin. Use built in defines
// when calling this, as the shiftOut() function does.
// All nonzero values are treated as "high" and zero is "low"
void pinWrite(unsigned int bit, long val )
{
 if (val){
   P1OUT |= bit;
 } else {
   P1OUT &= ~bit;
 }
}

// Pulse the clock pin
void pulseClock( void )
{
 P1OUT |= LEDCLOCKPIN;
 __delay_cycles(10);
 P1OUT ^= LEDCLOCKPIN;

}

// Take the given 16-bit value and shift it out, LSB to MSB
void shiftOut1(long val) {
 P1OUT |= DATAPIN;
 pulseClock();
 char i;

 // Iterate over each bit, set data pin, and pulse the clock to send it
 // to the shift register
 for (i = 0; i < 36; i++)  {
     pinWrite(DATAPIN, (val & (1 << i)));
     pulseClock();
 }

}

// Take the given 16-bit value and shift it out, LSB to MSB
void shiftOut2(long val) {
 P1OUT |= DATAPIN;
 pulseClock();
 char i;
 send1(0x0000);
 // Iterate over each bit, set data pin, and pulse the clock to send it
 // to the shift register
 for (i = 0; i < 19; i++)  {
     pinWrite(DATAPIN, (val & (1 << i)));
     pulseClock();
 }

}

// Take the given 3-bit value and shift it out, LSB to MSB
void shiftOut3(long val) {
 P1OUT |= DATAPIN;
 pulseClock();
 char i;
 send1(0x0000);
 send1(0x0000);
 // Iterate over each bit, set data pin, and pulse the clock to send it
 // to the shift register
 for (i = 0; i < 3; i++) {
     pinWrite(DATAPIN, (val & (1 << i)));
     pulseClock();
 }

}

Link to post
Share on other sites

My entry: Slot Cars Lap Counter/Timer

Finally it works the way I like it.

file.php?id=399

EDIT 21.6.: Good news everyone! I have a new code version, now with possibility to enable big digits or 4 lanes. Without big digits it fits in 2K FLASH devices supplied with LaunchPad in both 2 and 4 lanes modes. In 4 lanes mode buzzer needs to be placed on P2.6 (XIN).

Link to post
Share on other sites

My entry, 10 channel MIDI Lights Controller.

 

Works with note-on/off (velocity controls brightness) or with controllers. Responds to all notes and all controllers off.

MIDI channel and octave is fixed for now, but I have another version in works, one with dip switch and another with learn button.

The number of channels can be easily increased by adding serial boards.

The total limit for the whole unit is 2400W, but each channel can pull a lot more than 120W.

 

I will post a better video once I find a suitable Star Wars track :D

 

 

Here's my first light show.

Sorry to disappoint you guys, but a) I do not own any Star Wars media, B) I am so busy at work and with the kids I hardly have any time for my hobbies.

I know "It's No Good" but it is what it is :)

 

 

post-197-135135502667_thumb.jpg

Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...