Jump to content

gordon

Members
  • Content Count

    536
  • Joined

  • Last visited

  • Days Won

    13

Reputation Activity

  1. Like
    gordon reacted to voodoofish in Data Logger board   
    This is the first graph of data pulled from the data logger. This was a simple test, but verified saving and retrieving of data from the chip and some other test functions that I have been working on. This test used the WDT interval timer and took roughly an hour to run to collect 4096 samples. The variances in temp were due to the time and the amount of sun hitting the logger(2 rapid increases in temp). I think it's time to populate another board as I know the setup works and would allow me to start running longer tests while working on code.

  2. Like
    gordon reacted to oPossum in AC power usage Booster Pack   
    There are some good design ideas in that Instructable, but the implementation is weak. For example the current sensors are biased to allow the ADC to read the AC signal they produce - that is OK. The problem is that the bias voltage is not measured, it is assumed to be 1/2 of supply, so there can be a DC offset in the current measurement. There is also no anti-aliasing filter on the ADC. The way AC voltage is measured also has a few problems.
     
    Give me a few days and I'll draw up a schematic that fixes these design problems.
  3. Like
    gordon reacted to pabigot in Launchpad v1.5 + M430G2553 serial communication on Linux   
    Thanks to a couple of people here for suggestions on this issue. It was the cue that will finally get me to switch to the Fraunchpad as my default platform, and led to what appears to be the solution to a long-standing issue with the Fraunchpad.
     
    In my case, I've modified my test430 environment's platform-specific UART code to detect whether P4.0 is being held to ground, and if so spin with an LED flash pattern until the jumper is removed (P4.0 is right next to GND). I'm going to do the same for the Launchpad, but with P1.0 held to Vcc. Having this in my standard serial startup means whenever I grab an old board and plug it in, I can fix the problem by unplugging it, sticking on a jumper, and reconnecting. If I'm smart enough to install the jumper before I put the board away after use, it'll go even faster. (Holding the reset button may work, but it's awkward and inconvenient.)
     
    Once I did this for the Fraunchpad I started using that platform more. Which led to repeated instances of the old fuse blown issue, which was a pain, and ultimately led to the complete inability to contact the board with either BSL or JTAG (see this E2E chain). Which in turn led to the discovery of an error in TI's documentation of the FRAM chips, which led to an error in the chip-specific information TI provides me for the mspgcc toolchain, which led to the BSL and JTAG passwords being overwritten every time an mspgcc-generated application was programmed onto an FRAM device. Net result, after the patches I'll put out next week, will be elimination of a major inconvenience with the Fraunchpad, making it actually a really nice platform to use. (I can't test it now, because, well, both my boards are bricks. The ones my TI contact's sending me as replacements should arrive next week.)
     
    So all in all, significant improvements from a open discussion of a simple idea. This is how community is supposed to work. Thank you.
  4. Like
    gordon reacted to pabigot in Simple BIS/BIC macros for GCC   
    I've added a peephole optimization for the case of AND #X, DST into BIC #-X, DST where -X can be expressed by the constant generator. The fix will be in mspgcc version following 20120627, and will be out sometime next week. (I won't add the fix to the LTS release series as it's not actually wrong, just sub-optimal.)
     
    Thanks for the report. If you encounter other cases where the obvious code in C doesn't do the right thing, please create new tracker tickets so those can be fixed too.
  5. Like
    gordon reacted to Rickta59 in Linux Serial Communication working w/modified cdc-acm module   
    So I finally tried out the replacement cdc_acm module from the e2e forums. I'm using the file 7028.msp430_patch.zip mentioned in this post http://e2e.ti.com/support/low_power_rf/f/156/p/53610/697952.aspx#697952. I'm using Ubuntu 11.04 with a 2.6.38 kernel. Installing this patch solved my problems with /dev/ttyACM0 and linux.
     
    I tried the unmodified Energia ASCII Table example. The code in that sample doesn't wait before sending data, however with this patched module it just works. With the old cdc-acm my whole UI would freeze for multiple 10s of seconds.
     
    There are some things that are different from an Arduino. The main one being the launchpad doesn't reset the msp430g2553 chip when it receives a DTR line signal down the /dev/ttyACM0. What does that mean? Opening and closing the serial console doesn't restart the msp430. When you open the window you must press the reset button on the launchpad to have it restart like an Arduino would. However, with this patch, the UI doesn't lock up any more or stall when you first run it. You also don't have to be worried about printing data when the serial console isn't open.
     
    Two other people have also tried this patch with similar good results. One system was Ubuntu 10.04/2.6.something kernel and arch linux with a 3.something kernel.
     
    I think this goes a long way to addressing stability for the linux version of Energia. Yay Gerald Stanje the kernel hacker author. +1
     
    -rick
  6. Like
    gordon reacted to RobG in TI MSP430 Family Eagle library   
    Yes, I am using version 6, but I might have version 5 of this library somewhere, let me know if you need it.
  7. Like
    gordon reacted to voodoofish in Data Logger board   
    I received the datalogger board today and after multiple hw tests to verify that board functioned as expected, I completed the first of 3 test boards. The last test is to verify that the memory chip is recording correctly, and until then I can't say that this board is 100% functional. though the current 80% has me pretty excited. Now I'm waiting for the addon board that is breaks out the datalogging pins plus a couple other pins to a usable 3 pin configuration.
     
    Images included in this set have the button 1 switch which allows for it to be a reset or action button, and the male header pins. The other image shows the board pre switch and header mockup and also conected to the lp which allows me to do the uploading of programs. Very happy so far. Tonight and tomorrow I'll work on getting the memory chip tested as well as doing some initial tests on the data input ports(adc channels)and communications port(hw uart).
     

  8. Like
    gordon got a reaction from advaneharshal in LP Booster Pack Eagle footprints   
    (OK, I have no idea where to put this. BH, feel free to move it around.)
     
    Continuing from viewtopic.php?f=9&t=1348&start=40#p11369
     
    This is the final version; I don't think it can be made any better as well as generic at the same time.
     
    All variants verified against the TI LaunchPad Eagle files.
     
    Thanks to SugarAddict for the corrections.
     
    Pro tip: make your References layer yellow (or any other unused bright color) while placing your components.
     
    Addendum: DipTrace users look here: viewtopic.php?f=35&t=2972
    TI_launchpad.zip
  9. Like
    gordon reacted to oPossum in measuring power OF msp430   
    Ground referenced current measurements using a simple circuit can be done for voltages up to about 30 volts for milliamp range and higher. Outside of that the design becomes impractical for several technical reasons.
     
    The uCurrent solves the technical problems by floating the whole circuit at the voltage of the supply rail. That allows it to be used at almost any sane voltage, and it can be used on positive supply, negative supply or the ground. The meter connected to it must also float at the supply voltage - no problem for a handheld DMM.
     
    To use a 'scope with the uCurrent there are several options...
     
    - Power your MSP430 circuit from batteries or a bench supply with floating ground. You won't be able to have the FET connected unless you use it with a USB isolator. Use caution with any other test equipment because the power supply positive will be at ground level.
     
    - Use a differential scope probe. They are quite expensive because they are made to be general purpose. They start at hundreds of dollars and quickly go up to thousands. It is possible to use a differential probe with a simple current shunt (resistor), but the burden voltage will likely be unacceptable.
     
    - Float the scope with an isolation transformer. This is discouraged for many reasons, but some people do it with success.
  10. Like
    gordon reacted to oPossum in measuring power OF msp430   
    The supply current can be converted to a ground referenced voltage (for use with 'scope or DMM) using a high side current monitor.
     
    The circuit is very simple - just a shunt resistor and a load resistor. Easy to make on a chunk of perfboard.
  11. Like
    gordon reacted to shluzzzoid in TM1638 LEDs interface _version 1.7.0 available!   
    Hello!

    My library for interacting an MSP430g2553 with a TM1638 (SPI 3-wire mode)



    Description

    MSP430G2xx3 - USCI_A0 SPI Master Interface to TM1638, Read/Write command, key scanning, show digit and switch LEDs on board.
    TM1638 - Driver for Led's indicator, 10 segment output lines, 8 grid output lines, 8 segment/key - 3 lines scanning.

    Features
    Support for the TM1638;
    Support for dimming the display and LEDs;
    Reading simultaneous button presses
    Connection diagramm:


    Code:

    #include "msp430g2553.h" // MSP430 Ports Define #define LED_RED BIT0 //RED Led #define LED_GRE BIT6 //Green Led #define STROBE_TM1638 BIT5 #define DIO BIT2 #define CLK BIT4 // TM1638 Commands Define #define RED_TM1638 0x01 //RED Led #define GRE_TM1638 0x02 //Green Led #define DATA_WRITE_INCR_ADDR 0x40 //Command to switch TM1638 for automatic increment address mode #define DATA_WRITE_FIX_ADDR 0x44 //Command to switch TM1638 for fix address mode #define DATA_READ_KEY_SCAN_MODE 0x42 //Command for read key code from TM1638 #define ADDRSET 0xC0 //Command to set address 0x00 #define DISP_ON 0x8F //Command to Display ON and set (max) brightness #define DISP_OFF 0x80 //Command to Display OFF //#define MIN_VOLT 2700 //Critycal voltage of power OFF const unsigned int Num[]= //Code table of symbols { 0x3F, //0 0x06, //1 0x5B, //2 0x4F, //3 0x66, //4 0x6D, //5 0x7D, //6 0x07, //7 0x7F, //8 0x6F, //9 0x40, //Minus 0x63, //Degree 0x39, //"C" 0x00, //Blank 0x3E //"U" }; const unsigned int ERROR_DATA[] = { 0x79, // E 0x50, // r 0x50, // r 0x5C, // o 0x50, // r 0, 0, 0 }; //Function definitions void init_Ports() { P1OUT = 0x00; // P1 setup for LED & STROBE output P2OUT = 0x00; // P2 setup for output P1DIR = LED_RED + LED_GRE + STROBE_TM1638; P1SEL = BIT1 + BIT2 + BIT4; // Set secondary functions for PORT1 P1SEL2 = BIT1 + BIT2 + BIT4; // P1.1 - TXD, P1.2 - RXD P1OUT |= STROBE_TM1638; // Chip Select, Set STROBE = "1" } void init_WDT() { WDTCTL = WDTPW + WDTHOLD; //Stop watchdog } void init_SPI() { UCA0CTL0 |= UCCKPL + UCMST + UCSYNC; // 3-pin, 8-bit SPI master UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 |= 0x02; // /2 UCA0BR1 = 0; // UCA0MCTL = 0; // No modulation UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** } void SendCommand(unsigned char Command) { //Transmit Command P1OUT &= ~STROBE_TM1638; //Set STROBE = "0" _NOP(); _NOP(); P1OUT |= STROBE_TM1638; //Set STROBE = "1" _NOP(); _NOP(); P1OUT &= ~STROBE_TM1638; //Set STROBE = "0" _NOP(); UCA0TXBUF = Command; while (!(IFG2 & UCA0TXIFG)); P1OUT |= STROBE_TM1638; //Set STROBE = "1" } void SendData(unsigned int address, unsigned int data) { //Transmit Data SendCommand(DATA_WRITE_FIX_ADDR); P1OUT &= ~STROBE_TM1638; //Set STROBE = "0" UCA0TXBUF = (0xC0 | address); while (!(IFG2 & UCA0TXIFG)); UCA0TXBUF = data; while (!(IFG2 & UCA0TXIFG)); P1OUT |= STROBE_TM1638; //Set STROBE = "1" } void ShowDig(int position, int Data, int Dot) //show single digit { SendData(position << 1, Data | (Dot ? 0x80 : 0) ); } void ClearDig(unsigned int pos, unsigned int dot) { ShowDig(pos, 0x00, dot); } void ShowLed(int Number, int Color) { SendData((Number << 1)-1, Color); } void ShowLeds(int color) { unsigned int i; for (i=1; i<9; i++) { ShowLed (i, color); } } void DisplayClean() { //Clean RAM of TM1638 int i; for (i=0; i<17; i++) { SendData(i, 0x00); } } void SetupDisplay(char active, char intensity) { SendCommand (0x80 | (active ? 8 : 0) | intensity); P1OUT |= STROBE_TM1638; // Set STROBE = "1" } void init_Display() { __delay_cycles(100000); //Time to initial TM1638 DisplayClean(); //Clean display SendCommand(DISP_OFF); //Display off SendCommand(DATA_WRITE_FIX_ADDR); //Set address mode SendCommand(ADDRSET); //Set first adress } void ShowError() { unsigned int j; for (j=0; j<8; j++) { ShowDig(j, ERROR_DATA[j], 0); } } int GetKey() { unsigned int KeyData = 0; unsigned int i; P1OUT &= ~STROBE_TM1638; // Set STROBE = "0" UCA0TXBUF = DATA_READ_KEY_SCAN_MODE; while (!(IFG2 & UCA0TXIFG)); __delay_cycles(20); //wait to ready (see datasheet) UCA0TXBUF = 0xff; //Send dummy byte while (!(IFG2 & UCA0TXIFG)); //wait for buffer ready // 1'st reseiving byte = bad for (i=0; i<4; i++) { UCA0TXBUF = 0xff; while (!(IFG2 & UCA0RXIFG)); KeyData |= UCA0RXBUF << i; } P1OUT |= STROBE_TM1638; //Set STROBE = "1" return KeyData; } void main() { unsigned int j; unsigned int Keys = 0; init_WDT(); init_Ports(); init_SPI(); init_Display(); // Example program: for (j=0; j<8; j++) { //example set "01234567" on display ShowDig(j, Num[j], 0); } SetupDisplay(1, 7); // Display ON, max brightness while(1) { ShowLeds(0); //switch all LEDs off switch(GetKey()) { case 1: Keys = 1; break; case 2: Keys = 2; break; case 4: Keys = 3; break; case 8: Keys = 4; break; case 16: Keys = 5; break; case 32: Keys = 6; break; case 64: Keys = 7; break; case 128: Keys = 8; break; default: Keys = 0; break; } if (Keys) { ShowLed(Keys, GRE_TM1638);} ShowDig(7, Num[Keys], 1); } //end of example program } tm1638.rar
  12. Like
    gordon got a reaction from polymeris in Pronto IR code transmission   
    10R will result in 300mA through your LED, which is starting to get OK :).
     
    Some visible red glow is not necessarily bad. I am guessing the LED's peak wavelength is in the 850nm-ish range, that may very well mean that when overdriven, it will emit some light even in the visible red (750-780nm-ish) range (if you look at a webcam or some of these cheap-ish CCD cameras that have "night vision mode", you will probably see them doing this too). CIR applications usually operate in the 940nm-ish wavelength, which doesn't mean others won't work, just that the range and sensitivity will decrease. If that apparently 850-ish works for you, all the better, but you can achieve better results if you match your LEDs to the receiver in your camera (harvest some from old remotes and try). I am not familiar with cameras as such, dig the intertubes for info on what wavelength yours expects, someone must have figured it out already .
     
    You can safely leave the MCU on, just don't leave the pin that is controlling the transistor on (in other terms, do not try to use this setup for continuous infrared illumination) -- that would burn the LED out on short notice. Again, it is perfectly safe for remote control (short bursts with plenty of dead periods in between them).
     
    The 0.25W resistor is also OK, since it only has to cope with 300mA for very short time periods, it simply doesn't have time to overheat.
  13. Like
    gordon reacted to campbellsan in YABB - Breadboard Booster on steroids   
    YABB - Yet Another Breadboard Booster (this time on steroids)
     
    Launchpad Booster integrated breadboards are undoubtedly very handy for learning and experimentation. However, there is no denying the obvious; you can't squeeze very many components onto a breadboard this size.
     
    So, what about this? A breadboard Booster Pack with a CPLD lurking beneath?
    I chose a Xilinx XC9572XL which is very inexpensive and puts 3,200 re-programmable logic gates at your fingertips. You'd need a breadboard the size of a desktop to lay out that much logic on a traditional breadboard!
     
    Because the CPLD is mounted on the reverse side of the board, it has exactly the same 50mm form factor as other conventional breadboard Boosters. It therefore leaves access to the Launchpad LEDs and buttons. I included space for an optional crystal to clock the programmable logic. SInce this can theoretically go up to 178 MHz, it gives access to solving problems an MSP430 on its own could never tackle.
     
    Even if you're not ready to start playing with programmable logic, this board would be worth having. The default CPLD configuration will be for the MSP430 pins to pass straight through, so it will be just like using a regular breadboard Booster. However once you're ready, this little board will grow with you.
     
    I have based the layout around a little breadboard from Seeed Studio which measures 3.5 x 4.5 cm, but of course I would be open to better suggestions.
     
    Let me know what you think. If there is interest, I will post the schematic and board files I have so far.
  14. Like
    gordon reacted to RobG in Testing boards   
    Here's how I test my boards using poor man's pogo pins
     


  15. Like
    gordon got a reaction from GeekDoc in Pronto IR code transmission   
    10R will result in 300mA through your LED, which is starting to get OK :).
     
    Some visible red glow is not necessarily bad. I am guessing the LED's peak wavelength is in the 850nm-ish range, that may very well mean that when overdriven, it will emit some light even in the visible red (750-780nm-ish) range (if you look at a webcam or some of these cheap-ish CCD cameras that have "night vision mode", you will probably see them doing this too). CIR applications usually operate in the 940nm-ish wavelength, which doesn't mean others won't work, just that the range and sensitivity will decrease. If that apparently 850-ish works for you, all the better, but you can achieve better results if you match your LEDs to the receiver in your camera (harvest some from old remotes and try). I am not familiar with cameras as such, dig the intertubes for info on what wavelength yours expects, someone must have figured it out already .
     
    You can safely leave the MCU on, just don't leave the pin that is controlling the transistor on (in other terms, do not try to use this setup for continuous infrared illumination) -- that would burn the LED out on short notice. Again, it is perfectly safe for remote control (short bursts with plenty of dead periods in between them).
     
    The 0.25W resistor is also OK, since it only has to cope with 300mA for very short time periods, it simply doesn't have time to overheat.
  16. Like
    gordon got a reaction from oPossum in Pronto IR code transmission   
    10R will result in 300mA through your LED, which is starting to get OK :).
     
    Some visible red glow is not necessarily bad. I am guessing the LED's peak wavelength is in the 850nm-ish range, that may very well mean that when overdriven, it will emit some light even in the visible red (750-780nm-ish) range (if you look at a webcam or some of these cheap-ish CCD cameras that have "night vision mode", you will probably see them doing this too). CIR applications usually operate in the 940nm-ish wavelength, which doesn't mean others won't work, just that the range and sensitivity will decrease. If that apparently 850-ish works for you, all the better, but you can achieve better results if you match your LEDs to the receiver in your camera (harvest some from old remotes and try). I am not familiar with cameras as such, dig the intertubes for info on what wavelength yours expects, someone must have figured it out already .
     
    You can safely leave the MCU on, just don't leave the pin that is controlling the transistor on (in other terms, do not try to use this setup for continuous infrared illumination) -- that would burn the LED out on short notice. Again, it is perfectly safe for remote control (short bursts with plenty of dead periods in between them).
     
    The 0.25W resistor is also OK, since it only has to cope with 300mA for very short time periods, it simply doesn't have time to overheat.
  17. Like
    gordon got a reaction from polymeris in Pronto IR code transmission   
    What transistor have you used? Can it carry enough current? Can your power supply supply enough current (fast enough)? Are you sure you are switching the transistor on fully (2K seems a bit high, whatever transistor that is)?
     
    Seriously, just give this method a try, also read oPossum's stuff at http://forums.adafruit.com/viewtopic.php?p=22714 (many good things about how and why this works):
     

  18. Like
    gordon got a reaction from bluehash in Pronto IR code transmission   
    There was this guy on IRC yesterday whose questions started all this goodness . He left with a couple of his questions unanswered due to temporal inactivity. I only assume he came from here, so if you are reading this, try this one for solving your range/directionality/power problems. The board is part TH part SMD (but huge parts and lots of clearance so you can assemble it even if you have no SMD-soldering experience) and is designed to be glued on top of a 2xAA battery holder, not unlike this one:
     

     

     
    The crystal is completely optional (and I doubt it would work properly in that spot, but anyway).
     

     
    Completely untested.
    shutter.zip
  19. Like
    gordon got a reaction from polymeris in Pronto IR code transmission   
    There was this guy on IRC yesterday whose questions started all this goodness . He left with a couple of his questions unanswered due to temporal inactivity. I only assume he came from here, so if you are reading this, try this one for solving your range/directionality/power problems. The board is part TH part SMD (but huge parts and lots of clearance so you can assemble it even if you have no SMD-soldering experience) and is designed to be glued on top of a 2xAA battery holder, not unlike this one:
     

     

     
    The crystal is completely optional (and I doubt it would work properly in that spot, but anyway).
     

     
    Completely untested.
    shutter.zip
  20. Like
    gordon got a reaction from oPossum in Pronto IR code transmission   
    There was this guy on IRC yesterday whose questions started all this goodness . He left with a couple of his questions unanswered due to temporal inactivity. I only assume he came from here, so if you are reading this, try this one for solving your range/directionality/power problems. The board is part TH part SMD (but huge parts and lots of clearance so you can assemble it even if you have no SMD-soldering experience) and is designed to be glued on top of a 2xAA battery holder, not unlike this one:
     

     

     
    The crystal is completely optional (and I doubt it would work properly in that spot, but anyway).
     

     
    Completely untested.
    shutter.zip
  21. Like
    gordon reacted to Kman in 8x8 LED Matrix board with AS1116 chip with PONG?   
    Well, I figured it all out and the boys got their projects done! As a professional engineer, I typically have a 30% failure rate of the boards after they come out of the assembly shop. Somewhere there's a solder bridge or bad connection. The boys matched that rate, so most of the boards worked! I was very happy.
     
    Since this is the second time most of them had soldered (we practiced once), this was a great achievement for them.
     
    Besides the analog control of the paddle, I made it so that when you do well, the game gets quicker. When you do badly, the game ends. When the game ends, it displays the "level" you got to in the number of rows it lights up.
     
    Attached here are the instructions for assembling the boards, and some pictures of the boards. Thanks to everyone who helped this happen! It's certainly not the best code, but it works! Thanks fj604 for the base code!
     

    /* * Main.c * * Created on: May 4, 2012 * Author: Keven Coates (modified code from fj604's code) */ #include #include #define DATA_PIN BIT2 // data for as1116 #define LOAD_PIN BIT0 // load for as1116 #define CLOCK_PIN BIT4 // clock for as1116 #define MUTE_PIN BIT3 // Left button #define BR_PIN BITC // Right button #define SPEED_PIN BIT2 // Speed increase button #define GREEN_PIN BIT6 // Green LED on Launchpad (LED2) #define RED_PIN BIT9 // Red LED on Launchpad (LED1) #define BUZZER_PIN BIT7 // Piezo BUZZER = XOUT = P2.7 #define SPK_GND BIT4 // P2.4 used as speaker ground #define MAX_DELAY 2500 // Slowest speed #define MIN_DELAY 600 // Fastest speed #define STEP_DELAY 100 // Speed step #define TONE_CATCH 5 // Tone on catch #define TONE_MISS 10 // Tone on miss #define TONE_CHIRP 2 // Chirp tone #define CHIRP_DUR 10 // Chirp duration #define TONE_DUR 300 // Catch / miss tone duration unsigned char bitmap[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; volatile unsigned char t = 3, // catcher x position pot, // ADC10 value shifted right to divide refresh = 0, // flag to refresh matrix refreshing = 0, // set during refresh sound_enable = 0; // sound enable variable volatile unsigned int wins=10, // wins = number of catches clk = 0, // clock ticks, 1 tick = 1/10000 sec delay = MAX_DELAY, // step delay tone = 0, // tone frequency, 1 = 5000 Hz, 5 = 1000 Hz sound = 0; // sound duration in ticks void pixel_set(unsigned char x, unsigned char y) { bitmap[x] |= 1 << y; } void pixel_clear(unsigned char x, unsigned char y) { bitmap[x] &= ~ (1 << y); } // Shift out data, LSB first void shiftout(unsigned char data) { unsigned char n; for (n = 0; n < 8; n++) { if (data & BIT0) P1OUT |= DATA_PIN; //Set data else P1OUT &= ~DATA_PIN; P1OUT |= CLOCK_PIN; //Toggle clock pin P1OUT &= ~CLOCK_PIN; data >>= 1; } } // Send command to as1116 void as1116(unsigned char addr, unsigned char data) { P1OUT &= ~LOAD_PIN; shiftout(data); shiftout(addr); P1OUT |= LOAD_PIN; } // show bitmap on the matrix void display(void) { refreshing = 1; // Set flag so that we do not change bitmap during refresh unsigned char c; for (c = 0; c < 8; c++) as1116(c + 1, bitmap[c]); refreshing = 0; // Clear flag } void as1116_init(void) { unsigned char x,y; P1DIR |= (DATA_PIN | LOAD_PIN | CLOCK_PIN); P1OUT |= LOAD_PIN; // Turn on load pin (high = no activity) P1OUT &= ~CLOCK_PIN; as1116(0x0C, 0x00); // Turn off display as1116(0x0E, BIT1); // Reset all control registers _delay_cycles(100); as1116(0x09, 0x00); // Decode mode = Matrix as1116(0x0A, 0x0B); // Global brightness, med-high as1116(0x0E, 0x00); // Normal operation as1116(0x0B, 0x07); // Scan limit, all LEDs _delay_cycles(100); as1116(0x0C, 0x81); // Turn on (no shutdown) as1116(0x01, 0xff); // test row refreshing = 1; // Set flag so that we do not change bitmap during refresh for (y = 0; y < 8; y++) // Have fun with little light show and test { for (x = 1; x <= 0x80; x=x+0) { as1116(y + 1, x); _delay_cycles(10000); if (x!=0x80) x <<=1; else x++; } } refreshing = 0; // Clear flag display(); } void clock_init(void) { BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; } void timer_init(void) { TACCR0 = 100; // Generate interrupt 10000 times per second TACTL = TASSEL_2 + MC_1; // SMCLK, upmode TACCTL0 = CCIE; // Capture/Compare Interrupt Enable } void sound_init(void) { P2SEL = 0; // Disable XIN/XOUT P2DIR = BUZZER_PIN + SPK_GND; // XOUT pin = P2.7 and P2.4 are outputs P2OUT &= SPK_GND; // pull bit 4, P2.4 low to serve as ground for speaker } void intro_sound(void) { for (tone = 10; tone > 0; tone--) { sound = 500; while(sound) ; } } void button_init(void) { P1DIR &= ~(MUTE_PIN | BR_PIN); P1OUT |= MUTE_PIN | BR_PIN ; // Pull up P1REN |= MUTE_PIN | BR_PIN ; // Enable pull up resistors P1IE |= MUTE_PIN | BR_PIN; // Interrupt enable P1IES |= MUTE_PIN | BR_PIN; // Interrupt Edge Select high-to-low P2IES |= SPEED_PIN; P1IFG &= ~ (MUTE_PIN | BR_PIN); // Clear interrupt flag P2IFG &= ~ (SPEED_PIN); } void adc_init(void) { ADC10CTL1 = CONSEQ_2+INCH_5; // Repeat single channel and select channel 5 ADC10CTL0 = 0x0000 + ADC10SHT_2 + MSC + REFON + ADC10ON + ADC10IE; //Use Vcc and ground as reference, S+H=8, mult sample conversion,reference on, ADC10 on, interrupts on __enable_interrupt(); // Enable interrupts. LPM0; // Wait for delay. Low power mode off on exit __disable_interrupt(); ADC10DTC1 = 0x02; // 2 conversions ADC10AE0 |= 0x20; // P1.5 ADC option select } void main(void) { unsigned char n, p; // n = dot y, p = catcher x, WDTCTL = WDTPW + WDTHOLD; // Disable watchdog timer (WDT) as1116_init(); button_init(); timer_init(); sound_init(); adc_init(); sound_enable = 1; // Sound is on by default unless switched off by the button P1DIR |= RED_PIN | GREEN_PIN; P1OUT &= ~(RED_PIN | GREEN_PIN); pixel_set(t, 7); pixel_set(t+1, 7); _enable_interrupts(); intro_sound(); for (; { p = rand() % 8; // random drop x position for (n = 0; n < 7; n++) // drop { ADC10CTL0 &= ~ENC; while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit pixel_set(p, n); display(); refresh = 0; clk = 0; tone = TONE_CHIRP; sound = CHIRP_DUR; pot=~(ADC10MEM>>7) & 0x07; //pot value is inverse (otherwise paddle goes backwards) of ADC result divided into usable number if ((pot < t) && (t > 0) && !refreshing) //move up if pot value < current position of paddle and paddle isn't at top already { pixel_clear(t + 1, 7); pixel_set(--t, 7); refresh = 1; } if ((pot > t) && (t < 6) && !refreshing) //move down if value > current position { pixel_clear(t, 7); pixel_set(++t + 1, 7); refresh = 1; } while (clk < delay) { _low_power_mode_0(); if (refresh) { display(); refresh = 0; } } pixel_clear(p, n); } if ((p == t) || (p == t + 1)) // if caught { P1OUT |= GREEN_PIN; P1OUT &= ~RED_PIN; tone = TONE_CATCH; wins++; if ((wins > 14) && (delay >= MIN_DELAY)) // If you win more than 7 times, game speeds up { delay = delay - STEP_DELAY; wins = 7; } } else { P1OUT &= ~GREEN_PIN; P1OUT |= RED_PIN; tone = TONE_MISS; wins--; // Every miss counts against your wins if (wins <= 0) // If you miss more than 7 (default win number) than game ends { if(delay <= 600) bitmap[0]=0xFF; if(delay <= 700) bitmap[1]=0xFF; if(delay <= 800) bitmap[2]=0xFF; if(delay <= 1000) bitmap[3]=0xFF; if(delay <= 1400) bitmap[4]=0xFF; if(delay <= 1700) bitmap[5]=0xFF; if(delay <= 2100) bitmap[6]=0xFF; if(delay <= 2400) bitmap[7]=0xFF; display(); while(1); // Loop forever and end game } } sound = TONE_DUR; } } #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { if ((P1IFG & MUTE_PIN) && (t > 0) && !refreshing) // Sound off sound_enable = ~sound_enable & 0x01; // toggle sound enable P1IFG &= ~ (MUTE_PIN | BR_PIN); // clear interrupt flags for all buttons _low_power_mode_off_on_exit(); } #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A (void) { static unsigned int z; clk++; if (sound && sound_enable) { --sound; if ((z++ % tone) == 0) P2OUT ^= BUZZER_PIN; // vibrate buzzer } _low_power_mode_off_on_exit(); } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR) }
    Matrix Electronics Merit Badge Kit Instructions.zip
    MSP430LEDBooster.zip
    Launchpad_LEDMatrix_schematic.pdf
  22. Like
    gordon reacted to oPossum in Pronto IR code transmission   
    Pronto CIR codes have become a de facto standard for CIR code exchange. They where originally used by the Philips Pronto series of universal remotes, but are now supported by many universal remotes and PC CIR software. There is a database of codes at Remote Central.
     
    This MSP430 firmware will send most type 0 pronto codes - that is the most common type. It can run at 1 MHz, so it can be used with the G2231 and G2211 chips that came with the rev 1.4 and earlier Launchpad.
     
    The pronto codes have the timing in units of the IR carrier frequency. This characteristic allows the firmware to work with only one Timer A unit. It is used for both carrier generation with hardware PWM and for timing with an ISR.
     
     

    /* Copyright (C) 2012 Kevin Timmerman This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Pronto code format http://www.remotecentral.com/features/irdisp2.htm Pronto code database http://www.remotecentral.com/cgi-bin/codes/ */ #include static const unsigned pentax[] = { // - Pentax camera IR code in Pronto format // http://img811.imageshack.us/img811/6074/pentaxprotocol.jpg 0, // Modulated code 109, // Carrier period - 4,145,152 / 38 kHz = 109 8, // Number of one time pairs 0, // Number of repeat pairs 500, 115, // 13 ms on, 3 ms off 38, 39, // 1 ms on, 1 ms off 38, 39, // 1 ms on, 1 ms off 38, 39, // 1 ms on, 1 ms off 38, 39, // 1 ms on, 1 ms off 38, 39, // 1 ms on, 1 ms off 38, 39, // 1 ms on, 1 ms off 38, 39 // 1 ms on, 1 ms off }; // - Canon camera IR code in Pronto format // http://www.doc-diy.net/photo/rc-1_hacked/index.php static const unsigned canon_immed[] = { // Immediate shutter release 0, // Modulated code 127, // 32.768 kHz 16, // Number of one time pairs 0, // Number of repeat pairs 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240, // 488 us on, 7332 us off 16, 240 // 488 us on, 7332 us off }; // static const unsigned canon_delay[] = { // Delayed shutter release 0, // Modulated code 127, // 32.768 kHz 16, // Number of one time pairs 0, // Number of repeat pairs 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176, // 488 us on, 5372 us off 16, 176 // 488 us on, 5372 us off }; static volatile int cycle_count; // IR carrier cycle count #pragma vector = TIMERA0_VECTOR // Timer A Capture/Compare 0 interrupt __interrupt void timera0_isr(void) // This ISR must be very simple because there may // be as few as 16 cycles available for it to complete { // if(--cycle_count == 0) // Decrement cycle count __bic_SR_register_on_exit(LPM0_bits); // Wakeup main code when count reaches 0 } // inline void send_chunk(const unsigned *code, unsigned len) { do { // Do all pairs __bis_SR_register(LPM0_bits + GIE); // Sleep until cycle count is zero TACCTL1 = OUTMOD_7; // Turn on IR cycle_count += *code++; // Set on cycle count __bis_SR_register(LPM0_bits + GIE); // Sleep until cycle count is zero TACCTL1 = OUTMOD_0; // Turn off IR cycle_count += *code++; // Set off cycle count } while(--len); // Decrement pair count, do next pair if not zero } void send_code(const unsigned *code, unsigned repeat) { if(*code++) return; // First word must be 0 (0 = Modulated code) // Pronto carrier freq == 4,145,152 / N // ( 4,145,152 == 32,768 * 506 / 4 ) // 1,000,000 / 4,145,152 == 0.241246 // 0.241246 << 16 == 15,810 const unsigned period = (((unsigned long)*code++ * 15810) + 7905) >> 16; // For 1 MHz MPU clock //const unsigned period = *code++; // For 4.145152 MHz MPU clock const unsigned one_len = *code++; // One time length const unsigned repeat_len = *code++; // Repeat length // TACCR0 = period - 1 ; // Set timer period TACCR1 = TACCR0 >> 1; // Set timer on duration - 50% duty cycle cycle_count = 16; // Setup some initial IR off lead in TACCTL0 = CCIE; // Enable Timer A CC0 interrupt // if(one_len) send_chunk(code, one_len); // Send one time chunk // if(repeat_len) { // Send repeat chunk code += (one_len << 1); // Move pointer to repeat chunk while(repeat) { // Do it repeat times send_chunk(code, repeat_len); // Send it --repeat; // Decrement repeat count } // } // // __bis_SR_register(LPM0_bits + GIE); // Sleep until cycle count is zero TACCTL0 = 0; // Turn off Timer A CC0 interrupt } void main(void) { WDTCTL = WDTPW | WDTHOLD; // Disable watchdog reset DCOCTL = 0; // Run at 1 MHz BCSCTL1 = CALBC1_1MHZ; // Note: The ideal clock freq for this code DCOCTL = CALDCO_1MHZ; // is 4.145152 MHz - calibrate the DCO for // that freq for optimal timing - the second // word of the pronto code can then be used // without scaling P1OUT = 0; // P1DIR = BIT6; // Enable PWM output on P1.6 P1SEL = BIT6; // // TACTL = TASSEL_2 | MC_1; // Timer A config: SMCLK, count up TACCTL1 = OUTMOD_0; // Make sure IR is off // _enable_interrupts(); // Enable global interrupts // send_code(pentax, 1); // Send Pentax IR code // send_code(canon_immed, 1); // // send_code(canon_delay, 1); // }
  23. Like
    gordon reacted to RobG in TI MSP430 Family Eagle library   
    Updated library with 2 fixes.
     
    Two 14 pin devices (TSSOP package only,) had pin 8 assigned to pin 10 and vice versa.
    Affected devices: MSP430G2X31-14PW14 and MSP430G2X21-14PW14
  24. Like
    gordon got a reaction from Nytblade in Launchpad v1.5 + M430G2553 serial communication on Linux   
    It works, for certain defintions of "works". The TUSB is very picky and tends to trip over every time a butterfly in Argentina (Denmark, if you are in Argentina) flaps its wings, also the driver seems to leave a lot to be desired. Your best bet is not using it, and simply connecting the RX/TX pins of the LP target side to some proper USB<->UART bridge (like FTDI or whatnot).
  25. Like
    gordon got a reaction from bluehash in Fan controller   
    Not mine but our PhirePhly's, bumped into it over at DP: intelligent fan controller. The video has a nice smooth intro to PID controls for those not yet in the know .
×
×
  • Create New...