Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:97f11ee1c518, 2015-10-07 (annotated)
- Committer:
- Wallie117
- Date:
- Wed Oct 07 11:42:13 2015 +0000
- Revision:
- 0:97f11ee1c518
- Child:
- 1:290dc4628f1a
A script to look at the velocity change of a DC motor that works with signals of PWM.
Who changed what in which revision?
| User | Revision | Line number | New 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 | 0:97f11ee1c518 | 4 | // Author: Robert v/d Wal |
| 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 | } |