DesignSpark Electrical Logo
  • Brought to you by
  • RS Components
  • Allied Electronics
karlwoodward

May 23, 2017 15:17

Cypress PSoC Kit Makes Driving Brushless DC Motors Easy

BLDC motor control in 5 minutes with PsoC 4 Pioneer and motor control eval kit.

Brushless DC (BLDC) motors are used in high-end appliances the world over. Driving these motors correctly is an art in its own right and choosing the right controller for the application is essential.

Using software to control these motors from your system-on-chip can be very resource consuming and leave little in the way of CPU cycles for other parts of the application. Meaning either a slow user response or requirements for specialist or additional silicon and BOM (Bill Of Materials) cost. This is especially true for specialist applications that have mixed analogue/digital requirements.

Another way Introducing PSoC, a Programmable System-on-Chip developed by Cypress semiconductor and possibly one of the best kept secrets of the industry.

  

These wonders of modern IC technology integrate a CPLD and ARM Cortex-M0 (even ARM Cortex-M3 in the higher end parts), in addition to an analogue fabric. The cost of the parts is also comparable to similar microcontrollers. If this is not enough there are also devices with peripherals like Bluetooth and USB built in. 

What does this mean to our application? Well, with a single low cost IC we can make our own application-specific System-on-Chip, without the need for an FPGA or HDL. This would also mean the design is scalable if resources get tight and we need a faster CPU, and if we want to add USB or BLE to our system we can.

Better still most PSoC 4 designs come with integrated capacitive touch functionality, which can further increase the user experience and reduce product cost.

Where to start?

Cypress have a solution that enables quick evaluation and prototyping, the CY8CKIT-037 (124-4182) PSoC 4 Motor control kit. This is designed to fit onto a PSoC4 CY8CKIT-042 (124-4183) Pioneer kit (the building block for PSoC 4 kits) , this will need to be purchased in addition to the BLDC kit.

The kit comes with everything required to control a BLDC motor, including the motor itself, an Anaheim Automation BLY172S-24V-4000.

Following the glossy quick start guide, setting up the CY8CKIT-037 and changing the Pioneer kit to 5V operation was a cinch. The kit even provides a screwdriver for the screw terminals for connection of a BLDC motor.

Looking at the motor control board, it is very well laid out with a discrete dual H-Bridge circuit.

This is made up of IRF2101S High/Low side drivers driving IRFU3607 N channel FETS — some serious capability there.

You may ask, why provide a 3-phase BLDC motor but provide 4 sets of FETs? The answer is simple: the kit is designed for stepper motor control too.

Although a point to note is no stepper motor is provided with the kit.

 

One minor niggle when plugging in the motor: the kit was provided with a wide range 110/240V to 24V power supply. However, the only plug supplied was a US plug and for anywhere outside the Americas this means a local IEC lead will be required.

Wiring up the kit as per the quick reference sheet and installing the IDE was a simple and straightforward procedure. However, only a windows installation was available and there is no Mac or Linux support.

The software install was as simple as typing in the address on the quick start guide.

Alternatively typing into Google the kit number found the same page without effort.

The kit homepage is informative and has all of the design files. Clicking the setup link at the bottom of the page installed PSoC Creator and all of the required files without much input required.

After installing both kit 037 and 042, starting the software “PSoC Creator 4.0” we were met with a clean looking application.

 

  

In addition to a news section there are lots of links to additional information on how to use the PSoC IDE and the chips themselves, all within 1 click. From here following the instructions on the quick start had the “Sensored BLDC Motor Control.cywk” programmed into the development kit.

Within minutes the motor was spinning with a simple potentiometer for speed control. This may be enough for some applications.

 

How does it work?

Thankfully the project is fully documented, and usually between the IDE and this documentation we can work out what's happening without too much effort.

To aid with understanding the examples the kit is supplied with a full design package consisting of: schematics , block diagram, layout files and kit guides. These can be found in the install directory used when installing the kit.

Another nice feature is that the IDE allows you to right-click individual items and select to “Open data sheets” for each component if we are unsure how they work.

On the example specified after opening the “TopDesign.cysch” file we are met with a schematic of the design within the PSoC. This looks complicated, especially if we know little about BLDC motor control.

However, working though the schematic we can quickly discern: the motor is controlled via a lookup table (LUT) in the CPLD part of the design. In addition there seems to be another LUT for checking the motor position and speed. There is an ADC that seems to be sensing the Vbus and the potentiometer input.

Finally, the over-current protection seems to be implemented internally and will flag an input if the motor or motor drive circuit takes too much current.

Logic gates!

There is a lot of information provided with the kit, including a description of what the LUTs are decoding and a nice block diagram of the application. Without these it might be difficult to work out how the examples work.

From the information provided in the kit guide and the schematics within the chip we can see there is very little (if any) software overhead. Leaving more resources for our application specific designs — nice!

There is also a section within the manual to help configure the application for other BLDC motors. This explains the software structure used to control the motor and how to change direction of travel.

A simple register change controls the inversion of the Hall effect sensors and the rest is dealt with from the CPLD part of the PSoC. All the benefits of using a hardware solution, without the cost!

But there's lots of software in the example? After a little investigation it seems most of the software running in the main loop is either error checking or the speed control loop. This code is measuring the motor speed using a timer/counter and is checking and adjusting as required every 12.5ms.

Lots of features for 5 minutes of wiring and opening a single design example!

Adding more features

Adding BLE could be simple and the PSoC4200BLE has enough peripherals to manage the BLDC sensored example, in addition to providing Bluetooth Low Energy features.

Given PSoC has cap touch in it’s blood we can try adding this to the design. However, we quickly ran into an issue. The IDAC is being used but only to provide a reference for over current.

 

This can be addressed with some simple external circuity. However, alas due to the pin configuration imposed by the CY8CKIT-037, we still have issues because of routing limitations imposed using cap touch.

In most applications we’ll be laying out our own design. So this is more of an inconvenience than a show stopper, although a niggle that cannot be ignored.

Modifying the code

Adding our own blinking led code in the main loop was simple. We started by adding a digital output pin to the schematic and then routing this to a new LED.

Rather than re-writing the example we used the current software to our advantage, by adding a check every 80 occurrences of the motor control loop (happens every 12.5ms) and hey presto we have a 1 second flag/tick.

Using this with our led code and we soon have a flashing operation light!

        // We add our new code here
        if(TwelvemsTicks>=80) // enter every 80*12.5ms periods
        {
            TwelvemsTicks =0; // reset the counter
            if(Pin_LED1_RED_Read()==0) // check the pin state
            {
                Pin_LED1_RED_Write(1u);    // pin state was zero so make it a one
            }
            else
            {
                Pin_LED1_RED_Write(0u);    // pin state was one so make it a zero
            }  
        }

A very simple example but all great things start with small steps.

Happy motoring

Karl Woodward

karlwoodward

Karl is a design engineer with years of experience in high speed digital design and commercial electronics from concept start to manufacture.

Comments

Paul Dale

June 16, 2017 10:36

Thanks for the nice write-up Karl, I enjoyed it.

Vandoor

June 13, 2017 07:22

Hi, the moment I read software on a device description it gets the delete button........this might seem Neanderthal but if by experience you go 5 years down the track and then have a problem, the chances that the device is no longer supported or even remembered by a local technician is almost 100%.
Even at a very cheap price the loss of a device in a vital application is a worry I would not contemplate even if it was a freebie for evaluation.
Just my opinion based on normal computer practices.