CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Motor control

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ALPHA4390



Joined: 16 Feb 2016
Posts: 9

View user's profile Send private message

Motor control
PostPosted: Sun Mar 06, 2016 11:23 am     Reply with quote

I am in the process of trying writing some motor control code, I want to control a BLDC Motor.

The problem is i am struggling to make sense of example code and need simplistic documentation that spells it out simply. A bit like the tutorial book with CCS demo boards.

I understand the motor control part in depth and also the electronics part, however the microcontroller part is proving difficult mainly as I can't get any documentation on what parts of the code actually are doing.

I had working examples that i used years ago written in C for mplab 8 but they seem totally incompatible with CCS.

Does anyone know if there are any decent books on motor control for CCS or any fun project web sites, starting off simply the getting more complex.
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 11:44 am     Reply with quote

I posted here:

<http://www.ccsinfo.com/forum/viewtopic.php?t=54764&highlight=bldc&start=15>

A CCS translation of AN857.

Basically BLDC motors are exactly like the old synchronous motors. You feed a sinusoidal power waveform into the phases 'leading' the actual position of the motor, to generate acceleration/power.
Now because you can't actually generate a sinusoid easily, you synthesise the effect of this using a modulated PWM. This has to run a lot faster than the actual waveform you are synthesising.

Now you then have the question of knowing 'where' you are relative to the actual motor position. There are two approaches. Physically sensing the position with Hall effect sensors, or reading the BEMF on the third unenergised coil to estimate the position. This is the so called 'sensorless' approach, and is what is used in the code above.

The sensor approach makes it much easier to start the motor well. More torque etc. The sensorless approach needs less wires, and once the motor is spinning works as well.

To accelerate you increase the amount of phase 'lead', but must not go too far or the motor will skip a phase.

The most complex thing is generating efficient drives for the six outputs needs (positive and negative on each of the three phased).

Genuinely now, I'd say it is much easier to use an off the shelf IC to handle the actual BLDC. A chip like the A4960 does it all much easier, and even better, something like the LB11685AV implements soft switching to reduce the noise that can otherwise be generated, and handles all the current limiting, and dealing with error conditions like loss of lock.
ALPHA4390



Joined: 16 Feb 2016
Posts: 9

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 11:56 am     Reply with quote

Ttelmah wrote:
I posted here:

<http://www.ccsinfo.com/forum/viewtopic.php?t=54764&postdays=0&postorder=asc&highlight=bldc&start=15>

A CCS translation of AN857.

Basically BLDC motors are exactly like the old synchronous motors. You feed a sinusoidal power waveform into the phases 'leading' the actual position of the motor, to generate acceleration/power.
Now because you can't actually generate a sinusoid easily, you synthesise the effect of this using a modulated PWM. This has to run a lot faster than the actual waveform you are synthesising.

Now you then have the question of knowing 'where' you are relative to the actual motor position. There are two approaches. Physically sensing the position with Hall effect sensors, or reading the BEMF on the third unenergised coil to estimate the position. This is the so called 'sensorless' approach, and is what is used in the code above.

The sensor approach makes it much easier to start the motor well. More torque etc.. The sensorless approach needs less wires, and once the motor is spinning works as well.

To accelerate you increase the amount of phase 'lead', but must not go too far or the motor will skip a phase.

The most complex thing is generating efficient drives for the six outputs needs (positive and negative on each of the three phased).

Genuinely now, I'd say it is much easier to use an off the shelf IC to handle the actual BLDC. A chip like the A4960 does it all much easier, and even better, something like the LB11685AV implements soft switching to reduce the noise that can otherwise be generated, and handles all the current limiting, and dealing with error conditions like loss of lock.


The problem i have is i purchased a 33F256MU806 analogue dev pcb, i tried copy and pasting it just to see if it compiled ok, it didn't.

I am Looking for really well documented example projects to understand and ultimately make it fun otherwise i think i am going to get bored pretty quick. I bought CCS as i used it 10 years ago and found it much easier to use than mplab.

I have looked at many of the microchip dev kits and in my opinion they're as good as useless. Yes they get something to spin but I want to understand everything about what's going on Micro-wise.

I am a drives designer by trade and am trying to at least have some level of competency of micros.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 3:11 pm     Reply with quote

Quote:
i purchased a 33F256MU806 analogue dev pcb

Post a link to the web page for that board.
ALPHA4390



Joined: 16 Feb 2016
Posts: 9

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 4:32 pm     Reply with quote

PCM programmer wrote:
Quote:
i purchased a 33F256MU806 analogue dev pcb

Post a link to the web page for that board.


Its available on the CCS web site

http://www.ccsinfo.com/product_info.php?products_id=dsPIC-analog-kit
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 5:38 pm     Reply with quote

Just a heads up. The dsPIC on that dev board doesn't always start reliably because the crystal CCS used (12MHz) is too high for the processor to start from in PLL mode.

Read this post for a fix: http://www.ccsinfo.com/forum/viewtopic.php?t=47757&highlight=asm
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Mar 06, 2016 7:37 pm     Reply with quote

Could you tell WHAT is the make and model of your motor - it's specs
and MAX RPM ??

I've worked with BLDC in medical device APPS using 16f and 18F PICS, boosted by extra hardware, but the specs of your motor really determine if i am able to help you..........
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Mon Mar 07, 2016 2:17 am     Reply with quote

and (of course), whether it is sensored or sensorless. Also the 'nature' of the load.

If the load is one that has 'low drag' at startup, then sensorless is the way to go. If it needs good starting torque, then instead consider going sensored.

The code I pointed to, was based on doing the fastest possible varying PWM, with a basic PIC16/18, and as such ties closely to the hardware of these chips.
Not going to work on a PIC33.
I also have some based on the PIC18, with PCPWM, but the chips with this, all have significant errata on other parts, which made them really awkward to use.

Now you need to spend a lot of time to get the drive hardware working right. Driving the high side FETs efficiently, and particularly how the power is routed to avoid creating problems for the PIC. How complex these are will depend on just how much voltage/power is involved. The last BLDC drive I did, handled 150A continuous at 90v. Remember that peak currents will very significantly exceed the 'average' ratings. Personally, if 'analog' is involved (your buying of an analog development board suggests it is), I'd be going out of my way to separate this from the motor drive, not trying to drive the motor with the analog processor.

As a completely separate suggestion, if this is a DC motor operating below perhaps 36v, then look at one of the cheap RC ESC's. These cost less than you can buy the parts for, and require a simple RC PWM, to give motor control, with (in some cases), even programmable acceleration rates, current limits etc.. You could just operate one from a PWM off the PIC, and have things working in a tiny fraction of the time needed to develop a BLDC controller, and cheaper too!... The cheapest ones of these are low voltage only (typically under 10V), for things like cars, while the ones for quad-copters and larger aircraft can even be found in versions supporting up to 50v operation (but at higher cost).
ALPHA4390



Joined: 16 Feb 2016
Posts: 9

View user's profile Send private message

PostPosted: Mon Mar 07, 2016 2:56 am     Reply with quote

asmboy wrote:
Could you tell WHAT is the make and model of your motor - it's specs
and MAX RPM ??

I've worked with BLDC in medical device APPS using 16f and 18F PICS, boosted by extra hardware, but the specs of your motor really determine if i am able to help you..........


I am trying to spin a Bldc motor 4 pole with 3 hall effect sensors. The drive I have designed has 3 current sensors for each phase and a standard 3 phase bridge.

My goal is to develop a closed loop speed control, with an inner fast current loop. But to be honest my knowledge of the micro and c is not up to speed yet. Hence I want to start small and work up.
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Mon Mar 07, 2016 3:17 am     Reply with quote

With BLDC, you know how fast it is turning. Unless it is slipping, it is turning at the speed you are controlling it at. This is different from a normal DC motor, where it's speed varies with load, and so you have to 'speed control' the motor.
You wouldn't normally use 'closed loop speed control', directly on a BLDC motor. You _know_ how fast the motor is going. The speed you are telling it to do. Detecting slippage, is the only loop control you need. Where you do use a closed loop, is to control acceleration and deceleration to change the motor speed to it's desired target, or to adjust for load changes, so as part of a servo control loop.
The 'closed loop' control that Microchip show, adjusts the motor lead/lag, to match the speed it is doing, to the requested speed from a pot. Is this what you are after?.

Comments still stand though on size of motor, current, voltage etc..
ALPHA4390



Joined: 16 Feb 2016
Posts: 9

View user's profile Send private message

PostPosted: Mon Mar 07, 2016 5:06 am     Reply with quote

Ttelmah wrote:
With BLDC, you know how fast it is turning. Unless it is slipping, it is turning at the speed you are controlling it at. This is different from a normal DC motor, where it's speed varies with load, and so you have to 'speed control' the motor.
You wouldn't normally use 'closed loop speed control', directly on a BLDC motor. You _know_ how fast the motor is going. The speed you are telling it to do. Detecting slippage, is the only loop control you need. Where you do use a closed loop, is to control acceleration and deceleration to change the motor speed to it's desired target, or to adjust for load changes, so as part of a servo control loop.
The 'closed loop' control that Microchip show, adjusts the motor lead/lag, to match the speed it is doing, to the requested speed from a pot. Is this what you are after?.

Comments still stand though on size of motor, current, voltage etc..


its a cheap servo motor for a prusa i3 printer that I purchased off Ebay, its 24 volt. and has 3 hall sensors.

http://i1274.photobucket.com/albums/y439/michelle08070238/brushless%20dc%20motor/42BLF016570636E8BF4660Eebay6C345370_zpsbb322802.jpg
ALPHA4390



Joined: 16 Feb 2016
Posts: 9

View user's profile Send private message

PostPosted: Mon Mar 07, 2016 5:15 am     Reply with quote

Ttelmah wrote:
With BLDC, you know how fast it is turning. Unless it is slipping, it is turning at the speed you are controlling it at. This is different from a normal DC motor, where it's speed varies with load, and so you have to 'speed control' the motor.
You wouldn't normally use 'closed loop speed control', directly on a BLDC motor. You _know_ how fast the motor is going. The speed you are telling it to do. Detecting slippage, is the only loop control you need. Where you do use a closed loop, is to control acceleration and deceleration to change the motor speed to it's desired target, or to adjust for load changes, so as part of a servo control loop.
The 'closed loop' control that Microchip show, adjusts the motor lead/lag, to match the speed it is doing, to the requested speed from a pot. Is this what you are after?.

Comments still stand though on size of motor, current, voltage etc..


yes a pot could be used but ultimately I would just have a set speed then if the load wer to change the modulation index would change inducing more current, Ie to maintain the speed. so its realy a nested control scheme

outer speed loop then fast current loop.
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Mon Mar 07, 2016 5:19 am     Reply with quote

That is a Nema 17 motor, by Wantai.

Better data here (with the optional gearbox):

<http://www.ht-motor.com/en/01/42BLF%20Planet%20Gear.pdf>

Now we are still back to the question of whether you just want to control this, and if so 'to what' (what is going to give the control input), or do some analog as well. Problem is that keeping the electrical noise round your processor board 'low', while controlling a motor like this is where the hard design actually 'is'.
ALPHA4390



Joined: 16 Feb 2016
Posts: 9

View user's profile Send private message

PostPosted: Mon Mar 07, 2016 9:42 am     Reply with quote

Ttelmah wrote:
That is a Nema 17 motor, by Wantai.

Better data here (with the optional gearbox):

<http://www.ht-motor.com/en/01/42BLF%20Planet%20Gear.pdf>

Now we are still back to the question of whether you just want to control this, and if so 'to what' (what is going to give the control input), or do some analog as well. Problem is that keeping the electrical noise round your processor board 'low', while controlling a motor like this is where the hard design actually 'is'.


the control input could be fixed, lets say 2000 rpm. I have designed the hardware, a standard 3 phase full bridge with dc link and opto isolated gate drives.

so its primary function is speed control, the control loop tries to maintain 2000 rpm, if the load increases the modulation index needs to increase in order to maintain 2000 rpm. The outer control loop produces an error this is fed to the inter control loop. standard nested closed loop control.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group