Assa teamet / Mbed 2 deprecated SixstepInInterrupt

Dependencies:   mbed

Committer:
johmal
Date:
Wed Jun 11 11:28:03 2014 +0000
Revision:
0:8dc0f972a984
oyo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
johmal 0:8dc0f972a984 1 #include "mbed.h"
johmal 0:8dc0f972a984 2 // Att gora
johmal 0:8dc0f972a984 3
johmal 0:8dc0f972a984 4 // Select pins for
johmal 0:8dc0f972a984 5 // Kolla hur man gar fran string till binary
johmal 0:8dc0f972a984 6
johmal 0:8dc0f972a984 7 InterruptIn event1(p15);
johmal 0:8dc0f972a984 8 InterruptIn event2(p16);
johmal 0:8dc0f972a984 9 InterruptIn event3(p17);
johmal 0:8dc0f972a984 10
johmal 0:8dc0f972a984 11 InterruptIn stoppHallEvent1(p13);
johmal 0:8dc0f972a984 12 InterruptIn stoppHallEvent2(p14);
johmal 0:8dc0f972a984 13
johmal 0:8dc0f972a984 14 DigitalOut led1(LED1);
johmal 0:8dc0f972a984 15 DigitalOut led2(LED2);
johmal 0:8dc0f972a984 16 DigitalOut led3(LED3);
johmal 0:8dc0f972a984 17 DigitalOut led4(LED4);
johmal 0:8dc0f972a984 18
johmal 0:8dc0f972a984 19 Ticker VoltStep;
johmal 0:8dc0f972a984 20
johmal 0:8dc0f972a984 21 //Directions of rotation (rotor side)
johmal 0:8dc0f972a984 22 #define dirClock 0
johmal 0:8dc0f972a984 23 #define dirCounter 1
johmal 0:8dc0f972a984 24
johmal 0:8dc0f972a984 25
johmal 0:8dc0f972a984 26 int Frequency=100000; //Hz
johmal 0:8dc0f972a984 27 int X=0;
johmal 0:8dc0f972a984 28 int tim=0;
johmal 0:8dc0f972a984 29 char dir;
johmal 0:8dc0f972a984 30 int dutyPin;
johmal 0:8dc0f972a984 31 //IN funkar: int Voltage1[]={8,17,25,33,42,50,58,67,75,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,83,79,48,25,19,16,20,26,32,37,39,38,36,33,36,34,34,34,36,38,41,41,40,37,37,34,31,28,27,28,30,32,34,37,41,42,42,41,41,39,36,34,32,31,31,31,31,32,33,34,35,36,38,39,43,43,42,40,36,33,30,29,29,30,32,34,35,36,36,37,38,39,41,42,42,39,36,33,30,29,29,30,32,33,36,37,38,39,39,41,42,41,40,37,35,32,31,30,30,31,33,34,36,37,38,39,41,42,42,41,39,36,33,31,30,30,31,32,34,35,37,38,39,40,41,42,42,40,38,35,32,31,30,31,32,33,35,36,38,39,40,41,42,43,42,39,37,34,32,31,30,31,33,34,36,37,38,39,40,42,43,43,41,39,36,33,31,31,31,32,34,35,37,38,39,40,41,43,43,42,40,37,34,32,31,31,32,33,35,36,38,39,40,41,42,43,43,42,39,36,34,32,31,31,32,34,36,37,39,40,41,42,43,44,43,41,38,35,33,32,31,32,33,35,37,38,39,40,41,43,44,44,43,40,37,34,33,32,32,33,35,36,38,39,40,41,42,44,44,44,41,39,36,34,32,32,33,34,36,37,39,40,41,42,43,44,44,43,40,37,35,33,32,32,33,35,36,38,39,40,42,43,44,45,44,42,39,36,34,33,32,33,34,36,38,39,40,41,42,44,45,45,44,41,0,0,0,0};
johmal 0:8dc0f972a984 32 /*IN funkar ej*/ //int Voltage[]={50,58,67,75,83,92,97,92,87,83,82,81,79,77,75,75,77,79,79,78,77,75,73,71,68,66,64,64,64,64,64,64,64,64,64,62,63,65,66,66,66,66,66,66,66,63,63,63,63,64,64,64,64,64,63,62,62,63,64,64,64,64,64,64,64,62,62,62,63,63,63,63,63,63,63,61,62,62,63,63,63,63,63,63,63,61,61,62,62,62,62,62,62,62,62,61,61,62,63,63,63,63,63,63,63,61,61,62,62,63,63,63,63,63,63,61,61,62,62,62,62,62,62,62,62,60,60,61,61,62,62,62,62,62,61,60,60,60,61,61,61,61,61,61,61,59,60,60,60,61,61,61,61,61,61,59,59,60,60,60,60,60,60,60,60,59,59,60,60,60,60,60,60,60,60,59,59,60,60,60,60,60,60,60,60,59,59,60,60,60,60,60,60,60,60,59,59,60,60,61,11,11,11,11,11,9,9,10,10,10,10,10,10,10,10,9,9,9,10,10,10,10,10,10,10,9,9,9,9,10,10,10,10,10,10,8,8,9,9,9,9,9,9,9,9,8,8,8,9,9,9,9,9,9,9,7,7,8,8,8,8,8,8,8,8,7,7,8,8,8,8,8,8,8,8,7,7,8,8,8,8,8,8,8,8,7,7,8,8,8,8,8,8,8,8,7,7,8,8,9,9,9,9,9,9,8,8,8,8,9,9,9,9,9,9,8,8,8,8,8,8,8,8,8,8,7,7,7,8,8,8,8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,7,7,7,7,7,7,7,6,6,6,7,7,7,7,7,7,7,6,6,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,7,7,7,7,8,8,8,8,8,8,7,7,7,7,7,8,8,8,8,7,7,6,6,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,6,6,6,6,7,7,7,7,7,7,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,5,6,6,6,6,6,6,6,6,5,5,5,6,6,6,6,6,6,6,5,5,5,6,6,6,6,6,6,6,5,6,6,6,6,6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43,40,39,39,35,35,35,36,39,41,41,41,41,41,37,37,37,37,38,39,39,39,39,39,35,35,35,35,37,38,38,38,38,38,34,34,34,34,36,37,37,37,37,37,33,33,33,33,35,36,36,36,36,36,31,31,31,32,34,35,35,35,35,35,31,31,31,32,33,34,34,34,34,34,30,30,30,31,33,34,34,34,34,34,29,29,29,31,32,33,33,33,33,33,28,28,28,30,31,32,32,32,32,32,28,28,28,29,31,32,32,32,32,32,27,27,28,29,31,31,31,31,31,31,27,27,28,29,30,31,31,31,31,31,27,27,27,28,30,30,30,30,30,30,26,26,26,27,28,29,29,29,29,29,25,25,25,26,28,28,28,28,28,28,24,24,25,26,27,27,27,27,27,27,23,23,24,26,27,27,27,27,27,27,24,24,25,26,27,27,27,27,27,27,24,24,25,26,28,28,28,28,28,28,25,25,26,27,28,28,28,28,28,27,25,25,25,26,27,27,27,27,27,26,23,23,24,25,26,26,26,26,26,25,22,22,23,24,24,25,25,25,25,24,21,22,22,23,24,25,25,24,24,24,22,22,22,23,24,25,25,25,25,24,22,22,23,23,24,25,25,25,24,24,22,22,22,23,24,24,24,24,23,23,21,21,21,22,23,23,23,23,23,22,20,20,21,21,22,22,23,23,22,22,20,20,21,21,22,22,22,22,22,22,20,20,21,21,22,23,23,23,23,23,21,21,22,22,23,23,23,23,23,23,22,21,22,22,23,23,23,23,23,22,21,21,21,22,22,22,23,22,22,21,20,20,20,21,21,21,22,21,21,21,20,20,20,20,21,21,21,21,21,21,20,20,21,21,22,22,22,22,22,22,21,21,21,22,22,22,22,22,22,22,21,21,21,21,21,22,22,21,21,21,20,20,20,20,20,21,21,21,20,20,19,19,19,20,20,20,20,20,20,20,19,19,19,20,20,20,21,21,21,21,20,20,20,21,21,22,22,22,22,22,21,21,21,21,21,21,22,21,21,21,20,20,20,20,20,20,20,20,20,20,19,19,19,19,19,20,20,20,19,19,19,19,19,19,20,20,20,20,20,20,19,19,20,20,20,21,21,21,21,21,20,20,20,21,21,21,21,21,21,21,20,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19,19,19,19,19,19,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,19,19,20,20,20,20,20,21,20,20,20,20,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19,19,19,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19,19,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,19,19,19,19,19,19,19,19,19,19,19,18,18,18,18,18,18,18,18,18,18,18,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,18,18,18,18,18,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,18,18,18,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,18,18,18,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,18,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,18,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,14,13,13,12,11,10,10,10,10,11,10,9,8,8,7,6,6,6,6,7,7,7,7,7,7,7,7,6,6,7,7,7,7,7,7,7,6,5,4,6,6,6,6,6,6,6,5,4,4,5,5,5,5,5,5,5,4,4,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,4,6,6,6,6,6,6,6,5,4,4,5,5,5,5,5,5,5,4,3,3,4,4,4,4,4,4,4,3,3,2,3,3,3,3,3,3,3,3,2,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,0,0,0};
johmal 0:8dc0f972a984 34 //int Voltage[]={10,20,28,34,34,34,38,42,47,50,51,51,51,50,47,42,42,42,42,42,41,38,35,34,34,30,30,30,31,34,36,36,36,36,36,32,32,32,32,33,34,34,34,34,34,30,30,30,30,32,33,33,33,33,33,29,29,29,29,31,32,32,32,32,32,28,28,28,28,30,31,31,31,31,31,26,26,26,27,29,30,30,30,30,30,26,26,26,27,28,29,29,29,29,29,25,25,25,26,28,29,29,29,29,29,24,24,24,26,27,28,28,28,28,28,23,23,23,25,26,27,27,27,27,27,23,23,23,24,26,27,27,27,27,27,22,22,23,24,26,26,26,26,26,26,22,22,23,24,25,26,26,26,26,26,22,22,22,23,25,25,25,25,25,25,21,21,21,22,23,24,24,24,24,24,20,20,20,21,23,23,23,23,23,23,19,19,20,21,22,22,22,22,22,22,18,18,19,21,22,22,22,22,22,22,19,19,20,21,22,22,22,22,22,22,19,19,20,21,23,23,23,23,23,23,20,20,21,22,23,23,23,23,23,22,20,20,20,21,22,22,22,22,22,21,18,18,19,20,21,21,21,21,21,20,17,17,18,19,19,20,20,20,20,19,16,17,17,18,19,20,20,19,19,19,17,17,17,18,19,20,20,20,20,19,17,17,18,18,19,20,20,20,19,19,17,17,17,18,19,19,19,19,18,18,16,16,16,17,18,18,18,18,18,17,15,15,16,16,17,17,18,18,17,17,15,15,16,16,17,17,17,17,17,17,15,15,16,16,17,18,18,18,18,18,16,16,17,17,18,18,18,18,18,18,17,16,17,17,18,18,18,18,18,17,16,16,16,17,17,17,18,17,17,16,15,15,15,16,16,16,17,16,16,16,15,15,15,15,16,16,16,16,16,16,15,15,16,16,17,17,17,17,17,17,16,16,16,17,17,17,17,17,17,17,16,16,16,16,16,17,17,16,16,16,15,15,15,15,15,16,16,16,15,15,14,14,14,15,15,15,15,15,15,15,14,14,14,15,15,15,16,16,16,16,15,15,15,16,16,17,17,17,17,17,16,16,16,16,16,16,17,16,16,16,15,15,15,15,15,15,15,15,15,15,14,14,14,14,14,15,15,15,14,14,14,14,14,14,15,15,15,15,15,15,14,14,15,15,15,16,16,16,16,16,15,15,15,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,14,14,15,15,15,15,15,16,15,15,15,15,15,15,15,15,15,15,15,15,14,14,14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,14,14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13,13,13,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,14,14,14,14,14,13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,8,8,7,6,5,5,5,5,0,0,0};
johmal 0:8dc0f972a984 35 /*OUT no smooth*/ // int Voltage[]={27,55,83,83,83,83,83,83,83,61,12,0,83,83,83,61,20,0,0,0,0,0,83,83,83,83,59,18,0,0,0,0,83,83,83,82,41,4,0,0,0,0,83,83,83,80,40,4,0,0,0,0,83,83,83,72,34,0,0,0,0,0,83,83,83,67,30,0,0,0,0,0,83,83,83,61,25,0,0,0,0,0,83,83,83,57,22,0,0,0,0,2,83,83,83,53,20,0,0,0,0,0,83,83,83,50,17,0,0,0,0,0,83,83,79,47,16,0,0,0,0,0,83,83,77,46,15,0,0,0,0,0,83,83,74,44,14,0,0,0,0,1,83,83,73,43,14,0,0,0,0,5,83,83,70,41,13,0,0,0,0,2,83,83,63,35,10,0,0,0,0,7,83,80,59,32,7,0,0,0,0,9,83,77,56,30,7,0,0,0,1,10,80,75,55,30,8,0,0,0,3,12,78,73,54,30,9,0,0,0,5,15,77,72,53,30,9,0,0,0,8,23,75,72,54,32,13,0,0,1,9,26,72,67,50,29,10,0,0,1,9,25,68,64,48,28,10,0,0,1,9,26,65,61,46,27,10,0,0,2,9,17,62,58,44,26,11,1,0,4,11,19,62,58,44,26,12,1,0,4,12,19,60,57,44,27,13,4,1,6,13,20,57,53,41,26,12,4,2,6,12,20,55,51,40,25,12,3,2,5,12,18,52,49,38,25,12,4,2,5,12,21,49,47,37,24,13,5,3,7,12,18,48,46,36,24,13,7,5,8,14,19,47,46,37,25,15,9,7,10,15,20,45,43,34,24,15,9,7,10,14,26,43,42,34,24,14,8,7,9,13,24,41,40,33,23,14,9,7,9,13,18,39,38,31,23,15,10,8,10,14,21,39,38,31,23,16,11,9,11,15,21,39,38,32,24,17,13,11,14,17,20,38,36,30,22,15,12,11,12,15,22,35,34,29,21,15,11,10,12,15,19,34,33,28,21,15,12,11,12,15,18,33,32,27,21,16,12,12,13,16,19,33,32,28,22,17,14,13,15,17,20,34,33,29,24,19,15,14,15,16,19,31,30,26,21,17,14,13,14,16,18,30,29,25,20,16,13,13,14,16,18,29,28,24,20,16,13,13,14,16,22,29,28,25,21,17,15,14,15,17,22,29,29,26,22,19,16,16,17,18,20,29,27,24,21,17,15,14,15,17,20,27,26,23,20,17,14,14,14,16,20,26,25,23,19,16,14,14,15,16,20,25,25,23,20,17,15,14,15,17,20,26,25,23,21,18,16,16,17,18,20,27,27,25,22,19,17,16,16,17,20,24,24,22,20,17,16,15,15,16,18,23,23,21,19,17,15,15,15,16,18,23,22,21,19,17,15,15,16,17,18,23,23,22,20,18,16,16,17,18,19,24,24,23,21,19,18,18,19,19,20,23,22,21,19,17,16,16,16,17,19,22,22,20,18,17,16,15,15,16,17,21,21,20,18,17,16,16,16,17,18,21,21,20,19,17,17,16,17,18,20,22,22,21,20,19,18,18,18,19,20,23,23,21,20,18,17,17,17,17,18,21,21,20,18,17,16,16,16,16,17,20,20,19,18,17,16,16,16,16,18,20,20,19,18,17,17,16,17,17,18,21,21,20,19,18,18,18,18,19,19,22,22,22,21,19,18,18,18,18,18,20,20,19,18,17,17,16,16,17,18,19,19,19,18,17,16,16,16,16,17,19,19,18,18,17,16,16,16,17,17,19,19,19,18,18,17,17,18,18,19,21,21,21,20,20,19,19,19,19,19,20,19,19,18,17,17,17,17,17,17,19,18,18,17,17,16,16,16,16,17,18,18,18,17,17,16,16,16,17,17,18,19,18,18,18,17,17,17,18,18,20,20,20,19,19,19,19,19,19,20,20,20,19,18,17,17,17,17,17,17,19,18,18,17,17,16,16,16,16,17,18,18,17,17,17,16,16,16,16,17,18,18,18,17,17,17,17,17,17,18,19,19,19,18,18,18,18,18,19,19,20,20,20,19,19,18,17,17,17,17,18,18,18,17,17,17,16,16,16,16,17,17,17,17,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,20,20,20,19,19,19,18,18,17,18,18,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,17,17,17,17,16,16,16,16,16,17,17,17,17,17,17,17,17,17,18,18,19,19,19,19,19,19,19,19,19,18,18,18,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,17,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,18,18,17,17,17,16,17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,19,19,19,19,18,18,17,17,17,16,17,17,17,17,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,18,18,18,18,18,19,18,18,18,17,17,17,17,16,16,16,16,16,16,16,16,16,16,16,15,15,15,15,15,16,16,16,16,16,16,15,15,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,18,18,18,18,18,18,18,18,18,17,17,16,16,16,16,16,16,16,16,16,16,15,15,15,15,15,15,15,16,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,18,18,18,18,18,18,18,17,17,16,16,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,18,18,18,18,18,17,17,16,16,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,18,18,18,17,17,16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,0,0,0,0,3,14,24,27,0,0,0,0,0,0,7,17,24,26,0,0,0,0,0,0,1,11,21,25,0,0,0,0,0,0,0,8,18,24,0,0,0,0,0,0,0,6,14,20,0,0,0,0,0,0,0,5,15,22,0,0,0,0,0,0,0,10,20,25,0,0,0,0,0,0,0,10,19,24,0,0,0,0,0,0,0,3,12,20,0,0,0,0,0,0,0,3,11,19,0,0,0,0,0,0,0,0,7,14,0,0,0,0,0,0,0,0,6,14,0,0,0,0,0,0,0,3,12,19,0,0,0,0,0,0,0,0,8,17,0,0,0,0,0,0,0,4,12,19,0,0,0,0,0,0,0,0,2,9,0,0,0,0};
johmal 0:8dc0f972a984 36 //int Voltage[]={0,8,17,17,17,17,17,17,17,17,17,17,25,33,42,47,42,37,33,32,31,29,27,25,25,27,29,29,28,27,25,23,21,18,16,14,14,14,14,14,14,14,14,14,12,13,15,16,16,16,16,16,16,16,13,13,13,13,14,14,14,14,14,13,12,12,13,14,14,14,14,14,14,14,12,12,12,13,13,13,13,13,13,13,11,12,12,13,13,13,13,13,13,13,11,11,12,12,12,12,12,12,12,12,11,11,12,13,13,13,13,13,13,13,11,11,12,12,13,13,13,13,13,13,11,11,12,12,12,12,12,12,12,12,10,10,11,11,12,12,12,12,12,11,10,10,10,11,11,11,11,11,11,11,9,10,10,10,11,11,11,11,11,11,9,9,10,10,10,10,10,10,10,10,9,9,10,10,10,10,10,10,10,10,9,9,10,10,10,10,10,10,10,10,9,9,10,10,10,10,10,10,10,10,9,9,10,10,11,11,11,11,11,11,9,9,10,10,10,10,10,10,10,10,9,9,9,10,10,10,10,10,10,10,9,9,9,9,10,10,10,10,10,10,8,8,9,9,9,9,9,9,9,9,8,8,8,9,9,9,9,9,9,9,7,7,8,8,8,8,8,8,8,8,7,7,8,8,8,8,8,8,8,8,7,7,8,8,8,8,8,8,8,8,7,7,8,8,8,8,8,8,8,8,7,7,8,8,9,9,9,9,9,9,8,8,8,8,9,9,9,9,9,9,8,8,8,8,8,8,8,8,8,8,7,7,7,8,8,8,8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,7,7,7,7,7,7,7,6,6,6,7,7,7,7,7,7,7,6,6,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,7,7,7,7,8,8,8,8,8,8,7,7,7,7,7,8,8,8,8,7,7,6,6,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,6,6,6,6,7,7,7,7,7,7,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,5,6,6,6,6,6,6,6,6,5,5,5,6,6,6,6,6,6,6,5,5,5,6,6,6,6,6,6,6,5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,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,25,16,9,6,6,8,12,15,19,25,23,19,15,11,9,9,10,12,14,20,20,18,15,12,10,10,10,12,13,18,18,16,14,13,11,11,11,12,13,18,18,17,15,13,12,12,12,13,14,18,18,17,16,15,14,14,14,15,15,18,18,17,15,14,13,12,13,13,14,16,16,15,14,13,12,12,12,12,13,15,15,15,14,13,12,12,12,12,13,15,15,14,14,13,13,12,12,13,13,15,15,15,14,14,14,13,14,14,15,16,16,16,15,15,15,15,15,15,15,16,16,15,14,14,13,13,13,13,14,14,14,14,14,13,13,13,12,13,13,14,14,13,13,13,13,12,12,13,13,13,14,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,14,14,14,13,13,13,13,13,13,14,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,14,14,14,14,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,13,13,13,13,13,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,14,14,14,13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,14,14,14,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,15,15,15,14,14,14,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,13,13,13,13,12,12,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,13,13,13,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,13,13,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,14,14,13,13,13,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,11,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,12,12,12,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,13,13,13,13,12,12,12,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,13,13,13,12,12,12,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,11,11,10,10,10,10,10,10,10,10,10,10,10,10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,11,11,10,10,10,10,10,10,10,10,10,10,10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,11,11,11,10,10,10,9,9,9,9,9,9,9,9,9,9,9,8,8,8,8,9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,9,9,9,8,8,8,8,8,8,8,8,0,0,0,0,0};
johmal 0:8dc0f972a984 38 //int Voltage[]= { 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,9,12,15,17,18,20,26,27,28,28,29,30,30,30,30,31,31,31,31,31,32,32,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,33,33,33,33,34,34,34,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,34,34,34,33,33,33,33,33,33,33,32,32,32,31,31,31,30,29,29,29,28,27,27,27,26,26,26,25,24,24,24,24,24,22,21,21,21,21,19,19,18,18,18,18,18,18,19,18,18,18,15,15,15,15,16,17,19,19,19,19,17,17,18,18,18,19,18,18,17,17,19,20,20,20,20,20,20,19,17,17,18,19,20,20,21,21,21,20,20,19,16,16,16,16,16,16,14,14,14,14,16,16,16,16,16,16,16,17,18,18,19,19,19,19,19,19,18,17,17,17,17,18,18,18,19,19,22,22,23,23,22,22,22,23,23,24,24,24,23,23,22,23,23,23,22,22,22,22,22,23,25,26,26,27,27,28,28,28,27,26,26,24,24,24,24,25,25,25,25,25,26,26,27,27,28,28,28,27,24,24,24,24,25,25,25,25,25,24,24,23,21,20,20,20,20,21,21,21,23,23,23,21,21,21,21,21,21,19,19,19,22,22,22,22,21,20,18,18,18,18,19,20,20,21,21,21,21,22,21,21,20,18,17,17,18,18,18,20,20,20,19,19,19,20,20,20,18,18,18,18,20,20,20,20,20,20,20,18,17,17,19,19,19,20,20,21,21,21,21,20,17,17,17,17,18,18,19,19,19,19,21,22,22,22,21,21,20,19,18,19,19,21,22,22,22,23,23,22,21,21,18,18,17,17,17,17,20,20,21,21,20,20,20,21,21,21,21,21,21,21,22,23,24,24,23,23,23,22,21,20,19,19,20,20,20,20,23,23,24,24,22,22,22,21,22,22,22,23,22,22,22,24,23,23,22,22,20,19,19,19,21,22,22,23,23,23,25,24,23,23,21,21,21,20,20,20,21,21,24,24,24,22,22,21,21,20,20,20,20,20,22,22,22,22,22,22,22,20,21,21,21,22,22,22,22,22,22,22,22,22,19,19,19,20,21,22,21,21,20,20,22,22,22,23,23,22,22,20,19,18,19,19,20,20,21,21,21,21,21,21,21,21,21,22,22,23,23,23,25,25,25,28,28,28,28,28,28,27,27,27,30,31,31,31,31,31,31,29,28,28,26,26,26,26,26,26,26,26,26,26,23,22,22,22,22,22,21,20,20,19,22,22,22,22,22,22,22,20,19,18,19,20,20,21,21,21,21,20,20,20,18,18,18,18,18,19,19,20,21,21,21,21,21,20,20,20,20,20,20,20,22,22,22,22,22,22,22,22,22,22,21,21,21,21,21,21,21,21,21,21,19,19,20,20,21,21,21,21,21,21,21,21,21,21,21,21,20,18,18,18,20,20,20,21,21,21,21,21,21,21,21,22,22,23,23,23,24,24,24,24,25,26,26,27,27,27,26,25,25,25,29,29,29,29,29,28,28,26,25,25,25,25,25,25,26,26,26,26,26,26,22,22,21,21,22,22,22,21,21,21,23,24,24,24,23,23,23,21,20,20,23,23,24,24,24,24,24,23,23,23,21,20,20,20,20,21,21,22,24,24,24,24,24,24,24,24,22,22,22,22,25,25,25,24,24,24,24,23,23,23,25,25,26,26,26,27,27,27,26,26,25,23,23,23,23,23,23,23,23,23,24,25,25,26,26,26,26,24,23,23,24,24,25,25,25,25,24,24,24,24,23,23,23,23,23,24,24,25,28,28,27,27,27,27,27,28,28,28,27,27,28,28,29,29,28,28,27,27,27,27,28,28,28,28,28,28,28,28,28,28,26,25,25,25,25,25,23,22,21,20,19,19,18,18,18,17,16,15,13,13,13,13,13,13,13,13,12,12,12,12,12,11,11,11,11,11,11,10,9,9,9,9,8,8,8,8,8,8,7,7,6,6,6,6,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0};
johmal 0:8dc0f972a984 39 //int Voltage[]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,16,16,17,17,18,18,19,19,20,20,20,21,21,22,22,22,23,23,24,24,24,25,25,25,25,26,26,26,27,27,27,27,28,28,28,28,29,29,29,30,30,30,30,30,31,31,31,31,31,32,32,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,33,33,33,33,34,34,34,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,34,34,34,33,33,33,33,33,33,33,32,32,32,31,31,31,30,29,29,29,28,27,27,27,26,26,26,25,24,24,24,24,24,22,21,21,21,21,19,19,18,18,18,18,18,18,19,18,18,18,15,15,15,15,16,17,19,19,19,19,17,17,18,18,18,19,18,18,17,17,19,20,20,20,20,20,20,19,17,17,18,19,20,20,21,21,21,20,20,19,16,16,16,16,16,16,14,14,14,14,16,16,16,16,16,16,16,17,18,18,19,19,19,19,19,19,18,17,17,17,17,18,18,18,19,19,22,22,23,23,22,22,22,23,23,24,24,24,23,23,22,23,23,23,22,22,22,22,22,23,25,26,26,27,27,28,28,28,27,26,26,24,24,24,24,25,25,25,25,25,26,26,27,27,28,28,28,27,24,24,24,24,25,25,25,25,25,24,24,23,21,20,20,20,20,21,21,21,23,23,23,21,21,21,21,21,21,19,19,19,22,22,22,22,21,20,18,18,18,18,19,20,20,21,21,21,21,22,21,21,20,18,17,17,18,18,18,20,20,20,19,19,19,20,20,20,18,18,18,18,20,20,20,20,20,20,20,18,17,17,19,19,19,20,20,21,21,21,21,20,17,17,17,17,18,18,19,19,19,19,21,22,22,22,21,21,20,19,18,19,19,21,22,22,22,23,23,22,21,21,18,18,17,17,17,17,20,20,21,21,20,20,20,21,21,21,21,21,21,21,22,23,24,24,23,23,23,22,21,20,19,19,20,20,20,20,23,23,24,24,22,22,22,21,22,22,22,23,22,22,22,24,23,23,22,22,20,19,19,19,21,22,22,23,23,23,25,24,23,23,21,21,21,20,20,20,21,21,24,24,24,22,22,21,21,20,20,20,20,20,22,22,22,22,22,22,22,20,21,21,21,22,22,22,22,22,22,22,22,22,19,19,19,20,21,22,21,21,20,20,22,22,22,23,23,22,22,20,19,18,19,19,20,20,21,21,21,21,21,21,21,21,21,22,22,23,23,23,25,25,25,28,28,28,28,28,28,27,27,27,30,31,31,31,31,31,31,29,28,28,26,26,26,26,26,26,26,26,26,26,23,22,22,22,22,22,21,20,20,19,22,22,22,22,22,22,22,20,19,18,19,20,20,21,21,21,21,20,20,20,18,18,18,18,18,19,19,20,21,21,21,21,21,20,20,20,20,20,20,20,22,22,22,22,22,22,22,22,22,22,21,21,21,21,21,21,21,21,21,21,19,19,20,20,21,21,21,21,21,21,21,21,21,21,21,21,20,18,18,18,20,20,20,21,21,21,21,21,21,21,21,22,22,23,23,23,24,24,24,24,25,26,26,27,27,27,26,25,25,25,29,29,29,29,29,28,28,26,25,25,25,25,25,25,26,26,26,26,26,26,22,22,21,21,22,22,22,21,21,21,23,24,24,24,23,23,23,21,20,20,23,23,24,24,24,24,24,23,23,23,21,20,20,20,20,21,21,22,24,24,24,24,24,24,24,24,22,22,22,22,25,25,25,24,24,24,24,23,23,23,25,25,26,26,26,27,27,27,26,26,25,23,23,23,23,23,23,23,23,23,24,25,25,26,26,26,26,24,23,23,24,24,25,25,25,25,24,24,24,24,23,23,23,23,23,24,24,25,28,28,27,27,27,27,27,28,28,28,27,27,28,28,29,29,28,28,27,27,27,27,28,28,28,28,28,28,28,28,28,28,26,25,25,25,25,25,23,22,21,20,19,19,18,18,18,17,16,15,13,13,13,13,13,13,13,13,12,12,12,12,12,11,11,11,11,11,11,10,9,9,9,9,8,8,8,8,8,8,7,7,6,6,6,6,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0};
johmal 0:8dc0f972a984 40 //int Voltage[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,16,16,17,17,18,18,19,19,20,20,20,21,21,22,22,22,23,23,24,24,24,25,25,25,25,26,26,26,27,27,27,27,28,28,28,28,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,0,0,0,12,0,13,0,19,0,23,0,8,0,1,0,0,0,0,0,0,0,3,0,1,0,0,0};
johmal 0:8dc0f972a984 41 //int Voltage[]={0,3,3,5,5,7,7,9,9,10,10,12,12,13,13,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,22,22,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,28,28,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,33,32,32,32,32,31,31,31,31,30,30,30,30,29,29,29,29,28,28,28,28,27,27,27,27,26,26,26,26,25,25,25,25,24,24,24,24,23,23,23,23,22,22,22,22,21,21,21,21,20,20,20,20,19,19,19,19,18,18,18,18,17,17,17,17,16,16,16,16,15,15,15,15,14,14,14,14,13,13,13,13,12,12,12,12,11,11,11,11,10,10,10,10,9,9,9,9,8,8,8,8,7,7,7,7,6,6,6,6,5,5,5,5,4,4,4,4,3,3,3,3,3,0,0,0,0,0,0};
johmal 0:8dc0f972a984 42 /* Sparat volt simulering IN*/ //int Voltage[]={0,0,2,2,4,4,6,6,7,7,9,9,10,10,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,19,19,20,20,21,21,21,21,22,22,22,22,23,23,23,23,24,24,24,24,25,25,25,25,25,25,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,29,29,29,29,28,28,28,28,27,27,27,27,26,26,26,26,25,25,25,25,24,24,24,24,23,23,23,23,22,22,22,22,21,21,21,21,20,20,20,20,19,19,19,19,18,18,18,18,17,17,17,17,16,16,16,16,15,15,15,15,14,14,14,14,13,13,13,13,12,12,12,12,11,11,11,11,10,10,10,10,9,9,9,9,8,8,8,8,7,7,7,7,6,6,6,6,5,5,5,5,4,4,4,4,3,3,3,3,2,2,2,2,1,1,1,1,0,0,0};
johmal 0:8dc0f972a984 43 /* Sparat volt simulering UT*/ int Voltage[]={0,5,5,9,9,12,12,14,14,16,16,17,17,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19,19,19,19,19,19,18,18,18,18,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13,13,13,13,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9,9,9,9,9,9,9,9,9,9,9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1};
johmal 0:8dc0f972a984 44
johmal 0:8dc0f972a984 45 int voltage=Voltage[tim];
johmal 0:8dc0f972a984 46 int vlen=sizeof(Voltage)/sizeof(Voltage[0]);
johmal 0:8dc0f972a984 47 //int pos;
johmal 0:8dc0f972a984 48 char check;
johmal 0:8dc0f972a984 49 char Hall[3];
johmal 0:8dc0f972a984 50 int o=0;
johmal 0:8dc0f972a984 51 char guard=1;
johmal 0:8dc0f972a984 52
johmal 0:8dc0f972a984 53 void init_PWM()
johmal 0:8dc0f972a984 54 {
johmal 0:8dc0f972a984 55 LPC_SC->PCONP |= 1 << 6; // enable power for PWM1
johmal 0:8dc0f972a984 56
johmal 0:8dc0f972a984 57 int prescaler=1;
johmal 0:8dc0f972a984 58 LPC_SC->PCLKSEL0 |= prescaler << 12 ; //PCLK = CCLK = 96MHz
johmal 0:8dc0f972a984 59 // Prescalers: 0 cclk/4, 1 cclk/1, 2 cclk/2, 3 cclk/8
johmal 0:8dc0f972a984 60
johmal 0:8dc0f972a984 61 LPC_PWM1->TCR = 0x00; //Timer control reg
johmal 0:8dc0f972a984 62 LPC_PWM1->CTCR = 0x00; //Count control reg
johmal 0:8dc0f972a984 63 LPC_PWM1->MCR = 0x00; //Match control
johmal 0:8dc0f972a984 64 LPC_PWM1->CCR = 0x00; //Capture control
johmal 0:8dc0f972a984 65 LPC_PWM1->PCR = 0x00; //PWM control reg
johmal 0:8dc0f972a984 66 LPC_PWM1->LER = 0x00; //Load enable reg
johmal 0:8dc0f972a984 67 LPC_PWM1->PR = 1 - 1; //Prescale
johmal 0:8dc0f972a984 68
johmal 0:8dc0f972a984 69 LPC_PINCON->PINSEL4 = (1<<0)|(1<<2)|(1<<4)|(1<<6)|(1<<8)|(1<<10); //output to pin 2.0 - 2.5
johmal 0:8dc0f972a984 70 LPC_PINCON->PINMODE4 =(2<<0)|(2<<2)|(2<<4)|(2<<6)|(2<<8)|(2<<10); //pull down
johmal 0:8dc0f972a984 71
johmal 0:8dc0f972a984 72
johmal 0:8dc0f972a984 73 int Frequency=100000; //Hz
johmal 0:8dc0f972a984 74
johmal 0:8dc0f972a984 75
johmal 0:8dc0f972a984 76 int mr0=(96000000/prescaler)/Frequency;
johmal 0:8dc0f972a984 77
johmal 0:8dc0f972a984 78 LPC_PWM1->MR0 = mr0; //set clock cycles for PWM. PWM freq = PCLK/MR0 (?)
johmal 0:8dc0f972a984 79 LPC_PWM1->MR1 = 0; // DIP 26
johmal 0:8dc0f972a984 80 LPC_PWM1->MR2 = 0; // DIP 25
johmal 0:8dc0f972a984 81 LPC_PWM1->MR3 = 0; // DIP 24
johmal 0:8dc0f972a984 82 LPC_PWM1->MR4 = 0; // DIP 23
johmal 0:8dc0f972a984 83 LPC_PWM1->MR5 = 0; // DIP 22
johmal 0:8dc0f972a984 84 LPC_PWM1->MR6 = 0; // DIP 21
johmal 0:8dc0f972a984 85
johmal 0:8dc0f972a984 86 LPC_PWM1->LER = (1 << 0) | (1 << 1) ; //Apply changes
johmal 0:8dc0f972a984 87 LPC_PWM1->MCR |= (1 << 1) ; // interrupt on match0.Reset timer on Match0;
johmal 0:8dc0f972a984 88 LPC_PWM1->PCR = (1<<9)|(1<<10)|(1<<11)|(1<<12)|(1<<13)|(1<<14); //--- PWM1 output
johmal 0:8dc0f972a984 89 LPC_PWM1->TCR = (1<<0)|(1<<3);
johmal 0:8dc0f972a984 90 }
johmal 0:8dc0f972a984 91
johmal 0:8dc0f972a984 92 void dutyC(int dutyy, int pin) //dutyy is the input dutycycle (0-100), input in "pin" (1-6) which PWM pin that one wants to change.
johmal 0:8dc0f972a984 93 {
johmal 0:8dc0f972a984 94 int mr00=(96000000)/Frequency;
johmal 0:8dc0f972a984 95
johmal 0:8dc0f972a984 96 LPC_PWM1->TCR = (1<<1)|(1<<0);
johmal 0:8dc0f972a984 97
johmal 0:8dc0f972a984 98 LPC_PWM1->MR0 = 0;
johmal 0:8dc0f972a984 99 LPC_PWM1->TCR = (0<<1);
johmal 0:8dc0f972a984 100 LPC_PWM1->MR0 = mr00;
johmal 0:8dc0f972a984 101
johmal 0:8dc0f972a984 102 if (pin==1){LPC_PWM1->MR1 = mr00*dutyy/100;} // DIP 26
johmal 0:8dc0f972a984 103 else if (pin==2){LPC_PWM1->MR2 = mr00*dutyy/100;} // DIP 25
johmal 0:8dc0f972a984 104 else if (pin==3){LPC_PWM1->MR3 = mr00*dutyy/100;} // DIP 24
johmal 0:8dc0f972a984 105 else if (pin==4){LPC_PWM1->MR4 = mr00*dutyy/100;} // DIP 23
johmal 0:8dc0f972a984 106 else if (pin==5){LPC_PWM1->MR5 = mr00*dutyy/100;} // DIP 22
johmal 0:8dc0f972a984 107 else if (pin==6){LPC_PWM1->MR6 = mr00*dutyy/100;} // DIP 21
johmal 0:8dc0f972a984 108 LPC_PWM1->LER = (1 << 0) | (1 << 1) ; //Apply changes
johmal 0:8dc0f972a984 109 LPC_PWM1->TCR = (1<<0)|(1<<3);
johmal 0:8dc0f972a984 110 }
johmal 0:8dc0f972a984 111
johmal 0:8dc0f972a984 112 void Sixstepswitch(int En1, int En2, int En3, int Sw1, int Sw2, int Sw3) //En = enable switches //Sw set positive or negative direction (1pos, 0neg)
johmal 0:8dc0f972a984 113 {
johmal 0:8dc0f972a984 114 dutyC(En1,1); //Enable switch 1
johmal 0:8dc0f972a984 115 dutyC(Sw1,4); //switch 1
johmal 0:8dc0f972a984 116 dutyC(En2,2); //Enable switch 2
johmal 0:8dc0f972a984 117 dutyC(Sw2,5); //switch 2
johmal 0:8dc0f972a984 118 dutyC(En3,3); //Enable switch 3
johmal 0:8dc0f972a984 119 dutyC(Sw3,6); //switch 3
johmal 0:8dc0f972a984 120 }
johmal 0:8dc0f972a984 121
johmal 0:8dc0f972a984 122
johmal 0:8dc0f972a984 123 void stopHall1()
johmal 0:8dc0f972a984 124 {
johmal 0:8dc0f972a984 125 if (guard==1)
johmal 0:8dc0f972a984 126 {
johmal 0:8dc0f972a984 127 VoltStep.detach();
johmal 0:8dc0f972a984 128 voltage=Voltage[tim];
johmal 0:8dc0f972a984 129 o=100; //tim=0;
johmal 0:8dc0f972a984 130 X=100;
johmal 0:8dc0f972a984 131 Voltage[tim]=100;
johmal 0:8dc0f972a984 132
johmal 0:8dc0f972a984 133
johmal 0:8dc0f972a984 134 //Sixstepswitch(100,100,100, 100,100,100);
johmal 0:8dc0f972a984 135 //wait(2);
johmal 0:8dc0f972a984 136 dir=dirClock;
johmal 0:8dc0f972a984 137 check=1;
johmal 0:8dc0f972a984 138 tim=0;
johmal 0:8dc0f972a984 139 //pos=0;
johmal 0:8dc0f972a984 140 guard=2;
johmal 0:8dc0f972a984 141 }
johmal 0:8dc0f972a984 142 }
johmal 0:8dc0f972a984 143 void stopHall2()
johmal 0:8dc0f972a984 144 {
johmal 0:8dc0f972a984 145 if (guard==2)
johmal 0:8dc0f972a984 146 {
johmal 0:8dc0f972a984 147 VoltStep.detach();
johmal 0:8dc0f972a984 148 voltage=Voltage[tim];
johmal 0:8dc0f972a984 149 o=100; //tim=0;
johmal 0:8dc0f972a984 150 X=100;
johmal 0:8dc0f972a984 151 Voltage[tim]=100;
johmal 0:8dc0f972a984 152
johmal 0:8dc0f972a984 153
johmal 0:8dc0f972a984 154 //Sixstepswitch(100,100,100, 100,100,100);
johmal 0:8dc0f972a984 155 //wait(2);
johmal 0:8dc0f972a984 156 dir=dirCounter;
johmal 0:8dc0f972a984 157 check=1;
johmal 0:8dc0f972a984 158 tim=0;
johmal 0:8dc0f972a984 159
johmal 0:8dc0f972a984 160 //led1=0;
johmal 0:8dc0f972a984 161 //led2=0;
johmal 0:8dc0f972a984 162 //led3=0;
johmal 0:8dc0f972a984 163 //pos=0;
johmal 0:8dc0f972a984 164 guard=1;
johmal 0:8dc0f972a984 165 }
johmal 0:8dc0f972a984 166
johmal 0:8dc0f972a984 167 }
johmal 0:8dc0f972a984 168
johmal 0:8dc0f972a984 169 void Hall1r()
johmal 0:8dc0f972a984 170 {
johmal 0:8dc0f972a984 171 if (dir==dirClock) {Sixstepswitch(100,o,100, o,X,Voltage[tim]); dutyPin=6;}
johmal 0:8dc0f972a984 172 else if (dir==dirCounter){Sixstepswitch(100,100,o, o,Voltage[tim],X); dutyPin=5;}
johmal 0:8dc0f972a984 173 }
johmal 0:8dc0f972a984 174 void Hall2r()
johmal 0:8dc0f972a984 175 {
johmal 0:8dc0f972a984 176 if (dir==dirClock) {Sixstepswitch(100,100,o, Voltage[tim],o,X); dutyPin=4;}
johmal 0:8dc0f972a984 177 else if (dir==dirCounter){Sixstepswitch(o,100,100, X,o,Voltage[tim]); dutyPin=6;}
johmal 0:8dc0f972a984 178 }
johmal 0:8dc0f972a984 179 void Hall3r()
johmal 0:8dc0f972a984 180 {
johmal 0:8dc0f972a984 181 if (dir==dirClock) {Sixstepswitch(o,100,100, X,Voltage[tim],o); dutyPin=5;}
johmal 0:8dc0f972a984 182 else if (dir==dirCounter){Sixstepswitch(100,o,100, Voltage[tim],X,o); dutyPin=4;}
johmal 0:8dc0f972a984 183 }
johmal 0:8dc0f972a984 184 void Hall1f()
johmal 0:8dc0f972a984 185 {
johmal 0:8dc0f972a984 186 if (dir==dirClock) {Sixstepswitch(100,o,100, Voltage[tim],X,o); dutyPin=4;}
johmal 0:8dc0f972a984 187 else if (dir==dirCounter){Sixstepswitch(100,100,o, Voltage[tim],o,X); dutyPin=4;}
johmal 0:8dc0f972a984 188 }
johmal 0:8dc0f972a984 189 void Hall2f()
johmal 0:8dc0f972a984 190 {
johmal 0:8dc0f972a984 191 if (dir==dirClock) {Sixstepswitch(100,100,o, o,Voltage[tim],X); dutyPin=5;}
johmal 0:8dc0f972a984 192 else if (dir==dirCounter){Sixstepswitch(o,100,100, X,Voltage[tim],o); dutyPin=5;}
johmal 0:8dc0f972a984 193 }
johmal 0:8dc0f972a984 194 void Hall3f()
johmal 0:8dc0f972a984 195 {
johmal 0:8dc0f972a984 196 if (dir==dirClock) {Sixstepswitch(o,100,100, X,o,Voltage[tim]); dutyPin=6;}
johmal 0:8dc0f972a984 197 else if (dir==dirCounter){Sixstepswitch(100,o,100, o,X,Voltage[tim]); dutyPin=6;}
johmal 0:8dc0f972a984 198 }
johmal 0:8dc0f972a984 199
johmal 0:8dc0f972a984 200 void Vstep()
johmal 0:8dc0f972a984 201 {
johmal 0:8dc0f972a984 202 //if (Voltage[tim]==0);
johmal 0:8dc0f972a984 203 // {check=1}
johmal 0:8dc0f972a984 204 //else{
johmal 0:8dc0f972a984 205 if(check==0)
johmal 0:8dc0f972a984 206 {
johmal 0:8dc0f972a984 207 if (dir==dirClock)
johmal 0:8dc0f972a984 208 {
johmal 0:8dc0f972a984 209 dutyC(Voltage[tim],dutyPin);
johmal 0:8dc0f972a984 210 tim++;
johmal 0:8dc0f972a984 211 if (tim>=vlen){VoltStep.detach(); /*check=0;*/__disable_irq(); led2=1; wait(1); __enable_irq(); tim=0;}
johmal 0:8dc0f972a984 212 }
johmal 0:8dc0f972a984 213 else if(dir==dirCounter)
johmal 0:8dc0f972a984 214 {
johmal 0:8dc0f972a984 215 voltage=35;
johmal 0:8dc0f972a984 216 tim=0;
johmal 0:8dc0f972a984 217 Voltage[tim]=voltage;
johmal 0:8dc0f972a984 218 dutyC(voltage,dutyPin);
johmal 0:8dc0f972a984 219 }
johmal 0:8dc0f972a984 220 else if (dir==dirClock+2)
johmal 0:8dc0f972a984 221 {
johmal 0:8dc0f972a984 222 voltage=17;
johmal 0:8dc0f972a984 223 tim=0;
johmal 0:8dc0f972a984 224 Voltage[tim]=voltage;
johmal 0:8dc0f972a984 225 dutyC(voltage,dutyPin);
johmal 0:8dc0f972a984 226 }
johmal 0:8dc0f972a984 227 }
johmal 0:8dc0f972a984 228 }
johmal 0:8dc0f972a984 229
johmal 0:8dc0f972a984 230 int main(void)
johmal 0:8dc0f972a984 231 {
johmal 0:8dc0f972a984 232 event1.rise(&Hall1r); // rise p15
johmal 0:8dc0f972a984 233 event2.rise(&Hall2r); // rise p16
johmal 0:8dc0f972a984 234 event3.rise(&Hall3r); // rise p17
johmal 0:8dc0f972a984 235
johmal 0:8dc0f972a984 236 event1.fall(&Hall1f); // fall p15
johmal 0:8dc0f972a984 237 event2.fall(&Hall2f); // fall p16
johmal 0:8dc0f972a984 238 event3.fall(&Hall3f); // fall p17
johmal 0:8dc0f972a984 239
johmal 0:8dc0f972a984 240 stoppHallEvent1.fall(&stopHall1); //StoppEvent P18
johmal 0:8dc0f972a984 241 stoppHallEvent2.fall(&stopHall2); //StoppEvent p19
johmal 0:8dc0f972a984 242
johmal 0:8dc0f972a984 243 init_PWM();
johmal 0:8dc0f972a984 244 wait_ms(100);
johmal 0:8dc0f972a984 245 dir=dirCounter;
johmal 0:8dc0f972a984 246 check=1;
johmal 0:8dc0f972a984 247 int tickertime=500;//440;
johmal 0:8dc0f972a984 248 NVIC_SetPriority(TIMER3_IRQn, 4); // Timer priority
johmal 0:8dc0f972a984 249 VoltStep.attach_us(&Vstep, tickertime); // Voltage step interrupt timer and frequency
johmal 0:8dc0f972a984 250 VoltStep.detach();
johmal 0:8dc0f972a984 251
johmal 0:8dc0f972a984 252 /*int offset=2;
johmal 0:8dc0f972a984 253 int p=0;
johmal 0:8dc0f972a984 254 while (p<=vlen-1)
johmal 0:8dc0f972a984 255 {
johmal 0:8dc0f972a984 256 Voltage[p]=Voltage[p]+offset;
johmal 0:8dc0f972a984 257 if (Voltage[p]<0)
johmal 0:8dc0f972a984 258 {
johmal 0:8dc0f972a984 259 Voltage[p]=0;
johmal 0:8dc0f972a984 260 }
johmal 0:8dc0f972a984 261 p++;
johmal 0:8dc0f972a984 262 }*/
johmal 0:8dc0f972a984 263
johmal 0:8dc0f972a984 264
johmal 0:8dc0f972a984 265 while(1)
johmal 0:8dc0f972a984 266 {
johmal 0:8dc0f972a984 267 led1=0;
johmal 0:8dc0f972a984 268 if (check==1)//Init state
johmal 0:8dc0f972a984 269 {
johmal 0:8dc0f972a984 270 __disable_irq();
johmal 0:8dc0f972a984 271 led4=1;
johmal 0:8dc0f972a984 272 Sixstepswitch(100,100,100, 0,0,0);
johmal 0:8dc0f972a984 273
johmal 0:8dc0f972a984 274 wait(2);
johmal 0:8dc0f972a984 275 o=0;
johmal 0:8dc0f972a984 276 X=0;
johmal 0:8dc0f972a984 277 Voltage[tim]=voltage;
johmal 0:8dc0f972a984 278
johmal 0:8dc0f972a984 279
johmal 0:8dc0f972a984 280 Sixstepswitch(0,0,0, 0,0,0);
johmal 0:8dc0f972a984 281 wait(1);
johmal 0:8dc0f972a984 282 //attat
johmal 0:8dc0f972a984 283
johmal 0:8dc0f972a984 284
johmal 0:8dc0f972a984 285 if(event1>=0.5) {Hall[0]=1; led1=1;} else {Hall[0]=0; /*led1=0;*/}
johmal 0:8dc0f972a984 286 if(event2>=0.5) {Hall[1]=1; led2=1;} else {Hall[1]=0; /*led2=0;*/}
johmal 0:8dc0f972a984 287 if(event3>=0.5) {Hall[2]=1; led3=1;} else {Hall[2]=0; /*led3=0;*/}
johmal 0:8dc0f972a984 288 __enable_irq();
johmal 0:8dc0f972a984 289 //six steps Start
johmal 0:8dc0f972a984 290 if (dir==dirClock)
johmal 0:8dc0f972a984 291 {
johmal 0:8dc0f972a984 292 /*if (Hall[0]==1 && Hall[1]==0 && Hall[2]==1){Sixstepswitch(100,0,100, 0,X,Voltage[tim]); dutyPin=6;}
johmal 0:8dc0f972a984 293 else if (Hall[0]==1 && Hall[1]==0 && Hall[2]==0){Sixstepswitch(0,100,100, X,0,Voltage[tim]); dutyPin=6;}
johmal 0:8dc0f972a984 294 else if (Hall[0]==1 && Hall[1]==1 && Hall[2]==0){Sixstepswitch(100,100,0, Voltage[tim],0,X); dutyPin=4;}
johmal 0:8dc0f972a984 295 else if (Hall[0]==0 && Hall[1]==1 && Hall[2]==0){Sixstepswitch(100,0,100, Voltage[tim],X,0); dutyPin=4;}
johmal 0:8dc0f972a984 296 else if (Hall[0]==0 && Hall[1]==1 && Hall[2]==1){Sixstepswitch(0,100,100, X,Voltage[tim],0); dutyPin=5;}
johmal 0:8dc0f972a984 297 else if (Hall[0]==0 && Hall[1]==0 && Hall[2]==1){Sixstepswitch(100,100,0, 0,Voltage[tim],X); dutyPin=5;}*/
johmal 0:8dc0f972a984 298
johmal 0:8dc0f972a984 299 if (Hall[0]==1 && Hall[1]==0 && Hall[2]==1){Sixstepswitch(100,0,100, o,X,0); dutyPin=6;}
johmal 0:8dc0f972a984 300 else if (Hall[0]==1 && Hall[1]==0 && Hall[2]==0){Sixstepswitch(0,100,100, X,o,0); dutyPin=6;}
johmal 0:8dc0f972a984 301 else if (Hall[0]==1 && Hall[1]==1 && Hall[2]==0){Sixstepswitch(100,100,0, o,0,X); dutyPin=4;}
johmal 0:8dc0f972a984 302 else if (Hall[0]==0 && Hall[1]==1 && Hall[2]==0){Sixstepswitch(100,0,100, o,X,0); dutyPin=4;}
johmal 0:8dc0f972a984 303 else if (Hall[0]==0 && Hall[1]==1 && Hall[2]==1){Sixstepswitch(0,100,100, X,o,0); dutyPin=5;}
johmal 0:8dc0f972a984 304 else if (Hall[0]==0 && Hall[1]==0 && Hall[2]==1){Sixstepswitch(100,100,0, 0,o,X); dutyPin=5;}
johmal 0:8dc0f972a984 305
johmal 0:8dc0f972a984 306
johmal 0:8dc0f972a984 307 }
johmal 0:8dc0f972a984 308 else if (dir==dirCounter)
johmal 0:8dc0f972a984 309 {
johmal 0:8dc0f972a984 310 /*if (Hall[0]==1 && Hall[1]==0 && Hall[2]==1){Sixstepswitch(0,100,100, X,Voltage[tim],0); dutyPin=5;}
johmal 0:8dc0f972a984 311 else if (Hall[0]==1 && Hall[1]==0 && Hall[2]==0){Sixstepswitch(100,100,0, 0,Voltage[tim],X); dutyPin=5;}
johmal 0:8dc0f972a984 312 else if (Hall[0]==1 && Hall[1]==1 && Hall[2]==0){Sixstepswitch(100,0,100, 0,X,Voltage[tim]); dutyPin=6;}
johmal 0:8dc0f972a984 313 else if (Hall[0]==0 && Hall[1]==1 && Hall[2]==0){Sixstepswitch(0,100,100, X,0,Voltage[tim]); dutyPin=6;}
johmal 0:8dc0f972a984 314 else if (Hall[0]==0 && Hall[1]==1 && Hall[2]==1){Sixstepswitch(100,100,0, Voltage[tim],0,X); dutyPin=4;}
johmal 0:8dc0f972a984 315 else if (Hall[0]==0 && Hall[1]==0 && Hall[2]==1){Sixstepswitch(100,0,100, Voltage[tim],X,0); dutyPin=4;}*/
johmal 0:8dc0f972a984 316
johmal 0:8dc0f972a984 317 if (Hall[0]==1 && Hall[1]==0 && Hall[2]==1){Sixstepswitch(0,100,100, X,o,0); dutyPin=5;}
johmal 0:8dc0f972a984 318 else if (Hall[0]==1 && Hall[1]==0 && Hall[2]==0){Sixstepswitch(100,100,0, 0,o,X); dutyPin=5;}
johmal 0:8dc0f972a984 319 else if (Hall[0]==1 && Hall[1]==1 && Hall[2]==0){Sixstepswitch(100,0,100, 0,X,o); dutyPin=6;}
johmal 0:8dc0f972a984 320 else if (Hall[0]==0 && Hall[1]==1 && Hall[2]==0){Sixstepswitch(0,100,100, X,0,o); dutyPin=6;}
johmal 0:8dc0f972a984 321 else if (Hall[0]==0 && Hall[1]==1 && Hall[2]==1){Sixstepswitch(100,100,0, o,0,X); dutyPin=4;}
johmal 0:8dc0f972a984 322 else if (Hall[0]==0 && Hall[1]==0 && Hall[2]==1){Sixstepswitch(100,0,100, o,X,0); dutyPin=4;}
johmal 0:8dc0f972a984 323
johmal 0:8dc0f972a984 324 }
johmal 0:8dc0f972a984 325 //__enable_irq();
johmal 0:8dc0f972a984 326 check=0;
johmal 0:8dc0f972a984 327 tim=0;
johmal 0:8dc0f972a984 328 VoltStep.attach_us(&Vstep, tickertime); // Voltage step interrupt timer and frequency
johmal 0:8dc0f972a984 329 led4=0;
johmal 0:8dc0f972a984 330
johmal 0:8dc0f972a984 331
johmal 0:8dc0f972a984 332
johmal 0:8dc0f972a984 333
johmal 0:8dc0f972a984 334 }
johmal 0:8dc0f972a984 335
johmal 0:8dc0f972a984 336 }
johmal 0:8dc0f972a984 337 }