none 7 Posted December 4, 2011 Share Posted December 4, 2011 Could someone point me to a capture and compare code example for Launchpad (G2211)? I would like a quickstart for a model aicraft nav light controller.. Quote Link to post Share on other sites
bluehash 1,581 Posted December 4, 2011 Share Posted December 4, 2011 I'm not sure anyone has done it yet. But it looks like a nice project idea. This will have to be done in software. R/C PPMs have a minimum of four channels. Quote Link to post Share on other sites
none 7 Posted December 4, 2011 Author Share Posted December 4, 2011 MSP430 is not so nice for this application because of its voltage level, my RC has 5 V.. But: I have plenty of G2231 that are well-suited for the task. I will add a few FETs for level conversion and as power switches for the lights.. If you know of any code snippet that uses the timer in capture mode, please let me know.. PS: I was going for a single-channel decoder.. Quote Link to post Share on other sites
none 7 Posted December 4, 2011 Author Share Posted December 4, 2011 .. and I've previously asked for capture code: viewtopic.php?f=8&t=1333&p=8815&hilit=capture#p8815 Quote Link to post Share on other sites
none 7 Posted December 4, 2011 Author Share Posted December 4, 2011 And linked in this thread is viewtopic.php?p=991#p1015 which is a PPM decoder.. Quote Link to post Share on other sites
rockets4kids 204 Posted December 5, 2011 Share Posted December 5, 2011 MSP430 is not so nice for this application because of its voltage level, my RC has 5 V.. A simple voltage divider will get you from 5V down to 3V. Quote Link to post Share on other sites
cubeberg 540 Posted December 5, 2011 Share Posted December 5, 2011 MSP430 is not so nice for this application because of its voltage level, my RC has 5 V.. A simple voltage divider will get you from 5V down to 3V. I'll second that - I'm successfully reading input from a 5v peripheral - see the thread here. Quote Link to post Share on other sites
simpleavr 399 Posted December 7, 2011 Share Posted December 7, 2011 .. and I've previously asked for capture code: viewtopic.php?f=8&t=1333&p=8815&hilit=capture#p8815 the following is an extract from my ezprobe project http://www.43oh.com/forum/viewtopic.php?p=2160#p2160 the project demonstrates timer capture and timer compare, it can capture / count pulses and generate pwm signals. i used p1.6 (on a f2012, not available on a g2211) as input due to h/w layout constraint. to determine which pin u can use for timer capture, u need to read the datasheet for the device itself. u should look for those pins w/ CCI0A or CCI1A function (cee-cee-eye). on g2211/g2231 they are p1.1 and p2.2. basically u need to . setup capture pin via P1DIR and P1SEL . turn on capture and specify trigger edge via CCTL0 or CCTL1 . setup your interrupt or check CCIFG captured flag in CCTLx register, and optionally do your count if u are into analyzing your pwm pulse width / duty cycle and such, u might need to setup to capture BOTH edges and then count the different of high-low and low-high, they are explained in the datasheet slau144? //______________________________________________________________________ void sample(void) { P1DIR &= ~P_PROBE; // probe pin as input P1SEL &= ~P_PROBE; // turn off alternate function on pin ADC10AE0 |= P_PROBE; // probe pin in adc ADC10CTL0 |= ENC + ADC10SC; // enable, start adc conversion __bis_SR_register(CPUOFF | GIE); // enter lpm0 sleep for adc read ADC10AE0 &= ~P_PROBE; // adc done, turn off probe pin as adc //______ setup timer TACTL = TASSEL_2|ID_1|SCS|MC_2|TACLR; // continous mode uint8_t adc = ADC10MEM>>2; // we only need 8 bit if ((adc) < 0x30 || (adc) >= 0xd0) { // that's what we consider non-floating P1SEL |= P_PROBE; // turn probe pin as timer capture pin CCTL1 = CAP | CCIS_1 | CM_2; // capture falling edges uint16_t trips = 0; // timer will overflow in // 8mhz = 8,000,000 / 0x10000 = 1/122 sec (/2 clk = 1/61) // 12mhz = 12,000,000 / 0x10000 = 1/183 sec (/2 clk = 1/91) while (!(TACTL & TAIFG)) { if (CCTL1 & CCIFG) { // tripped CCTL1 &= ~CCIFG; trips++; }//if }//while CCTL1 = 0; P1SEL &= ~P_PROBE; //trips >>= 1; // divide by 2 as we counted both edges if (trips > 640) { trips /= 91; trips *= 100; }//if else { trips *= 100; trips /= 91; // now trips in 100ms units }//else Quote Link to post Share on other sites
none 7 Posted December 8, 2011 Author Share Posted December 8, 2011 Thanks for your help! Quote Link to post Share on other sites
none 7 Posted January 23, 2012 Author Share Posted January 23, 2012 Well I managed to get going with the examples you provided and now have my receiver's PPM signal train (all channels) resolved with Quote Link to post Share on other sites
none 7 Posted January 25, 2012 Author Share Posted January 25, 2012 As it turns out, the TC4017BP responsible to separate the PPM signal into pulses for each channel is reset every frame (about 20 ms), so the modified PPM needs to be synchronous to the original signal (just one frame later). Although I have tried to keep calculations in pin- and timer interrupts to a minimum (by setting flags and crunching numbers in the main loop instead), they take long enough to cause problems when overlapping, i.e. an edge of the incoming signal concurs with an edge of the generated signal, causing jitter. Is there any way to prevent this, without moving the output after the input frame (into the sync gap, either by skipping an input frame or taking over the TC4017BP's reset input or using a different ouput scheme altogether)? Quote Link to post Share on other sites
none 7 Posted January 26, 2012 Author Share Posted January 26, 2012 I failed to grasp that TimerA has two CCUs, which allows for independent PPM capture and generation. The only important part is to read/compute/write the new CCR values in time. The other thing is that the demultiplexer reset needs to be controlled by the microcontroller, too, in order to be able to output channel signals even if there is no valid input signal (failsafe), as the reset pulse (on my receiver) depends on the reception as well. It is easily generated along with the ouput frame. 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.