Jump to content
Premium Aquatics Aquarium Supplies

WORKING DIY Koralia Controllable Driver


mabviper

Recommended Posts

After countless of burned chips, I finally managed to make a Koralia controllable Nano spin!

I'll post pics of the proto board and a video later on tonight.

Link to comment
  • Replies 90
  • Created
  • Last Reply

I'll be waiting :)

 

After countless of burned chips, I finally managed to make a Koralia controllable Nano spin!

I'll post pics of the proto board and a video later on tonight.

Link to comment

Sorry sorry, I tested the circuit right before I had to leave. ^^

 

I just finished making the schematic and I have a pic of the proto board. The schematic is very very simple because the chip that controls them is complicated. I'm using a Digital Signal Processor (DSP) chip from Microchip specially designed for motor control. It has the required elements needed to control motors. The maximum number of motors this chip can control is 3 because it only has 3 motor logic pair I/O.

 

Basically, what I'm programming this dsPIC33 to do is to create an AC signal (60 Hz) by altering the duty cycle of the carrier signal (10 kHz). Anyways, here are the pics.

 

I've uploaded the video

.

 

If you have any questions, I'll try to answer what I can. ^^

I'm not an expert. o.o

 

As promised, there's the code I used for the demo video.

#include <p33FJ256MC710.h>_FOSCSEL(FNOSC_PRI & IESO_OFF)_FOSC(FCKSM_CSDCMD & OSCIOFNC_ON & POSCMD_XT)_FWDT(FWDTEN_OFF)_FICD(BKBUG_OFF & ICS_PGD2)_FPOR(PWMPIN_OFF & HPOL_ON & LPOL_ON)#define FCY 4000000 // 4 MIPS#define FPWM 10000 // 10kHz carrier frequency#define DEADTIME (unsigned int)(0.000002 * FCY)#define _DES_FREQ 60 // THIS IS THE CONTROL FREQUENCY FOR THE MOTOR#define _DELTA_PHASE (unsigned int)(_DES_FREQ * 65536 / FPWM)// This is a look up table to generate a sine waveconst int __attribute__ ((space(auto_psv))) sine[64] = {0,3212,6393,
[indent]9512,12539,15446,18204,20787,23170,25329,27245,28898,30273,31356,32138,32609,32767,32609,32138,31356,30273,28898,27245,25329,23170,20787,18204,15446,12539,9512,6393,3212,0,-3212,-6393,-9512,-12539,-15446,-18204,-20787,-23170,-25329,-27245,-28898,-30273,-31356,-32138,-32609,-32767,-32609,-32138,-31356,-30273,-28898,-27245,-25329,-23170,-20787,-18204,-15446,-12539,-9512,-6393,-3212[/indent]

};unsigned int Phase, Delta_Phase;int Multiplier, Result;int vf = 0x7fff;// This function configures the dsPIC33 motor registers and interrupts
void InitMotorControl() {


[indent]P1TCON = 0x0002;
PTPER = (FCY/FPWM - 1) >> 1;
PWM1CON1 = 0x0011;
PWM1CON2 = 0x0000;
P1DTCON1bits.DTA = DEADTIME;
P1DTCON2 = 0x0000;
P1OVDCON = 0x0300;
[/indent]



[indent]P1DC1 = PTPER;
IFS3bits.PWMIF = 0;
IEC3bits.PWMIE = 1;
INTCON1bits.NSTDIS = 1;
Phase = 0;
Delta_Phase = _DELTA_PHASE;
P1TCONbits.PTEN = 1;
[/indent]

}

void _ISR _PWMInterrupt(void) {


[indent]IFS3bits.PWMIF = 0;
Phase += Delta_Phase;
Multiplier = sine[(Phase) >> 10];
asm("MOV _Multiplier, W4");
asm("MOV _PTPER, W5");
asm("MOV #_Result, W0");
asm("MPY W4*W5, A");
asm("SAC A, [W0]");
P1DC1 = Result + PTPER;
[/indent]

}

int main(void) {


[indent]InitMotorControl();
while(1);
[/indent]

}

post-33268-1255571298_thumb.jpg

post-33268-1255571629_thumb.jpg

Link to comment

sorry to jump in this thread but i got a k1 controlable sittin in box.... got it as a gift but i dont got the controller anyone wana buy it??(and as for this id im not a active member on this site im more active on scnrs.)

soorry and thanks.

Link to comment

Were you using WebBench to simulate the circuit, or just to lay out the schematic?

 

Can you also give a quick example of how you are coding the pwm AC signal?

Link to comment

I used Electronic Workbench just for the schematic. I didn't have any simulation. I tried to do it before but it would just freeze on me since the thing is so complicated to simulate.

 

The easiest way to explain how to create an AC pwm signal is w/ waveforms. You'll see what is needed in the code once you understand the waveforms. Suppose you need to have an AC sine wave @ 60 Hz. This is your target AC frequency. You also need a triangle wave that is much much faster than your AC frequency, say 20 kHz. When you plot them on the same graph,

 

If the triangle wave is greater than the sine wave, "Gating Signal 1" = 1.

 

If triangle wave is less than sine wave, "Gating Signal 1" = 0;

 

"Gating Signal 2" is the compliment of "Gating Signal 1".

 

 

To program it in software, you need to:

 

Create/have access to a counter that counts up and down to recreate the triangle wave.

Create a sine wave in memory.

 

Every time the counter counts up/down, you would check to see if the value of the counter is greater than or less than the sine wave variable. You'll get the gating signals from there.

post-33268-1255629351_thumb.jpg

Link to comment

Aquarium powerheads, imo, use weird motors. It's like a mix of induction and syncronous machines o.o

 

Most motor control applications are in 3 phases but Koralia only has 2 phase so keep that in mind when reading notes.

 

I got a like from microchip that might help. They have numerous app notes for motor control.

Microchip app note

Link to comment

@ls7corvete: yeah, I can modify the speed but it's kinda cumbersome at the moment. I'd need to go into program and modify it manually.

 

@newhobby: yup, this is for the 12V versions. In theory, it can be adapted to 110v versions too but I'm not too comfortable w/ line voltages. You'd need to rectify the line voltage to get DC to feed stronger mosfets. The basic schematic and the gating signals are the same.

 

If anybody is interested, I can upload the source file I used for this experiment.

Link to comment

I would be interested in the source code.

Thanks

 

 

@ls7corvete: yeah, I can modify the speed but it's kinda cumbersome at the moment. I'd need to go into program and modify it manually.

 

@newhobby: yup, this is for the 12V versions. In theory, it can be adapted to 110v versions too but I'm not too comfortable w/ line voltages. You'd need to rectify the line voltage to get DC to feed stronger mosfets. The basic schematic and the gating signals are the same.

 

If anybody is interested, I can upload the source file I used for this experiment.

Link to comment

I'd be interested in the source code,

might be able to get it to work with arduino,

my motivation is that they are such a cheap microcontroller.

 

It is interesting,

really cool now that I'm understanding how it works.

Link to comment

I've been busy the last few days. I'll try to upload the source code this week.

 

As for the Arduino, I'd love to get it working on them but unless Arduino gets ported to an Atmel chip that is capable of hardware motor control with functions like dead gap, up/down counters etc, I personally won't consider coding on one. I'm not saying that it can't be done. They can all be implemented in sure software but I'm spoiled from hardware functions ^^;

Link to comment

I'd much rather do what you're doing,

I know just enough to code and not much past that.

 

Maybe I could improve on it,

get a GUI and make it better than the vortech.

 

I know in arduino how to implment a text based LCD screen,

touchscreen and make it a very controllable wavemaker.

 

How hard is it to code compared to arduino's programming language?

 

 

EDIT

Checked the price and gagged.. well sorta.

 

How can I go about finding a compatible controller that is stripped down,

all I am finding are $200 development kits.

Link to comment

Yeah, these dev boards aren't really that cheap.

 

I personally don't have any experience w/ the Arduino but I know it's relatively simpler than coding in C. One of the things than you need to be able to do is have 2 PWM signals that compliment each other. If PWM1 is ON, PWM2 is OFF and so on. Another thing than you need is a small timing gap from the moment you turn OFF PWM1 to the moment you turn ON PWM2. It's called 'dead gap' and it's a short protection for the bridge.

 

Now, you can implement this in software but it's probably going to take you more than a few lines of code. However, when you have a chip that can control motors like the one that I used, you can configure it such that it does all the things I said above in a single line of code.

 

My vision is to make a prototype for myself then get working on an board for people to use. Though, unlike the Arduino (which has a bootloader so you can download programs via serial or USB), you'd need to get a programmer to program these chips, probably about $30-50 for the programmer itself.

 

If you're interested in a low cost board, my suggestion is to build one yourself. I can give you suggestions for parts. It's not as hard as you might think ^^. Bare minimum, all you need is a dsPIC33 'MC' chip and a 3.3V power supply.

Link to comment

Currently I'm moving around,

but when things settle down I'd love to do that.

 

Heck if you have some links I'd like to read them over,

the chip is $6 so that's not an issue on cost :)

 

I can do schematics,

I've got some breadboards laying around,

hookup wire and I can order what is needed.

The programmer is not big deal.

 

Dumb question,

how would I change it to do pulses,

control how quickly it revs to 100% duty cycle,

how quickly it goes to a near stall duty cycle ....

 

Basically a vortech,

I got the code for arduino that would work well for a motor that would take in simple PWM but not what you're mentioning.

Link to comment

@jm82792:

There's only 1 variable you really need to change, the frequency of motor rotation. So let's say it rotates at 60 Hz at full power. The way I would do it if I want to vary its speed is to run a separate continuous timer function. Say it takes 1s for the timer to start from 0 and end at whatever number it ends with. Basically a continuous timer w/ a 1s period. Every time the timer finishes 1 cycle, I would decrement the motor frequency by 1Hz to 59Hz and so on.

That way, if you want it to ramp faster or slower, all you need to change is the frequency of the continuous timer. Hope that helped ^^.

 

@ls7corvete:

jm82792 was talking about the Microchip Explorer16 dev board w/ a dsPIC33 MC chip that I used for the video I posted earlier.

Link to comment

I think I get it,

add power and it rotates,

delay the power being added and it coasts then power is added.

The more frequent the pulse of PWM the faster it goes.

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recommended Discussions


×
×
  • Create New...