Jump to content
43oh

Action Packed Booster Pack


Recommended Posts

  • Replies 39
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

I immediately think of mdfly.com.   viewtopic.php?f=30&t=203&start=10

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 p

Ok, so I'm still leaning towards using a MSP430G2553 on this booster pack. It will have 2 push button rotary encoders, 2 push buttons, 1 5110 lcd and 1 row of 8 leds. RobG got me a little sidetracked

Posted Images

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;
   }
}

Link to post
Share on other sites

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]

Link to post
Share on other sites

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.

Link to post
Share on other sites
  • 2 weeks later...

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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

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]

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...