evive has two inbuilt motor control units with which you can control motors with a current limit of 1A each. It uses an SN754410NE Quad H-Bridge IC to control two DC Motors.
If you look at the SN754410NE chip, you will notice a u-shaped notch at one end. This helps you identify pin 1.
Pin 4, 5, 12, 13 are connected to ground.
Pin 16 is connected to 5V and pin 8 is connected to power voltage which can vary from 4.5V to 30V.
1A and 2A are connected to Arduino Mega Digital pin 28 and 29 respectively and 3A and 4A to digital pin 30 and 31. Depending on the states of the pins, the motor state is determined:
|Pin 30||Pin 31||State|
|LOW||LOW||Motor is free|
|LOW||HIGH||Motor rotates in one direction|
|HIGH||LOW||Motor rotates in another direction|
Motor is stalled
The outputs are provided from 1Y and 2Y (for motor 1) and 3Y and 4Y (for motor 2). This output is amplified voltage which is determined by enable pin (1 for motor 1 and 9 for motor 2). Hence if the VCC is 12V then to generate 6V output, one has to provide 2.5 V to enable pin. This is done using PWM (Pulse Width Modulation).
Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off.
The duration of “on time” is called the pulse width. To get varying analog values, you change or modulate, that pulse width. If you repeat this on-off pattern fast enough, the result is as if the signal is a steady voltage between 0 and 5v controlling the speed of the motor.
Generally, Arduino’s PWM frequency is about 500Hz. In Arduino IDE, we use PWM concept through analogWrite() function. We give a value ranging on a scale of 0 – 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example.
In evive, the PWM pin for motor 1 is connected to digital pin 44 and for motor 2 it is connected to digital pin 45.
VVR vs VVS
The power voltage can be provided to the motor drive IC through variable voltage or source voltage, using a jumper. So if you want to change the power voltage, then you connect to the VVR side (left one) else VVS (right).
You can control or test your motors through evive menu based system. You have to just navigate into control, select the motor and then select which motor output you want to use (Motor 1, Motor 2 or both Motor 1 and Motor 2).
Using inbuilt potentiometers, you can control the PWM of the motors and use slide switches you can control the state of the motor (CW, CCW or free state).
Controlling motor using Arduino IDE
If you don’t know how to use a library then you can visit here to learn more.
|dir1_pin||Integer||Stores pin no of direction1|
|dir2_pin||Integer||Stores pin no of direction2|
|pwm_pin||Integer||Stores pin no of PWM pin|
|dir1||Integer||Stores value of DIR1PIN as 1 or 0|
|dir2||Integer||Stores value of DIR2PIN as 1 or 0|
|pwm||Integer||Stores the PWM value is given to the motor|
|mean_speed||Integer||The value to which motor moves when speed=100%|
|speed||Float||Speed of the motor in the percentage of mean speed|
|damping||Integer||To be changed later by trial|
|Motor(int Dir1,int Dir2,int Pwm);||Constructor with attachments of pins|
|void attachMotor(int Dir1,int Dir2,int Pwm);||Attachments of pins|
|void moveMotor(int Pwm);||Positive for CW and negative for CCW|
|void moveMotor(int Dir1,int Dir2,int Pwm);||dir1 and dir2 can be 1 or 0,PWM can only be positive for CW|
|void stopMotor();||By default stop, motor will lock motor|
|void lockMotor();||To lock the motor|
|void freeMotor();||Free the motor|
|void setMeanSpeed(int Speed);||Sets the mean speed with which motor moves when speed=100%|
|void setMotorSpeed(int Speed);||Positive for CW and negative for CCW. Speed in the percentage of mean speed|
|void setMotorSpeed(int Dir1,int Dir2,int Speed);||dir1 and dir2 can be 1 or 0|
|void changePWM(int Pwm);||Just to change the PWM in whatever direction the motor was moving|
|void changeSpeed(int Speed);||Just to change the speed (In percentage) not the direction|
|int getDirection();||+1 for CW and -1 for CCW and 0 for free or locked|
|int isFree();||+1 for free and 0 for not free|
|int isLocked();||+1 for locked and 0 for not locked|
|int getSpeed();||Returns speed in % of mean speed|
|int getPWM();||Returns positive for CW and negative for CCW.|
|void startSmoothly(int Speed);||Positive for CW and negative for CCW.|
Using these library functions, you can control your motors easily. Here is a sample code to illustrate how to use the motor library: