Jump to content

mtlevine0

Members
  • Content Count

    36
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    mtlevine0 reacted to bluehash in [Group Buy-11][C]WizFi210 Serial to Wifi Module   
    I'll do another one next week or so, when this batch comes in.
  2. Like
    mtlevine0 got a reaction from timsoer in LED Twitter Ticker   
    I've been working on a project using the launchpad with the msp430g2553 interfaced to a LED display. A Python script running on my PC fetches the most recent tweet of a specific twitter user and sends it to the launchpad via serial. Being my first time ever using Python I was impressed to find how easy it was to implement this. I plan on adding an unread email counter and weather ticker to the script in the future.
     
    Heres a quick video of it in action:

    http://www.youtube.com/watch?v=IDIMfBfikjU
    I tweeted "Hello 43oh.com" from my twitter account and of course twitter shortened it with their url shortener. Couldn't find an option to turn that feature off.
     
    Edit: I was able to get my hands on a nicer camera, so I replaced the video with a nicer looking one.
  3. Like
    mtlevine0 got a reaction from timsoer in LED Twitter Ticker   
    Here is the C code I wrote for the MSP430. Code is a bit messy and unorganized I plan on cleaning it up further and adding support for more LED display modules. Any input of the code is appreciated!
     

    /* * LED Twitter Ticker - A Python script running on my PC sends a tweet via serial to the MSP430 * and is scrolled across an 8x32 LED display. * * Jan, 2012 * By Matt Levine * * Special thanks to: * Bill Westfield: Code for communicating with the LED display * (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225239439) * Richard Prinz: 8x8 ROM PixelFont Editor * (http://www.min.at/prinz/software/pixelfont/) */ #include #include "ht1632.h" #include "8X8!FONT.h" #define X_MAX 31 #define Y_MAX 7 #define ASSERT(conditon) // do nothing #define ht1632_data BIT3 // Data pin (pin 7) #define ht1632_wrclk BIT4 // Write clock pin (pin 5) #define ht1632_cs BIT5 // Chip Select (1, 2, 3, or 4) #define HIGH 1 #define LOW 0 #define SCROLLDELAY 0 // delay in ms between pixel shifts #define LED BIT0 typedef char byte; void digitalWrite(unsigned char bit, unsigned char val); void delay(unsigned long ms); void ht1632_chipselect(byte chipno); void ht1632_chipfree(byte chipno); void ht1632_writebits(byte bits, byte firstbit); static void ht1632_sendcmd(byte command); static void ht1632_senddata(byte address, byte data); void plot(char x, char y, char val); void scan(void); byte ht1632_shadowram[64]; // our copy of the display's RAM (much faster then using onboard display ram) byte buffer[32]; byte length = 0; byte uartIndex = 0; char message[140]; byte t,j,i,x,y,temp; int main(void) { BCSCTL1 = CALBC1_16MHZ; // Setup basic clock for 16MHZ DCOCTL = CALDCO_16MHZ; // Set DCO to 16MHZ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR |= ht1632_cs + LED; P1OUT |= LED; digitalWrite(ht1632_cs, HIGH); /* unselect (active low) */ P1DIR |= ht1632_wrclk + ht1632_data; P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 0x83; // 16MHz 9600 UCA0BR1 = 0x06; // 16MHz 9600 UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt __bis_SR_register(GIE); ht1632_sendcmd(HT1632_CMD_SYSDIS); // Disable system ht1632_sendcmd(HT1632_CMD_COMS10); // 16*32, PMOS drivers ht1632_sendcmd(HT1632_CMD_MSTMD); // Master Mode ht1632_sendcmd(HT1632_CMD_SYSON); // System on ht1632_sendcmd(HT1632_CMD_LEDON); // LEDs on for (i=0; i<64; i++){ ht1632_senddata(i, 0); // clear the display! } for(i = 0; i < 32; i++){ buffer[i] = 0x00; // clear the buffer! } for(i = 0; i < 140; i++){ message[i] = 0x00; // clear the message! } while(1){ for(i = 0; i < length; i++){// message index for(t = 0; t < 8; t++){//8X8!FONT.h index //Write buffer to display for(x = 0; x < 32; x++){ for(y = 0; y < 8; y++){ plot(x,y,((buffer[x]>>y) & 0x01)); } } //Update buffer with scrolling for(j = 0; j < 32; j++){ temp = buffer[j+1]; buffer[j] = temp; } buffer[31] = font[message[i]][t]; delay(SCROLLDELAY); // delay in ms between pixel shift } } UCA0TXBUF = 'A'; // request next tweet while(UCA0STAT & UCBUSY); // wait until byte has been sent } } #pragma vector=USCIAB0RX_VECTOR __interrupt void USCI0RX_ISR(void) { P1OUT ^= LED; // show uart activity on Red LED while (!(IFG2&UCA0TXIFG)); message[uartIndex] = UCA0RXBUF; if(message[uartIndex] == 0x0D){ length = uartIndex; uartIndex = 0; i = 0; // reset message index? }else{ uartIndex++; // increment message index } } void digitalWrite(unsigned char bit, unsigned char val){ if(val){ P1OUT |= bit; }else{ P1OUT &= ~bit; } } void delay(unsigned long ms){ while (ms--){ __delay_cycles(16000); // 16mhz (1000 for 1mhz) } } /* * ht1632_writebits * Write bits (up to 8) to h1632 on pins ht1632_data, ht1632_wrclk * Chip is assumed to already be chip-selected * Bits are shifted out from MSB to LSB, with the first bit sent * being (bits & firstbit), shifted till firsbit is zero. */ void ht1632_chipselect(byte chipno) { digitalWrite(chipno, 0); } void ht1632_chipfree(byte chipno) { digitalWrite(chipno, 1); } void ht1632_writebits (byte bits, byte firstbit) { while (firstbit) { digitalWrite(ht1632_wrclk, LOW); if (bits & firstbit) { digitalWrite(ht1632_data, HIGH); __delay_cycles(130); //MSP430 @ 16mhz } else { digitalWrite(ht1632_data, LOW); __delay_cycles(130); //MSP430 @ 16mhz } digitalWrite(ht1632_wrclk, HIGH); firstbit >>= 1; __delay_cycles(65); //MSP430 @ 16mhz } } static void ht1632_sendcmd (byte command) { ht1632_chipselect(ht1632_cs); // Select chip ht1632_writebits(HT1632_ID_CMD, 1<<2); // send 3 bits of id: COMMMAND ht1632_writebits(command, 1<<7); // send the actual command ht1632_writebits(0, 1); /* one extra dont-care bit in commands. */ ht1632_chipfree(ht1632_cs); //done } static void ht1632_senddata (byte address, byte data) { ht1632_chipselect(ht1632_cs); // Select chip ht1632_writebits(HT1632_ID_WR, 1<<2); // send ID: WRITE to RAM ht1632_writebits(address, 1<<6); // Send address ht1632_writebits(data, 1<<3); // send 4 bits of data ht1632_chipfree(ht1632_cs); // done } /* * plot a point on the display, with the upper left hand corner * being (0,0), and the lower right hand corner being (23, 15). * Note that Y increases going "downward" in contrast with most * mathematical coordiate systems, but in common with many displays * No error checking; bad things may happen if arguments are out of * bounds! (The ASSERTS compile to nothing by default */ void plot (char x, char y, char val) { char addr, bitval; ASSERT(x >= 0); ASSERT(x <= X_MAX); ASSERT(y >= 0); ASSERT(y <= y_MAX); /* * The 4 bits in a single memory word go DOWN, with the LSB * (last transmitted) bit being on top. However, writebits() * sends the LSB first, so we have to do a sort of bit-reversal * somewhere. Here, this is done by shifting the single bit in * the opposite direction from what you might expect. */ bitval = 8>>(y&3); // compute which bit will need set addr = (x<<1) + (y>>2); // compute which memory word this is in if (val) { // Modify the shadow memory ht1632_shadowram[addr] |= bitval; } else { ht1632_shadowram[addr] &= ~bitval; } // Now copy the new memory value to the display ht1632_senddata(addr, ht1632_shadowram[addr]); }
  4. Like
    mtlevine0 got a reaction from timsoer in LED Twitter Ticker   
    Here is the Python code I wrote to send Tweets to the MSP430. This is my first time using Python so this code may make some more experienced Python users cringe, Any input is appreciated.
     

    # # LED Twitter Ticker - This Python script fetches the latest tweet from a given twitter # account and sends its out via serial to the MSP430. Once the MSP430 # has finished displaying the tweet it requests that the script sends the # next tweet to be displayed. # # Jan, 2012 # By Matt Levine # # Special thanks to: # pySerial # http://pyserial.sourceforge.net/ # python-twitter # http://code.google.com/p/python-twitter/ # from time import sleep import twitter import serial port = 3 index = 0; api = twitter.Api() ser = serial.Serial(port-1) #user = api.GetUser("@LDisplay") user = api.GetUser("@_AthensOhio") oldStatus = twitter.Api() print ser.portstr ser.write(" \r") while True: if ser.read() == 'A': if index == 0: user = api.GetUser("@_AthensOhio") status = user.GetStatus() print status.GetText() ser.write(" " + status.GetText() + " \r") if index == 1: user = api.GetUser("@Ohiou") status = user.GetStatus() print status.GetText() ser.write(" " + status.GetText() + " \r") if index == 2: user = api.GetUser("@LDisplay") status = user.GetStatus() print status.GetText() ser.write(" " +status.GetText() + " \r") if index == 3: user = api.GetUser("@BreakingNews") status = user.GetStatus() print status.GetText() ser.write(" " +status.GetText() + " \r") if index == 4: user = api.GetUser("@Hackaday") status = user.GetStatus() print status.GetText() ser.write(" " +status.GetText() + " \r") index = -1 index +=1 #sleep(1)
  5. Like
    mtlevine0 reacted to RobG in [Group Buy-11] [C] RGB LED Strips (with WS2811)   
    OK, let's get a count.
     
     
    1) 5050/WS2811 LEDs - $0.20/pcs (min. 25)
     
    2) 60LED/m strip - $14/m
     
    3) 30LED/m strip - $11/m
     
    I am also working on a Booster Pack PCB (mentioned here.) It will be available 2 weeks later, so I would ship them separately.
    4) Booster Pack PCB - $3 shipped (special price for GB participants.)
     
    Prices are based on min 300 LEDs and 8m of strips.
    If we don't meet those number, GB will be cancelled.
    If we get enough, I will order next Friday.
     
    Shipping in US $3
    I will consider shipping to Europe, but contact me first.
  6. Like
    mtlevine0 reacted to jpnorair in RGB LED PC Case Fan   
    Have you ever used Eagle before? I use DipTrace. It is a billion times more intuitive. The autorouter is not great, but I do RF boards mainly, so autorouting is always going to be bad. Anyway, DipTrace is like a cheap version of the old Protel, with the added benefit that it can import Eagle footprint libs into DipTrace.
  7. Like
    mtlevine0 got a reaction from abecedarian in RGB LED PC Case Fan   
    I have several of these case fans installed on my PC. Each fan uses four standard 5mm LEDs like the one pictured here.
    I'd like to replace each LED with an RGB LED controlled by a ws2801 ic. I plan to design a small PCB which would include the ws2801 controller along with a 5mm RGB LED. I would probably just control the whole thing with a Launchpad and use the USB to UART connect for communication with a visual basic or python app on the PC side.
    The board I'm planning would almost identical the Sparkfun ws2801 breakout, the only differences being the dimensions and LED type. This will be the first PCB I've ever designed so I'm hoping the 43oh community will be able to help me with some advice and hopefully double checking my work.
    The PC side app would allow for the user to select any color or animation. Another mode I'd like to implement would be a visual temperature monitor that would fade the LEDs from blue to red based on ambient or CPU temp.

     
    Phase One:
    Design PCB: Would you guys recommend I use Eagle PCB for this? Any tutorials you would recommend? I'll be doing this over the next few weeks or so depending on my class work load.
    Order PCB: I'm going to need 8 to 12 identical boards (depending on price breaks) for two to three fans. Whats the recommended budget PCB house around here, Itead/Dorkbot?

    Phase Two:
    Write embedded application: I'm thinking a MSP430g2553 should be fine, It's overkill really.
    Write PC side application: A GUI that runs in the background and hangs out on the task bar would be awesome for this. This will be another learning curve for me.

     
    That's all for now, let me know what you guys think.
    -Matt
  8. Like
    mtlevine0 got a reaction from jsolarski in RGB LED PC Case Fan   
    I have several of these case fans installed on my PC. Each fan uses four standard 5mm LEDs like the one pictured here.
    I'd like to replace each LED with an RGB LED controlled by a ws2801 ic. I plan to design a small PCB which would include the ws2801 controller along with a 5mm RGB LED. I would probably just control the whole thing with a Launchpad and use the USB to UART connect for communication with a visual basic or python app on the PC side.
    The board I'm planning would almost identical the Sparkfun ws2801 breakout, the only differences being the dimensions and LED type. This will be the first PCB I've ever designed so I'm hoping the 43oh community will be able to help me with some advice and hopefully double checking my work.
    The PC side app would allow for the user to select any color or animation. Another mode I'd like to implement would be a visual temperature monitor that would fade the LEDs from blue to red based on ambient or CPU temp.

     
    Phase One:
    Design PCB: Would you guys recommend I use Eagle PCB for this? Any tutorials you would recommend? I'll be doing this over the next few weeks or so depending on my class work load.
    Order PCB: I'm going to need 8 to 12 identical boards (depending on price breaks) for two to three fans. Whats the recommended budget PCB house around here, Itead/Dorkbot?

    Phase Two:
    Write embedded application: I'm thinking a MSP430g2553 should be fine, It's overkill really.
    Write PC side application: A GUI that runs in the background and hangs out on the task bar would be awesome for this. This will be another learning curve for me.

     
    That's all for now, let me know what you guys think.
    -Matt
  9. Like
    mtlevine0 reacted to oPossum in Advice on purchasing my first scope   
    Get the Rigol from Saelig. It is a popular proven model from a reputable retailer. Some of the other low cost 'scopes have various firmware glitches that may never be fixed.
     
    The Tek TDS200 and TDS1000 series are very good monochrome LCD DSOs. I wouldn't pay more than about $200 for one due to their age and buffer size (2.5k). They typically go for $250 to $500 on eBay.
     
    The older Tek and HP/Agilent CRT DSOs are quality stuff, but they are old and could fail at any time. Repair may be difficult or impossible, so not recommended.
  10. Like
    mtlevine0 reacted to RobG in Advice on purchasing my first scope   
    TDS-340 you linked to does not have any expansion cards so you will not be able to hook it up to your computer. In addition, it's CRT so it's large and heavy. For ~$350-$500 you can get TDS 1002B (60MHz) or similar.
  11. Like
    mtlevine0 reacted to cubeberg in T6963 Graphical LCD libraries   
    I'm not powering mine currently because of power consumption. It takes 450mA @ 4.2v, but runs fine @ 5v. Here's a link to the datasheet from the manufacturer's site. You might find it helpful.
  12. Like
    mtlevine0 reacted to turd in MSP430FG4618 and 24LC512   
    What errors do you get?
     
    This might work:
     

    //#include //For mspgcc //#include //For mspgcc #include "msp430g2553.h" //Address word + "HELLO WORLD" unsigned char txdata[14] = {0x00, 0x00, 0x00, 0x48, 0x45, 0x4C, 0x4C, 0x4F, 0x20, 0x57, 0x4F, 0x52, 0x4C, 0x44}; unsigned char rxdata[12]; unsigned char tx_byte_count; unsigned char rx_byte_count; unsigned char tx_byte_counter; unsigned char rx_byte_counter; unsigned char i; unsigned char tx_rx; void i2c_tx(unsigned char tx_count); void i2c_rx(unsigned char rx_count); void main(void) { WDTCTL = WDTPW + WDTHOLD; //Stop WDT BCSCTL1 = CALBC1_1MHZ; //Set DCO to 1MHz DCOCTL = CALDCO_1MHZ; P4SEL = BIT6 + BIT7; //Set RXD and TXD P4SEL2 = BIT6 + BIT7; UCA0CTL1 |= UCSSEL_2; //Have USCI use SMCLK AKA 1MHz main CLK UCA0BR0 = 104; //Baud = 9600 UCA0BR1 = 0; UCA0MCTL = UCBRS_1; //Modulation UCA0CTL1 &= ~UCSWRST; //Start USCI P3SEL |= BIT1 + BIT2; //Set I2C pins P3SEL2|= BIT1 + BIT2; UCB0CTL1 |= UCSWRST; //Enable SW reset UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; //I2C Master, synchronous mode UCB0CTL1 = UCSSEL_2 + UCSWRST; //Use SMCLK, keep SW reset UCB0BR0 = 12; //fSCL = SMCLK/12 = ~100kHz UCB0BR1 = 0; UCB0I2CSA = 0b1010000; //Slave Address UCB0CTL1 &= ~UCSWRST; //Clear SW reset, resume operation IE2 |= UCB0TXIE; //Enable TX interrupt IE2 |= UCB0RXIE; //Enable RX interrupt __delay_cycles(20000); //Just a start up delay i2c_tx(13); //i2c TX 13 bytes(Address word + "HELLO WORLD" __delay_cycles(20000); //Allow 24LC256 to write data i2c_tx(2); //i2c TX address i2c_rx(12); //i2c RX data for(i = 1; i < 12; i++) { while(!(IFG2 & UCA0TXIFG)); UCA0TXBUF = rxdata[i]; //UART TX data } __bis_SR_register(CPUOFF + GIE); //Wait for a reset } void i2c_tx(unsigned char tx_count) { tx_rx = 0; tx_byte_count = tx_count + 1; tx_byte_counter = tx_count; // Load TX byte counter UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition __bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts // Remain in LPM0 until all data is TX'd } void i2c_rx(unsigned char rx_count) { tx_rx = 1; rx_byte_count = rx_count + 1; rx_byte_counter = rx_count; // Load RX byte counter UCB0CTL1 &= ~UCTR; // I2C RX UCB0CTL1 |= UCTXSTT; // I2C start condition __bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts // Remain in LPM0 until all data is RX'd } //interrupt(USCIAB0TX_VECTOR) USCIAB0TX_ISR(void) #pragma vector = USCIAB0TX_VECTOR __interrupt void USCIAB0TX_ISR(void) //For mspgcc { if(tx_rx == 0) { if (tx_byte_counter > 0) //Check TX byte counter { UCB0TXBUF = txdata[tx_byte_count - tx_byte_counter]; // Load TX buffer tx_byte_counter--; //Decrement TX byte counter } else if(tx_byte_counter == 0) { UCB0CTL1 |= UCTXSTP; //I2C stop condition while (UCB0CTL1 & UCTXSTP); //Ensure stop condition got sent IFG2 &= ~UCB0TXIFG; //Clear USCI_B0 TX int flag __bic_SR_register_on_exit(CPUOFF); //Exit LPM0 } } else if(tx_rx == 1) { if (rx_byte_counter > 0) //Check RX byte counter { rxdata[rx_byte_count - rx_byte_counter] = UCB0RXBUF; rx_byte_counter--; //Decrement RX byte counter } else if(rx_byte_counter == 0) { UCB0CTL1 |= UCTXSTP; // I2C stop condition while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent rxdata[rx_byte_count - (rx_byte_counter + 1)] = UCB0RXBUF; rxdata[rx_byte_count - (rx_byte_counter + 1)] = UCB0RXBUF; IFG2 &= ~UCB0RXIFG; // Clear USCI_B0 RX int flag __bic_SR_register_on_exit(CPUOFF); // Exit LPM0 } } }
  13. Like
    mtlevine0 reacted to turd in MSP430FG4618 and 24LC512   
    Here's an example using an MSP430G2553 and a 24LC256.
    It's not perfect but it works.
     
    It first writes "HELLO WORLD" too 0x0000 then reads it back and sends it out the UART at 9600.
    I hope it helps
     

    //#include //For mspgcc //#include //For mspgcc #include "msp430g2553.h" //Address word + "HELLO WORLD" unsigned char txdata[14] = {0x00, 0x00, 0x00, 0x48, 0x45, 0x4C, 0x4C, 0x4F, 0x20, 0x57, 0x4F, 0x52, 0x4C, 0x44}; unsigned char rxdata[12]; unsigned char tx_byte_count; unsigned char rx_byte_count; unsigned char tx_byte_counter; unsigned char rx_byte_counter; unsigned char i; unsigned char tx_rx; void i2c_tx(unsigned char tx_count); void i2c_rx(unsigned char rx_count); void main(void) { WDTCTL = WDTPW + WDTHOLD; //Stop WDT BCSCTL1 = CALBC1_1MHZ; //Set DCO to 1MHz DCOCTL = CALDCO_1MHZ; P1SEL = BIT1 + BIT2; //Set RXD and TXD P1SEL2 = BIT1 + BIT2; UCA0CTL1 |= UCSSEL_2; //Have USCI use SMCLK AKA 1MHz main CLK UCA0BR0 = 104; //Baud = 9600 UCA0BR1 = 0; UCA0MCTL = UCBRS_1; //Modulation UCA0CTL1 &= ~UCSWRST; //Start USCI P1SEL |= BIT6 + BIT7; //Set I2C pins P1SEL2|= BIT6 + BIT7; UCB0CTL1 |= UCSWRST; //Enable SW reset UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; //I2C Master, synchronous mode UCB0CTL1 = UCSSEL_2 + UCSWRST; //Use SMCLK, keep SW reset UCB0BR0 = 12; //fSCL = SMCLK/12 = ~100kHz UCB0BR1 = 0; UCB0I2CSA = 0b1010000; //Slave Address UCB0CTL1 &= ~UCSWRST; //Clear SW reset, resume operation IE2 |= UCB0TXIE; //Enable TX interrupt IE2 |= UCB0RXIE; //Enable RX interrupt __delay_cycles(20000); //Just a start up delay i2c_tx(13); //i2c TX 13 bytes(Address word + "HELLO WORLD" __delay_cycles(20000); //Allow 24LC256 to write data i2c_tx(2); //i2c TX address i2c_rx(12); //i2c RX data for(i = 1; i < 12; i++) { while(!(IFG2 & UCA0TXIFG)); UCA0TXBUF = rxdata[i]; //UART TX data } __bis_SR_register(CPUOFF + GIE); //Wait for a reset } void i2c_tx(unsigned char tx_count) { tx_rx = 0; tx_byte_count = tx_count + 1; tx_byte_counter = tx_count; // Load TX byte counter UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition __bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts // Remain in LPM0 until all data is TX'd } void i2c_rx(unsigned char rx_count) { tx_rx = 1; rx_byte_count = rx_count + 1; rx_byte_counter = rx_count; // Load RX byte counter UCB0CTL1 &= ~UCTR; // I2C RX UCB0CTL1 |= UCTXSTT; // I2C start condition __bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts // Remain in LPM0 until all data is RX'd } //interrupt(USCIAB0TX_VECTOR) USCIAB0TX_ISR(void) #pragma vector = USCIAB0TX_VECTOR __interrupt void USCIAB0TX_ISR(void) //For mspgcc { if(tx_rx == 0) { if (tx_byte_counter > 0) //Check TX byte counter { UCB0TXBUF = txdata[tx_byte_count - tx_byte_counter]; // Load TX buffer tx_byte_counter--; //Decrement TX byte counter } else if(tx_byte_counter == 0) { UCB0CTL1 |= UCTXSTP; //I2C stop condition while (UCB0CTL1 & UCTXSTP); //Ensure stop condition got sent IFG2 &= ~UCB0TXIFG; //Clear USCI_B0 TX int flag __bic_SR_register_on_exit(CPUOFF); //Exit LPM0 } } else if(tx_rx == 1) { if (rx_byte_counter > 0) //Check RX byte counter { rxdata[rx_byte_count - rx_byte_counter] = UCB0RXBUF; rx_byte_counter--; //Decrement RX byte counter } else if(rx_byte_counter == 0) { UCB0CTL1 |= UCTXSTP; // I2C stop condition while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent rxdata[rx_byte_count - (rx_byte_counter + 1)] = UCB0RXBUF; rxdata[rx_byte_count - (rx_byte_counter + 1)] = UCB0RXBUF; IFG2 &= ~UCB0RXIFG; // Clear USCI_B0 RX int flag __bic_SR_register_on_exit(CPUOFF); // Exit LPM0 } } }
    It hasn't been tested with CCS or IAR just mspgcc.
     



  14. Like
    mtlevine0 got a reaction from MarkoeZ in LED Twitter Ticker   
    I've been working on a project using the launchpad with the msp430g2553 interfaced to a LED display. A Python script running on my PC fetches the most recent tweet of a specific twitter user and sends it to the launchpad via serial. Being my first time ever using Python I was impressed to find how easy it was to implement this. I plan on adding an unread email counter and weather ticker to the script in the future.
     
    Heres a quick video of it in action:

    http://www.youtube.com/watch?v=IDIMfBfikjU
    I tweeted "Hello 43oh.com" from my twitter account and of course twitter shortened it with their url shortener. Couldn't find an option to turn that feature off.
     
    Edit: I was able to get my hands on a nicer camera, so I replaced the video with a nicer looking one.
  15. Like
    mtlevine0 got a reaction from dacoffey in LED Twitter Ticker   
    I've been working on a project using the launchpad with the msp430g2553 interfaced to a LED display. A Python script running on my PC fetches the most recent tweet of a specific twitter user and sends it to the launchpad via serial. Being my first time ever using Python I was impressed to find how easy it was to implement this. I plan on adding an unread email counter and weather ticker to the script in the future.
     
    Heres a quick video of it in action:

    http://www.youtube.com/watch?v=IDIMfBfikjU
    I tweeted "Hello 43oh.com" from my twitter account and of course twitter shortened it with their url shortener. Couldn't find an option to turn that feature off.
     
    Edit: I was able to get my hands on a nicer camera, so I replaced the video with a nicer looking one.
  16. Like
    mtlevine0 got a reaction from imrahil in LED Twitter Ticker   
    I've been working on a project using the launchpad with the msp430g2553 interfaced to a LED display. A Python script running on my PC fetches the most recent tweet of a specific twitter user and sends it to the launchpad via serial. Being my first time ever using Python I was impressed to find how easy it was to implement this. I plan on adding an unread email counter and weather ticker to the script in the future.
     
    Heres a quick video of it in action:

    http://www.youtube.com/watch?v=IDIMfBfikjU
    I tweeted "Hello 43oh.com" from my twitter account and of course twitter shortened it with their url shortener. Couldn't find an option to turn that feature off.
     
    Edit: I was able to get my hands on a nicer camera, so I replaced the video with a nicer looking one.
  17. Like
    mtlevine0 got a reaction from bluehash in LED Twitter Ticker   
    Here is the Python code I wrote to send Tweets to the MSP430. This is my first time using Python so this code may make some more experienced Python users cringe, Any input is appreciated.
     

    # # LED Twitter Ticker - This Python script fetches the latest tweet from a given twitter # account and sends its out via serial to the MSP430. Once the MSP430 # has finished displaying the tweet it requests that the script sends the # next tweet to be displayed. # # Jan, 2012 # By Matt Levine # # Special thanks to: # pySerial # http://pyserial.sourceforge.net/ # python-twitter # http://code.google.com/p/python-twitter/ # from time import sleep import twitter import serial port = 3 index = 0; api = twitter.Api() ser = serial.Serial(port-1) #user = api.GetUser("@LDisplay") user = api.GetUser("@_AthensOhio") oldStatus = twitter.Api() print ser.portstr ser.write(" \r") while True: if ser.read() == 'A': if index == 0: user = api.GetUser("@_AthensOhio") status = user.GetStatus() print status.GetText() ser.write(" " + status.GetText() + " \r") if index == 1: user = api.GetUser("@Ohiou") status = user.GetStatus() print status.GetText() ser.write(" " + status.GetText() + " \r") if index == 2: user = api.GetUser("@LDisplay") status = user.GetStatus() print status.GetText() ser.write(" " +status.GetText() + " \r") if index == 3: user = api.GetUser("@BreakingNews") status = user.GetStatus() print status.GetText() ser.write(" " +status.GetText() + " \r") if index == 4: user = api.GetUser("@Hackaday") status = user.GetStatus() print status.GetText() ser.write(" " +status.GetText() + " \r") index = -1 index +=1 #sleep(1)
  18. Like
    mtlevine0 got a reaction from Rickta59 in LED Twitter Ticker   
    Here is the C code I wrote for the MSP430. Code is a bit messy and unorganized I plan on cleaning it up further and adding support for more LED display modules. Any input of the code is appreciated!
     

    /* * LED Twitter Ticker - A Python script running on my PC sends a tweet via serial to the MSP430 * and is scrolled across an 8x32 LED display. * * Jan, 2012 * By Matt Levine * * Special thanks to: * Bill Westfield: Code for communicating with the LED display * (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225239439) * Richard Prinz: 8x8 ROM PixelFont Editor * (http://www.min.at/prinz/software/pixelfont/) */ #include #include "ht1632.h" #include "8X8!FONT.h" #define X_MAX 31 #define Y_MAX 7 #define ASSERT(conditon) // do nothing #define ht1632_data BIT3 // Data pin (pin 7) #define ht1632_wrclk BIT4 // Write clock pin (pin 5) #define ht1632_cs BIT5 // Chip Select (1, 2, 3, or 4) #define HIGH 1 #define LOW 0 #define SCROLLDELAY 0 // delay in ms between pixel shifts #define LED BIT0 typedef char byte; void digitalWrite(unsigned char bit, unsigned char val); void delay(unsigned long ms); void ht1632_chipselect(byte chipno); void ht1632_chipfree(byte chipno); void ht1632_writebits(byte bits, byte firstbit); static void ht1632_sendcmd(byte command); static void ht1632_senddata(byte address, byte data); void plot(char x, char y, char val); void scan(void); byte ht1632_shadowram[64]; // our copy of the display's RAM (much faster then using onboard display ram) byte buffer[32]; byte length = 0; byte uartIndex = 0; char message[140]; byte t,j,i,x,y,temp; int main(void) { BCSCTL1 = CALBC1_16MHZ; // Setup basic clock for 16MHZ DCOCTL = CALDCO_16MHZ; // Set DCO to 16MHZ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR |= ht1632_cs + LED; P1OUT |= LED; digitalWrite(ht1632_cs, HIGH); /* unselect (active low) */ P1DIR |= ht1632_wrclk + ht1632_data; P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 0x83; // 16MHz 9600 UCA0BR1 = 0x06; // 16MHz 9600 UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt __bis_SR_register(GIE); ht1632_sendcmd(HT1632_CMD_SYSDIS); // Disable system ht1632_sendcmd(HT1632_CMD_COMS10); // 16*32, PMOS drivers ht1632_sendcmd(HT1632_CMD_MSTMD); // Master Mode ht1632_sendcmd(HT1632_CMD_SYSON); // System on ht1632_sendcmd(HT1632_CMD_LEDON); // LEDs on for (i=0; i<64; i++){ ht1632_senddata(i, 0); // clear the display! } for(i = 0; i < 32; i++){ buffer[i] = 0x00; // clear the buffer! } for(i = 0; i < 140; i++){ message[i] = 0x00; // clear the message! } while(1){ for(i = 0; i < length; i++){// message index for(t = 0; t < 8; t++){//8X8!FONT.h index //Write buffer to display for(x = 0; x < 32; x++){ for(y = 0; y < 8; y++){ plot(x,y,((buffer[x]>>y) & 0x01)); } } //Update buffer with scrolling for(j = 0; j < 32; j++){ temp = buffer[j+1]; buffer[j] = temp; } buffer[31] = font[message[i]][t]; delay(SCROLLDELAY); // delay in ms between pixel shift } } UCA0TXBUF = 'A'; // request next tweet while(UCA0STAT & UCBUSY); // wait until byte has been sent } } #pragma vector=USCIAB0RX_VECTOR __interrupt void USCI0RX_ISR(void) { P1OUT ^= LED; // show uart activity on Red LED while (!(IFG2&UCA0TXIFG)); message[uartIndex] = UCA0RXBUF; if(message[uartIndex] == 0x0D){ length = uartIndex; uartIndex = 0; i = 0; // reset message index? }else{ uartIndex++; // increment message index } } void digitalWrite(unsigned char bit, unsigned char val){ if(val){ P1OUT |= bit; }else{ P1OUT &= ~bit; } } void delay(unsigned long ms){ while (ms--){ __delay_cycles(16000); // 16mhz (1000 for 1mhz) } } /* * ht1632_writebits * Write bits (up to 8) to h1632 on pins ht1632_data, ht1632_wrclk * Chip is assumed to already be chip-selected * Bits are shifted out from MSB to LSB, with the first bit sent * being (bits & firstbit), shifted till firsbit is zero. */ void ht1632_chipselect(byte chipno) { digitalWrite(chipno, 0); } void ht1632_chipfree(byte chipno) { digitalWrite(chipno, 1); } void ht1632_writebits (byte bits, byte firstbit) { while (firstbit) { digitalWrite(ht1632_wrclk, LOW); if (bits & firstbit) { digitalWrite(ht1632_data, HIGH); __delay_cycles(130); //MSP430 @ 16mhz } else { digitalWrite(ht1632_data, LOW); __delay_cycles(130); //MSP430 @ 16mhz } digitalWrite(ht1632_wrclk, HIGH); firstbit >>= 1; __delay_cycles(65); //MSP430 @ 16mhz } } static void ht1632_sendcmd (byte command) { ht1632_chipselect(ht1632_cs); // Select chip ht1632_writebits(HT1632_ID_CMD, 1<<2); // send 3 bits of id: COMMMAND ht1632_writebits(command, 1<<7); // send the actual command ht1632_writebits(0, 1); /* one extra dont-care bit in commands. */ ht1632_chipfree(ht1632_cs); //done } static void ht1632_senddata (byte address, byte data) { ht1632_chipselect(ht1632_cs); // Select chip ht1632_writebits(HT1632_ID_WR, 1<<2); // send ID: WRITE to RAM ht1632_writebits(address, 1<<6); // Send address ht1632_writebits(data, 1<<3); // send 4 bits of data ht1632_chipfree(ht1632_cs); // done } /* * plot a point on the display, with the upper left hand corner * being (0,0), and the lower right hand corner being (23, 15). * Note that Y increases going "downward" in contrast with most * mathematical coordiate systems, but in common with many displays * No error checking; bad things may happen if arguments are out of * bounds! (The ASSERTS compile to nothing by default */ void plot (char x, char y, char val) { char addr, bitval; ASSERT(x >= 0); ASSERT(x <= X_MAX); ASSERT(y >= 0); ASSERT(y <= y_MAX); /* * The 4 bits in a single memory word go DOWN, with the LSB * (last transmitted) bit being on top. However, writebits() * sends the LSB first, so we have to do a sort of bit-reversal * somewhere. Here, this is done by shifting the single bit in * the opposite direction from what you might expect. */ bitval = 8>>(y&3); // compute which bit will need set addr = (x<<1) + (y>>2); // compute which memory word this is in if (val) { // Modify the shadow memory ht1632_shadowram[addr] |= bitval; } else { ht1632_shadowram[addr] &= ~bitval; } // Now copy the new memory value to the display ht1632_senddata(addr, ht1632_shadowram[addr]); }
  19. Like
    mtlevine0 got a reaction from oPossum in LED Twitter Ticker   
    Here is the Python code I wrote to send Tweets to the MSP430. This is my first time using Python so this code may make some more experienced Python users cringe, Any input is appreciated.
     

    # # LED Twitter Ticker - This Python script fetches the latest tweet from a given twitter # account and sends its out via serial to the MSP430. Once the MSP430 # has finished displaying the tweet it requests that the script sends the # next tweet to be displayed. # # Jan, 2012 # By Matt Levine # # Special thanks to: # pySerial # http://pyserial.sourceforge.net/ # python-twitter # http://code.google.com/p/python-twitter/ # from time import sleep import twitter import serial port = 3 index = 0; api = twitter.Api() ser = serial.Serial(port-1) #user = api.GetUser("@LDisplay") user = api.GetUser("@_AthensOhio") oldStatus = twitter.Api() print ser.portstr ser.write(" \r") while True: if ser.read() == 'A': if index == 0: user = api.GetUser("@_AthensOhio") status = user.GetStatus() print status.GetText() ser.write(" " + status.GetText() + " \r") if index == 1: user = api.GetUser("@Ohiou") status = user.GetStatus() print status.GetText() ser.write(" " + status.GetText() + " \r") if index == 2: user = api.GetUser("@LDisplay") status = user.GetStatus() print status.GetText() ser.write(" " +status.GetText() + " \r") if index == 3: user = api.GetUser("@BreakingNews") status = user.GetStatus() print status.GetText() ser.write(" " +status.GetText() + " \r") if index == 4: user = api.GetUser("@Hackaday") status = user.GetStatus() print status.GetText() ser.write(" " +status.GetText() + " \r") index = -1 index +=1 #sleep(1)
  20. Like
    mtlevine0 got a reaction from bluehash in LED Twitter Ticker   
    I've been working on a project using the launchpad with the msp430g2553 interfaced to a LED display. A Python script running on my PC fetches the most recent tweet of a specific twitter user and sends it to the launchpad via serial. Being my first time ever using Python I was impressed to find how easy it was to implement this. I plan on adding an unread email counter and weather ticker to the script in the future.
     
    Heres a quick video of it in action:

    http://www.youtube.com/watch?v=IDIMfBfikjU
    I tweeted "Hello 43oh.com" from my twitter account and of course twitter shortened it with their url shortener. Couldn't find an option to turn that feature off.
     
    Edit: I was able to get my hands on a nicer camera, so I replaced the video with a nicer looking one.
  21. Like
    mtlevine0 reacted to bluehash in Questions about program ROM. Vs. RAM usage.   
    Credit:

  22. Like
    mtlevine0 reacted to gordon in Questions about program ROM. Vs. RAM usage.   
    No, no. They refer to the various sections in the final binary (I'm making the connection with ELF here, this is what mspgcc uses anyway; the other compilers use different binary formats -- not exactly sure if they can be mapped 1:1 to ELF, but I'm guessing the principles can't be too far off): text is where the code (actual instructions) go (it's also likely constant (non-writeable) data go here as well), data is where writeable data (as in variables et all) go.
     
    There are other sections as well, things that contain debug symbols and stuff; get more about this at http://wiki.osdev.org/ELF for example, but read this with a grain of salt -- this article describes things from a perspective of a full-blown CPU with memory management and the like, quite some of the sections in this article simply make no sense in an MCU-context (no separate .text and .rodata for example, you simply have both of them in flash, whereas on a full-blown CPU things get a tad bit more complicated than that).
  23. Like
    mtlevine0 reacted to simpleavr in Questions about program ROM. Vs. RAM usage.   
    for "const" type data, as your font data are defined, u don't need to use ram as they are not going to change dynamically during program execution. i.e. u don't need to change values of these variables.
     
    the compiler (at least mspgcc that i use) will place your data along w/ your code and that occupies your programming flash space instead of ram space.
     
    also msp430 has only flash, there is no rom. and they are similar.
  24. Like
    mtlevine0 got a reaction from bluehash in IR controlled 5W RGB lamp.   
    I purchased one of these 5 watt RGB lamps off of ebay recently. I decoded the IR protocol with a tsop4838 and a Saleae logic. Using RobG's Sony IR remote (viewtopic.php?f=9&t=302) project as a starting point I was able to send messages of my own from a launchpad with a msp430g2231. I plan on later implementing the MSGEQ7 (http://www.sparkfun.com/products/10468) to create a standalone color organ.

     
    Any help / suggestions are welcome and appreciated!

    #include "msp430g2231.h" #define T500us 19 // 500us #define T600us 23 // 600us #define T1100us 42 // 1100us #define T1600us 61 // 1600us #define T4500us 172 // 4500us #define T9000us 345 // 9000us #define RED 0x7F80 #define GREEN 0xBF40 #define BLUE 0x3FC0 #define STARTCODE 0xFD02 char color = 0; char stopFlag = 0; char start = 0; char mode = 1; unsigned char bitCounter = 0; // command's bit counter unsigned char carrierFlag = 0; // flag to indicate carrier on or off unsigned int tmpCommand = 0; // copy of the current command used for shifting unsigned int command; void main(void) { WDTCTL = WDTPW + WDTHOLD; // stop WDT DCOCTL |= DCO0 + DCO1; // DCO = ~300kHz BCSCTL1 |= RSEL0 + RSEL1; // as above BCSCTL1 &= ~(RSEL2 + RSEL3); // as above BCSCTL2 |= DIVS0 + DIVS1; // divide SMCLK by 8 which will give us ~38kHz P1DIR |= BIT4; // port 1.4 is configured as SMCLK out and connected to IR emitter, this will be our carrier frequency, 38kHz P1OUT &= ~BIT4; P1SEL |= BIT4; // for now turn it on TACCR0 = T500us; // interrupt every 500us for starters TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, upmode TACCTL0 = CCIE; // CCR0 interrupt enabled tmpCommand = STARTCODE; command = BLUE; __bis_SR_register(LPM0_bits + GIE); // switch to LPM0 with interrupts for(;{ // Loop here for main program } } void sendOne(void){ P1SEL &= ~BIT4; TACCR0 = T500us; } void sendZero(void){ P1SEL &= ~BIT4; TACCR0 = T1600us; } void carrierOn(void){ P1SEL |= BIT4; // carrier on, once before every bit TACCR0 = T600us; // carrier on for 500us } void sendStart(unsigned char data){ if(data){ P1SEL &= ~BIT4; TACCR0 = T4500us; }else{ P1SEL |= BIT4; TACCR0 = T9000us; } } void sendStop(void){ sendZero(); } // Timer A interrupt service routine #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { if(start < 2 && mode){ sendStart(start); // send start signal there are two of them start++; }else{ if(carrierFlag){ carrierOn(); // carrier on, once before every bit }else{ if(bitCounter < 16){ // we have 16 bits to process if(tmpCommand & 0x8000){ // test bit 16 sendOne(); // if bit is 1, carrier off for 600us }else{ sendZero(); // if bit is 0, carrier off for 1600us } bitCounter++; tmpCommand<<=1; // shift bits to the left in tmp variable }else if(( bitCounter == 16) && (!mode) ){ sendStop(); // Send Stop bit bitCounter++; }else{ if(mode){ tmpCommand = command; mode = 0; carrierFlag = 1; }else{ tmpCommand = STARTCODE; mode = 1; stopFlag = 1; } bitCounter = 0; start = 0; P1SEL |= BIT4; TACCR0 = 0; //carrierFlag = 1; } } carrierFlag ^= 1; // toggle flag } }
  25. Like
    mtlevine0 got a reaction from RobG in IR controlled 5W RGB lamp.   
    I purchased one of these 5 watt RGB lamps off of ebay recently. I decoded the IR protocol with a tsop4838 and a Saleae logic. Using RobG's Sony IR remote (viewtopic.php?f=9&t=302) project as a starting point I was able to send messages of my own from a launchpad with a msp430g2231. I plan on later implementing the MSGEQ7 (http://www.sparkfun.com/products/10468) to create a standalone color organ.

     
    Any help / suggestions are welcome and appreciated!

    #include "msp430g2231.h" #define T500us 19 // 500us #define T600us 23 // 600us #define T1100us 42 // 1100us #define T1600us 61 // 1600us #define T4500us 172 // 4500us #define T9000us 345 // 9000us #define RED 0x7F80 #define GREEN 0xBF40 #define BLUE 0x3FC0 #define STARTCODE 0xFD02 char color = 0; char stopFlag = 0; char start = 0; char mode = 1; unsigned char bitCounter = 0; // command's bit counter unsigned char carrierFlag = 0; // flag to indicate carrier on or off unsigned int tmpCommand = 0; // copy of the current command used for shifting unsigned int command; void main(void) { WDTCTL = WDTPW + WDTHOLD; // stop WDT DCOCTL |= DCO0 + DCO1; // DCO = ~300kHz BCSCTL1 |= RSEL0 + RSEL1; // as above BCSCTL1 &= ~(RSEL2 + RSEL3); // as above BCSCTL2 |= DIVS0 + DIVS1; // divide SMCLK by 8 which will give us ~38kHz P1DIR |= BIT4; // port 1.4 is configured as SMCLK out and connected to IR emitter, this will be our carrier frequency, 38kHz P1OUT &= ~BIT4; P1SEL |= BIT4; // for now turn it on TACCR0 = T500us; // interrupt every 500us for starters TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, upmode TACCTL0 = CCIE; // CCR0 interrupt enabled tmpCommand = STARTCODE; command = BLUE; __bis_SR_register(LPM0_bits + GIE); // switch to LPM0 with interrupts for(;{ // Loop here for main program } } void sendOne(void){ P1SEL &= ~BIT4; TACCR0 = T500us; } void sendZero(void){ P1SEL &= ~BIT4; TACCR0 = T1600us; } void carrierOn(void){ P1SEL |= BIT4; // carrier on, once before every bit TACCR0 = T600us; // carrier on for 500us } void sendStart(unsigned char data){ if(data){ P1SEL &= ~BIT4; TACCR0 = T4500us; }else{ P1SEL |= BIT4; TACCR0 = T9000us; } } void sendStop(void){ sendZero(); } // Timer A interrupt service routine #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { if(start < 2 && mode){ sendStart(start); // send start signal there are two of them start++; }else{ if(carrierFlag){ carrierOn(); // carrier on, once before every bit }else{ if(bitCounter < 16){ // we have 16 bits to process if(tmpCommand & 0x8000){ // test bit 16 sendOne(); // if bit is 1, carrier off for 600us }else{ sendZero(); // if bit is 0, carrier off for 1600us } bitCounter++; tmpCommand<<=1; // shift bits to the left in tmp variable }else if(( bitCounter == 16) && (!mode) ){ sendStop(); // Send Stop bit bitCounter++; }else{ if(mode){ tmpCommand = command; mode = 0; carrierFlag = 1; }else{ tmpCommand = STARTCODE; mode = 1; stopFlag = 1; } bitCounter = 0; start = 0; P1SEL |= BIT4; TACCR0 = 0; //carrierFlag = 1; } } carrierFlag ^= 1; // toggle flag } }
×
×
  • Create New...