# why arduino nano is used

Now the Nano is going to control the speed of the motor using a 0 to 20 milliamp current loop. Now this is the circuitry here, so the Nana will output a pulse width, modulation signal into the circuitry between a 0 to 20 million current loop, so zero percent PWM signal will be zero current, which would be stopped on the motor and 100 percent. Pwm would be 20 milliamps in the current loop, which would be maximum speed on the motor. Now I put an LED in my current loop, so we could actually monitor the current through the brightness of the LED, and I got it mapped to the keyboard. So if I give it some PWM signal, you can see the current increasing on the LED and that’s 20 milliamp, so that would be maximum speed and I could take the speed down by decreasing the current down to zero. So I have total control of my keyboard. The speed of the motor from 0 to 20 milliamps now to control the direction of the motor, either clockwise or counter clockwise, or forward and reverse. I have I have an opto coupler feeding the digital input of the variable frequency drive, and so I can control the direction of the motor by sending a signal into the variable frequency drive. So if I send a clockwise signal you see, the left LED comes on. So that would be a clockwise or forward speed on the motor. Now, if I, if I type counterclockwise and send that into the motor, you can see now it’s reversed direction now it’s counter clockwise or reverse now, I’ll just stop.

If I send a stop signal, both LEDs will go off, so I think eight is stopped, so there’s two ways to stop the motor either by the digital input or by sending a zero milliamp current loop signal into the variable frequency drive: okay, here’s, the schematic diagram Of the variable frequency drive that I used in my project. If you look at the very left hand side, you can see the AC power input so that’s your single phase, input into terminals l1 and l3. If you look at the right hand side, you can see the three phase: power output on terminals, t1, t2 and t3 that’s feeding the three phase motor. Now you look at the very left hand side. You can see five push button switches, labeled s; 1. 2 s 5 and then there’s common terminal that’s your multifunction input, so you could program. Those switches do to do anything you want so I program a switch s1 and s2 to be my direction: control for clockwise and counter clockwise direction of the motor. So if I connect terminals s1 to common, my motor will spin clockwise and if I connect my terminals s2 to common, my motor will spin counterclockwise and if both are open circuit, then the motor will stop and that’ll be an inverter. Stop that be a power. Stop itstop by killing the power from the inverters to the motor. Now, instead of using push button switches, I use two optocouplers that have been driven by the nanos GPIO to control my clockwise and counterclockwise control.

If you look further down on the left hand side, you can see the AC. I input that’s analog current input, that’s your 0 to 20 milliamp and that’s used to control the speed of the motor. So my Nano can control at 0 to 20 milliamp current loop and that’s fed into the AC I input. So I control the speed using my 0 to 20 million current loop and I use my melted function, input s1 and s2 to control my my Direction control. So with with these inputs and my Nano, I have total control over my three phase: motor. Ok, my variable frequency drive is powered up and you can see the forward LEDs, blinking, so it’s in the forward mode and the front part is disabled. It’S not controlling the speed, so the Arduino Nano is controlling the speed of the variable frequency drive through the 20 milliamp current loop interface. But you can see on the on the strip here: it’s labeled, a CI for analog current input, and you can see the two wires they’re feeding the analog current input. If you look at the very left, you can see a switch 1 and switch 2 that’s. My forward reverse control, that’s hooked up to the Nano. So if I give, if I give some current into the 20 milliamp current loop into the into the motor, you can see it being activated. So now the motor is starting to spin. I got I got the motor running if you pick it up and I can take it down so I’m controlling it through the narrow controlled by my keyboard, all the way back down to stop okay.

This is my three phase motor and I have a coupled up to a gear drive. This is the gear drive here. You could get it in different gear ratios and this is the output of the drive, so he put in some keyed round stock into here and that will drive that will drive your project. So if I give, if I give some current into my current loop through my keyboard, I can start up the motor and if you look at my breadboard, you can see my my clockwise led is on my direction, LED so it’s gon na run clockwise so I’ll Give it some current, I can slowly bring it up, it’s running clockwise. I can bring it up to speed or I can bring it back down just by changing the current in the current loop I’ll, bring it all the way back down to stop so in. In my code, the way I would control the speed of the motor, I would give it a percentage value. So, if you look at, if we look at the breadboard, you can see my my clockwise led is on so I’ll. Give I’ll give it 50 I’ll tape that onto my keyboard 50, so that would be 12 my speed. So she goes up to half speed. I go 20 percent, that’d be 20 percent drive and you can see it’s running clockwise and I could actually change it to counterclockwise for the keyboard. Well, she changes direction and it’ll go to the same speed as if it was in clockwise.

So the speed doesn’t change. So I could alternate between clockwise and counterclockwise and around the same speed, so I’ll take it up to 100, so it’s maximum speed and I’ll take it down to 0. That takes it back down to stop okay, here’s the code running on my Nano to control. My three phase motor now this code is written in forth, so I could execute the code from the keyboard for troubleshooting now I’m using timer counter number one on the Nano and I’m configuring that as mode 14, so that’s fast, PWM and I’m using a pre scale. I’Ll divide by one so I’m, using the full 16 megahertz clock to drive the PWM circuitry. Now the output of the PWM will be out of pin 9, so I’ve set. Pin 9 is an output in the GPIO and I’ve entered the value of 2015 into into my input capture register that sets my t.o.p might assess my top value, so the counter will count from 0 to 2015 and then back down to zero gain and I’ll continue On over and over again now giving my pulse width modulation period, so all I have to do is enter a value into into the output. Compare register. To give me my pulse width, so I enter a value from 0 to 2015 and they’ll. Give me my pulse width, so the next word is an it opto, and that sets up my up two Isolators and they’re on pin 7 and pin 8 so I’m setting them as outputs and I’m driving them low and they’ll control my direction.

My clockwise my counter. Clockwise direction on my up two Isolators, so next four words are the heart of the commands. The first word is percent. So if I type zero percent I’ll get a stop speed. If I type 100 percent I’ll get maximum speed. So if I type 50, it will take 50 multiplied it by 2015 and divided by 100, and that value will putting it will be put into the output compare register, which will give me a pulse width to drive my motor at 50 speed. So next is stop and I will set my up to Isolators for a stock configuration and clockwise will set my optimized they up to Isolators for clockwise, also for counterclockwise. Now this next word demo is going to use these commands in the sequence and alright, it will run this sequence and it will control this motor in each step here, as we can see each command. So what I’ll do actually run this program on? On my on my motor and we could actually see it respond to the demo program just a little silly program, but it just will give you an idea how to send sequence commands to the motor. Now on the very bottom, we see 0 and that’s that’s that’s. A 0 stop, so it actually will stop the motor by sending the frequency to zero or Hertz. Now the next stop is to stop by the up the Isolators and that’s real actual that will kill the inverter power to the motor to stop it.

But the speed information is intact. So as soon as you go to a direction like clockwise you’ll resume the last speed that it saw. But if you stop the motor with a 0, then you got to ramp up the speed to whatever a desired speed that you want. So next we’ll actually run this demo program and see how the motor responds okay, I’m gon na run my little demo program. So it’s my little silly program, it really doesn’t do anything it’s, just a demo on some sequence programming, so watch the direction and speed of the motor and watch the two Direction. Leds and we’ll go through our sequence code. So I’ll start that now so it’s. First of all, it’s gon na go into stop mode for two seconds then watch the clockwise LED come on for three seconds and it’s gon na go to 50 speed for 5 seconds and then 20 speed for 5 seconds that’s clockwise. Now it changes to counterclockwise for 5 seconds. Let’S go 100 for five seconds, that’s a zero percent. That’S frequency stopped for five seconds. The nail they deal will change the clockwise and will hold there for five seconds and go up to 75 percent speed clockwise for eight seconds. They’Ll. Do a zero percent? Stop and it’ll go to a digital? Stop you see the LED go out. Okay, if you want to control your own three phase motor, but you don’t want to build the circuitry involved.

You could get two off the shelf PWM to current or voltage signal converter like this one here made by axiomatic. So you could get a PWM to 0 to 20 milliamps or a PWM from 0 to 10 volts, and you could use either one of these to feed. The variable frequency drive like that when I was using to control your own three phase motor.

# why arduino nano is used Social

official.arduino
2019-10-25T18:08:03+0000

Last weekend we announced that we’re working on a new development environment with advanced features. Let’s take a deeper look at what is in store for the Arduino Pro IDE!
official.arduino
2019-10-25T15:12:36+0000

“Let us change the world by making technology accessible to everyone and put it into the hands of every student and educator.”

viewdemy
Mon Jul 26 16:33:28 +0000 2010

https://t.co/RtIWDVDBEY

https://t.co/RtIWDVDBEY

(Visited 24 times, 1 visits today)

## Comment (48)

1. Ishwar pandhare says:

Hello sir can you send me the circuit diagram

1. Ishwar pandhare says:

Thank you sir

2. Punit Patel says:

Try using Modbus RTU on RS485 port to control your 3-ph motor.

1. 0033mer says:

Yes .. that is another option. The VFD will operate with Modbus RTU control. I have used MAX485/487 interfaces with the Nano for Modbus ASCII control. Modbus RTU control with Arduino Nano is a bit involved and better suited for PLC or PC control.

3. Rainer Kresken says:

Hi! Thanks a lot! Could you please explain a bit how the circuit converts PWm to controlled current?

1. Rainer Kresken says:

Thanks!

2. Rainer Kresken says:

Both videos are really very helpfull to me! Thanks for sharing your knowledge!

4. rodstartube says:

WRONG TITLE. IT SHOULD SAY: “HOW TO CONTROL A VFD”

5. Sompong Tungmepol says:

//Arduino Atmega 168 Atmega 328P 3 phase induction motor Variable Speed Controller //Code
// Complier By Arduino Version 101 Version 106 Software
//รุ่นนี้เป็นแบบ AUTO RE RUN โค๊ดนี้ใช้วอลลุ่ม 5KB ตัวเดียวทำหน้าที่ ปิด -ปิด ปรับรอบ ให้ใช้ R //4K7 ต่อ ไฟ+5Vdc แล้วต่อเข้า ขาข้างด้าน + MAX ของ VR ต่อ R 1K-10 K ต่อ เข้า A3 ของ //ATmega 168 ATmega 328 P
#define UN (400.0) //napiecie znamionowe silnika
#define FN (50.0) //czestotliwosc znamionowa silnika
#define P (UN/FN) //wsp. okreslajacy proporcje napiecia do czestotliwoci znamionowej
#define T_PWM (0.000255) //okres sygnalu PWM – ustawiony przez preskaler w licznikach
#define T_MAX (4.0) //okreslenie maksymalnego okresu napiecia wyjsciowego
#define T_MIN (0.02) //minimalny okres napiecia wyjsciowego
#define K_MAX floor(T_MAX/T_PWM) //liczba wartosci okresu dla T_MAX
#define K_MIN ceil(T_MIN/T_PWM) //liczba wartosci okresu dla T_MIN

volatile static unsigned int dlugosc_tab_sin; //zmienna zawierajaca liczbe wartosci w pelnym
//okresie napiecia wyjsciowego
static unsigned int i = 0; //zmienna pomocniacza
volatile static unsigned int licznik_glowny = 0;//zmienna wystepujaca w przerwaniu czyklicznie
//^ co okres T_PWM zwiekszajaca swoja wartosc o 1
static unsigned int next_value_sin = 0; //zmienna ktora wartosc sin nalezy obliczyc
static double t_param=100; //parametr okreslajacy okres napiecia wyjsciowego
static float t = T_PWM; //T_PWM
static float omega_t; //pulsacja napiecia wyjsciowego pomnozona przez T_PWM
static float t_out; //okres wyjsciowy napiecia
static float U_o_param; //parametr okreslajacy wielkosc napiecie wyjsciowego
//^ obliczony na podstawie t_out i U_in
static unsigned int ocr0a, ocr0b, ocr1a;//zmienne pomocnicze do przechowywania obl. wypelnien
static unsigned int ocr1b, ocr2a, ocr2b;//^
static double sin_in; //zmienna zawierajaca parametr funkcji sin
static double blad = 1; //zmienna uzyta do zatrzymania generowania napiecia przy przeciazeniu
static unsigned int analog=0; //zmienna zawierajaca zmierzona wartosc
static double U_in = 0; //zmienna przechowujนca pomiar napiecia ukladu posredniczacego
static double U_rms_max; //maksymalna aktualnie mozliwa do generacji wartosc skuteczna napiecia
static bool a=0; //zmienna logiczna do realizacji dwoch naprzemiennych pomiarow
int main()
{
io_init(); //inicjalizacja wejsc i wyjsc
timers_init(); //inicjalizacja licznikow PWM
while(1) //nieskonczona petla z programem glownym
{
if(i==185) //warunek okreslajacy wejscie do funkcji zmiany
{ //parametrow napiecia wysjciowego, wywolanie co okolo 100ms
zmien_predkosc(); //funkcja zmiany parametrow napiecia wyjsciowego
i=0;
}
next_value_sin = licznik_glowny%dlugosc_tab_sin; //kolejna wartoœๆ sinusa do obliczenia
sin_in=omega_t*next_value_sin;

//obliczenie wartosci do rejestrow okreslajacych wypelnienie sygnalu wyjscioweg/
ocr0b = ocr0a – 1;
ocr1b = ocr1a – 1;
ocr2b = ocr2a – 1;

//uaktualnienie wartosci w rejestrach/
cli(); //zabronienie na obsloge przerwan na wypadek gdyby
//podczas uaktualniania wystapilo przerwanie
OCR0A = ocr0a; //pin 6
OCR0B = ocr0b; //pin 5
OCR1AL = ocr1a; //pin 9
OCR1BL = ocr1b; //pin 10
OCR2A = ocr2a; //pin 11
OCR2B = ocr2b; //pin 3
sei(); //zezwolenie na obsloge przerwan
i++;
}
}
{
ADMUX |= _BV(REFS0);// napiecie odniesienia ustawione jako napiecie zasilania
}
void timers_init()
{
cli(); // obsloga przerwan zabroniona
//timer0 init
TCCR0A |= _BV(COM0A1) | _BV(COM0B0) | _BV(COM0B1) | _BV(WGM00);
TCCR0B |= _BV(CS01); //preskaler 8
TIMSK0 |= _BV(TOIE0); //flaga od wartosci 0 wlaczona
//timer1 init
TCCR1A |= _BV(COM1A1) | _BV(COM1B0) | _BV(COM1B1) | _BV(WGM10);
TCCR1B |= _BV(CS11); //preskaler 8
//timer2 init
TCCR2A |= _BV(COM2A1) | _BV(COM2B0) | _BV(COM2B1) | _BV(WGM20);
TCCR2B |= _BV(CS21); //preskaler 8
//zerowanie wartosci licznik๓w
TCNT0 = 0;
TCNT1L = 0;
TCNT2 = 0;
/* licznik zlicza w g๓re do 255, nastepnie w d๓ณ: /\/\/\
przy wartosci 255 jest przerwanie przy ktorym dokonuje sie
*/
sei(); //zezwolenie na obsloge przerwan
}
void io_init()
{
pinMode(6, OUTPUT); //OC0A
pinMode(5, OUTPUT); //OC0B
pinMode(9, OUTPUT); //OC1A
pinMode(10, OUTPUT);//OC1B
pinMode(11, OUTPUT);//OC2A
pinMode(3, OUTPUT); //OC2B
pinMode(2, INPUT);
pinMode(4, INPUT);
pinMode(12, OUTPUT);
}
ISR(TIMER0_OVF_vect) //przerwanie przy wartosci 0 licznika0
{
if(a)
{
U_in = 0.0709*analog;
}
else
{
if(analog>579)
{
blad = 0; //jezeli przeciazenie wylaczenie generacji napiecia
digitalWrite(12, HIGH); //zapalenie diody
}
}
a=a^1; //bramka XOR neguje wartosc logiczna a
licznik_glowny++;
if(licznik_glowny>=dlugosc_tab_sin) licznik_glowny = 0;
}
void zmien_predkosc()
{

U_rms_max = U_in*0.62; //wartosc 0.62 wyzanczona eksperymentalnie
bool up; //zmienna logiczna, informuje o nacisnietym przycisku zwieksz czestotliwosc
bool down; //zmienna logiczna, informuje o nacisnietym przycisku zmiejsz czestotliwosc
up = digitalRead(4); //odczyt: czy nacisniety przycisk zwieksz czestotliwosc
down = digitalRead(2); //odczyt: czy nacisniety przycisk zmiejsz czestotliwosc
if(up==1) t_param–; //jezeli nacisniety przycisk zwieksz czestotliwosc to zmiejsz okres
if(down==1) t_param++; //jezeli nacisniety przycisk zmniejsz czestotliwosc to zwieksz okres
if(t_param<0) t_param=0; //zabezpieczenie przekroczenia wartosci skrajnych
if(t_param>100) t_param=100;//^
dlugosc_tab_sin = ceil((K_MAX-K_MIN)*t_param/500+K_MIN);//ilosc wartosci wypelnien w jednym okresie
t_out = T_PWM*dlugosc_tab_sin; //obliczenie okresu napiecia wyjsciowego
omega_t = t*2*PI/t_out; //obliczenie pulsacji napiecia wyjsciowego
U_o_param = (P/t_out)/U_rms_max; //obliczenie parametru okreslajacego wielkosc napiecia wyjsciowego
if(t_out>1) U_o_param = 0.5*(18.5/U_rms_max); //napi๊cie na wyjsciu przy niskiej czestotliwo

1. chatchai Kareeram says:

Sompong Tungmepol ขอบคุณครับ

6. Rishabh Gambhir says:

Hey, can you tell me exact materials required to make a model of- “speed control of three phase induction motor by pwm” n to make link with matlab simulink.?

7. 陈禹 says:

can i use the code control the single phase ac motor?

1. 陈禹 says:

0033mer thanks a lot if i want to use arduino to controll single phase acmotor （we need build a Ac motor electrical racing car ）is it a good way like using arduino nano like this to control speed ？ can you give us some advice thanks a lot！

8. Lorch Service says:

Clickbait. You cant do any 8-bit ARM 3-f motor control. Maybe AT90PWM3 but doubting.

1. Ahapid says:

you can actually.

9. Sayan Biswas says:

Where I have to write the program? IDE or any other software

1. 0033mer says:

The program was written in Forth but you can use the Arduino IDE.
Any PWM sketch can be used to create a 20 mA current loop or 0 – 10 volt output using the Arduino Nano’s timer/counter
Check out this video: https://youtu.be/VcqCR7IOatw

2. Sayan Biswas says:

please don’t mind sir, actually I am not getting the code structure, What portion I should write in void setup() part and what portion to void loop() part? sir please help me.

actually I want the same function you have shown over here, from my 3-phase ac motor but I need a little help regarding the program and circuit diagram given in this video. sir please help me.

3. 0033mer says:

You can also use a 0- 10 volt signal into the VFD to control a 3 phase motor.
You might find this easier to implement.
https://youtu.be/gRWDG9JhyDs

stop wasting our time

1. 0033mer says:

If you would of read the description box first you would of seen this is a grade 8 electronics class lab and tutorial on breadboarding and Atmega328 programming. If this is not at your level there are other channels available on Youtube.

WRONG TITLE. IT SHOULD SAY: “HOW TO CONTROL A VFD

11. WallStreet Review says:

Well done this is a very practical industrial application truly simplified. No need expensive plc controller or ladder logic programming to achieve this.

WRONG TITLE. IT SHOULD SAY: “HOW TO CONTROL A VFD

13. Truth Power Info. says:

Hy bro,i m your big fan,i need your help plz,i wanna connact anduino with VFD and run some progrms plz help me bro,and I will give you money for your work,facebook/devthakurhps, I m waiting for you

14. Magnus sjöstrand says:

What is the value of these two capacitors?

15. Ruby Selvam says:

Can you share the program

1. 0033mer says:

Code starts at 6:25

16. Brandt Cameron says:

Would this same configuration work for a 220v outlet. I have an MCG AB 34000 and I am trying to run our braiding machine for it, and your setup seems about the same thing we are going for. Appreciate the video

1. 0033mer says:

My setup is an induction motor controlled by a VFD. Your have a servo motor which needs a servo controller. Check with MCG.

2. Brandt Cameron says:

@0033mer They have been out of business for a while now, so very hard to find information on, but I will see what I can do. Thank you

3. Brandt Cameron says:

I just acquired a pwm brushless servo drive, and was still wondering if your arduino setup would be able to control it?

4. 0033mer says:

Check the user manual for your drive and see what control lines you need. Any microcontroller or PLC can be used to control the drive. Servo motor control is closed looped so the code would be quite different than VFD control.

5. Brandt Cameron says:

@0033mer Thank you

17. Sankar R says:

try to control via modbus….

1. K9 says:

check out his other video on modbus control.

18. ginskey matrix says:

can it be controlled by arduino using bluetooth sir?

19. Sompong Tungmepol says:
20. miesjeweet says:

Thanks for this video! i am using arduino digital output to connect / disconnect the common with S1 on VFD using an optocoupler (MOC3020) just like you do. Although when I write HIGH to the digital output pin, the optocoupler causes the VFD changes state, but when I write LOW to the pin, the VFD doesnt change back its state.. But stays ‘on’ the specific state. Any idea what I am doing wrong here?

1. 0033mer says:

Check the VFD user manual to see how your switch inputs are programmed. S1 might latch and another switch input might unlatch and switch modes. Use a jumper wire to check operation first on your VFD.

2. miesjeweet says:

@0033mer hmm. i dont think that is the case: i tested the operation of the switch between 24V and S1 (or S2 S3 S4) with a wire making the connection. when unreleasing the wire you see immediately on the VFD display the changes… Actually I also have the TECO L510s ! any thoughts? maybe the optocoupler? I use MOC3020

3. 0033mer says:

The problem is your optocoupler. The output switching device is a Triac which latches on and stays on when triggered. You need an optocoupler with a transistor output.

4. miesjeweet says:

@0033mer Ah! Thanks so much! This is what I was looking for