Jump to content

GeekDoc

Members
  • Content Count

    1,391
  • Joined

  • Last visited

  • Days Won

    13

Reputation Activity

  1. Like
    GeekDoc reacted to oPossum in 15 channel PWM with async serial control   
    This code really isn't suitable for use with RC servos. They typically want a ~20 ms frame rate to work properly, and are usually addressed sequentially rather than concurrently.
     
    See this thread for some more appropriate code.
  2. Like
    GeekDoc reacted to oPossum in 15 channel PWM with async serial control   
    This is derived from 16 channel PWM with a single timer.
     
    The ISR has be extended to handle PWM and async serial reception. The first timer capture/compare is used for timing the serial bits and the second is used for PWM.
     
    This is the ISR...

    __interrupt void Timer0_A1(void) { static unsigned bit_mask = 0; // Serial rx data bitmask static unsigned rx_data; // Serial rx data // const unsigned x = TAIV; // Clear interrupt flag, get vector // if(x == 4) { // --- CCR2 - PWM P1OUT &= ~pa->port_off; // Port pins off P2OUT &= ~pa->port_off >> 8; // P1OUT |= pa->port_on; // Port pins on P2OUT |= pa->port_on >> 8; // pa = pa->next; // Next node in list TACCR2 = pa->time; // Update timer compare time // } else if(x == 2) { // --- CCR1 - Serial rx if(TACCTL1 & CAP) { // Start bit (capture mode) rx_data = 0; // Clear rx data bit_mask = 1; // Begin with bit 0 TACCTL1 &= ~CAP; // Switch from capture to compare mode TACCR1 += 2500; // Set timer for middle of first data bit } else { // Data/stop (compare mode) if(bit_mask & 0x0100) { // Stop bit? *head++ = rx_data; // Add rx data to ring buffer if(head >= &rx_buf[sizeof(rx_buf)/sizeof(rx_buf[0])]) head = rx_buf; TACCTL1 |= CAP; // Switch from compare to capture mode } else { // Data bit if(TACCTL1 & SCCI) rx_data |= bit_mask; // Update rx data bit_mask <<= 1; // Next data bit TACCR1 += 1667; // Set timer for middle of next bit } } } }
     
    The PWM code is unchanged, but now is only executed when the interrupt vector indicates capture/compare 2 match.
    The serial code begins in capture mode. When a falling edge is detected the mode is changed to compare to sample in the middle of each data bit and the stop bit. A ring buffer is used to prevent loss of received data.
     
    Two test cases are provided. The first allows the brightness of the Lauchpads LED to be set using 0 to 9 and a to j.
    The second test case implements a simple serial protocol to set the PWM value of all 15 outputs. The packet format is...
    0x55 0xAA PWM0 PWM1 ...... PWM13 PWM14 Checksum
    Addressing could easily be added to allow multiple MSP430 on the same serial line.
     
    Since this code uses only a single TimerA module, it can run on any MSP430 with a TimerA.
     

    #include "msp430g2553.h" #include "string.h" typedef struct { // PWM ISR linked list node struct unsigned time; // Time for on/off action to occur unsigned port_off; // Port pins to turn off unsigned port_on; // Port pins to turn on void *next; // Next node in linked list } TPWM; // TPWM pw[16], *pi; // Array and inactive list head volatile TPWM *pa; // Active node unsigned char rx_buf[32]; unsigned char *head, *tail; void pwm_set(const unsigned pin, const unsigned time) { const unsigned mask = 1 << pin; // const unsigned tm = time & 0xFF00; // Limit closeness of entries TPWM *b, *p, *n; // // // -- Try to find existing active node for this pin for(b = &pw[0], p = b->next; p != &pw[0]; b = p, p = b->next) { if(p->port_off & mask) { // Found it if(p->time == tm) return; // - Time is the same, nothing to do, return... while(pa != p); // Wait for this node to be active while(pa == p); // Wait for this node to become inactive // Safe to remove now if(p->port_off == mask) { // - Node is only used for this pin, remove it b->next = p->next; // Remove link p->next = pi; // Add to inactive list pi = p; // } else { // - Node is used for multiple pins p->port_off &= ~mask; // Remove this pin from the node } // break; // Found the pin, so stop searching } // } // // - Update first node in list if(tm == 0) { // If time is 0, turn off and return pw[0].port_on &= ~mask; // pw[0].port_off |= mask; // return; // } else { // If time is non-zero, turn on pw[0].port_on |= mask; // pw[0].port_off &= ~mask; // if(time == 0xFFFF) return; // If max, no need to turn off, so return } // // // Find where the new turn off node will go for(b = &pw[0], p = b->next; p != &pw[0]; b = p, p = b->next) if(p->time >= tm) break; // Stop when an entry of >= time is found // if(p->time == tm) { // If same time, use existing node p->port_off |= mask; // Add this pin return; // All done... } // // n = pi; // Get a node from the inactive list pi = n->next; // // n->port_off = mask; // Setup new node n->port_on = 0; // n->time = tm; // // n->next = p; // Insert node in to active list b->next = n; // } void pwm_init(void) { unsigned n; memset(pw, 0, sizeof(pw)); // Clear entire array pa = &pw[0]; // Active list always begins with first array element pa->next = &pw[0]; // Begin with only 1 node in list pi = &pw[1]; // First inactive node is second array element for(n = 1; n < sizeof(pw)/sizeof(TPWM) - 1; ++n) // Link the inactive nodes pw[n].next = &pw[n + 1]; // // TACTL = TASSEL_2 + MC_2 + ID_0; // Setup timer, continuous mode, SMCLK/1 TACCTL2 = CCIE; // Enable timer interrupt _EINT(); // Enable interrupts } #pragma vector = TIMER0_A1_VECTOR __interrupt void Timer0_A1(void) { static unsigned bit_mask = 0; // Serial rx data bitmask static unsigned rx_data; // Serial rx data // const unsigned x = TAIV; // Clear interrupt flag, get vector // if(x == 4) { // --- CCR2 - PWM P1OUT &= ~pa->port_off; // Port pins off P2OUT &= ~pa->port_off >> 8; // P1OUT |= pa->port_on; // Port pins on P2OUT |= pa->port_on >> 8; // pa = pa->next; // Next node in list TACCR2 = pa->time; // Update timer compare time // } else if(x == 2) { // --- CCR1 - Serial rx if(TACCTL1 & CAP) { // Start bit (capture mode) rx_data = 0; // Clear rx data bit_mask = 1; // Begin with bit 0 TACCTL1 &= ~CAP; // Switch from capture to compare mode TACCR1 += 2500; // Set timer for middle of first data bit } else { // Data/stop (compare mode) if(bit_mask & 0x0100) { // Stop bit? *head++ = rx_data; // Add rx data to ring buffer if(head >= &rx_buf[sizeof(rx_buf)/sizeof(rx_buf[0])]) head = rx_buf; TACCTL1 |= CAP; // Switch from compare to capture mode } else { // Data bit if(TACCTL1 & SCCI) rx_data |= bit_mask; // Update rx data bit_mask <<= 1; // Next data bit TACCR1 += 1667; // Set timer for middle of next bit } } } } unsigned char get_rx(void) { const unsigned char c = *tail++; if(tail >= &rx_buf[sizeof(rx_buf)/sizeof(rx_buf[0])]) tail = rx_buf; return c; } void protocol(void) { static unsigned state = 0; unsigned n; unsigned char pwm[15]; unsigned char checksum; unsigned char c; for(; { c = get_rx(); switch(state) { case 0: // First byte of packet must be 0x55 if(c == 0x55) ++state; break; case 1: // Second byte of packet must be 0xAA if(c == 0xAA) { n = 0; checksum = 0; ++state; } else { state = 0; } break; case 2: // Get 15 PWM bytes pwm[n++] = c; checksum += c; if(n >= 15) ++state; break; case 3: // Get checksum if(c == checksum) { // Update PWM if checksum is valid for(n = 0; n < 15; ++n) { pwm_set((n < 2) ? n : n + 1, (unsigned)pwm[n] << 8); } } state = 0; // Next packet break; } } } void main(void) { unsigned char c; WDTCTL = WDTPW | WDTHOLD; // Disable watchdog DCOCTL = 0; // Run at 16 MHz BCSCTL1 = CALBC1_16MHZ; // DCOCTL = CALDCO_16MHZ; // P1OUT = P2OUT = 0; // P1DIR = 0xFF ^ BIT2; // P1.2 is serial in, all other output P1SEL = BIT2; // Enable capture interrupt P2SEL = 0; // Allow P2.6 and P2.7 to be used as GPIO P2DIR = 0xFF; // Enable all P2 pins as output pwm_init(); // Initialize software PWM TACCTL1 = CM_2 | CAP | CCIE; // Enable capture on falling edge head = tail = rx_buf; // Init rx ring buffer pointers #if 0 protocol(); // Serial control of all 15 PWM outputs #else for(; { // Control LP LEDs with 0-9 and a-j if(head != tail) { c = get_rx(); if(c >= '0' && c <= '9') { pwm_set(0, (c - '0') * 7000); } else if(c >= 'a' && c <= 'j') { pwm_set(6, (c - 'a') * 7000); } } } #endif }
  3. Like
    GeekDoc reacted to RobG in [Help] 4x4 Matrix Keypad   
    Take a look at this thread.
  4. Like
    GeekDoc reacted to jpnorair in Budget Workbench Necessites   
    That might be a worthy hack for one of these (or anything much like it).
    KRUPS FBC4 Convection Toaster Oven, 1600-watt, Stainless Steel
     
    I bring up this model because I've had one for years, it is great, and I know that it has digital control.  I might try hacking it over the weekend, now that I brought it up.
  5. Like
    GeekDoc reacted to cubeberg in Seeed PCB assembly   
    @@bluehash and I have used the component sourcing - good results so far.  They even caught that my parameters on the caps were too wide (voltage range) and didn't match the footprint on the PCB.  We used them for the IV-18 clock kits (minus the tube which can only be sourced from Russia). 
  6. Like
    GeekDoc got a reaction from abecedarian in Budget Workbench Necessites   
    BRILLIANT!  We need a "Cheese Profile" for the optimal quesadillas and nachos!
  7. Like
    GeekDoc got a reaction from oPossum in Budget Workbench Necessites   
    BRILLIANT!  We need a "Cheese Profile" for the optimal quesadillas and nachos!
  8. Like
    GeekDoc reacted to lastaid in Annoy A Tron 2.0   
    Hey ,
     
    Ok, i am currently building 2 kinds of annoyatrons, one being very small an having a high annoy frequency ( delay between beeps) and the other one a huge annoyatron that rarely beebs but is insanly loud and has oversized batteries because i was afraid that a coincell might not provide enough juice and the mcu would brownout.
     
    the big version can be attached to anything metal thanks to a harddrive donored magnet. the small one will fit in a matchbox so it can be hidden in plain sight.
     
    http://youtu.be/90sXqgu-0XA here is a video of the breadboard circuit in action, the beep is somewhere around 0:53 and might not be audible on some speakers.
     
    still wondering how much power this circuit really draws.
     
    -lastaid



  9. Like
    GeekDoc reacted to spirilis in TI Back to School Promotion   
    As you go through the checkout process, pay attention to the right side of the screen--like 1 or 2 screens in you'll see "Enter coupon code:" on the right side, put SA_BTS in there as the code.
  10. Like
    GeekDoc reacted to spirilis in Seeed PCB assembly   
    Elecrow does this but they have a Component Sourcing service you can use to source anything first... I've not tried them though.
     
    Sent from my Galaxy Note II with Tapatalk 4
     
     
  11. Like
    GeekDoc reacted to PunKidd in Reflow Oven Booster Pack   
    I tried to use the "image" button and link to full size files in my dropbox, but I guess that didn't work.
    I've reduced the files sizes and changed them to attachments.
    - Jared. 
  12. Like
    GeekDoc reacted to Automate in TI Back to School Promotion   
    It's available now http://e2e.ti.com/blogs_/b/msp430blog/archive/2013/08/25/back-to-school-sale-part-2-sa430.aspx
     
    Coupon code SA_BTS
  13. Like
    GeekDoc reacted to cubeberg in SXSW Interactive - Vote for our panel session.   
    Voted!
  14. Like
    GeekDoc got a reaction from bluehash in SXSW Interactive - Vote for our panel session.   
    VERY cool!  Hope you get to do it, B#!
     
    (I already voted for this, of course.)
  15. Like
    GeekDoc reacted to f4dtr in Energia Cheat Sheet   
    Hi,
     
    I created a cheat-sheet for Launchpad, based on  http://www.cheat-sheets.org/#Arduino'>
  16. Like
    GeekDoc reacted to Rickta59 in WS2811 timing   
    In case anyone is interested, here is the gnu arm asm code I ended up with.
     
    Note:
    '@' characters begin comments in cortex-m0+ gnu asm
    Most cortex-m0+ instructions are 1 cycle. Branches can be 1 or 2 (2 if branch taken)
    ldr instructions from memory only take 2 thanks to the 2 stage pipeline in the m0+
     
    The numbers in the comments reflect the number of cycles during the time critical
    portion of the code
     
    -rick
     
    url: gist.github.com/RickKimball/6122630

  17. Like
    GeekDoc reacted to jpnorair in [Reasonably] New MSP430 Parts   
    I was poking around on ti.com today, and I was pleasantly surprised as I noted two product families that are now public.  The datasheet and user-guide dates are not super-new, but there has been little fanfare and somehow I missed it.  Maybe the reason is because I've spent the last 6 months working mainly on Cortex-M.  But anyway...
     
    1. RF430F5978
    I have been working with this for a long time, in private (i.e. there are libraries and board support in OpenTag).  It's really cool, because it combines a CC430F5137 with a 134kHz passive RF IC.  One cool app you can do with it is wireless charging, but really there are all kinds of cool apps that combine passive RF for localization with long-range active RF for data backhaul.
     
    2. RF430FR15xH
    This is an NFC chip with a small FRAM MSP430 built right in. I have not used it, but I love NFC so it can't be bad.  
  18. Like
    GeekDoc reacted to Tribes in Simple ADC LED control program MSP430G2553   
    If you really want PWM on P1.0 I would rather generate the signal using interrupts generated by TimerA than a loop with delays. This is a much more elegant solution and allows you to use the low power modes of the MSP430. I am pretty sure you can find examples for software PWM on the forum
  19. Like
    GeekDoc reacted to abecedarian in Wireless digital pricetags   
    Pretty cool the way it works, watching the tags blink when they acknowledge the update.
     
    I also imagine if the display were e-paper, the power consumption would be quite low.
  20. Like
    GeekDoc reacted to JWoodrell in Glue to use for securing prototyping solder jobs   
    Slow cure or thick CA glue works great and dries clear usually depending on conditions. Accelerator is a must usually in a dark brown little spray bottle.
     
    http://www.hobbyking.com/hobbyking/store/RC_PRODUCT_SEARCH.asp?strSearch=Ca+glue
    I have used these to secure wires in place after soldering
    Every hobby place sells this brand and puts their name sticker on it, but you can recognize it by the bottles, and color of the label/lid
     
    Blue label "insta-cure thin" is standard superglue, and flows like alcohol, sets in seconds. Not very useful
    Purple "insta-cure plus" is a medium syrup thickness that fills gaps more than flows into them sets in 30 seconds to a minute, usefull to use accelerator
    Magenta "maxi-cure" is a THICK gel consistency, stays put sets over several minutes. Accelerator is a must get this if you can
     
    The specialty ones, cyan "flexible", and pink "clear rubber" i havent used personally
     
    "Foam safe" just means it doesnt outgas like normal CA so less white powder crystals and less smell, but its bond is weaker than normal CA
     
    Always buy these, they are high grade hobby glues, cheap knock offs just annoy you and arent consistent
    You can find them at any store or online shop that sells RC hobby stuff
     
    Buy the 2oz bottles, they last forever and dont dry out if you store them with the lid on tight
    Once you get used to using CA like this you will hate it in the stupid little 0.1oz metal tubes you get at the store
  21. Like
    GeekDoc reacted to dubnet in Color LCD Booster Pack   
    @Kabron  First of all, welcome to the forum.,
     
    Based on your posts thus far, it appears that you may not fully understand what this board/community is all about. It is a forum for sharing experiences and experimetation around the TI MSP430 series MCUs. Although there is a store, the understanding is that it is there to facilitate that experimentation by providing "building blocks" which save others in the community time and effort.  In fact, the store also helps Bluehash to offset the costs associated with maintaining this board.  As @@RobG stated in his post, for most this is a hobby and not a full time commercial endevour so please do not expect commercial level support. However, most in the commmunity are happy to help with questions from other community members, regardless of their experience level. 
     
    RobG, despite his limited time, is a prolific contributor to this community and has helped many a member (including myself).  If you note the reputation rating under the member's name, it represents the number of times they have been thanked by other users of the community.
     
    Hopefully you are not offended in any way by my post.  My intent was to clarify the intent of the community and to facilitate realistic expectations.
     
    All the best and I sincerely hope that you can get as much enjoyment out of this community that I do.
  22. Like
    GeekDoc reacted to RobG in Color LCD Booster Pack   
    http://forum.43oh.com/topic/1758-color-lcd-booster-pack/page-4#entry21448
    http://forum.43oh.com/topic/1758-color-lcd-booster-pack/page-4#entry25893
     
    To answer your first question, I am not a big company, I am a single person entity. All I do for this community is in my spare time between my job and my family time, and that's not a whole lot. I have to do research, design the board, send it to fab, source parts, assemble, ship, etc. My assumption is that people using my products are experimenters and know a little bit, want to learn, or will ask questions if stuck. Some boards are popular, some not, some are work in progress and change fairly quickly. I am not posting details until there's interest, otherwise time is waisted. Many times details and schematics get buried between dozens of posts and you just have to search for them.
  23. Like
    GeekDoc reacted to RobG in Attic Treasures   
    While cleaning my garage (yes, garage, but attic sounds so much better ,) I came across this long forgotten little treasure.
    As always, I have a hard time deciding if I should put this thing together or keep it as is.
    After all, this thing is more than 33 years old and in it's original box (see the invoice?)
    Maybe I will give it to my kids when they get bigger, or my grand kids :grin:.
     

  24. Like
    GeekDoc reacted to hvontres in Share pics of your workspace setup   
    I realize this is kind of an old thread, but I finally got around to re-organizing my space in the garage.
     
    Here is the Before Picture, kind of my Bob Pease Memorial Shrine on a desk:
     

     
    Here is the new improved Setup:
     

     
    Note, I have not moved over all of the parts and tools from the old pile yet. I am hoping to keep most of my stuff in the big black cabinet. Most of the stuff here is surplus stuff from work. We are moving to a smaller building, so I scored the ESD safe bench, the cabinet, the two standard monitors, the chair and the magnifier. The scope I got off of Ebay for ~$400 bucks and the supply is an old AT (not ATX ) supply in a custom wood box. The 15" Monitor on the left is for the scope and was originaly a custom monitor in a STEEL box for one of our machines. we decided to go with regular displays instead, so it wound up in the boneyard until we cleaned that out about a year ago Someday it might end up as a display on a mill or somthing more industrial, but I don't know yet. The Computer and the SCSI enclosure were leftovers from IT, as were the tape drive and all of the Hard Drives inside. I am in the middle of upgrading the disk layout since I got a hold of a couple more 18 and 34 GB SCSI drives from the IT pile. The Computer is an old HP workstation with dual PIII 600's inside... I know it's kind of underpowered, but it has two isa slots for my GPIB card and the interface to the universal programmer. And the price was right. I still need to move over my microscope, but I need to figure out exactly where to mount it.
  25. Like
    GeekDoc reacted to JWoodrell in any rechargeable batteries Lithium Ion for robot   
    You can easily build charging into your own pcb. I use the MCP73831 chip. Handles all the nitty gritty of charging for you. It can handle up to 500 ma charging current internally, although you could use it to control a larger external circuit for larger charging currents
     
    https://www.sparkfun.com/datasheets/Prototyping/Batteries/MCP73831T.pdf
×
×
  • Create New...