大秦正声 发表于 2014-11-25 17:47

元器件不好购买啊购买了个小空心杯电机没有带螺旋桨

大秦正声 发表于 2014-11-25 17:47

能转了

大秦正声 发表于 2014-11-26 10:49

小空心杯可以用普通的三极管驱动!

大秦正声 发表于 2014-11-26 10:50

pkjapan 发表于 2014-11-27 17:36

坐等更新啊,android对BLE支持不怎么好,你使用ios来控制么?

大秦正声 发表于 2014-11-27 20:52

pkjapan 发表于 2014-11-27 17:36
坐等更新啊,android对BLE支持不怎么好,你使用ios来控制么?

多谢关注!安卓建议
用4.3版本以上的

大秦正声 发表于 2014-11-28 10:13

cc2540fkeyfob官方原理图

大秦正声 发表于 2014-11-29 12:36

pwm例程
/*******************************************************************************
Filename:   t4_pwm.c

Description:Generates a sine wave signal, by using Timer 4 to generate
                a PWM signal with varying duty cycle. The frequency f of the
                sine wave is
                              f = f_tts / (t4_div * 2 * t4_tcv * N)

                where f_tts is the Timer tick speed (can be adjusted in the
                CLKCON register), t4_div is the Timer 4 prescaler divider value
                (can be adjusted in the T4CTL register), t4_tcv is the Timer 4
                terminal count value (can be adjusted in the T4CC0 register) and
                N is the number of samples per sine wave.
   
                The values for adjusting the PWM duty cycle are stored in a
                lookup table, and this value sets the compare value for
                Timer 4, which is running in up/down mode, setting output on
                compare-up and clearing output on compare-down. The compare
                value is changed when Timer 4 reaches 0x00 (and generates an
                interrupt).


                On the SmartRF05EB, Timer 4 channel 1 is connected to P1_0
                (GREEN LED1) for the CC2543EM and CC2545EM and to P1_1
                (RED LED2) for the CC2541EM. On the CC2544Dongle Timer 4
                channel 1 is connected to P0_2 (g0reen LED). I/O location
                alternative 1 is chosen.


                This example uses f_tts = 4 Mhz and t4_div = 128, to keep the
                pwm period above 120 Hz, to appear smooth to the eye with low
                duty cycles. We use N = 16, and t4_tcv = 244 is used to fine
                tune a 4 Hz sine wave.

*******************************************************************************/

/*******************************************************************************
* INCLUDES
*/
#include <hal_types.h>
// Include Name definitions of individual bits and bit-fields in the CC254x device registers.
#include <ioCC254x_bitdef.h>
// Include device specific file
#if (chip==2541)
#include "ioCC2541.h"
#elif (chip==2543)
#include "ioCC2543.h"
#elif (chip==2544)
#include "ioCC2544.h"
#elif (chip==2545)
#include "ioCC2545.h"
#else
#error "Chip not supported!"
#endif

/*******************************************************************************
* CONSTANTS
*/

// Number of sine samples.
#define NO_SAMPLES 16

/*******************************************************************************
* LOCAL VARIABLES
*/

/*******************************************************************************
* LOCAL FUNCTIONS
*/

/*******************************************************************************
* @fn      t4_isr
*
* @brief   Interrupt handler for Timer 4 overflow interrupts. Interrupts from
*          Timer 4 are level triggered, so the module interrupt flag is cleared
*          prior to the CPU interrupt flag. Timer 4 interrupt source is not
*          checked, since only overflow interrupts are enabled. On Timer 4
*          overflow interrupts, the PWM duty cycle is changed by altering the
*          compare value.
*
* @param   void
*
* @returnvoid
*
*******************************************************************************/
#pragma vector = T4_VECTOR
__interrupt void t4_isr(void)
{
    /* Local variables. The sine wave consists of 16 samples, so the PWM
   * lookup table pwmLut has 16 values. These are calculated from
   *
   *      121 * cos(k * 2pi/N) + T4CC0/2, k = 0, 1, ..., 15
   *
   * Since a too large amplitude may saturate the LED or the 8 bit register,
   * we attenuate the amplitude by atleast T4CC0/2 - 1.
   */
    static uint8 i = 0;
    static const uint8 pwmLut = {243, 234, 208, 168, 122, 76, 36, 10,
                                             1, 10, 36, 76, 122, 168, 208, 234};
   
    // Clears the module interrupt flag.
    T4OVFIF = 0;

    /* Writes the PWM value to the compare register and increments the
   * index. Writing to the compare register TxCC1 takes effect immediately.
   */
    T4CC1 = pwmLut;

    if (i == NO_SAMPLES)
    {
      i = 0;
    }

    // Clears the CPU interrupt flag.
    T4IF = 0;
}

/*******************************************************************************
* @fn          main
*
* @brief       Configures P1_0 as Timer 4 output, sets up Timer 4 for centre-
*            aligned PWM operation and enables overflow interrupts. The rest
*            of the program is interrupt driven, so an infinite loop is needed
*            after the initialization.
*
* @param       void
*
* @return      0
*******************************************************************************/
int main(void)
{
    /***************************************************************************
   * Setup clock & frequency
   */
    // Set global timer tick frequency to 4 MHz
    CLKCONCMD = (CLKCONCMD & ~CLKCON_TICKSPD) | CLKCON_TICKSPD_4M;


    /***************************************************************************
   * Setup peripheral I/O for Timer 4
   */
#if (chip==2541)
    // Selects P1_1 as peripheral I/O (RED LED2).
///P1SEL |= P1SEL_SELP1_1;   
#elif (chip==2543 || chip==2545)
    // Selects P1_1 as peripheral I/O (GREEN LED1).
    P1SEL |= P1SEL_SELP1_0;   
#elif (chip==2544)
    // Select P0_2 for peripheral function Timer4 on channel 1.
    P0SEL1 |= 0x0B;
#endif

#if (chip==2541)
    //Timer 4 has priotity over Timer 1.
    P2SEL |= P2SEL_PRI1P1;
#elif (chip==2543)
    // Set port 1 peripheral priority to Timer 1 over USART0.
    PPRI &= ~PPRI_PRI0P1;
#elif (chip==2545)
    // Set P1_0 Timer 4 to have priority over Timer 1.
    PPRI |= PPRI_PRI0P1;
#endif

#if (chip==2541 || chip==2543 || chip==2545)
    // Select Timer 4 pin location as alternative 1
    PERCFG &= ~PERCFG_T4CFG;
#endif

    /***************************************************************************
   * Setup interrupt
   *
   * Enables global interrupts (IEN0.EA = 1) and interrupts from Timer 4
   * (IEN1.T3IE = 1).
   */
    EA = 1;
    T4IE = 1;


    /***************************************************************************
   * Timer 4 Setup
   *
   * Timer 4 channel 1 compare control configuration. Selects the output mode
   * so that the output is set on compare-up and cleared on compare-down and
   * enables compare mode. This also disables compare interrupts.
   */
    T4CCTL1 = T4CCTLn_CMP_SET_CMP_UP_CLR_0 | T4CCTLn_MODE;

    /* Timer 4 channel 0 compare value. Sets the Timer 4 terminal count value
    * to 244, which makes the Timer count up to 244 before counting down to 0.
    * Hence it controls the PWM period and dynamic range.
    */
    T4CC0 = 244;

    /* Timer 4 channel 1 compare value. Sets the initial compare value to 156
    * This value controls the pulse width (duty cycle) and is changed at each
    * Timer overflow interrupt.
    */
    T4CC1 = 156;

    /* Timer 4 control. Sets the prescaler divider value to 128, starts the Timer,
    * enables overflow interrupts, clears the Timer and sets the mode to
    * up-down.
    */
    T4CTL = T4CTL_DIV_128 | T4CTL_START | T4CTL_OVFIM |
    T4CTL_CLR | T4CTL_MODE_UPDOWN;

    // Infinite loop.
    while (1);
}

大秦正声 发表于 2014-11-30 10:13

由于条件和时间有限欢迎大家指正

chunyang 发表于 2014-11-30 23:41

才注意到二姨家新开了这么个版块……

大秦正声 发表于 2014-12-1 10:55

chunyang 发表于 2014-11-30 23:41
才注意到二姨家新开了这么个版块……

多谢关注

chunyang 发表于 2014-12-1 16:09

这年头流行玩这个啊……

大秦正声 发表于 2014-12-1 17:47

chunyang 发表于 2014-12-1 16:09
这年头流行玩这个啊……

做好不容易啊

海中水 发表于 2014-12-14 11:27

最近在搞CC2541的蓝牙,有时间准备研究四轴,纯属兴趣。

nrf200 发表于 2015-3-20 14:51

强烈推荐Nordic nRF51822 M0的强大内核,你懂的

loudianxin 发表于 2015-4-17 13:24

楼主你这个飞起来了吗??我最进看好51822的32为M0内核

rogerllg 发表于 2015-5-19 08:14

用蓝牙还可以做IOS或者 android的APP来控制,想法不错~ 可以定义为室内机~

sum123456 发表于 2018-4-12 17:15


mpu模块简单测试通过了!
页: 1 [2]
查看完整版本: 【21ic飞控】+蓝牙BLE4.0四轴小飞行器资料