Help - Search - Members - Calendar
Full Version: WORKING DIY Koralia Controllable Driver
Nano-Reef.com Forums > System Setup > Do It Yourself

mabviper
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.
newhobby
I'll be waiting smile.gif

QUOTE (mabviper @ Oct 14 2009, 08:34 AM) *
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.

evilc66
You SOB, stop teasing omgomgomg.gif
ajmckay
Wow... Sounds really cool. I'm excited to see the details.

corallineadam
yes!!!!
ls7corvete
tease
mabviper
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 here.

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.
CODE
#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 wave
const int __attribute__ ((space(auto_psv))) sine[64] = {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,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
};

unsigned int Phase, Delta_Phase;
int Multiplier, Result;
int vf = 0x7fff;

// This function configures the dsPIC33 motor registers and interrupts
void InitMotorControl() {
P1TCON = 0x0002;
PTPER = (FCY/FPWM - 1) >> 1;
PWM1CON1 = 0x0011;
PWM1CON2 = 0x0000;
P1DTCON1bits.DTA = DEADTIME;
P1DTCON2 = 0x0000;
P1OVDCON = 0x0300;
P1DC1 = PTPER;
IFS3bits.PWMIF = 0;
IEC3bits.PWMIE = 1;
INTCON1bits.NSTDIS = 1;
Phase = 0;
Delta_Phase = _DELTA_PHASE;
P1TCONbits.PTEN = 1;
}

void _ISR _PWMInterrupt(void) {
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;
}

int main(void) {
InitMotorControl();
while(1);
}
ibom
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.
cptbjorn
Bah, if only I could fit a koralia nano in my pico I would be all over this.

They better be working on a koralia pico smile.gif
evilc66
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?
mabviper
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.



evilc66
Hmm. Going to have to read into that one a little more. Got any good links for that Mab?
mabviper
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
ls7corvete
Are you able to modify the speed well? How about speeds beyond stock(slower, faster)?
newhobby
This is for the 12v version, right?
Can you do something like this with the 110v too?
mabviper
@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.
robw
I would be interested in the source code.
Thanks


QUOTE (mabviper @ Oct 16 2009, 01:06 PM) *
@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.

jm82792
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.
mabviper
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 ^^;
jm82792
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.
mabviper
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.
jm82792
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 smile.gif

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.
ls7corvete
gagged at the price of what?

what kind of controller are you looking for?
mabviper
@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.
jm82792
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.
mabviper
Kinda o.o
Let's put it this way. The PWMmotor signals that controls the mosfets and thus the motor is going to be out of the user's reach. That PWMmotor signal has a set frequency of 10kHz. It won't change. The software program that generates the PWMmotor doens't need to be touched and will do it's thing indefinitely. It only has 1 input parameter which is the motorSpeed.

You can change the motorSpeed in many different ways. You might want to use a voltage potentiometer for some voltage division action or you can use a different PWM frequency. Changing motorSpeed is only limited by the user's imagination. That's all you get to play with ^^. The rest, you can forget about how it works, heh.
jm82792
Okay that is what I was thinking,
proportionately changing the PWM frequency.

Having the option of sync and antisync,
then going to how long off and how long on,
then set the max PWM frequency (10KHz less if you wanted to)
the minimum/idle, how many steps(like 5% is one step(smoothness of transition etc) or 1 or whatever_
basically how quickly it goes on then do it for how quickly it goes off.

That's what I was thinking.
ls7corvete
Would you guys be able to program chips and send them out to forum members? Saving most of us the cost of a programmer.

Do you plan to program this as stand alone or have it respond to various inputs(slave from another controller), ie, 0-10v, I2c, etc?

I think the ability to connect this to some kind of reefcontroller would really set it apart. The 89$ build, auqacontroller or others.
mabviper
Hmm, to be honest, I'm only a mere student in university.

I wanted to make something for myself to control these motors. If I was successful, I'd be willing to share it. I wasn't really planning on making a board that I can distribute to the masses. I don't think it's feasible for me to do that.

However, I will answer questions to my software and hardware designs when people ask them. People can make modifications on the software and hardware as they see fit.

The software that I'm using is just a proof of concept. In the future, I can implement various motor control mechanisms like 0-10v, I2C, UART, pwm control, etc. It's meant to be a Koralia driver with flexible automated user control. As for the programmed chips, it is possible in the future, maybe. Though I really can't see myself programming a bag full of chips along w/ doing school work >.<
ls7corvete
There seems to be more and more members with experience programing chips to help with that, especially if this becomes a popular project. I sure hope it gets popular, a controllable koralia that I can setup with other reef controllers has alot more functionality to me than a vortech.

The circuit seems easy enough to DIY. PCB would be nice but doesnt seem needed in this case.
jm82792
I don't mind DIY,
if I can program it I jsut need to know how to wire it up to control the koralias.
tarzan
Just a thougt:

would it work, if you would use just one MOSFET that can handle 24V and switch it ON and OFF instead of using 12V H-bridge???

Regards, Tarzan
mabviper
Unfortunately, no. 1 mosfet is not going to work. The H-bridge recreates an AC signal. A single mosfet wont' be able to do that.

tarzan
QUOTE (mabviper @ Oct 25 2009, 04:16 AM) *
Unfortunately, no. 1 mosfet is not going to work. The H-bridge recreates an AC signal. A single mosfet wont' be able to do that.

Why wouldn't it be able to do that? I don't understand it, forgive me, i am almost completely clueless about how this MOSFETs work and what they can and can't do...

->Theoretically if you use just first gating signal [g1] than you would get the same output [AO] as your H-bridge controller, if you would have just one MOSFET and 24V DC suply instead ov 12V DC.
mabviper
If you use the gating signal g1 to drive just 1 mosfet, all you'll get is a DC signal that's ramping up and down between 0 - 24V. If you connect your motor between 24V and the drain terminal of the mosfet, the current will only flow one way, not enough to drive the motor. You'll just hear a click.

Now, the output AO is not made solely by g1. AO is actually g1-g2. These gating signals must be paired w/ its corresponding mosfet in the H-bridge to get an AC output across the motor terminals.

This link might help to understand the H-bridge concept. Though, the motor that they're using is DC and the H-bridge is for the direction of rotation of the motor. AC H-bridge is similar but it alternates at a higher frequency. Fundamentally, the operation is similar.
H-bridge secrets

I hope that helps ^^

tarzan
Thank you mabviper, that was very educational. Now I understand it all. You should consider giving private lectures smile.gif
tarzan
Hi mabviper, it's me again biggrin.gif As jm82792 I am also interested in getting it working on Arduino. I searched the arduino forum and here, and as I understood, it is possible to change the PWM frequency from default 500Hz to much higher values. Would 4kHz be enough for the carrier freq.?

Now I need to find out if it is possible to vary arduinos "PWM duty cycle" in sin waveform with 60 Hz and later to make ths 60Hz a variable that can be changed on the fly from 30-100%. I guess it would be easy to make 2 control signals out of one - just by inverting the signal. To prevent both of serial MOSFETS beeing switched "on" perhaps making a small gap would also be possible by making the output delayed for for some time when changing from 0 to 1.

Somme suggestions?
jm82792
I am too much of a newbie to know what to do,
I know basics but not that much and my experience is limited.

I'll look into it,
maybe sometime soon I can get help from a friend who codes for a profession and is to a lesser extent an electronics engineer....
That would be by the end of the year since that is when I'd be living by him.
mabviper
Yeah, I think 4kHz is enough for the carrier frequency. The higher the carrier frequency, the less harmonics (vibration, sound, etc) on the motor.

I have no experience w/ Arduinos but if you look at the code I posted, making is waveforms is relatively 'simple' o.o. Alot simpler than pure software coding anyways ^^;
jl7854
Here is a thread of someones Arduino AC Power Shield It is suppose to dim lights. I do not think it would work for the 120v Koralia but perhaps something useful may be gleaned from the code listings for use with this project.
tarzan
QUOTE (jl7854 @ Oct 27 2009, 03:14 AM) *
Here is a thread of someones Arduino AC Power Shield It is suppose to dim lights. I do not think it would work for the 120v Koralia but perhaps something useful may be gleaned from the code listings for use with this project.

I don't believe this would work very well with 120 V Koralias since it just changes the duty cycle of sine wave by switching it off berore the sine wave would reach zero. To regulate speed you need to regulate frequency...

I JUST GOT MY 12V KORALIA, I AM IN MAMA!!!!

One thouht about this 12V koralias:
since this output you are getting out of your controller is actually PWM generated 24V AC @60Hz has anybody tried to connect it to AC source (to a transformer that converts USA 120 V AC to 24V AC @60 Hz or in Europe to a transformer with 230:24 V AC @50Hz?????????????????? Would That Work???? You would of course have no speed control option, but you would at least have your Koralia working during the controller making process biggrin.gif
jm82792
Hmm I don't know,
coding that in arduino doesn't sound like a smart idea as I could see it getting way more complex since you are doing it at a lower level of coding.

I'm too much of a newbie to know where to start.

Plus I don't fully understand the code,
although the concept isn't that complex.

I'd stay away from trying to use the 120 line voltage ones,
more of a pain, there is a hazard and I'd stay away.....
jl7854
QUOTE (tarzan @ Oct 27 2009, 01:58 PM) *
I don't believe this would work very well with 120 V Koralias since it just changes the duty cycle of sine wave by switching it off berore the sine wave would reach zero. To regulate speed you need to regulate frequency...


QUOTE (jm82792 @ Oct 27 2009, 02:11 PM) *
Hmm I don't know,
coding that in arduino doesn't sound like a smart idea as I could see it getting way more complex since you are doing it at a lower level of coding.

I'd stay away from trying to use the 120 line voltage ones,
more of a pain, there is a hazard and I'd stay away.....


I never meant to suggest that I was planning on using the linked 120v Power shield. I thought I was clear that

"I do not think it would work for the 120v Koralia but perhaps something useful may be gleaned from the code listings"

As far as coding it in the Arduino not being a good idea because of complexity....some would say going the whole DIY route is too complex when you can buy a complete working Koralia Controller off the shelf. DIY is always going to be more complex than buying the completed item that you are trying to DIY. Now, if you think that it is not a smart idea to use the Arduino because there is no possible way for the hardware to send the proper signals to the circuit then that is a different story.

That being said, I would like to try programming the Arduino to send the signals for the 12v circuit that is on page one post #7 of this thread. I will be using the Arduino as well as a 12v Nano Koralia because I already have both.



tarzan
Nobody answered my question so I'll do it myself: About fixed frequency transformation from home line voltage to 24 V - i got the answer on this link. He hooked it up on a 12V AC power supply, but actually what the correct output voltage should be is higher than 12V AC and it should be 21 V AC. First I thought it should be just 16,97 V (that is 24V/square root of 2) since that is an effective voltage for square if you would use a square signal of 60Hz if the DC voltage powering it was supposedly 12V. Then I found this thread with oscilloscope readings of Koralia wavemakers output on which it is obvious, that they use 15V for H-bridge so the output is actually 30 Vpp (pick to pick). Devide it wih 1,41 and you get the 21V i mentioned earlier.

I am pretty sure that 20 V transformer rated for 5VA would just do magic cool.gif . Today I connected my koralia nano to a small transformer with output voltage 6V (measured with no load) that I had laying around from old DIY ATO, and Koralia did spin, but the flow it was producing was really really low. Also it had starting problems - not enough torque to start -rate of success was just 70%. Power consumption was just 1W (measured power the transformer drew from net) biggrin.gif

@mabviper: You never mentioned where you got this 60Hz from? In one of the post someone said he is using simple square wave and change the freq from 40 to 60 Hz, and one dude mentioned that they are actually 50Hz AC motors. I also read that you stated, that Vpp should be changed with frequency to avoid damaging motor, but I am not sure of that... Please explain tha logic behind that.

@jm82792, i think we should be asking questions about arduino on some other forum and then just come back with the results (hopefully good ones) ;D I am posting the problem tomorrow!

mabviper
@tarzan
hmm, your Vrms calculations are incorrect. Vrms is not calculated from Vpp (peak to peak). Vrms is calculated using Vp (peak) such that Vrms = Vp/sqrt(2). Evilc scoped out the controller output and it shows a peak to peak voltage of 30V, 15V peak. I'm not sure what Hydor meant by "12V" because it can either be 12Vrms or 12Vp. If it's 12Vrms, that means, from the equation, Vp has to be 16.97Vp. But we already saw the output waveforms so they can't be 12Vrms. So they have to mean 12Vp. As for the waveform showing 15Vp, it's very simple to knock the amplitude of the h-bridge down to 12Vp through software. Furthermore, the mosfets in the bridge aren't ideal switches. They do have a voltage drop across Drain and Source when they're ON. This depends on the current through the mosfet and the ONresistance of the mosfet. Having 15V to power the bridge and the motor allows a bit of flexibility when you factor in circuit losses.

As for the 60Hz frequency, I simply assumed because mostly all cheap AC motors operate at 60Hz just because 60Hz is the line voltage frequency in North America. It's more work for the engineers to design a motor to run at a specific frequency than to make it work at 60Hz. It's probably the same reason why somebody said it's a 50Hz motor because their line voltage frequency is 50Hz.

As for proportionally varying the voltage along w/ the frequency, it's a technique for controlling induction motors. It's called V/F control. When you control induction motors, it is essential that you vary V along side F to maintain the motor's torque curves. If you don't do it, the torque curve will be altered and you might end up having very low torque at motor startup. I said mentioned those things because I didn't know the type of these motors.

wow, that's alot of explainations o.o
I have a cyber stalker! lol. I remeber saying those things in RC about a year or so ago.
jm82792
QUOTE (jl7854 @ Oct 27 2009, 05:04 PM) *
I never meant to suggest that I was planning on using the linked 120v Power shield. I thought I was clear that

"I do not think it would work for the 120v Koralia but perhaps something useful may be gleaned from the code listings"

As far as coding it in the Arduino not being a good idea because of complexity....some would say going the whole DIY route is too complex when you can buy a complete working Koralia Controller off the shelf. DIY is always going to be more complex than buying the completed item that you are trying to DIY. Now, if you think that it is not a smart idea to use the Arduino because there is no possible way for the hardware to send the proper signals to the circuit then that is a different story.

That being said, I would like to try programming the Arduino to send the signals for the 12v circuit that is on page one post #7 of this thread. I will be using the Arduino as well as a 12v Nano Koralia because I already have both.

I appologize for not fully reading you're post about the arduino AC shield.

I am not saying don't do it,
but I've never been in any profession that involves coding,
I'm 17 and I've only dabbled enough to have a basic understanding of coding,
not enough to do this with arduino on my own.

If you could get it to work,
and I honestly think you should be able to do so,
that would be great then you could have a $40 wavemaker with a LCD and a basic button interface.
ls7corvete
Do you guys really want this running on Arduino?

I think after you get all the pump controller programming setup you wont have much room for anything else. Not sure how many outputs you will be able to configure. I think doing the setup in a reef controller(arduino? or other) then having it send instructions to the pump controller(whatever chip you set that up on) would be better. The main reef controller will already be setup for light timing etc. so adding pump timing and control that should be an easy add on that can send instructions to the slave.

You guys are mentioning RC threads, is there a thread there that is mirroring this one? Maybe we should start one, there is many skilled reefers there.
tarzan
QUOTE (mabviper @ Oct 28 2009, 03:15 AM) *
I have a cyber stalker! lol. I remeber saying those things in RC about a year or so ago.

LOL biggrin.gif Yes, I did a search on DIY Koralia Controllers that got me to RC forum and there were some post with "known" urername biggrin.gif biggrin.gif biggrin.gif

So eeee... what you are saying now is that V/f contorol is not needed here? Right?

As for my calculation - I am ashamed, really am, but you have to know that i was not thinking straight since it was almost 1 AM ... (i'm in GMT+1 ->Central Europe).

@jm82792 & ls7corvete
I think both methods should be explored. ls7corvetet's thoughts about controlling pump controller might be the best solution. I'll look into it, but would't mind having one arduino solely to control my pump -they are like 25$ happy.gif...
jm82792
Well that was a thought,
let the motor controller do it's thing and have it accept PWM input and use it to correlate with the frequency,
basically low level motor controller and using arduino as a higher level I/O.
ls7corvete
http://www.reefcentral.com/forums/showthre...ollable+koralia

Thought I would post the RC thread so we can call follow along and keep this thread alive.

IMHO, the hobby needs something like this more than a cheap reef controller. Though I do want both!
Pages: 1, 2

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc. | Copyright © 2001-2008 Nano-Reef.com