RobG 1,892 Posted October 9, 2011 Share Posted October 9, 2011 Do you have a source of cheap 0.05s? Quote Link to post Share on other sites
RobG 1,892 Posted October 10, 2011 Share Posted October 10, 2011 Here's what I had in mind for debouncer's firmware (untested,) 8 ins and 8 outs, no IRQ (IRQ can be easily implemented by toggling one of the available ports inside timer's ISR, but would require 28 pin chip.) What do you think? #include "msp430g2553.h" char counter[8] = {25,25,25,25,25,25,25,25}; main() { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_1MHZ; // 1MHz clock DCOCTL = CALDCO_1MHZ; P1OUT = 0; // P1 all inputs P1DIR = 0; P2SEL &= ~(BIT6|BIT7); // P2.6 and P2.7 will be used as I/O P2OUT = 0; P2DIR = 0xFF; // P2 all outputs P2OUT = P1IN; // set outs to match ins P1IES = P1IN; // set edges according to what inputs are P1IFG = 0; // clear interrupt flags P1IE = 0xFF; // enable interrupts on all P1 ins TACTL = TASSEL_2 + MC_1 + ID_3; // setup timer, SMCLK/8, upmode CCR0 = 250; // 2ms CCTL0 = CCIE; // enable timer __bis_SR_register(GIE + LPM0_bits); // enable interrupts and sleep } // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { unsigned char c = 0; unsigned char bit = 1; while( c < 8 ) { // check which ins triggered interrupt if(P1IFG & bit) { P1IFG &= ~bit; // clear flag (P1IN & bit) ? (P1IES |= bit) : (P1IES &= ~bit); // set trigger edge according to what input is counter[c] = 25; // set timer, 50ms delay } c++; bit <<= 1; } } // increment count up to 64 #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0 (void) { unsigned char c = 0; unsigned char bit = 1; while( c < 8 ) { // go through counters if(counter[c] == 0){ // when counter reaches 0, 50ms... (P1IN & bit) ? (P2OUT |= bit) : (P2OUT &= ~bit); // ...copy input to output counter[c]--; // decrement input's counter to -1 to prevent further decrements } else if(counter[c] > 0) { counter[c]--; // decrement input's counter } c++; bit <<= 1; } } gwdeveloper 1 Quote Link to post Share on other sites
gwdeveloper 275 Posted October 10, 2011 Author Share Posted October 10, 2011 Wow! Nice work. That code is way cleaner and more concise than anything I was coming up with. I had multiple IF statements in the P1 ISR. Yours does the checks in a much better fasion. I also distracted myself a bit creating it as an I2C slave. Had it toggling a pin to generate an interrupt on the master. It does make more sense to use all 8 ins and all 8 outs as opposed to 8 inputs on an i2c slave. Updated Schematic: [attachment=0]senorboosterpack.png[/attachment] Quote Link to post Share on other sites
RobG 1,892 Posted October 10, 2011 Share Posted October 10, 2011 There are still improvements to be made, but this should work pretty well. The only problem with this and MAX6818's design is that it will kill pulses shorter than debounce duration. For example 20ms pulse will not be visible on the output. So, if you rotate your encoder fast enough, you may loose a lot of pulses and get inaccurate readings. Quote Link to post Share on other sites
zeke 693 Posted October 10, 2011 Share Posted October 10, 2011 Do you have a source of cheap 0.05s? I immediately think of mdfly.com. viewtopic.php?f=30&t=203&start=10 RobG and GeekDoc 2 Quote Link to post Share on other sites
RobG 1,892 Posted October 11, 2011 Share Posted October 11, 2011 Found one issue, fixed and updated code above. Quote Link to post Share on other sites
SugarAddict 227 Posted October 12, 2011 Share Posted October 12, 2011 And thanks to SugarAddict for the TI Launchpad template, I just don't read the forums as often as I should... g0rdon made it, I just fixed some alignment issues. I like this booster idea though... Quote Link to post Share on other sites
kenemon 29 Posted October 12, 2011 Share Posted October 12, 2011 nice that someone finally improvised a little with the cap touch Rob! Pretty cool. Will designs like that work with basic fabricated PCB's? Quote Link to post Share on other sites
RobG 1,892 Posted October 13, 2011 Share Posted October 13, 2011 I don't think I will have the time to finish it, but maybe someone will. keypad-touch.sch keypad-touch.brd Quote Link to post Share on other sites
gwdeveloper 275 Posted October 22, 2011 Author Share Posted October 22, 2011 I updated the 1st post with final schematic and preliminary board layout. Any changes and source code will be edited into the 1st post for clarity. @RobG, thanks for your G2153 debouncing code. It will work well with this system and make the completed Booster Pack much, much cheaper. Quote Link to post Share on other sites
bluehash 1,581 Posted October 22, 2011 Share Posted October 22, 2011 GW, it would mean more if the Booster Pack was named after what it does. Action Packed sounds a little too general. Just a suggestion. Quote Link to post Share on other sites
RobG 1,892 Posted October 22, 2011 Share Posted October 22, 2011 I have couple suggestions re LCD and LEDs, but I am traveling right now and have no access to Eagle. Will post my suggestions tonight. Quote Link to post Share on other sites
gwdeveloper 275 Posted October 22, 2011 Author Share Posted October 22, 2011 Any suggestions would be great! I've done a bit more research on the 5110. I can drop the extra 595 shift register and just use 3 LP pins to control it directly. Just going to tie SCE to ground and add a button for Reset. That should cleanup the board a good bit. Definitely let me know what you think. I'm trying to cram a bunch in a small space but keep the rotaries and buttons somewhat symmetrical. Quote Link to post Share on other sites
RobG 1,892 Posted October 22, 2011 Share Posted October 22, 2011 I wouldn't tie SCE to GND. I think you should tie data and clock pins of LED's 595 and LCD's, and connect latch, SCE, and C/D to it's own LP pins. You could also add some little logic gates to control 595. Next, I would add weak pull downs so when jumpers are not installed, inputs are not floating. Finally, I would design jumpers so all three could be used, USI, USCIA, and USCIB. USCIA is not that important, but the other two have their data in and out flipped so you have to keep that in mind. Instead of parallel jumpers, do crossed ones so you can accommodate both, USI and USCI. Quote Link to post Share on other sites
rockets4kids 204 Posted October 22, 2011 Share Posted October 22, 2011 I just spied this. CapTouch is one of the few remaining G2-series peripherals that I have yet to play with. Do you have (or can you recommend) a guide that provides the background behind how to design something like this? Since you want to have more than a simple debouncer and use serial comm, why not go a step further and add a keypad [attachment=0]keypad-booster.png[/attachment] Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.