A Script to analyse the change in velocity of a DC motor by using an uprising PWM signal.

Dependencies:   MODSERIAL mbed

Committer:
Wallie117
Date:
Wed Oct 07 11:48:44 2015 +0000
Revision:
1:290dc4628f1a
Parent:
0:97f11ee1c518
Authors change

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wallie117 0:97f11ee1c518 1 // ****************************************************** MOTORSHIELD Script for rising velocity ***************************************************
Wallie117 0:97f11ee1c518 2 // This script has been written to gaing knowledge how the motor reacts to diffrent PWM values.
Wallie117 0:97f11ee1c518 3 // This script may be used for research an industrial use.
Wallie117 1:290dc4628f1a 4 // Author: Robert v/d Wal, Lisa Verhoeven, Thijs van der Wal, Ewoud Velu, Emily Zoetbrood
Wallie117 0:97f11ee1c518 5
Wallie117 0:97f11ee1c518 6 // ********************************** LIBRARIES DECLARATION *******************************************
Wallie117 0:97f11ee1c518 7 #include "mbed.h"
Wallie117 0:97f11ee1c518 8 #include "MODSERIAL.h"
Wallie117 0:97f11ee1c518 9
Wallie117 0:97f11ee1c518 10 // ********************************** FUNCTION DECLARATION *******************************************
Wallie117 0:97f11ee1c518 11
Wallie117 0:97f11ee1c518 12 DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield)
Wallie117 0:97f11ee1c518 13 PwmOut motor2speed(D5);
Wallie117 0:97f11ee1c518 14
Wallie117 0:97f11ee1c518 15 // ****************************************************************************************************************************************************
Wallie117 0:97f11ee1c518 16
Wallie117 0:97f11ee1c518 17 // Script DC Motor velocity
Wallie117 0:97f11ee1c518 18
Wallie117 0:97f11ee1c518 19 int main()
Wallie117 0:97f11ee1c518 20 {
Wallie117 0:97f11ee1c518 21 double p =0;
Wallie117 0:97f11ee1c518 22 double j =0;
Wallie117 0:97f11ee1c518 23 motor2direction.write(1);
Wallie117 0:97f11ee1c518 24
Wallie117 0:97f11ee1c518 25 for(int i=0;i<11; i++)
Wallie117 0:97f11ee1c518 26 {
Wallie117 0:97f11ee1c518 27
Wallie117 0:97f11ee1c518 28 j = j +1;
Wallie117 0:97f11ee1c518 29 p = j*0.1;
Wallie117 0:97f11ee1c518 30 motor2speed.write(p);
Wallie117 0:97f11ee1c518 31 wait(0.4);
Wallie117 0:97f11ee1c518 32 }
Wallie117 0:97f11ee1c518 33
Wallie117 0:97f11ee1c518 34 }