element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Smarter Life
  • Challenges & Projects
  • Design Challenges
  • Smarter Life
  • More
  • Cancel
Smarter Life
Blog PSoC 4 Tricopter (Smarter Life Challenge) part #6
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: yuritikhonov
  • Date Created: 1 Dec 2013 6:45 PM Date Created
  • Views 1540 views
  • Likes 2 likes
  • Comments 14 comments
  • RoadTest
  • tricopter
  • psoc4
  • Multiwii
  • smarter_life_challenge
  • smarter_life
  • smart_tricopter
  • smart_control_and_diagnostics
  • arduino
  • quadcopter
Related
Recommended

PSoC 4 Tricopter (Smarter Life Challenge) part #6

yuritikhonov
yuritikhonov
1 Dec 2013

If you like my project vote for "A Smarter Tricopter - Yuri Tikhonov" image

 

Good day comrades!

Unfortunately my previous posts have not received special attention of the community. This time, I will try to improve and make a post more extensive and interesting!

As you probably already knew - we are going to talk today about the system of motor control. However this week has been more fruitful for several reasons:

 

1. I finally got the first package from HobbyKing:

one 2200mAh 3S LiPo. Other details are taking long time to arrive, I hope to get them soon.

image

2. I got the final package from Farnell: Arduino Yun! I worked a little bit with it and I can say that this is a great device, and it will find it's place in my tricopter! Thanks again to Farnell for such generous gifts.

image

 

3. When working on the project, I bypassed the main task: the construction of tricopter. It is tri, not the quad! This week I have made a number of modifications to make it's firmware compatible with quadcopter and tricopter.

 

So, a bit of theory. As it is known I use BLDC's in my copter and they require specialized control system. I went the easy way out and decided to buy such a system from HobbyKing, however, there is a small problem: I have not BLDC motors and I have not ESC's (motor control systems) However, I worked previously with such systems when I built my helicopter:

image

 

To control ESC I need a PWM signal of a certain frequency (I don't know exactly, what is the perfect frequency for my ESC's). Control is carried out as follows:

  1. At the time of startup, you should briefly send to the motor signal "maximum throttle", and then go to the "minimum throttle" this is the initialization.
  2. Speed control is performed by changing the pulse duration of the PWM signal.
  3. Ideally, tricopter should "hang" with the average signal level (50% of full throttle).

 

I don't claim the above to be 100% truth, however, a few years ago I wrote a diploma in multicopters and there,  these principles were used for motor control.

Servo control is by analogy, but it uses a different frequency of PWM and do not require the initialization procedure.

Let's consider 'PSoC Schematics' obtained at a given time :

image

 

As you can see I have not used UDB-blocks, because they ended image

 

Purple module:

  • PWM_FL - front left motor (for quad and tri);
  • PWM_FR - front right motor (for quad and tri);
  • PWM_RL - rear left (for quad) or rear (for tri) motor;
  • PWM_RR - rear right motor (for quad) or YAW servo (for tri).

 

The configuration of each PWM unit was left by default:

image

 

I don't want to show all of the code of the motors and servo control system, I'd better say in words how a copter works:

image

Quadcopter:

  • Right/Left (ROLL): increase/decrease motors 1 and 4 power, decrease/increase motors 2 and 3 power.
  • Forward/Backward (PITCH): increase/decrease motors 3 and 4 power, decrease/increase motors 1 and 2 power.
  • Turn clockwise/counterclockwise (YAW): increase/decrease motors 1 and 3 power, decrease/increase motors 2 and 4 power.
  • Up/Down (THORTLE): increase/decrease all motors power.

I think, it's very simple and clear.

 

Tricopter:

- Right/Left (ROLL): increase/decrease motor 1 power, decrease/increase motor 2.

- Forward/Backward (PITCH): increase/decrease motor 3 power, decrease/increase motors 1 and 2 power.

- Turn clockwise/counterclockwise (YAW): by servo.

- Up/Down (THORTLE): increase/decrease all motors power.

 

As you might have guessed, this week has implemented mixing of channels, and now, I can try to configurate my sistem on a real copter, but unfortunately I haven't got it yet...

 

For example, I made a few screanshoots of MultiWii GUI and the testimony of the oscilloscope in one of the channels:

 

Thorttle = 0:

image

 

Throttle > 0:

image

 

I also measured the signal using oscilloscope from the YAW-output (servo), in the case of tricopter configuration:

image

 

Finally, code:

 

1. Configuration of the motors PWM's:

void initOutput(void)
{
    pwmClock_Start();
    PWM_RL_Start();
    PWM_RR_Start();
    PWM_FR_Start();
    #if (NUMBER_MOTOR > 3)
        PWM_FL_Start();
    #endif

 

2. Configuration of the servo PWM:

#if defined(SERVO)
void initializeServo(void)
{
    PWM_FL_Start();
    PWM_FL_SetPrescaler(PWM_FL_PRESCALE_DIVBY8);
    PWM_FL_WritePeriod(30000);
    PWM_FL_WriteCompare(30000);
    //#define SERVO_CHANNEL OCR0A
    //#define SERVO_1K_US 250
}
#endif

 

3. Writing the signal from the motor[] array in to the motors (EXT_MOTOR_RANGE is using for DC motors):

void writeMotors(void) // [1000;2000] => [32000;64000] * 256 (~190Hz motors!)
{
    #ifndef EXT_MOTOR_RANGE
        PWM_RR_WriteCompare( motor[0] << 5 ); //  Rear Right (Tri: Rear)
    #else
        PWM_RR_WriteCompare( (motor[0] << 6) - 64000 );
    #endif
    #ifndef EXT_MOTOR_RANGE
        PWM_FR_WriteCompare( motor[1] << 5 ); //  Front Right (Tri: Top Right)
    #else
        PWM_FR_WriteCompare( (motor[1] << 6) - 64000 );
    #endif
    #ifndef EXT_MOTOR_RANGE
        PWM_RL_WriteCompare( motor[2] << 5 ); //  Rear Left (Tri: Top Left)
    #else
        PWM_RL_WriteCompare( (motor[2] << 6) - 64000 );
    #endif
    #if (NUMBER_MOTOR > 3)
        #ifndef EXT_MOTOR_RANGE
            PWM_FL_WriteCompare( motor[3] << 5 ); //  Front Left
        #else
            PWM_FL_WriteCompare( (motor[3] << 6) - 64000 );
        #endif
    #endif
}

 

4. Writing the same signal to the all motors:

void writeAllMotors(int16_t mc)
{
    uint8_t i;
    for (i=0; i<NUMBER_MOTOR; i++)
        motor[i]=mc;
    writeMotors();
}

 

5. Writing the singnal from the servo[] array to the YAW servo:

#if defined(SERVO)
void initializeServo(void)
{
    PWM_FL_Start();
    PWM_FL_SetPrescaler(PWM_FL_PRESCALE_DIVBY8);
    PWM_FL_WritePeriod(30000);
    PWM_FL_WriteCompare(30000);
}
#endif

 

I hope today's post can seem you more interesting than the previous. Write your comments and suggestions on the project!

 

The next two weeks I'm going to devote to the completion of the frimware, and then - as soom as I receive all components the decisive stage of the project will begin : building of the the machine!

 

See you next week!

image

                                                                                                                                              

#linkdescription
1PSoC 4 Tricopter Part #1Introduction
2PSoC 4 Tricopter Part #2Purchase of components from Farnell and HobbyKing
3PSoC 4 Tricopter Part #3PSoC firmware: upTime & Rx
4PSoC 4 Tricopter Part #4PSoC firmware: UART & MultiWii GUI
5PSoC 4 Tricopter Part #5PSoC firmware: EEPROM emulation
6PSoC 4 Tricopter Part #6PSoC firmware: Servo & ESC control
7PSoC 4 Tricopter Part #7PSoC firmware: IMU, LED's & PID
8PSoC 4 Tricopter Part #8Hardware: PCB
9PSoC 4 Tricopter Part #9Hardware: tricopter's frame
10PSoC 4 Tricopter Part #10Hardware: YAW mechanics & motors
11PSoC 4 Tricopter Part #11Hardware: ESC's, wires & misc
12PSoC 4 Tricopter Part #12Final: The first fly

 

If you like my project vote for "A Smarter Tricopter - Yuri Tikhonov" image

  • Sign in to reply

Top Comments

  • yuritikhonov
    yuritikhonov over 12 years ago in reply to rodreig89kishore +1
    Thanks for you comment I apologize for the possible complexity of my texts. I just don't have much experience in writing texts in English... In one of the following posts I want to make a video of how…
Parents
  • rodreig89kishore
    rodreig89kishore over 12 years ago

    That was one of the simplest and complicated explanations I have seen in a long time. image
    Greta job Yuri.!!! image
    P. KISHORE KUMAR

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • yuritikhonov
    yuritikhonov over 12 years ago in reply to rodreig89kishore

    Thanks for you comment image

    I apologize for the possible complexity of my texts. I just don't have much experience in writing texts in English...

    In one of the following posts I want to make a video of how it all (Rx, IMU, motors etc.) works together.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • yuritikhonov
    yuritikhonov over 12 years ago in reply to rodreig89kishore

    Thanks for you comment image

    I apologize for the possible complexity of my texts. I just don't have much experience in writing texts in English...

    In one of the following posts I want to make a video of how it all (Rx, IMU, motors etc.) works together.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube