Jump to content
43oh

gatesphere

Members
  • Content Count

    430
  • Joined

  • Last visited

  • Days Won

    6

Reputation Activity

  1. Like
    gatesphere reacted to NJC in ADC10 Vs SD16?   
    I know my response comes a bit late, but I have worked with both quite extensively in multiple applications.
     
    The biggest difference is what gatesphere mentioned, the vertical resolution (how many bit's the ADC is) is much larger with the SD16. There are many applications where 10 bits is not enough (for example, an EEG). The other major differentiating factor is speed, the ADC10 is significantly faster than the SD16; if I remember correctly the SD16 in the F2013 has a maximum sample speed of about 4kHz. Remember that the Sigma Delta ADCs oversample the signal by multiple orders of magnitude and then does something called "digital decimation" to get the 16 bit output. This is a bit complicated to understand, but all the end user needs to know is that the Nyquist frequency is very different for SD16s than it is for the ADC10.
     
    Basic moral of the story, if you need speed choose the ADC10, if you need vertical precision use the SD16.
     
    Hope that helps.
  2. Like
    gatesphere reacted to d.keenan in Adding structured control flow to any assembler   
    If your assembler doesn't already have structured control-flow, e.g. _IF _ELSE _ENDIF _UNTIL _WHILE etc (not to be confused with conditional assembly)
    then here's how to add it yourself for free, without needing access to the assembler's source code.
     
    http://dkeenan.com/AddingStructuredControlFlowToAnyAssembler.htm
     
    Structured control-flow eliminates the need for most explicit jumps, and the labels they jump to, and thereby makes your code more readable and maintainable.
     
    -- Dave Keenan
  3. Like
    gatesphere reacted to NatureTM in CCS is coming to linux   
    http://e2e.ti.com/support/development_t ... 61266.aspx
  4. Like
    gatesphere reacted to bluehash in [ ENDED ] Dec 2010 - 43oh Project of the Month Contest   
    Entry to the December 2010 contest is open. This is an opportunity for you to show off what you can do with the MSP430. The 43oh community forum has been growing both with good discussions and members. The project section of the forum as well as the Blog has a lot of project ideas you can base your submission on. Feel free to ask questions about the project on the forum.
     
    Previous Contests
    November 2010 [ Announce] [ Winner]
     
    Now for the prize:
    Winner : A $20 Sparkfun gift certificate. You can finally get that thingy you were eyeing on.
    Runner up :[J]bremnant has been kind enough to donate a pristine unopened Launchpad kit. Although you may already have one, having another Launchpad can be quite handy like a project you may not want to take apart or recreate[J]oby's SPI Ninja. Thanks [J]bremnant for sponsoring this month's contest giveaway.
     
    To submit your entry, make an entry into this thread with the following:
    1 - A small description of your project.
    2 - A picture or video of your setup
    3 - Code.
    4 - Schematic(rough/hand drawn is fine as long its legible)
     
    About judging the winner :
    A week before the contest ends, a poll will be created with all the project entries. Only members of the forum will be allowed to vote.
    The contest will roll over to the next month if there are fewer than 5 projects(four or less).
     
    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.
  5. Like
    gatesphere reacted to bluehash in Anyone looking forward for Dec POTM?   
    Yes, It's allowed. That will be in the rules.
  6. Like
    gatesphere reacted to bluehash in We are growing!   
    Hello Everyone,
     
    We owe this update to you, since you guys are the main drivers of this portal, submitting and discussing the MSP430 and everything else. We would also like to thank our sponsors - Texas Instruments for the TI Chronos watch and Geekdoc for the Launchpad
     
    1. The 43oh blog received ~16000 pageviews this month and has steadily grown. We get around 400 pageviews a day, still small but a big jump from last month.(~9000)

     
     
    2. The forum received ~26000 pageviews this month. The good part of the board is that we have a steadily growing Projects section with code and schematics. This helps new users to use them as reference projects and ramp up quickly.

     
    3. We added ~100 forum members this month to the board. We are now at 120 members.
     
    4. We were also surprised to get six good projects for the Project of the Month. All six were were submitted with code and related material. Thanks and keep building.
     
    5. This month's project will hopefully be announced by the 5th of Dec. We are in the process of arranging the prize.
     
    6. Big thanks to jbremnant who donated 5 Launchpads for future contests.
     
    All in all, a big thank you!
  7. Like
    gatesphere reacted to NatureTM in Launchpad TV output   
    Here's the writeup:
    http://naturetm.com/?p=47
     
    I've attached two versions of the code, one for use with an external 16MHz oscillator, and one for if you have your 16MHz DCO constant calibrated.
    Launchpad_TV_Out.rar
    Launchpad_TV_Out_for_calibrated.rar
  8. Like
    gatesphere reacted to simpleavr in Value Line series easy DCO setting library   
    if u dump out the stock flash portion where the calibrated values are defined.
     

    (mspdebug) dis 0x10f0 010f0: ff ff ff ff AND.B @R15+, 0xffff(R15) 010f4: ff ff ff ff AND.B @R15+, 0xffff(R15) 010f8: ff ff ff ff AND.B @R15+, 0xffff(R15) 010fc: 01 02 MOVA #0x4, SP 010fe: 6b 87 SUB.B @R7, R11
     
    the double word from 0x10fc (0x0102, 0x6b87) are the calibrated 1Mhz values from factory.
    the other 3 sets (8, 12, 16Mhz) are pre-allocated but blank for the value line (cheaper, so no calibration).
     
    [EDIT] correction, the 4 calibrated values should be double bytes, not double words according to header files.

    0x10ff, 0x10fe are 1Mhz BCSCTL1+DCOCTL values 0x10fd, 0x10fc are 8Mhz 0x10fb, 0x10fa are 12Mhz 0x10f9, 0x10f8 are 16Mhz
    value shown from my mspdebug session has been messed up (i guess) when i was trying the calibration code.
    too early to give "thank you"s to me,
    [END EDIT]
     
    typically u can modify NatureTMs example and "write" the calibrated values to those memory locations, after that u can use
     

    if (CALBC1_16MHZ != 0xff && CALDCO_16MHZ != 0xff) { BCSCTL1 = CALBC1_16MHZ; // Set DCO to 16MHz DCOCTL = CALDCO_16MHZ; }//if
     
    additional check for 0xff will ensure u only use it if it's set.
     
    there is also a c example msp430x20xx_dco_flashcal.c in the slau80 examples that also writes to the flash constant locations, but i never got it to work.
     
    this way u don't have to carry the library on all of your projects and u only need the crystal when doing calibration.
  9. Like
    gatesphere reacted to bluehash in [ ENDED ] Nov 2010 - 43oh Project of the Month Contest   
    Congratulations!
    Results of the November 2010 Project of the Month contest:
    First Place: The "Strobr: High speed photography controller" by AMagill
    Runner up : The "Launchpad RFM12B RF spectrum analyzer" by simpleavr
     
    Thanks to the following members who participated:
    MSP430G2xxx Tea Timer by gatesphere
    Killing Zombies with the Launchpad by juani_c
    Motion Detection Wildlife Camera by paradug
    Digital LED Clock by mnpumar
     
    A big thanks to our prize sponsors:
    Texas Instruments
    Geekdoc.
     
    Also, a big thank you to all those who voted.
  10. Like
    gatesphere reacted to NatureTM in Launchpad TV output   
    I got my Launchpad to output B/W composite video. It only displays one image without re-flashing though, so it's not extremely useful. The only external components are two resistors and a crystal oscillator. I plan on writing it up on my blog and releasing the source sometime this week, unless I get too busy with school. I wasn't sure if I'd be able to ever get this working, so I'm feelin' pretty good right now!
    Proof ;-)

     
    Code for use with an external oscillator:
    Launchpad_TV_Out.rar
     
    Code for if you have your DCO configuration constants calibrated:
    Launchpad_TV_Out_for_calibrated.rar
     
    EDIT: Here's the writeup!
    http://naturetm.com/?p=47
  11. Like
    gatesphere reacted to NatureTM in Value Line series easy DCO setting library   
    Here's an existing TI lib I modified to work with the Value Line series and CCS.
     
    Since the G series doesn't come with factory-calibrated DCO settings, I wanted an easy way to set the MCLK to 16MHz or some other arbitrary frequency. A TI library existed for setting the DCO using an external watch crystal as a reference, however it didn't work with the G series. It just took some minor editing.
    I think this should be nice for Launchpad owners especially, since the kit comes with an external crystal and a 16MHz rated chip.
     
    DCO Library: http://naturetm.com/files/Launchpad%20setDCO%20lib.rar
  12. Like
    gatesphere reacted to bluehash in Support for embedding Youtube videos   
    Hello Everyone,
     
    Support for embedding Youtube videos has been added. All you have to do is click the "Youtube" button above and place the youtube URL(which can be found under the Share button on the Youtube page).

    [Youtube]http://www.youtube.com/watch?v=BolgBSXjxeE[/Youtube]
     
    Enjoy! One of my favorite animations:
     


  13. Like
    gatesphere reacted to OCY in Receive only uart?   
    I wrote 4 little procedures. You can cut them down easily. For example, you may not need "set_baud" nor "auto_baud". And you may only need "getchar" or "putchar".
     

    /******************************************************************************* * Sub-Standard I/O for LaunchPad Board * * OCY Nov 2010 * *******************************************************************************/ #include #define RXD BIT2 #define TXD BIT1 int baud_divider = 104; /* default for 9600 b/s @ SMCLK = 1 MHz */ //============================================================================== int set_baud ( int i ) { baud_divider = i; return (i); } //============================================================================== int auto_baud ( void ) { __no_init int zero; P1SEL |= RXD; TACCTL0 = 0; TACCTL1 = CM_2 | SCS | CAP; TACTL = TASSEL_2 | MC_2 | TACLR; while ((TACCTL1 & CCIFG) == 0) {/* wait */} zero = TACCR1; TACCTL1 = CM_1 | SCS | CAP; while ((TACCTL1 & CCIFG) == 0) {/* wait */} P1SEL &= ~RXD; TACTL = 0; return (baud_divider = TACCR1 - zero); } //============================================================================== int putchar ( int i ) { TACCR0 = 0; TACCTL0 = OUT; TACCTL1 = 0; P1SEL |= TXD; P1DIR |= TXD; TACTL = TASSEL_2 | MC_2 | TACLR; i = (i + 0x100) << 1; do { TACCR0 += baud_divider; if (i & 1) TACCTL0 = OUTMOD_1; else TACCTL0 = OUTMOD_5; while ((TACCTL0 & CCIFG) == 0) {/* wait */} } while ((i = (i >> 1)) != 0); P1DIR &= ~TXD; P1SEL &= ~TXD; TACTL = 0; return 1; }//============================================================================= int getchar ( void ) { int byte = 0; P1SEL |= RXD; TACCTL0 = 0; TACCTL1 = CM_2 | SCS | CAP; TACTL = TASSEL_2 | MC_2 | TACLR; while ((TACCTL1 & CCIFG) == 0) {/* wait */} TACCR1 += baud_divider >> 1; for (int bit = 8; bit > 0; bit--) { TACCR1 += baud_divider; TACCTL1 = 0; while ((TACCTL1 & CCIFG) == 0) {/* wait */} if (TACCTL1 & CCI) byte |= 0x100; byte = byte >> 1; } P1SEL &= ~RXD; TACTL = 0; return (byte); } //==============================================================================
  14. Like
    gatesphere reacted to juani_c in Killing Zombies with the Launchpad   
    Well, this is my entry for the November 2010 Project of the Month Contest. It is very simple and far less usefull than the others projects. The truth is that I wasn't participating until I saw the Chronos .So i had to come up with something easy and fast to develop. I was plaiyng arround with some leds and photodiodes in front of my pc monitor and I thought that cold be interesting to interact with the screen with the photodiodes or some other ligth sensor. that idea eventually ended up being a shooting game. I wasn't too sure what to shoot at but then i realized that the option was obvious; ZOMBIESS!!!. everybody like killing zombies.The circuit is very simple. the LDR is in a voltage divider with a 10K potentiometer. moving the potentiometer will help with the calibration.It has also a capacitor to stabilize the analog signal. the trigger is a switch in series with a resistor and a capacitor for debouncing. this swicth is in fact in parallel with S2 in the Launchpad so you could just use that one an reduce the number of needed parts. I just use my hand for the gun so I didn't have to make one (it also makes a great human machine interface ).The source code for the MSP430 is basically the same as the "Snake game". every time you pull the trigger the ADC takes 16 samples and send the avarage to the computer. The analog signal is provided by the LDR. the LDR has a different response depending on the wavelength of the incident light (that`s the reason for the funky colors). it isn't very accurate, variations on the ambient light or in screen distance will lead to a misunderstanding between the zombies. Every time you pull the trigger and hit one of them you'll hear a shot and a zombie scream because, well, even zombies don
    LaunchPad-Zombies.rar
  15. Like
    gatesphere reacted to juani_c in Connector for 2013 target board with staples   
    In case somebody want to use that Launchpad's feature I made the connector with some 26/6 staples
     

     

     

  16. Like
    gatesphere reacted to AMagill in MSP430G2xxx Tea Timer   
    Why bother with the pull-up/pull-down resistors on the switches? You could drop them from your circuit and set:

    P1OUT |= 0x08; // Pull P1.3 resistor high P1REN = 0x78; // Enable internal resistors for P1.3, P1.4, P1.5, P1.6
  17. Like
    gatesphere got a reaction from znanev in Electronics reverse-engineering game   
    Hey all, just thought I'd share this cool game I found. It's pretty sweet, as most of the games on this site are.
    Anyways, it's called Ruckingenur II, and it's free.
     
    http://thesiteformerlyknownas.zachtroni ... com/?p=654
  18. Like
    gatesphere reacted to AMagill in [ ENDED ] Nov 2010 - 43oh Project of the Month Contest   
    My project is a programmable strobe controller for high speed photography. A device like this is crucial for many types of high-speed photography, as it can orchestrate multiple sensors such as photogates and contact microphones with several outputs, such as a flash trigger and a camera's shutter release, so as to capture a photograph of just the exact right instant with microsecond precision.
    An example; I connected my device to a small electronic water valve, to my camera's cable release port, and to a flash. I arranged it so water could flow down from a bottle, through the valve, out a small nozzle, and down into a bowl of water below whenever the valve is powered. Then I wrote a script to control the device;

    while (true) { if (RIN0 == 1) { // Button 1: Double drip reg delay1 = 50; reg delay2 = 192; ROUT.T3 = 1; // Prime the camera waitms(10); // Setup time ROUT.T2 = 1; // Open valve waitms(15); // Wait for drop ROUT.T2 = 0; // Close valve waitms(delay1); // Put some space between drops ROUT.T2 = 1; // Open valve waitms(15); // Wait for drop ROUT.T2 = 0; // Close valve waitms(delay2); // Wait for drops to fall ROUT.R3 = 1; // Fire the camera waitms(63); // Wait for shutter to open ROUT.R1 = 1; // Fire flash waitms(10); ROUT = 0; // Finish flash pulse, close camera waitms(200); // Lockout } }
    Once I got the timing just right, this script has the valve release exactly two drops of water such that the second will collide with the splash from the first, and take a picture of the result. It produces pictures like this, each and every time I press a button on the device;

     
    Here's the device itself. I call it Strobr.

    That's an MSP430F2274 in the center, driven by a 16MHz clock crystal (to keep timing more precise and repeatable). On the top left are two analog input ports, each with one input pin and a software-switchable power pin (because some sensors, like photogates, need power to work). In addition to being polled by the MSP430's ADC, it can also route them through the MSP430F2274's built-in op-amps for small signals like microphones. Top middle are a pair of buttons, just two more inputs available to the chip. Top right are a pair of ports that can be connected to each other via a pair of solid-state relays, of course software controlled as well. The idea behind adding these was to be able to switch on and off an audio signal to a speaker, for making sound sculptures. Haven't tried it yet. On the bottom right are four output jacks, each with a pair of digital output pins. Finally, on the left there's a FTDI FT232RL USB-to-serial converter, and under the power switch, you can just barely make out a USB port on the bottom side of the board.
    The device connects to my computer by USB. The PC application I've written allows you two write simple scripts for the device, error-check and compile those scripts, load the compiled bytecode onto the device, and poll the device's status and display it in realtime. It looks like this;

    The MSP430, in addition to maintaining communication with the PC, runs a very simple virtual machine that executes the scripts that have been loaded onto it. The virtual machine is fixed instruction length (32 bits), and has no stack or memory of any kind except for 16 general-purpose registers and 16 specialized registers. In the screenshot of the PC application, you can see the bytecode that the script is compiled into, as well as the registers that the virtual machine operates on. Those registers are; RIN0 (buttons input), RIN1(analog input 1), RIN2 (analog input 2), RD1 and RD2 (analog input deltas, change since last sample), RLED (the ring of LEDs), ROUT (the eight digital outputs), RPWR (power to the input ports and to the relays), RAIM (analog input mode- no amps, one amp on each port, daisy-chained amps on one port, etc.), RG1 and RG2 (amplifier gain setting), RAP (automatically poll state to the host), RFLG (flags- running, test truth), and RPC (program counter).
     
    Schematic (click for full size):

     
    PCB layout (clicky clicky):

     
    And finally, for source code, you'll have to go to my web site, since the file is too big to attach to this post. It includes Eagle files for the schematic and PCB layout (including a detailed bill of materials totaling about $100), CAM files for the PCB (in case you want to get one made and don't care to muck about with Eagle), source code for the MSP430 and for the PC application, and even a few scripts to run on the whole contraption. If you do decide to make one of these, though, you should note that my design isn't perfect, and you would do well to double-check my work and address a number of issues first.
     
    My web site, where I have writeups for this project and others, is OminousHum.com.
  19. Like
    gatesphere reacted to cde in LaunchPad I2C Communication   
    Yea, the I2C Explorer has a bus-pirate like way of communicating from a pc through the uart to an i2c bus. It uses the builtin USI of the msp430G2231 to handle receiving and transmitting. It is nearly exactly what the TI description of how to use the USI for I2C master shows, put in C code.
    MSP430 Family Guide with USI description (PDF Page 449):
    http://focus.ti.com/lit/ug/slau144e/slau144e.pdf
     
    What you want is USI Slave though. It does not implement that. TI has great USI Slave examples that run on the msp430g line (I have not personally tried them).
     
    TI also has a precreated I2C USI code library in assembly, for both master and slave operation, which I would assume is a higher order more optimized than mine
    http://focus.ti.com/general/docs/litabs ... r=slaa368a
    The pdf explains how it is used, functions and all, while the zip has the actual library.
     
    Additionally, you can use a software i2c slave, not using the builtin USI peripheral. Based on a msp430f2131, which has 8kb, so I'm not sure it will run on a valueline part:
    http://www.ti.com/sc/docs/psheets/abstr ... laa330.htm
    Again, PDF for code examples, and zip for actual code.
    I'd go with using the USI instead of bitbanging it. The USI is better, it handles open drain pins, and it can deal with clock stretching.
     
    There is also a way to implement a SMBus Master or Slave on the msp430:
    http://www.ti.com/litv/pdf/slaa073
    SMBus is basically i2c v1.1.
     
    Finally, there are full examples that can run on the msp430g valueline chips.
    http://www.ti.com/litv/zip/slac080h
    It is the MSP430F20xx, MSP430G2xx Code Examples (Rev. H)
    The ones you want to look at are (Depending on if you Use C or Assembly) USI 06-16. Show how to implement USI based I2C Masters and Slaves, for single and multi-byte usage. One even shows how to emulate an i2c eeprom.
     
    TLDR: Read the Code examples in
    http://www.ti.com/litv/zip/slac080h
    Or consider using the TI USI i2c Code Library
    http://focus.ti.com/general/docs/litabs ... r=slaa368a
  20. Like
    gatesphere reacted to bluehash in Member Ranks   
    Hello fellow 43oh'ers
    Forum users now have ranks. This is just an indication that a member has been helpful to the forums by posting regularly. This is solely based on the number of posts... like Karma.

     
    An interesting feature will be rolled out in the next month or so - Badges.
    - A badge if a member receives "Thanks" above a certain count.
    - A badge if a member wins a "Project Of The Month" contest.
    - Many more, we have to think as this community evolves.
     
    Thanks again for all your support by visiting, helping and posting here. If for any reason, you don't like a feature, feel free to let us know - either PM or here in the forum.
  21. Like
    gatesphere reacted to bluehash in 43oh IRC is now #43oh   
    Hello Everyone,
     
    The IRC was first suggested by Mystboy. Since there was alot of interest for an IRC channel, we now have one. Check the main bar link "IRC".
     
    Its a bit color cluttered up there, but we'll fix it.
    Channel name is #43oh.
  22. Like
    gatesphere got a reaction from GeekDoc in MSP430G2xxx Tea Timer   
    Here is my entry for the November 2010 Project of the Month Contest, an MSP430G2xxx based tea timer!
     
    I love tea, and thought this contest was an excellent reason to actually get off of my lazy behind and put this together.
     
    Below is my blog post on it, modified slightly to show the pictures and code here rather than just link to them as on my blog. Blog post is available here: http://blog.suspended-chord.info/?c=27
     
    Below this point is the post:
    ------------------------------------------------------
    Hello all,
     
    I am an avid tea drinker. As such, I make many cups of various kinds of tea, each with their own optimal steep times. Usually, I just keep track of the time, but I have found that I can make the best cup of tea by setting a timer to go off after a certain amount of time, depending on the style of tea that I am brewing. I find the best results come from going by the following table (based on personal preference and experimentation):
     
     
    Tea Variety => Recommended Steep Time
    White tea => 2 minutes
    Green tea => 3 minutes
    Black/Oolong tea => 4 minutes
    Herbal tea/infusions (most varieties) => 5 minutes
    Rooibos tea (African redbush) => 6 minutes
    Chai tea (regardless of base) => 8 minutes
    Kukicha twig tea and other varieties => in intervals of 1 minute
     
     
    With this in mind, I decided that I should make a tea timer. This seems simple enough, and it has been on my to-do list for a while anyway, and 43oh! is having an MSP430 Project of the Month Contest, so I decided to hack it together. Turned out rather simple.
     


    The full part count is as follows:
    [*:3snbat08] 3 toggle switches (or a 3-switch DIP, as I used)
    [*:3snbat08] 4 10k resistors
    [*:3snbat08] 1 5mm green LED
    [*:3snbat08] 1 piezo buzzer with integrated driver circuit
    [*:3snbat08] 1 tact switch/push button
    [*:3snbat08] wire
    [*:3snbat08] Any MSP430 uC with at least 1k flash and a TimerA module (though I could have hacked the WDT to work)
     
    So, I assembled the circuit on my breadboard, following the schematic at the end of my post, and programmed the MSP430.
     
    For the code, I borrowed beretta's TimerA code example, and tweaked it to fit the needs of my timer. The timer is to read the input value of the three switches as a binary value to determine tea type, set a "goal" amount of half-second ticks based upon the user's request, and when the user presses the "start" button, go into a waiting period. While the uC is waiting, the LED will be flashed slowly at first, but increasingly faster as the timer ticks closer to the goal. Once the goal amount of ticks has been reached, the LED will be turned on, and the buzzer will sound (mine sounds reminiscent of an old-fashioned tea kettle, so it's suitable). The buzzing can be stopped by pressing the "start" button again to reset the device, and allow another time to be set. Simple enough, right?
     
    The code is available:

    // MSP430 based Tea Timer // Sets off a buzzer to let you know when your tea is done steeping // Supports several types of tea // suspended-chord (http://blog.suspended-chord.info) /* Tea steeping chart Tea type Time DIP Code ------------------------------------------ White 2 minutes 000 Green 3 minutes 001 Black/Oolong 4 minutes 010 Herbal 5 minutes 011 Chai 8 minutes 100 Rooibos 6 minutes 101 Other 1 minute 110 Other 2 30 seconds 111 */ // circuit: // LED on P1.0 // Piezo buzzer with driver on P1.1 // 3-switch dip (or 3 toggle switches) on P1.4, P1.5, and P1.6 // push button tact on P1.3, pullup resistor //#define DEBUG #define __MSP430G2231__ #include // pin for status LED #define LED BIT0 // pin for buzzer #define BUZZER BIT1 // pin for start switch #define START BIT3 // three consecutive pins for mode selection #define INPUT1 BIT4 #define INPUT2 BIT5 #define INPUT3 BIT6 // numeric value of the first pin #define SHIFT 4 // unused bits #define UNUSED BIT2 + BIT7 // variables unsigned int goal = 0; unsigned int tickCount = 0; unsigned char statusCount = 0; char statusMode = 0; char mode = 0; char reset = 0; volatile unsigned int i = 0; void main() { while(1) { WDTCTL = WDTPW + WDTHOLD; // kill wdt P1OUT = 0; // clear outputs P1DIR = LED + BUZZER + UNUSED; // setup outputs and unused to out/low to reduce power consumption BCSCTL1 = CALBC1_1MHZ; // setup DCO DCOCTL = CALDCO_1MHZ; // setup TimerA TACCR0 = 62499; // .5s cycle with 1MHZ clk and /8 divider // delay a few cycles to debounce i = 0; while (i < 50000) i++; while ((P1IN & START) == START) { // keep setting mode until start switch is pressed // setup mode mode = (P1IN & (INPUT1 + INPUT2 + INPUT3)) >> SHIFT; // setup goal switch (mode) { case 0: // white tea goal = 240; // 2 minutes break; case 1: // green tea goal = 360; // 3 minutes break; case 2: // black/oolong tea goal = 480; // 4 minutes break; case 3: // herbal tea goal = 600; // 5 minutes break; case 4: // chai tea goal = 960; // 8 minutes break; case 5: // rooibos tea goal = 720; // 6 minutes break; case 6: // other goal = 120; // 1 minute break; case 7: // other2 goal = 60; // 30 seconds break; default: goal = 0; } } #ifdef DEBUG goal = 30; // 15 seconds #endif // reset the TAR, and finish setting up TimerA TACTL = TASSEL_2 + ID_3 + MC_1 + TACLR; // select SMCLK/8, up mode, and clear the TAR TACCTL0 = CCIE; // enable interrupts // enable interrupts _enable_interrupt(); // turn on LED P1OUT |= LED; // reset variables statusCount = statusMode = tickCount = reset = 0; // enter LPM1 //LPM1; while (reset == 0); } } // timerA interrupt for CCR0 #pragma vector = TIMERA0_VECTOR __interrupt void CCR0_ISR (void) { tickCount++; // increase tick count // toggle LED increasingly faster as the time counts towards the end statusCount++; if (tickCount >= goal/4) statusMode = 1; if (tickCount >= goal/2) statusMode = 2; if (tickCount >= 3*(goal/4)) statusMode = 3; switch (statusMode) { case 0: if (statusCount >= 4) { // blink every 2 seconds P1OUT ^= LED; // toggle LED statusCount = 0; } break; case 1: if (statusCount >= 3) { // blink every 1.5 seconds P1OUT ^= LED; // toggle LED statusCount = 0; } break; case 2: if (statusCount >= 2) { // blink every 1 second P1OUT ^= LED; // toggle LED statusCount = 0; } break; case 3: default: // blink every .5 second P1OUT ^= LED; // toggle LED statusCount = 0; break; } if (tickCount >= goal) { _disable_interrupt(); // kill interrupts TACCTL0 &= ~CCIE; // disable TimerA CCR0 interrupt //LPM1_EXIT; // exit LPM1 P1OUT |= LED + BUZZER; // buzzer + LED on while ((P1IN & START) == START); // if START pressed, return to main() reset = 1; } }
     
    Basically, as I stated above, the user selects a mode (tea type) by way of the three switches, and then presses a button to start the timer. When the tea is done steeping, the buzzer goes off, and the user can press the button again to reset it. The switch positions corresponding to the tea types are as follows:
     
    6, 5, and 4 refer to P1.6, P1.5, and P1.4
    6 5 4 Tea type (time)
    0 0 0 White Tea (2 minutes)
    0 0 1 Green Tea (3 minutes)
    0 1 0 Black/Oolong Tea (4 minutes)
    0 1 1 Herbal Tea/Infusions (5 minutes)
    1 0 0 Chai Tea (8 minutes)
    1 0 1 Rooibos Tea (6 minutes)
    1 1 0 Other1 (1 minute)
    1 1 1 Other2 (30 seconds)
     
     
    Now, this isn't the most accurate timer, as I'm not using the crystal, but it's accurate enough to steep a good cup of tea (believe me, I've used it a lot since I hacked it together), and my stopwatch tells me it's accurate to within around 6 seconds on average.
     
    In the future, I'd like to use a better input mechanism (I might be geeky enough to remember binary codes for tea types, but most are not, so a rotary switch or something would be perfect), maybe a cheap LCD for a status indicator, even showing how much time remains, and potentially having the last two codes (110 and 111) be user programmable for any time in second increments up to half of an unsigned long (as the ticks are half-second ticks). Maybe even shove it all into an Altoids tin for portability and the geek-chic factor. Who knows?
     
    Anyways, here's the schematic, and a photo of it in action:
     

    Tea-Timer in action! (notice the LaunchPad is only used as a power supply here... I don't have a battery clip yet.)
     

    schematic
     
    Thanks for reading!
     
    Keep tweaking~
     
    EDIT: I'm an idiot sometimes... I forgot the code and images.
  23. Like
    gatesphere reacted to GeekDoc in Need a favicon?   
    Do you want/need a favicon.ico for the site? I was making one for my blog, and thought I'd whip one up for you using your theme colors. Use it or trash it; you won't hurt my feelings. It took all of a couple of minutes.
     
    16x16px, looks like this:

     
    43oh-favicon.ico.zip
     
    -Doc
  24. Like
    gatesphere got a reaction from bluehash in MSP430G2xxx Tea Timer   
    Here is my entry for the November 2010 Project of the Month Contest, an MSP430G2xxx based tea timer!
     
    I love tea, and thought this contest was an excellent reason to actually get off of my lazy behind and put this together.
     
    Below is my blog post on it, modified slightly to show the pictures and code here rather than just link to them as on my blog. Blog post is available here: http://blog.suspended-chord.info/?c=27
     
    Below this point is the post:
    ------------------------------------------------------
    Hello all,
     
    I am an avid tea drinker. As such, I make many cups of various kinds of tea, each with their own optimal steep times. Usually, I just keep track of the time, but I have found that I can make the best cup of tea by setting a timer to go off after a certain amount of time, depending on the style of tea that I am brewing. I find the best results come from going by the following table (based on personal preference and experimentation):
     
     
    Tea Variety => Recommended Steep Time
    White tea => 2 minutes
    Green tea => 3 minutes
    Black/Oolong tea => 4 minutes
    Herbal tea/infusions (most varieties) => 5 minutes
    Rooibos tea (African redbush) => 6 minutes
    Chai tea (regardless of base) => 8 minutes
    Kukicha twig tea and other varieties => in intervals of 1 minute
     
     
    With this in mind, I decided that I should make a tea timer. This seems simple enough, and it has been on my to-do list for a while anyway, and 43oh! is having an MSP430 Project of the Month Contest, so I decided to hack it together. Turned out rather simple.
     


    The full part count is as follows:
    [*:3snbat08] 3 toggle switches (or a 3-switch DIP, as I used)
    [*:3snbat08] 4 10k resistors
    [*:3snbat08] 1 5mm green LED
    [*:3snbat08] 1 piezo buzzer with integrated driver circuit
    [*:3snbat08] 1 tact switch/push button
    [*:3snbat08] wire
    [*:3snbat08] Any MSP430 uC with at least 1k flash and a TimerA module (though I could have hacked the WDT to work)
     
    So, I assembled the circuit on my breadboard, following the schematic at the end of my post, and programmed the MSP430.
     
    For the code, I borrowed beretta's TimerA code example, and tweaked it to fit the needs of my timer. The timer is to read the input value of the three switches as a binary value to determine tea type, set a "goal" amount of half-second ticks based upon the user's request, and when the user presses the "start" button, go into a waiting period. While the uC is waiting, the LED will be flashed slowly at first, but increasingly faster as the timer ticks closer to the goal. Once the goal amount of ticks has been reached, the LED will be turned on, and the buzzer will sound (mine sounds reminiscent of an old-fashioned tea kettle, so it's suitable). The buzzing can be stopped by pressing the "start" button again to reset the device, and allow another time to be set. Simple enough, right?
     
    The code is available:

    // MSP430 based Tea Timer // Sets off a buzzer to let you know when your tea is done steeping // Supports several types of tea // suspended-chord (http://blog.suspended-chord.info) /* Tea steeping chart Tea type Time DIP Code ------------------------------------------ White 2 minutes 000 Green 3 minutes 001 Black/Oolong 4 minutes 010 Herbal 5 minutes 011 Chai 8 minutes 100 Rooibos 6 minutes 101 Other 1 minute 110 Other 2 30 seconds 111 */ // circuit: // LED on P1.0 // Piezo buzzer with driver on P1.1 // 3-switch dip (or 3 toggle switches) on P1.4, P1.5, and P1.6 // push button tact on P1.3, pullup resistor //#define DEBUG #define __MSP430G2231__ #include // pin for status LED #define LED BIT0 // pin for buzzer #define BUZZER BIT1 // pin for start switch #define START BIT3 // three consecutive pins for mode selection #define INPUT1 BIT4 #define INPUT2 BIT5 #define INPUT3 BIT6 // numeric value of the first pin #define SHIFT 4 // unused bits #define UNUSED BIT2 + BIT7 // variables unsigned int goal = 0; unsigned int tickCount = 0; unsigned char statusCount = 0; char statusMode = 0; char mode = 0; char reset = 0; volatile unsigned int i = 0; void main() { while(1) { WDTCTL = WDTPW + WDTHOLD; // kill wdt P1OUT = 0; // clear outputs P1DIR = LED + BUZZER + UNUSED; // setup outputs and unused to out/low to reduce power consumption BCSCTL1 = CALBC1_1MHZ; // setup DCO DCOCTL = CALDCO_1MHZ; // setup TimerA TACCR0 = 62499; // .5s cycle with 1MHZ clk and /8 divider // delay a few cycles to debounce i = 0; while (i < 50000) i++; while ((P1IN & START) == START) { // keep setting mode until start switch is pressed // setup mode mode = (P1IN & (INPUT1 + INPUT2 + INPUT3)) >> SHIFT; // setup goal switch (mode) { case 0: // white tea goal = 240; // 2 minutes break; case 1: // green tea goal = 360; // 3 minutes break; case 2: // black/oolong tea goal = 480; // 4 minutes break; case 3: // herbal tea goal = 600; // 5 minutes break; case 4: // chai tea goal = 960; // 8 minutes break; case 5: // rooibos tea goal = 720; // 6 minutes break; case 6: // other goal = 120; // 1 minute break; case 7: // other2 goal = 60; // 30 seconds break; default: goal = 0; } } #ifdef DEBUG goal = 30; // 15 seconds #endif // reset the TAR, and finish setting up TimerA TACTL = TASSEL_2 + ID_3 + MC_1 + TACLR; // select SMCLK/8, up mode, and clear the TAR TACCTL0 = CCIE; // enable interrupts // enable interrupts _enable_interrupt(); // turn on LED P1OUT |= LED; // reset variables statusCount = statusMode = tickCount = reset = 0; // enter LPM1 //LPM1; while (reset == 0); } } // timerA interrupt for CCR0 #pragma vector = TIMERA0_VECTOR __interrupt void CCR0_ISR (void) { tickCount++; // increase tick count // toggle LED increasingly faster as the time counts towards the end statusCount++; if (tickCount >= goal/4) statusMode = 1; if (tickCount >= goal/2) statusMode = 2; if (tickCount >= 3*(goal/4)) statusMode = 3; switch (statusMode) { case 0: if (statusCount >= 4) { // blink every 2 seconds P1OUT ^= LED; // toggle LED statusCount = 0; } break; case 1: if (statusCount >= 3) { // blink every 1.5 seconds P1OUT ^= LED; // toggle LED statusCount = 0; } break; case 2: if (statusCount >= 2) { // blink every 1 second P1OUT ^= LED; // toggle LED statusCount = 0; } break; case 3: default: // blink every .5 second P1OUT ^= LED; // toggle LED statusCount = 0; break; } if (tickCount >= goal) { _disable_interrupt(); // kill interrupts TACCTL0 &= ~CCIE; // disable TimerA CCR0 interrupt //LPM1_EXIT; // exit LPM1 P1OUT |= LED + BUZZER; // buzzer + LED on while ((P1IN & START) == START); // if START pressed, return to main() reset = 1; } }
     
    Basically, as I stated above, the user selects a mode (tea type) by way of the three switches, and then presses a button to start the timer. When the tea is done steeping, the buzzer goes off, and the user can press the button again to reset it. The switch positions corresponding to the tea types are as follows:
     
    6, 5, and 4 refer to P1.6, P1.5, and P1.4
    6 5 4 Tea type (time)
    0 0 0 White Tea (2 minutes)
    0 0 1 Green Tea (3 minutes)
    0 1 0 Black/Oolong Tea (4 minutes)
    0 1 1 Herbal Tea/Infusions (5 minutes)
    1 0 0 Chai Tea (8 minutes)
    1 0 1 Rooibos Tea (6 minutes)
    1 1 0 Other1 (1 minute)
    1 1 1 Other2 (30 seconds)
     
     
    Now, this isn't the most accurate timer, as I'm not using the crystal, but it's accurate enough to steep a good cup of tea (believe me, I've used it a lot since I hacked it together), and my stopwatch tells me it's accurate to within around 6 seconds on average.
     
    In the future, I'd like to use a better input mechanism (I might be geeky enough to remember binary codes for tea types, but most are not, so a rotary switch or something would be perfect), maybe a cheap LCD for a status indicator, even showing how much time remains, and potentially having the last two codes (110 and 111) be user programmable for any time in second increments up to half of an unsigned long (as the ticks are half-second ticks). Maybe even shove it all into an Altoids tin for portability and the geek-chic factor. Who knows?
     
    Anyways, here's the schematic, and a photo of it in action:
     

    Tea-Timer in action! (notice the LaunchPad is only used as a power supply here... I don't have a battery clip yet.)
     

    schematic
     
    Thanks for reading!
     
    Keep tweaking~
     
    EDIT: I'm an idiot sometimes... I forgot the code and images.
  25. Like
    gatesphere got a reaction from jsolarski in MSP430G2xxx Tea Timer   
    Here is my entry for the November 2010 Project of the Month Contest, an MSP430G2xxx based tea timer!
     
    I love tea, and thought this contest was an excellent reason to actually get off of my lazy behind and put this together.
     
    Below is my blog post on it, modified slightly to show the pictures and code here rather than just link to them as on my blog. Blog post is available here: http://blog.suspended-chord.info/?c=27
     
    Below this point is the post:
    ------------------------------------------------------
    Hello all,
     
    I am an avid tea drinker. As such, I make many cups of various kinds of tea, each with their own optimal steep times. Usually, I just keep track of the time, but I have found that I can make the best cup of tea by setting a timer to go off after a certain amount of time, depending on the style of tea that I am brewing. I find the best results come from going by the following table (based on personal preference and experimentation):
     
     
    Tea Variety => Recommended Steep Time
    White tea => 2 minutes
    Green tea => 3 minutes
    Black/Oolong tea => 4 minutes
    Herbal tea/infusions (most varieties) => 5 minutes
    Rooibos tea (African redbush) => 6 minutes
    Chai tea (regardless of base) => 8 minutes
    Kukicha twig tea and other varieties => in intervals of 1 minute
     
     
    With this in mind, I decided that I should make a tea timer. This seems simple enough, and it has been on my to-do list for a while anyway, and 43oh! is having an MSP430 Project of the Month Contest, so I decided to hack it together. Turned out rather simple.
     


    The full part count is as follows:
    [*:3snbat08] 3 toggle switches (or a 3-switch DIP, as I used)
    [*:3snbat08] 4 10k resistors
    [*:3snbat08] 1 5mm green LED
    [*:3snbat08] 1 piezo buzzer with integrated driver circuit
    [*:3snbat08] 1 tact switch/push button
    [*:3snbat08] wire
    [*:3snbat08] Any MSP430 uC with at least 1k flash and a TimerA module (though I could have hacked the WDT to work)
     
    So, I assembled the circuit on my breadboard, following the schematic at the end of my post, and programmed the MSP430.
     
    For the code, I borrowed beretta's TimerA code example, and tweaked it to fit the needs of my timer. The timer is to read the input value of the three switches as a binary value to determine tea type, set a "goal" amount of half-second ticks based upon the user's request, and when the user presses the "start" button, go into a waiting period. While the uC is waiting, the LED will be flashed slowly at first, but increasingly faster as the timer ticks closer to the goal. Once the goal amount of ticks has been reached, the LED will be turned on, and the buzzer will sound (mine sounds reminiscent of an old-fashioned tea kettle, so it's suitable). The buzzing can be stopped by pressing the "start" button again to reset the device, and allow another time to be set. Simple enough, right?
     
    The code is available:

    // MSP430 based Tea Timer // Sets off a buzzer to let you know when your tea is done steeping // Supports several types of tea // suspended-chord (http://blog.suspended-chord.info) /* Tea steeping chart Tea type Time DIP Code ------------------------------------------ White 2 minutes 000 Green 3 minutes 001 Black/Oolong 4 minutes 010 Herbal 5 minutes 011 Chai 8 minutes 100 Rooibos 6 minutes 101 Other 1 minute 110 Other 2 30 seconds 111 */ // circuit: // LED on P1.0 // Piezo buzzer with driver on P1.1 // 3-switch dip (or 3 toggle switches) on P1.4, P1.5, and P1.6 // push button tact on P1.3, pullup resistor //#define DEBUG #define __MSP430G2231__ #include // pin for status LED #define LED BIT0 // pin for buzzer #define BUZZER BIT1 // pin for start switch #define START BIT3 // three consecutive pins for mode selection #define INPUT1 BIT4 #define INPUT2 BIT5 #define INPUT3 BIT6 // numeric value of the first pin #define SHIFT 4 // unused bits #define UNUSED BIT2 + BIT7 // variables unsigned int goal = 0; unsigned int tickCount = 0; unsigned char statusCount = 0; char statusMode = 0; char mode = 0; char reset = 0; volatile unsigned int i = 0; void main() { while(1) { WDTCTL = WDTPW + WDTHOLD; // kill wdt P1OUT = 0; // clear outputs P1DIR = LED + BUZZER + UNUSED; // setup outputs and unused to out/low to reduce power consumption BCSCTL1 = CALBC1_1MHZ; // setup DCO DCOCTL = CALDCO_1MHZ; // setup TimerA TACCR0 = 62499; // .5s cycle with 1MHZ clk and /8 divider // delay a few cycles to debounce i = 0; while (i < 50000) i++; while ((P1IN & START) == START) { // keep setting mode until start switch is pressed // setup mode mode = (P1IN & (INPUT1 + INPUT2 + INPUT3)) >> SHIFT; // setup goal switch (mode) { case 0: // white tea goal = 240; // 2 minutes break; case 1: // green tea goal = 360; // 3 minutes break; case 2: // black/oolong tea goal = 480; // 4 minutes break; case 3: // herbal tea goal = 600; // 5 minutes break; case 4: // chai tea goal = 960; // 8 minutes break; case 5: // rooibos tea goal = 720; // 6 minutes break; case 6: // other goal = 120; // 1 minute break; case 7: // other2 goal = 60; // 30 seconds break; default: goal = 0; } } #ifdef DEBUG goal = 30; // 15 seconds #endif // reset the TAR, and finish setting up TimerA TACTL = TASSEL_2 + ID_3 + MC_1 + TACLR; // select SMCLK/8, up mode, and clear the TAR TACCTL0 = CCIE; // enable interrupts // enable interrupts _enable_interrupt(); // turn on LED P1OUT |= LED; // reset variables statusCount = statusMode = tickCount = reset = 0; // enter LPM1 //LPM1; while (reset == 0); } } // timerA interrupt for CCR0 #pragma vector = TIMERA0_VECTOR __interrupt void CCR0_ISR (void) { tickCount++; // increase tick count // toggle LED increasingly faster as the time counts towards the end statusCount++; if (tickCount >= goal/4) statusMode = 1; if (tickCount >= goal/2) statusMode = 2; if (tickCount >= 3*(goal/4)) statusMode = 3; switch (statusMode) { case 0: if (statusCount >= 4) { // blink every 2 seconds P1OUT ^= LED; // toggle LED statusCount = 0; } break; case 1: if (statusCount >= 3) { // blink every 1.5 seconds P1OUT ^= LED; // toggle LED statusCount = 0; } break; case 2: if (statusCount >= 2) { // blink every 1 second P1OUT ^= LED; // toggle LED statusCount = 0; } break; case 3: default: // blink every .5 second P1OUT ^= LED; // toggle LED statusCount = 0; break; } if (tickCount >= goal) { _disable_interrupt(); // kill interrupts TACCTL0 &= ~CCIE; // disable TimerA CCR0 interrupt //LPM1_EXIT; // exit LPM1 P1OUT |= LED + BUZZER; // buzzer + LED on while ((P1IN & START) == START); // if START pressed, return to main() reset = 1; } }
     
    Basically, as I stated above, the user selects a mode (tea type) by way of the three switches, and then presses a button to start the timer. When the tea is done steeping, the buzzer goes off, and the user can press the button again to reset it. The switch positions corresponding to the tea types are as follows:
     
    6, 5, and 4 refer to P1.6, P1.5, and P1.4
    6 5 4 Tea type (time)
    0 0 0 White Tea (2 minutes)
    0 0 1 Green Tea (3 minutes)
    0 1 0 Black/Oolong Tea (4 minutes)
    0 1 1 Herbal Tea/Infusions (5 minutes)
    1 0 0 Chai Tea (8 minutes)
    1 0 1 Rooibos Tea (6 minutes)
    1 1 0 Other1 (1 minute)
    1 1 1 Other2 (30 seconds)
     
     
    Now, this isn't the most accurate timer, as I'm not using the crystal, but it's accurate enough to steep a good cup of tea (believe me, I've used it a lot since I hacked it together), and my stopwatch tells me it's accurate to within around 6 seconds on average.
     
    In the future, I'd like to use a better input mechanism (I might be geeky enough to remember binary codes for tea types, but most are not, so a rotary switch or something would be perfect), maybe a cheap LCD for a status indicator, even showing how much time remains, and potentially having the last two codes (110 and 111) be user programmable for any time in second increments up to half of an unsigned long (as the ticks are half-second ticks). Maybe even shove it all into an Altoids tin for portability and the geek-chic factor. Who knows?
     
    Anyways, here's the schematic, and a photo of it in action:
     

    Tea-Timer in action! (notice the LaunchPad is only used as a power supply here... I don't have a battery clip yet.)
     

    schematic
     
    Thanks for reading!
     
    Keep tweaking~
     
    EDIT: I'm an idiot sometimes... I forgot the code and images.
×
×
  • Create New...