universal motor speed control problem

hi
I’m trying to control a universal motor i get this code but i cant understand it
i want to increase the rpm until the analog read get 4v or 5v etc
i cant understand the (dim) (inc) and (i) and how can i stop the interrput

#include <TimerOne.h>
volatile int i=0;
volatile boolean zero_cross=0;
int AC_pin = 9;
int dim = 0;
int inc=1;
int freqStep = 75;

void setup() {
pinMode(AC_pin, OUTPUT);
attachInterrupt(0, zero_cross_detect, RISING);
Timer1.initialize(freqStep);
Timer1.attachInterrupt(dim_check, freqStep);

void zero_cross_detect() {
zero_cross = true;
i=0;
digitalWrite(AC_pin, LOW);
}

void dim_check() {
if(zero_cross == true) {
if(i>=dim) {
digitalWrite(AC_pin, HIGH);
i=0;
zero_cross = false; /
}
else {

i++;
}
}
}

void loop() {
dim+=inc;
if((dim>=128) || (dim<=0))
inc*=-1;
delay(50);
}

thank for reading

and how can i stop the interrput

Which one? There is one that is monitoring an AC sine wave, and triggering every time the wave crosses 0, and there is a timer interrupt.

The purpose of that code is to make the Arduino into a variable speed controller for AC devices.

Why would you want to stop either interrupt?

i want to increase the rpm until the analog read get 4v or 5v etc

Sorry, that doesn't make sense. If you want a limit on the analog value written to the pin, you are going about this wrong.

thanks dude
i want to increase the rpm until the analog pin red 700 or 1000, there is a tacho for the motor i get 40 v when the motor rpm is 14000
I cant find a way to code it
can you guide me
thanks for help

A normal "universal motor" does not have a "tacho" so you need to provide some idea what you are talking about (data sheet etc.). As for "40v" - if that is a true output, then you are going to have to scale it down to the 5v max the Arduino can look at - anything over the supply voltage of the Arduino can cause an input to go "poof" and let the magic smoke out.

its brushes motor
7 wire
2 for stator
2 for rotor
2 for tacho (40v when rpm is 14000)
1 for E

I'm trying to control a universal motor i get this code but i cant understand it

The Arduino Playground has a tutorial on AC Phase Control with an explanation of what the code is doing.

The playground code sets up the timer directly rather than using the Timer1 library. You control the speed with the OCR1A value.

Is the tachometer output voltage linear with rpm? Is the 4V you want = 14000/10 = 1400 rpm? You may be able to ramp the motor from 0 to 1400 rpm, but as gpsmikey suggests, you should design a voltage divider circuit to give the Arduino 5v maximum input voltage. You may actually want to design the divider to give 1V to the Arduino so you can use the internal 1.1v reference. See this thread http://forum.arduino.cc/index.php?topic=397590.0

Do you have any motor or tachometer specifications?

Cross-post, thread locked.

Sigh.