PopularFX
Home Help Search Login Register
Welcome,Guest. Please login or register.
2024-05-23, 06:37:09
News: Registration with the OUR forum is by admin approval.

Pages: [1]
Author Topic: RomeroUK Pic Micro Motor Driver  (Read 19233 times)

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
***Please Note i never did finish debugging the software below, there were interrupt problems and more time was needed but i ditched the project when it became obvious it was a hoax and therefore never finished, i will leave the code there for a foundation for someone to build on or if i pick it up at some point i will continue.

This board uses Digital Fets to drive the coils and can be easily built on a piece of strip board.
fet is ZVN4306A and i use 3 to give me plenty of current capacity.

NOTE ZVN4306A turned out not to work very well so have now switched

There are UP and Down buttons to set the operating RPM just press and hold
The Pic Increases / Decreases the pulse width until the rotor reaches the set RPM
I am using a 18F1320 18 pin device because it has some nice features and is quiet fast, this will allow me to add things to the circuit if need be.

I have attached the code as asm and as hex and am just knocking up the circuit and will attach this soon.

the hex code can be dropped straight into the pic
PIC settings are as follows
IE switchover OFF
Internal OSC both pins IO
Brownout ON
Watchdog OFF
MCLR OFF
Low Voltage Programming OFF
Fail safe clock OFF
Brownout voltage 4.5V
Power up timer ON

**** Version has changed to 1.1 i have now added the function where you can switch to Modulated Pulse drive, this can be switched on and off so the assembler assembles which ever version is required, PWM=1 assembles for modulated, PWM=0 assembles for non modulated.

I have now included 2 zip's one has the hex for modulated and the other for Non Modulated already to drop into the pic.
the assembly code is the same except i have set the PWM to equate to 1 or 0
« Last Edit: 2012-02-09, 15:58:58 by Peterae »
   
Hero Member
*****

Posts: 805
Very nice Peter,  I guess you were serious about using a PIC controller.   Once you are setup with this you can do so much more by just programing it.   I browsed the code and I'm so glad you documented it, else I would have been lost.    I noticed you just adjust the pulse width to match the RPM you want, stored in a variable and controlled by the button interrupts.   Instead of just turning on the coil for a set time, have you thought about turning on a PWM generator during the ON time?  This will be similar to what Ishmael Aviso is doing, generating lots of pulses during the ON time instead of just one long one.   This cuts down on the I^2 R losses.   I'm thinking to break out my PIC controller and follow your example, and this is what I want to do.  Anyway, good luck with this, it should be lots of fun.
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
Hi EM
That is totally do able quiet easily, i think i am already using the correct pin to drive the fet i would need to check this.
I will make this mod in the next day or 2 as it sounds like a great idea thx  O0

EDIT PS the buttons are polled not interrupt driven, interrupts are used for the hall and 2 timers, i didn't want to use the buttons with interrupts because the button can be held down for long periods to scan up and down, and using interrupts could cause too much processing time in the service routine.
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
The way the software works is as follows

Timer 0 free runs

When the hall goes low 8 times (8 magnet passes) Timer 0 contents is recorded and reset to zero

This recorded time is thus for one whole revolution.

We use this timer value to work out if we need to increase or decrease our pulse on time and we do this until the set RPM is reached.

Timer 1 is used to time the pulse on period
So when a hall goes low we turn on the fet and load the timer with our on period, when Timer 1 overflows FFFF an interrupt occurs which turns the fet off, we then wait for the next hall low transition.
Note the higher Timer1 loaded value the sooner it will overflow and therefore we get a shorter on period.

A safeguard is in place, if the hall goes back to a logic one when the fet is still on, Timer1 gets over ridden and turned off and the fet is also turned off.

There are limits in place to limit our minimum on time and maximum on time these are adjustable, there is also a preset on period that loads when the pic is turned on this is our preset power on starting power level, although the pic will immediately start adjusting this as soon as the rotor starts rotating.

The up and down keys alter the RPM setpoint and have pre defined limits and also a preset value that loads when the pic is powered on.
Basically i compare the current rotor RPM to the setpoint RPM and increase or decrease the pulse on time until the rotor reaches this RPM value.

I have also added some code ready to accept a 3rd key which would be a menu key
In the future i would like to add another time period just after the fet switches off and drive another fet to reclaim bemf for a period of time, that means we could then charge a cap from the wasted energy we used to energise the drive coil in the first place.

The only thing i have not worked out is wether i need to opto isolator this otherwise the fet would need to be grounded to the common ground plain and may make connecting a cap to the coil a bit harder, where as if i opto isolator then it would not matter but then i would need to find 5volts to drive the gate with, so currently not sure if this will ever go anywhere.
   
Group: Guest
Adding an input for a linear Hall is an idea for the future. This Hall would monitor amplitude of the radial fields generated when opposing magnets are in vertical alignment.

The firmware would adjust/maintain RPM for maximum radial field strength  :D
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
Hey that's possible, this chip has 10bit A/D converters on some of the pins  :)
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
I have updated post 1 with the new code
Now added modulated on period, this is setable by setting PWM=1 in the variable equates.

Here's the setup equates in the code
;PWM IS SET UP FOR 40kHz 50% DUTY IF YOU WANT TO ALTER THIS THEN GOTO THIS WEB SITE AND ALTER THE VALUES BELOW
;http://www.micro-examples.com/public/microex-navig/doc/097-pwm-calculator.html
PWM            EQU 0         ;THIS SWITCHES OUR DRIVER TO USE PWM INSTEAD OF PLAIN ON/OFF 1=PWM ON, 0=PWM OFF

PWM_PR2         EQU B'00110001' ;PWM PERIOD REGISTER VALUE

PWM_T2CON      EQU B'00000100' ;SET UP TIMER 2 AND PRESCALE

PWM_CCPR1L      EQU B'00011000' ;PWM DUTY CYCLE

PWM_CCP1CON      EQU B'00111100' ;ONLY 1 OUTPUT USED FOR PWM, ACTIVE HIGH PULSE



Here's a picture of the modulated on period on the fet gate
   
Hero Member
*****

Posts: 805
Very nice!  That's going to be so efficient now, but 40 kHz seems a bit excessive! How are you going to deal with the kickback from these pulses?
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
This can be altered to what ever you wish by going to the web link and changing the values that it calculates, what would you like for a default i can adjust it in the master.
   
Hero Member
*****

Posts: 805
Well, here's my insight into all this.  

This is similar to Switch Mode Power Supplies:  (SMPS)  The higher the PWM frequency the lower the power transfer and the higher the efficiency.  It all has to do with the coil time constant which dictates how quickly the current ramps up.

Your coils probably have a time constant around 1 ms, like mine.    At 1 kHz, the ON time is 1 ms, so exactly one time constant.  This is pretty efficient since most of the current that has built up is going into building up the magnetic field, and very little is wasted in the resistance.   But I would not go any higher than this, if efficiency is on you mind.  (and it should  :) )

I would set it at around 4 kHz, but play with it and see what you get, see how fast the rotor is turning etc..   With this approach you can now turn the rotor very slow and highly efficient!    Who knows you might even discover an over-unity mode.    

I have a PIC16 micro controller somewhere, you've motivated me to look for it.  Than we can compare results.  

EM

PS  Oh,  we have to harvest the kickbacks to another capacitor or back to the source with a pulse transformer and diode setup.  That's my plan.
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
You need to make sure it does the newer 18F1320 these are slightly different to program than the old 16F if i remember correctly

PS yeah i can set it to 4KHz default
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
Quote
we have to harvest the kickbacks to another capacitor or back to the source with a pulse transformer and diode setup

Who needs a diode why waste energy in the diode.

We know when we turn off the drive fet, so if we were to wait an adjustable amount of time and switch a cap across the coil using a fet for a determined amount of time then we should be able to dump the energy into the cap without a diode.
The question is how to connect a cap to the coil using a fet when the fet needs to be referenced to the pic ground.
If we had 2 fets and 2 caps, each cap opposite polarity then we could then capture positive and negative cycles if needed, but again we would need to drive this from a pic port line.

as WW said which i loved LOL rectification by logic  ;D
Infact this has given me an idea for a project, to build the worlds first pic bridge rectifier without diodes  :)
Bearing in mind we know what the voltage of the waveform is by sampling using an A/D converter
« Last Edit: 2011-08-13, 22:11:53 by Peterae »
   
Group: Guest
Peterae,

You do know a FET junction isn't that much different from a diode junction when it is on?

Quote
The question is how to connect a cap to the coil using a fet when the fet needs to be referenced to the pic ground.

An H-Bridge?
   
Group: Guest
You need to make sure it does the newer 18F1320 these are slightly different to program than the old 16F if i remember correctly

PS yeah i can set it to 4KHz default

Thanks for posting your code and schematic.

The JDM based PIC programmers have some issues with some of the 18F and 12F series I think...sometimes they can get written once the first time, but not again (without some special jumpers) I use one though, with www.ic-prog.com's thing, worked alright once I rewired one connection. I still can get an error at times. Could not get my ZIF socket to work, so have to use the onboard one, which is bad on the pins.

I use the 18F2320, was doing some audio (sine and PWM), and Oshon Software's PIC18Simulator IDE. It has PWM routines as well.

Here's a timer page I have used.

http://eng-serve.com/pic/pic_timer.html

Robert
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
Thanks AG yes that's very handy for the timer values.  O0

OK i have moved the pic rectifier over to it's own thread now
http://www.overunityresearch.com/index.php?topic=1054.msg16145#msg16145
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
I have been having loads of trouble with the fets i am trying to drive with the pic, so i now need to find an alternative, it would appear this fet is not as good as i was lead to believe at being switched from a TTL pic line.

Anyone know of an easy alternative for driving my coil from a TTL logic, maybe i need to go back to bipolar as the FET driver chips are just to hungry for power.
   

Group: Tinkerer
Hero Member
*****

Posts: 3055
You may need to use a MosFet specifically
designed to operate at the logic level gate
signal voltage.


Here's one.


The FDS6680 is another which should work.


---------------------------
For there is nothing hidden that will not be disclosed, and nothing concealed that will not be known or brought out into the open.
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
   

Group: Tinkerer
Hero Member
*****

Posts: 3055
Well done Peterae!

I believe you're on your way!


---------------------------
For there is nothing hidden that will not be disclosed, and nothing concealed that will not be known or brought out into the open.
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
WW just to let you know, while i am waiting on my Logic level fets, i quiet easily managed to find the null zone when applying a bias magnet, although i have no motor drive hooked right now, i could spin the rotor by hand and see the sinewave of the magnetic field on the top of the core, i adjusted this so the ratiometric sensor was showing equally above and below it 0G setting, i could not see any difference in the coils unloaded output waveform though.

If i can get my pic motor driver up and running i will be able to do some load testing.
   
Group: Guest
Thanks Peterae. That is good to know.

I'm working on a stepper motor driver so I can show what I've been describing.
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
Wave goodbye to high consumption fet drivers, the BUK552-60A drives really well directly from the pic pin  O0
Not been able to measure rise time yet but for the pic driver i am not worried, just need to tweak the software parameters a bit yet and all will be go
   
Group: Elite
Hero Member
******

Posts: 3537
It's turtles all the way down
The purpose of high consumption FET drivers is to supply the current required to rapidly charge and discharge  the input gate capacitance at high frequencies, insuring clean switching.

This device has a Ciss of 400 to 600 pf. If you know what the PIC output current source and sink capability is, you should be able to calculate where you will get into trouble (slow switching).

Or you could just hook it up and try it with a reasonable resistive load on the drain and see where it starts slewing badly when you sweep the frequency upwards.

Logic level FETs can be handy as long as the driving device can do the job at high frequencies.

You probably already know this, just got some talkin' time on my hands.



---------------------------
"Secrecy, secret societies and secret groups have always been repugnant to a free and open society"......John F Kennedy
   

Group: Administrator
Hero Member
*****

Posts: 3881


Buy me some coffee
Hi ION

Thankyou, yeah i was really referring to the Romero Driver, trying to produce an efficient motor driver using a fet driver that switches 6 amps just doesn't help the efficiency much, so am very happy to use the digital fet for this purpose.

But having said that, i want to scope the fet and see what i need to drive it with (Maybe a number of pins or gates) to get a reasonable speed so i can do some more on the crackling coil experiments.
   
Pages: [1]
« previous next »


 

Home Help Search Login Register
Theme © PopularFX | Based on PFX Ideas! | Scripts from iScript4u 2024-05-23, 06:37:09