Jump to content

timotet

Members
  • Content Count

    223
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by timotet

  1. I have to chime in and say I like the idea of one forum, with sub forums for the different chips. Seems easier to manage. It's too bad about the c2000 forum going away but nobody goes there and the chip has a steep learning curve. With a sub forum aleast that info would not go away completley . I agree with @@Fred on energia having a forum all its own, not because I think its not a good thing, but it may be easier for the people who use it to find the content there.
  2. timotet

    MSP430 Nixie Clock

    I bought one of @@RobG's clock kits and I am very happy with the results. I have kids and didn't want to have any wandering fingers getting zapped, so I designed and printed an enclosure for it. Here are some photos of it. I couldn't resist adding the colon. I uploaded the .stl files if anyone wants to print it. Thanks to Rob for the awesome kit! RobG_Clock_Case.zip
  3. Hi @pallisi I was able to get one of the booster packs designed by @RobG to work with hardware spi with out too much trouble. That was a while ago and I know Rob has designed several new boards that would I'm sure work. He has a library that is easy to work with, and get's you up and running fast. Here is a link to his Tindie page: https://www.tindie.com/stores/RobG/?ref=offsite_badges&utm_source=sellers_RobG&utm_medium=badges&utm_campaign=badge_small
  4. Thanks for sharing. 0603 is plenty small if you ask me.
  5. Nice Work , would like to see a photo of the booster pack itself. I like the thought of controlling a "big ass" motor, just need to figure out for what. I also like the oh_shit function.... that's good.
  6. This is cool ! Good work
  7. Ahhh! the old power equation kicking my butt!!! Thanks for the suggestions guys, just what I was looking for.
  8. timotet

    Button use

    I have not tried energia, but I think you left some important stuff out of your code. Here try this: #include <msp430.h> /* * main.c */ #define button BIT3 // define your port1 #define redLed BIT0 #define grnLed BIT6 int BTN = 0; // for button read void p1_init(void){ // set up port 1 P1DIR |= redLed + grnLed; // set to output P1DIR &= ~button; // set as input P1REN |= button; // pull up on button P1OUT |= button; // set pull up on button P1OUT |= redLed; // turn on red led P1OUT &= ~grnLed; // green off to start } int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer DCOCTL = 0; BCSCTL1 = CALBC1_1MHZ; // Run at 1 MHz DCOCTL = CALDCO_1MHZ; p1_init(); while(1){ BTN = (P1IN & button); // read port 1 for button press if(!BTN){ // is the button pressed? P1OUT ^= grnLed; // toggle the green led } else P1OUT &= ~grnLed; // green is off } } good luck!
  9. I built a 3d printer last year and needed a small light to illuminate the build area, this is what I came up with. I call it the ringLight. I thought about using an Adafruit Neopixel ring, but due to the finished part being for a specific size I decided to roll my own. I used a MSP430G2452 in the TSSOP 14 pin package for the micro. I have to thank every one on the forum for the wealth of info related to the WS2812 leds, and a special thanks to @@oPossum for the led driver code he posted. The code is pretty straight forward. Once powered on the msp430 loads what ever value from flash that was used from the last time power was on, then waits for a button press. If the button gets pressed it will scroll through a few pre programmed colors or animations, per press. Then that value is re-written into flash for the next time. Here is the code: // 5/10/14 // For controlling the Mandelbots ringLight WS2812 leds // Thanks to Kevin Timmerman for the ws2811_hs.asm led driver code // Written by Larry Fogg and Tim Toliver // #include "stdint.h" #include "stdlib.h" #include <msp430g2452.h> void write_ws2811_hs(uint8_t *data, unsigned length, uint8_t pinmask); //prototype for ws2811_hs.asm #define button BIT3 #define ledPin BIT7 #define numColors 1972 static const uint8_t red[12] = { 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00 }; static const uint8_t green[12] = { 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00 }; static const uint8_t blue[12] = { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF }; static const uint8_t purple[12] = { 0, 128, 128, 0, 128, 128, 0, 128, 128, 0, 128, 128 }; static const uint8_t yellow[12] = { 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00 }; static const uint8_t orange[12] = { 0x80, 0xFF, 0x00, 0x80, 0xFF, 0x00, 0x80, 0xFF, 0x00, 0x80, 0xFF, 0x00 }; static const uint8_t steelBlue[12] = { 130, 70, 180, 130, 70, 180, 130, 70, 180, 130, 70, 180 }; static const uint8_t pink[12] = { 20, 255, 147, 20, 255, 147, 20, 255, 147, 20, 255, 147 }; static const uint8_t aqua[12] = { 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255 }; static uint8_t z[12]; //GRB values for 4 LEDs uint8_t pressCount; //keep track of button presses uint8_t buttonPressed = 1; //start with true so stored pressCount is executed //for writing flash uint8_t * Flash_ptr = (unsigned char *) 0x1040; //location to write in flash info segment C void millisecDelay(int delay) { int i; for (i=0; i<delay; i++) _delay_cycles(10000); //roughly 1 msec. calibrate this } #pragma vector=PORT1_VECTOR __interrupt void PORT1_ISR(void) { _disable_interrupts(); pressCount++; //increment button presses buttonPressed = 1; //true millisecDelay(300); //for button debounce P1IFG &= ~button; //clear interrupt flag _enable_interrupts(); } void writeFlash(unsigned char data){ _disable_interrupts(); FCTL1 = FWKEY + ERASE; //Set Erase bit FCTL3 = FWKEY; //Clear Lock bit *Flash_ptr = 0; //Dummy write to erase Flash segment FCTL1 = FWKEY + WRT; //Set WRT bit for write operation *Flash_ptr = data; //Write value to flash FCTL1 = FWKEY; //Clear WRT bit FCTL3 = FWKEY + LOCK; //Set LOCK bit _enable_interrupts(); } void loadLED (int ledNum, uint8_t R, uint8_t G, uint8_t //load z[] for one LED { z[ledNum*3]=G; z[ledNum*3+1]=R; z[ledNum*3+2]=B; } void writeLEDs () { _disable_interrupts(); write_ws2811_hs(z, sizeof(z), ledPin); _enable_interrupts(); } void getRGB(int color, uint8_t *R, uint8_t *G, uint8_t * //this generates RGB values for 1972 rainbow colors from red to violet and back to red { float brightness = 0.3; //scale factor to dim LEDs. if they are too bright, color washes out if (color>=(numColors/2)) //adjust color for return from violet to red color=numColors-color; if (color < 199) { *R = 255; *G = 56 + color; *B = 57; } else if (color < 396) { *R = 254 - (color - 199); *G = 255; *B = 57; } else if (color < 592) { *R = 57; *G = 255; *B = 58 + (color - 396); } else if (color < 789) { *R = 57; *G = 254 - (color - 592); *B = 255; } else { *R = 58 + (color - 789); *G = 57; *B = 255; } *R*=brightness; //apply brightness modification *G*=brightness; *B*=brightness; } void allWhite(uint8_t intensity) //all LEDs stay white { int i; for (i=0; i<12;i++) z[i] = intensity; writeLEDs(); } void allBlack() //all LEDs off (black) { int i; for (i=0; i<12;i++) z[i] = 0x00; writeLEDs(); } void lightning () { uint8_t R, G, B; int color; //numeric index into color palette int flashDuration; while (!buttonPressed) { allBlack(); //clear LEDs color = rand()%numColors; if (color%7==0) //every so often, throw in a bright white flash { R=G=B=0xff; flashDuration = 10; //quicker for white flash } else { getRGB (color, &R, &G, &; //get random color flashDuration = 50; //slower for color flash. makes color more apparent } loadLED (rand()%4, R, G, ; //load color into random LED writeLEDs(); //flash the LED millisecDelay(flashDuration); allBlack(); //clear LEDs millisecDelay(rand()%500); //wait for next flash } } void drawSnake (int headLoc) //draw snake starting at headLoc { int shoulderLoc, torsoLoc, tailLoc; uint8_t R, G, B; //color of head getRGB (rand()%numColors, &R, &G, &; shoulderLoc = (headLoc+1)%4; //find correct array locations for body parts. keep within 0-3 range torsoLoc = (headLoc+2)%4; tailLoc = (headLoc+3)%4; loadLED (headLoc, R, G, ; //random color head loadLED (shoulderLoc, 0, 0, 0); loadLED (torsoLoc, 0, 0, 0); loadLED (tailLoc, 0, 0, 0); //black tail writeLEDs(); //draw the snake } void chaseSnakeTail () //white head, black tail. Snake goes in circles { int headLocation=0; //which LED is the head (white) int crawlSpeed; //delay between snake moves int slowSpeed=150; int fastSpeed= 10; int CWdirection = 1; //start with clockwise direction = true while (!buttonPressed) { for (crawlSpeed=slowSpeed; crawlSpeed>fastSpeed; crawlSpeed-=2) //speed up tail chasing { drawSnake (headLocation); millisecDelay(crawlSpeed); if (CWdirection) headLocation +=3; else headLocation++; headLocation%=4; //keep LED in range (0-3) if (buttonPressed) break; } CWdirection = !CWdirection; //reverse direction for next cycle for (crawlSpeed=fastSpeed; crawlSpeed<slowSpeed; crawlSpeed+=2) //slow down tail chasing { drawSnake (headLocation); millisecDelay(crawlSpeed); if (CWdirection) headLocation +=3; else headLocation++; headLocation%=4; //keep LED in range (0-3) if (buttonPressed) break; } } } void allColors() //display rainbow color progression, each LED out of phase with the others { uint8_t R, G, B; int color; int ledNum; //0-3 while (!buttonPressed) for (color=0; color<numColors; color++) //progress from red to violet and back to red { for (ledNum=0; ledNum<4; ledNum++) { getRGB ((color+ledNum*200)%numColors, &R, &G, &; //offset LED colors by 200 from neighbors loadLED (ledNum, R, G, ; } writeLEDs(); millisecDelay(4); if (buttonPressed) //allow exit from function break; } } void writeLeds(const uint8_t color[12]) { unsigned j; for (j = 0; j < 12; j++) { z[j] = color[j]; write_ws2811_hs(z, sizeof(z), ledPin); } } void main(void) { WDTCTL = WDTPW + WDTHOLD; // No watchdog reset DCOCTL = 0; BCSCTL1 = CALBC1_12MHZ; // Run at 12 MHz DCOCTL = CALDCO_12MHZ; //P1SEL &= ~ledPin | button; P1DIR |= ledPin; // ledPin is an output P1OUT = 0; // set port 1 low P1DIR &= ~button; // button is an input P1REN |= button; // pull down on button P1OUT &= ~button; // set pull down P1IES &= ~button; // Interrupt Edge Select - 0: trigger on rising edge, 1: trigger on falling edge P1IFG &= ~button; // interrupt flag for p1.3 is off P1IE |= button; // enable interrupt FCTL2 = FWKEY + FSSEL_1 + FN3; // MCLK/32 for Flash Timing Generator 12mhz/32 = 375hz // these both work has to be between 257-476 hz //FCTL2 = FWKEY + FSSEL_1 + 0x1A; // MCLK/27 for Flash Timing Generator 12mhz/27 = 444hz pressCount = *Flash_ptr; // load value written in flash _enable_interrupts(); while (1) { if (buttonPressed) { buttonPressed = 0; //reset switch (pressCount) { case 0: //bright white allWhite(0x80); break; case 1: //dim white allWhite(0x40); break; case 2: lightning(); break; case 3: allColors(); break; case 4: chaseSnakeTail(); break; case 5: writeLeds(red); break; case 6: writeLeds(blue); break; case 7: writeLeds(green); break; case 8: writeLeds(purple); break; case 9: writeLeds(yellow); break; case 10: writeLeds(orange); break; case 11: writeLeds(steelBlue); break; case 12: writeLeds(pink); break; case 13: writeLeds(aqua); break; default: pressCount = 0; //default to 0 buttonPressed = 1; //force execution of case 0 break; } writeFlash(pressCount); // write to flash for poweroff } } } I didn't use any kind of level shifting for the leds. It seems alot of folks on here had no trouble getting the leds to work with out it, and I didn't read about the level shifting until after I sent off for the boards. So I got lucky on that one. For powering the the board I wanted to use the existing 12volt supply for the printer, so I put a couple of LDO's on board for that. I of course used TI parts that I sampled from TI. (as a matter of fact I sampled the msp430 too thanks TI!!!) For the 3.6 volt side I used the TPS70936 and for the 5 volt side I used the LP2989. Both of the LDO's are able according to the data sheets to handle a 12 volt input.The 3.6 volt side worked out as expected but I must have done something wrong with the LP2989. The data sheet says the part will provide up to 500mA continuously, the WS2812 at full brightness pulls 60mA. I put 4 leds on the board so thats 240mA if they are all full blast. When I have all the leds on full the LDO gets HOT! As far as the layout goes I copied the shematic from the data sheet, and used the recommended parts. This is from the datasheet: This is from my schematic: To get around a full redesign I don't push them that hard, and it works. It does bug me though, so if anyone has any insight or suggestions let me know. I have one more pcb I can hack on and see if I can make it work better. Besides that I am happy with the design and it fits the machine perfectly. (Just like it supposed to!) It's nice to see what I am printing. Here are a couple more photos , and some video.
  10. I found the document: TMS320x2802x, 2803x Piccolo Analog-to-Digital Converter (ADC) and Comparator Reference guide To be helpful, if you dont have it. Search for SPRUGE5F on TI's site. I think in your ADC_init code you want: ADC_setVoltRefSrc(myAdc, ADC_VoltageRefSrc_Int); // sets adc to internal reference According to the chips data sheet pin 12 on the Tms320F28027 is VREFLO. Datasheet also says it always tied to ground. or for external source: ADC_setVoltRefSrc(myAdc, ADC_VoltageRefSrc_Ext); // for external reference source In this case you would have your VREFHI connected to pin 10 on the micro(J5.6 on C2000 launchpad) I looked at the example you are using and its in there as an internal source. Hope this helps Tim
  11. Are you running this out of Flash or RAM? Project -> Properties -> Build configuration Flash [Active]. You need this linker cmd file: F2802x_generic_flash.cmd Browse to it from the Project CCS General tab at the bottom where it says linker command file. In ControlSUITE -> Development Kits -> C2000 Launchpad -> f2802x_common -> cmd fingers are crossed. Tim
  12. Well thats progress. I just posted in the other thread you created, so ignore that. We should probably keep it to one thread I think Tim
  13. timotet

    SPI_write8

    Hi If you changed the function to the SPI_Write function then you are not transmitting the correct data. The SPITXBUF is 16 bits wide and the data has to be shifted to the left 8 bits for the lcd to see the transmission. The Nokia 5110 lcd is looking for an 8 bit transmission, I know you can send more than 8 bits per transmission , but thats a different topic. For example if you want to send 0x21(0010 0001). When the SPITXBUF register gets loaded it looks like this 0x0021(0000 0000 0010 0001). When you use the SPI_Write function in this situation the lcd sees the 1st 8 bits (the zeros). When you use the SPI_Write8 function the 0x0021 gets shifted << to the left 8 times and ends up looking like 0x2100(0010 0001 0000 0000). Now the lcd sees the 0x21 as it was intended. I think your on the right track, you need to find the header file (spi.h) with the SPI_Write8 function in it and use that, as explained in the other thread. http://www.forum.c2kcentral.com/topic/139-hardware-spi-working-with-the-nokia-5110-lcd/ Hope this helps Tim
  14. Hi You need to make sure the spi.h header file you are linking to contains the SPI_write8 function. If you look in your controlSUITE install the device support folder for the f2820x devices , latest version v220, f2802x_common, than the includes file, the spi.h file in there has the function you need. Either copy the function into the file you are linking to or replace the file with the newer one, then you should be good. I think the earlier contolSUITE was missing the SPI_write8 function for some reason. As far as the wiring look in the nokia5110.h file and the pin out is in the 1st few lines of code: #define nokiaVcc GPIO_Number_28 //connect to pin J1_3 on c2000 LP board #define nokiaSce GPIO_Number_34 //connect to pin J1_5 on c2000 LP board #define nokiaRst GPIO_Number_29 //connect to pin J1_4 on c2000 LP board #define nokiaDc GPIO_Number_4 //connect to pin J6_5 on c2000 LP board #define nokiaBlight GPIO_Number_5 //connect to pin J6_6 on on c2000 LP board #define nokiaMosi GPIO_Number_16 //connect to pin J6_7 on on c2000 LP board SPISIMOA #define nokiaClk GPIO_Number_18 //connect to pin J1_7 on on c2000 LP board SPICLK Hope this helps Tim
  15. timotet

    Mailbag

    Yes kind of , I built a 3d printer and wanted to mount a light up under the print head. I looked into using one of the neo pixel rings but they didnt quite fit the dimensons needed. I also wanted to be able to control it more than just on and off so I put a msp430 on there. I will post about it once I have them built up and working.
  16. timotet

    Mailbag

    I got these a couple days ago!
  17. Toby I will try to help. Im no pro at this, although I have used the SPI peripheral successfully. "I guess the master needs to transmit dummy bytes for every byte that it wants to receive, is that right?" Yes thats right "But how should the master "know" how many bytes that should be? Maybe it just keeps going until the slave clears the TALK bit?" Thats your job to establish in software, maybe the last byte of your transmission from the slave could be 0x00 and in your masters Rx_Isr have it look for that to end the transmission. Just a thought. good luck
  18. WOW! lots of soldering. good work
×
×
  • Create New...