Infineon Team
Published © MIT

Hacking Louie

We hacked the world-renown game Looping Louie, manipulated the physics of the game and enabled playing with virtual players

IntermediateFull instructions provided8 hours499
Hacking Louie

Things used in this project

Hardware components

KIT XMC47 RELAX LITE V1
Infineon KIT XMC47 RELAX LITE V1
×1
BLDC Shield IFX007T
Infineon BLDC Shield IFX007T
×2
TLE5012B E1000 MS2GO
Infineon TLE5012B E1000 MS2GO
Sensor used on a custom PCB
×2
T-Motor GB2208
×1
T-Motor GB54-1
×1
Looping Louie
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

GB54-1 sensoradapter

holds the angle sensor in the base

TLE5012 round

holds the custom sensor PCB

cover base

GB54-1 cableshield

prevens the cables in the base of chafing

GB54-1 Louping Louie adapter

holds the rotor onto the base motor

baseplate

baseplate of updated rotor

left ar

left part of updated rotor

right arm

right arm of updated rotor

GB2208 holder

motor holder of updated rotor

adapter

holds the arm as part of updated rotor

Schematics

Schematics

TLE5012 round PCB

Production files of sensor PCB

Code

Hacking Looping Louie

Arduino
//MASTER

#include <Tle5012b.h>
#include <Tle5012b_reg.h>

//#define PI                (double)  3.14159265359
#define PHASE_DELAY_1     (double)  2.094395102 //120°
#define PHASE_DELAY_2     (double)  4.188790205 //240°

//Sensor 1 and 2 init
#define PIN_SPI1_SS0   38 // P0.3
#define PIN_SPI1_MOSI  39 // P0.1 -----> 0.1 und 0.0 zusammenlöten! (3-Wire SPI)
#define PIN_SPI1_MISO  65 // P0.0
#define PIN_SPI1_SCK   40 // P0.10

#define PIN_SPI2_SS0   96 // P0.12
#define PIN_SPI2_MOSI  71 // P3.11 -----> 3.11 und 3.12 zusammenlöten! (3-Wire SPI)
#define PIN_SPI2_MISO  97 // P3.12
#define PIN_SPI2_SCK   70 // P3.13

#define sensorTotalNum 2
double   nAngle[2]     = {0, 0};

Tle5012b_SPI SPICh1 = Tle5012b_SPI(1);
Tle5012b_SPI SPICh2 = Tle5012b_SPI(2);
Tle5012b_reg sensor1 = Tle5012b_reg();
Tle5012b_reg sensor2 = Tle5012b_reg();
Tle5012b_reg sensor[sensorTotalNum] = { //!> the sensor array with four sensors per SPI interface
  (sensor1),
  (sensor2),
};

//Motor init
const int U_base = 11; /*violett*/   const int U = 81;
const int V_base = 10; /*braun*/     const int V = 83;
const int W_base = 9;  /*orange*/    const int W = 72;
const int EN_U_base = 6;             const int EN_U = 86;
const int EN_V_base = 5;             const int EN_V = 84;
const int EN_W_base = 3;             const int EN_W = 95;

int duty_arm = 40;              int duty_base = 20;

double pwm_U = 0;               double pwm_U_base = 0;
double pwm_V = 0;               double pwm_V_base = 0;
double pwm_W = 0;               double pwm_W_base = 0;

int myPWM_U_values[3600] = {-47, -48, -49, -49, -50, -51, -52, -53, -53, -54, -55, -56, -57, -57, -58, -59, -60, -60, -61, -62, -62, -63, -64, -64, -65, -66, -66, -67, -68, -68, -69, -69, -70, -71, -71, -72, -72, -73, -74, -74, -75, -75, -76, -76, -77, -77, -78, -78, -79, -80, -80, -81, -82, -82, -83, -84, -84, -85, -86, -86, -87, -88, -89, -90, -91, -91, -92, -93, -93, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -92, -91, -91, -90, -90, -90, -89, -89, -88, -88, -87, -86, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -76, -75, -73, -73, -72, -71, -70, -69, -68, -68, -66, -65, -64, -64, -62, -61, -60, -59, -58, -56, -55, -54, -52, -51, -50, -48, -47, -45, -44, -43, -41, -40, -39, -37, -36, -35, -34, -32, -31, -30, -29, -28, -26, -25, -24, -23, -22, -21, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -6, -6, -4, -3, -2, 0, 0, 1, 3, 5, 7, 9, 10, 12, 14, 15, 17, 19, 20, 21, 23, 24, 25, 27, 28, 29, 31, 32, 33, 35, 36, 38, 39, 39, 41, 42, 43, 44, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 57, 59, 59, 60, 61, 62, 63, 64, 65, 66, 66, 67, 68, 69, 70, 70, 71, 72, 73, 73, 74, 75, 75, 76, 77, 77, 78, 79, 79, 80, 80, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 87, 87, 88, 88, 89, 90, 90, 91, 91, 92, 93, 93, 93, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 92, 91, 91, 91, 91, 90, 89, 88, 87, 87, 86, 86, 85, 84, 84, 83, 82, 81, 81, 80, 80, 79, 78, 78, 77, 76, 76, 75, 74, 73, 73, 72, 71, 70, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 54, 53, 52, 51, 49, 47, 46, 45, 44, 42, 41, 40, 39, 38, 37, 35, 34, 32, 31, 29, 28, 27, 26, 24, 23, 22, 20, 19, 18, 17, 15, 14, 12, 11, 10, 8, 7, 5, 4, 2, 0, 0, -2, -4, -7, -9, -10, -11, -13, -14, -16, -17, -18, -20, -21, -22, -24, -25, -27, -29, -30, -31, -32, -34, -35, -36, -37, -38, -39, -40, -41, -41, -42, -43, -44, -45, -46, -46, -47, -48, -50, -51, -51, -52, -52, -53, -54, -54, -55, -56, -56, -57, -58, -59, -60, -61, -62, -63, -64, -64, -65, -66, -67, -67, -68, -69, -70, -70, -71, -73, -74, -75, -76, -76, -77, -77, -78, -79, -80, -80, -81, -81, -82, -83, -83, -84, -85, -86, -86, -87, -88, -88, -89, -90, -91, -91, -92, -93, -93, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -98, -97, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -95, -94, -94, -94, -94, -93, -93, -93, -92, -92, -92, -92, -91, -91, -90, -90, -90, -89, -88, -88, -87, -87, -86, -86, -85, -84, -83, -82, -81, -80, -80, -79, -78, -77, -76, -75, -74, -73, -73, -72, -71, -70, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -55, -54, -53, -52, -50, -49, -48, -47, -45, -44, -43, -42, -40, -39, -38, -37, -36, -35, -34, -33, -31, -30, -29, -28, -27, -26, -24, -23, -23, -21, -20, -19, -18, -17, -16, -15, -13, -12, -11, -10, -9, -7, -6, -4, -3, -1, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 21, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 60, 61, 62, 63, 64, 65, 66, 66, 67, 68, 69, 70, 70, 71, 72, 73, 73, 74, 74, 75, 76, 76, 77, 78, 78, 79, 79, 80, 80, 81, 81, 82, 83, 83, 83, 84, 85, 85, 86, 86, 87, 88, 88, 89, 90, 91, 91, 92, 93, 93, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 90, 90, 90, 89, 89, 88, 88, 88, 87, 86, 86, 86, 85, 84, 84, 83, 82, 82, 81, 80, 80, 79, 78, 78, 77, 76, 76, 75, 74, 73, 73, 72, 72, 71, 70, 70, 69, 68, 68, 67, 66, 65, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 53, 52, 51, 50, 48, 47, 45, 44, 43, 42, 40, 39, 38, 37, 36, 34, 33, 32, 31, 30, 28, 27, 26, 25, 24, 23, 21, 20, 19, 17, 16, 15, 14, 12, 11, 10, 8, 7, 6, 4, 3, 2, 0, -1, -2, -4, -6, -7, -9, -11, -13, -15, -16, -17, -19, -20, -22, -23, -24, -26, -27, -28, -29, -31, -32, -33, -34, -35, -37, -38, -39, -40, -41, -42, -43, -44, -45, -45, -46, -47, -48, -49, -50, -51, -52, -53, -53, -54, -55, -56, -57, -58, -59, -60, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -70, -70, -71, -72, -73, -74, -74, -76, -76, -77, -78, -79, -79, -80, -81, -81, -82, -83, -84, -84, -85, -86, -86, -87, -88, -89, -90, -90, -91, -92, -92, -93, -93, -94, -94, -95, -95, -96, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -95, -94, -94, -94, -93, -93, -92, -92, -92, -91, -91, -91, -90, -90, -89, -89, -88, -87, -87, -86, -86, -85, -84, -83, -82, -81, -81, -80, -79, -78, -77, -76, -76, -75, -74, -73, -72, -72, -71, -70, -70, -69, -68, -67, -66, -65, -64, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -46, -45, -44, -43, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -10, -9, -8, -7, -5, -4, -2, 0, 0, 1, 3, 6, 7, 9, 11, 13, 15, 16, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 59, 60, 61, 62, 62, 63, 64, 65, 66, 66, 67, 68, 69, 69, 70, 71, 71, 72, 73, 73, 74, 74, 75, 76, 76, 77, 78, 78, 79, 79, 80, 81, 81, 82, 83, 83, 84, 84, 85, 86, 87, 88, 88, 89, 90, 91, 92, 93, 93, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 97, 96, 96, 96, 95, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 89, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 82, 81, 80, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 71, 71, 70, 69, 68, 67, 67, 66, 65, 64, 64, 62, 62, 60, 59, 58, 58, 57, 55, 54, 53, 51, 50, 48, 47, 46, 44, 43, 42, 41, 39, 38, 36, 35, 34, 33, 32, 30, 29, 28, 27, 26, 24, 23, 22, 21, 20, 18, 17, 16, 15, 14, 13, 12, 10, 9, 8, 7, 6, 5, 3, 2, 1, 0, 0, -2, -3, -4, -6, -8, -9, -11, -12, -14, -16, -17, -18, -19, -21, -22, -23, -24, -26, -27, -28, -29, -30, -31, -32, -33, -34, -36, -36, -37, -38, -40, -40, -41, -42, -43, -44, -45, -46, -46, -47, -48, -49, -50, -51, -52, -52, -53, -54, -55, -56, -56, -57, -58, -59, -60, -61, -61, -62, -63, -64, -65, -66, -67, -68, -68, -69, -70, -71, -72, -72, -73, -74, -75, -75, -76, -77, -77, -78, -79, -79, -80, -81, -81, -82, -83, -83, -84, -85, -85, -86, -87, -87, -88, -89, -90, -90, -91, -92, -92, -93, -93, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -93, -93, -93, -92, -92, -91, -91, -90, -90, -89, -89, -88, -88, -87, -86, -86, -85, -84, -84, -83, -82, -81, -80, -79, -78, -77, -77, -76, -75, -75, -74, -73, -72, -71, -71, -70, -69, -69, -68, -67, -66, -66, -65, -64, -63, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -50, -49, -48, -47, -45, -44, -42, -41, -40, -38, -37, -36, -35, -33, -32, -31, -30, -29, -27, -27, -25, -24, -23, -22, -20, -19, -18, -17, -16, -14, -13, -12, -10, -9, -8, -6, -5, -3, -2, -1, 0, 2, 3, 6, 8, 10, 11, 13, 15, 17, 18, 20, 21, 23, 24, 25, 26, 28, 30, 31, 32, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 59, 60, 61, 61, 62, 63, 63, 64, 65, 66, 66, 67, 67, 68, 69, 69, 70, 70, 71, 72, 72, 73, 73, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 80, 80, 81, 81, 82, 83, 83, 84, 85, 86, 86, 87, 88, 89, 90, 91, 91, 92, 92, 93, 94, 94, 94, 95, 95, 96, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 85, 84, 83, 83, 81, 81, 79, 79, 78, 77, 76, 75, 74, 73, 72, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 56, 55, 54, 52, 51, 50, 49, 47, 46, 44, 43, 42, 40, 39, 38, 37, 35, 34, 33, 31, 30, 29, 28, 27, 26, 25, 24, 23, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 6, 5, 4, 3, 2, 1, 0, -1, -3, -4, -6, -8, -10, -12, -14, -15, -17, -18, -20, -21, -23, -24, -25, -27, -28, -29, -31, -32, -33, -34, -36, -37, -38, -39, -40, -41, -43, -44, -45, -46, -47, -48, -49, -50, -51, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -63, -64, -65, -66, -67, -68, -68, -69, -70, -71, -71, -72, -73, -74, -74, -75, -76, -76, -77, -77, -78, -79, -79, -80, -81, -81, -82, -82, -83, -84, -84, -85, -85, -86, -86, -87, -87, -88, -89, -89, -90, -90, -91, -92, -92, -93, -93, -94, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -94, -94, -94, -94, -93, -93, -92, -92, -92, -91, -91, -90, -90, -89, -89, -88, -88, -87, -87, -86, -86, -85, -84, -83, -83, -82, -81, -80, -80, -79, -78, -77, -77, -76, -75, -74, -73, -73, -72, -71, -71, -70, -69, -68, -68, -67, -66, -65, -64, -63, -62, -61, -60, -60, -58, -57, -56, -54, -53, -52, -50, -49, -48, -46, -45, -43, -42, -40, -40, -38, -37, -36, -34, -33, -31, -31, -29, -28, -26, -25, -24, -22, -21, -19, -18, -17, -16, -14, -13, -12, -10, -8, -7, -6, -4, -3, -1, 0, 1, 3, 5, 7, 9, 11, 12, 14, 16, 17, 19, 20, 22, 23, 24, 26, 27, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 51, 52, 53, 54, 55, 56, 56, 57, 58, 58, 59, 60, 61, 62, 62, 63, 64, 65, 65, 66, 67, 68, 68, 69, 70, 71, 71, 72, 73, 74, 74, 75, 76, 76, 77, 78, 78, 79, 80, 80, 81, 82, 82, 83, 84, 84, 85, 86, 86, 87, 88, 89, 90, 90, 91, 92, 92, 93, 93, 94, 94, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 94, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 90, 89, 89, 88, 88, 87, 86, 86, 85, 84, 83, 83, 82, 81, 80, 79, 78, 77, 77, 76, 75, 74, 73, 73, 72, 71, 70, 69, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 53, 52, 51, 50, 49, 47, 46, 45, 44, 42, 41, 40, 39, 38, 37, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 13, 12, 11, 10, 9, 7, 6, 5, 3, 2, 0, -1, -2, -5, -7, -9, -11, -13, -15, -16, -18, -20, -21, -22, -24, -25, -27, -28, -29, -31, -32, -34, -35, -37, -38, -39, -41, -42, -43, -44, -45, -46, -47, -48, -49, -51, -52, -53, -53, -54, -56, -56, -57, -58, -59, -60, -61, -62, -63, -63, -64, -65, -66, -67, -67, -68, -69, -70, -71, -71, -72, -73, -73, -74, -75, -75, -76, -77, -77, -78, -78, -79, -79, -80, -80, -81, -81, -82, -82, -83, -84, -84, -85, -85, -86, -86, -87, -88, -88, -89, -90, -91, -91, -92, -93, -93, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -92, -91, -91, -90, -90, -90, -89, -89, -88, -88, -87, -87, -87, -86, -85, -85, -84, -84, -83, -82, -82, -81, -80, -79, -79, -78, -77, -77, -76, -75, -74, -74, -73, -73, -72, -71, -71, -70, -69, -69, -68, -67, -66, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -53, -52, -51, -49, -47, -46, -45, -43, -43, -41, -40, -39, -38, -37, -35, -34, -33, -32, -31, -29, -28, -26, -25, -24, -22, -21, -20, -19, -18, -17, -15, -14, -13, -11, -10, -9, -7, -6, -5, -3, -1, 0, 0, 2, 4, 6, 7, 9, 11, 13, 15, 16, 17, 19, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 61, 62, 62, 63, 65, 65, 66, 67, 68, 69, 70, 71, 71, 72, 73, 74, 75, 76, 77, 77, 78, 79, 79, 80, 81, 82, 82, 83, 84, 84, 85, 86, 87, 87, 88, 89, 90, 91, 91, 92, 93, 93, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 91, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 85, 85, 84, 83, 82, 81, 80, 79, 78, 78, 77, 76, 75, 75, 74, 73, 73, 71, 71, 70, 69, 68, 68, 67, 66, 65, 64, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 33, 33, 32, 30, 30, 29, 28, 27, 25, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 8, 7, 6, 4, 3, 1, 0, -1, -3, -5, -7, -9, -11, -13, -14, -16, -17, -18, -20, -21, -23, -25, -26, -27, -28, -30, -31, -33, -33, -35, -36, -37, -39, -40, -41, -42, -43, -44, -45, -46, -47, -47, -49, -49, -50, -51, -52, -53, -54, -55, -55, -56, -57, -58, -59, -60, -60, -61, -62, -63, -63, -64, -65, -66, -66, -67, -68, -68, -69, -70, -70, -71, -72, -73, -73, -74, -75, -75, -76, -76, -77, -78, -78, -79, -79, -80, -81, -81, -82, -83, -83, -84, -85, -86, -86, -87, -88, -89, -90, -91, -91, -92, -93, -93, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -93, -93, -92, -92, -92, -91, -91, -91, -90, -90, -90, -89, -89, -88, -88, -87, -87, -86, -86, -85, -85, -84, -84, -83, -82, -81, -80, -79, -78, -77, -76, -76, -75, -74, -74, -73, -72, -71, -71, -70, -69, -68, -67, -66, -66, -65, -64, -63, -62, -61, -60, -59, -57, -56, -55, -54, -52, -51, -49, -48, -47, -46, -44, -43, -42, -40, -39, -38, -36, -35, -34, -33, -31, -30, -29, -27, -26, -25, -24, -22, -21, -20, -19, -18, -16, -15, -14, -13, -12, -11, -10, -9, -8, -6, -5, -4, -3, -1, 0, 0, 2, 3, 4, 6, 8, 10, 11, 12, 14, 16, 17, 18, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 37, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 48, 49, 50, 51, 52, 53, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 62, 63, 64, 65, 65, 66, 67, 68, 69, 70, 70, 71, 72, 73, 73, 74, 75, 75, 76, 77, 77, 78, 79, 79, 80, 81, 81, 82, 83, 83, 84, 85, 86, 86, 87, 88, 88, 89, 90, 91, 91, 92, 93, 93, 94, 94, 94, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 92, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 86, 86, 85, 84, 83, 82, 82, 81, 80, 79, 78, 77, 76, 76, 75, 74, 74, 73, 72, 71, 70, 70, 69, 68, 68, 67, 66, 66, 65, 64, 63, 62, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 47, 46, 44, 43, 42, 40, 39, 37, 36, 35, 34, 33, 32, 31, 30, 28, 27, 26, 25, 24, 23, 21, 20, 19, 18, 17, 15, 14, 13, 12, 10, 9, 8, 6, 5, 4, 2, 1, 0, -1, -3, -5, -7, -9, -11, -12, -14, -16, -18, -19, -21, -22, -23, -25, -27, -28, -29, -30, -32, -33, -34, -36, -37, -38, -40, -40, -42, -43, -44, -45, -46};
int myPWM_V_values[3600] = {-49, -48, -47, -47, -46, -46, -45, -44, -43, -42, -41, -41, -40, -39, -38, -37, -37, -35, -35, -34, -33, -32, -31, -31, -30, -29, -28, -28, -27, -26, -25, -24, -23, -22, -21, -21, -20, -19, -18, -17, -16, -15, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, 0, 0, 2, 3, 5, 7, 9, 11, 13, 15, 16, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 46, 48, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 65, 66, 67, 67, 68, 69, 70, 71, 71, 72, 73, 73, 74, 74, 75, 76, 77, 77, 78, 78, 79, 79, 80, 80, 81, 82, 82, 83, 83, 84, 84, 85, 86, 86, 87, 88, 88, 89, 90, 90, 91, 92, 92, 93, 93, 94, 94, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 92, 92, 91, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 85, 85, 84, 83, 82, 81, 79, 78, 78, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 58, 58, 57, 56, 54, 54, 52, 52, 50, 49, 48, 47, 47, 46, 45, 43, 43, 42, 41, 40, 38, 38, 37, 35, 35, 34, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 15, 15, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, -1, -2, -4, -5, -6, -8, -9, -10, -12, -13, -14, -15, -17, -18, -19, -21, -22, -23, -24, -25, -26, -27, -28, -29, -31, -31, -33, -34, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -45, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -66, -67, -68, -69, -70, -71, -72, -72, -73, -74, -75, -75, -76, -76, -77, -78, -79, -79, -80, -80, -81, -81, -82, -83, -83, -84, -84, -85, -86, -86, -87, -87, -88, -89, -89, -90, -91, -91, -91, -92, -93, -93, -93, -94, -94, -94, -95, -95, -96, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -95, -95, -95, -94, -94, -93, -93, -92, -92, -91, -91, -90, -89, -89, -88, -87, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -75, -74, -74, -73, -72, -71, -69, -69, -68, -67, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -51, -50, -49, -48, -47, -47, -46, -45, -44, -43, -43, -42, -41, -40, -39, -38, -38, -36, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -9, -8, -7, -6, -5, -4, -3, -1, -1, 0, 1, 3, 4, 6, 8, 10, 12, 14, 15, 16, 18, 19, 21, 22, 23, 25, 26, 27, 28, 30, 31, 32, 33, 34, 36, 36, 38, 39, 40, 41, 41, 43, 44, 44, 45, 46, 47, 48, 49, 50, 51, 51, 52, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 62, 62, 63, 64, 65, 66, 66, 67, 68, 69, 69, 70, 71, 71, 72, 73, 73, 74, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 80, 80, 81, 81, 81, 82, 83, 83, 84, 84, 85, 86, 86, 87, 87, 88, 89, 90, 90, 91, 92, 92, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 92, 92, 92, 91, 91, 90, 90, 89, 88, 88, 87, 86, 86, 85, 84, 82, 82, 80, 79, 78, 77, 75, 75, 74, 72, 71, 71, 69, 68, 67, 66, 65, 63, 62, 61, 60, 59, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 40, 40, 39, 37, 36, 36, 35, 33, 32, 32, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, -1, -2, -3, -5, -6, -8, -10, -12, -14, -15, -17, -18, -20, -21, -23, -24, -25, -27, -28, -28, -30, -31, -32, -33, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -49, -50, -51, -52, -53, -54, -55, -56, -57, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -69, -70, -71, -72, -73, -73, -74, -75, -76, -76, -77, -77, -78, -79, -79, -80, -81, -81, -82, -82, -83, -83, -84, -84, -85, -85, -86, -86, -87, -87, -88, -88, -89, -89, -90, -90, -91, -91, -92, -92, -93, -93, -93, -94, -94, -95, -95, -95, -95, -96, -96, -96, -96, -97, -97, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -94, -94, -94, -93, -93, -92, -92, -91, -91, -90, -90, -89, -89, -88, -87, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -68, -66, -66, -65, -64, -62, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -52, -51, -50, -49, -48, -47, -46, -45, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -31, -30, -29, -28, -26, -25, -25, -23, -22, -21, -19, -18, -17, -16, -15, -14, -12, -11, -10, -9, -8, -6, -5, -4, -2, -1, 0, 1, 2, 4, 5, 7, 9, 11, 13, 15, 16, 17, 19, 20, 22, 22, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 43, 44, 46, 46, 47, 48, 49, 50, 50, 51, 52, 53, 55, 56, 56, 57, 58, 59, 60, 62, 62, 63, 64, 65, 66, 67, 68, 69, 69, 70, 71, 72, 72, 73, 74, 75, 75, 76, 77, 77, 78, 78, 79, 80, 80, 81, 82, 82, 83, 84, 84, 85, 85, 86, 86, 87, 88, 88, 89, 90, 91, 91, 92, 92, 93, 93, 94, 94, 95, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 91, 91, 91, 90, 90, 89, 88, 88, 87, 86, 86, 85, 84, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 40, 38, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 23, 21, 21, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 2, 1, 0, -1, -2, -4, -6, -8, -10, -12, -14, -15, -17, -19, -20, -21, -23, -24, -25, -26, -27, -29, -31, -32, -33, -34, -36, -37, -38, -39, -40, -42, -43, -44, -45, -46, -47, -48, -49, -50, -52, -53, -54, -55, -56, -57, -59, -59, -60, -61, -62, -64, -65, -65, -67, -67, -68, -69, -70, -71, -71, -72, -73, -74, -74, -75, -76, -76, -77, -78, -78, -79, -79, -80, -80, -81, -81, -82, -82, -83, -83, -84, -84, -85, -85, -85, -86, -86, -87, -87, -88, -89, -89, -90, -90, -91, -91, -92, -93, -93, -94, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -96, -96, -96, -96, -95, -95, -94, -94, -94, -93, -93, -92, -92, -91, -91, -90, -90, -89, -89, -89, -88, -87, -87, -86, -86, -85, -84, -83, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -73, -71, -71, -70, -69, -68, -67, -67, -66, -65, -64, -63, -62, -61, -60, -60, -59, -58, -57, -56, -55, -54, -54, -53, -52, -51, -50, -50, -48, -48, -47, -46, -45, -44, -43, -42, -41, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -14, -13, -12, -11, -10, -9, -8, -7, -6, -4, -3, -2, -1, 0, 1, 2, 4, 5, 7, 9, 10, 12, 14, 15, 17, 18, 19, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 42, 44, 45, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 65, 66, 67, 68, 69, 70, 71, 71, 73, 73, 74, 75, 76, 76, 77, 78, 78, 79, 80, 81, 81, 82, 83, 83, 84, 84, 85, 86, 86, 87, 88, 88, 89, 90, 91, 91, 92, 92, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 88, 88, 87, 86, 86, 85, 84, 83, 82, 81, 80, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 46, 45, 44, 43, 42, 41, 41, 40, 39, 38, 37, 37, 36, 35, 34, 33, 32, 32, 30, 30, 29, 28, 27, 27, 26, 25, 24, 23, 22, 22, 21, 20, 19, 18, 17, 17, 16, 15, 14, 13, 12, 11, 11, 10, 9, 8, 7, 5, 5, 3, 2, 1, 0, -1, -2, -4, -6, -8, -10, -12, -14, -15, -16, -18, -19, -21, -22, -23, -24, -26, -27, -28, -29, -30, -32, -33, -34, -35, -36, -37, -38, -40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -57, -58, -60, -61, -61, -62, -63, -64, -65, -66, -67, -68, -68, -69, -70, -71, -71, -72, -73, -73, -74, -75, -75, -76, -76, -77, -78, -78, -79, -79, -80, -81, -81, -81, -82, -83, -83, -84, -84, -85, -86, -86, -87, -87, -88, -89, -90, -91, -91, -92, -92, -93, -94, -94, -94, -95, -95, -96, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -93, -93, -93, -92, -92, -91, -91, -91, -90, -90, -89, -89, -88, -88, -87, -87, -86, -85, -85, -84, -83, -82, -81, -79, -78, -78, -76, -75, -75, -73, -72, -71, -71, -70, -69, -68, -66, -66, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -22, -21, -20, -20, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 30, 31, 33, 33, 34, 35, 36, 37, 38, 39, 40, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 62, 62, 63, 64, 65, 66, 67, 68, 69, 69, 70, 71, 72, 73, 73, 74, 75, 75, 76, 77, 77, 78, 79, 79, 80, 81, 81, 82, 82, 83, 83, 84, 85, 85, 86, 86, 87, 88, 88, 89, 90, 90, 91, 91, 92, 92, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 95, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 88, 88, 87, 86, 85, 84, 84, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 66, 66, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 51, 50, 49, 48, 47, 47, 45, 45, 44, 43, 42, 42, 41, 40, 39, 38, 37, 36, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 16, 16, 14, 14, 12, 11, 10, 9, 8, 7, 6, 5, 4, 2, 1, 0, -1, -2, -3, -5, -7, -9, -10, -12, -14, -16, -17, -19, -20, -21, -23, -24, -25, -27, -28, -29, -30, -32, -33, -34, -35, -36, -37, -38, -39, -40, -42, -43, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -61, -62, -63, -64, -65, -65, -66, -67, -68, -69, -69, -70, -71, -71, -72, -72, -73, -74, -74, -75, -75, -76, -76, -77, -78, -78, -79, -79, -80, -80, -81, -81, -82, -82, -83, -83, -84, -84, -85, -85, -86, -87, -87, -88, -89, -89, -90, -91, -91, -92, -92, -93, -93, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -92, -92, -92, -91, -91, -90, -90, -89, -88, -88, -87, -86, -86, -85, -84, -83, -81, -80, -79, -78, -77, -76, -75, -73, -72, -71, -70, -69, -68, -67, -66, -65, -63, -62, -61, -60, -59, -58, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -40, -40, -39, -37, -37, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 5, 6, 8, 10, 11, 13, 15, 17, 18, 19, 21, 22, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 38, 38, 39, 41, 42, 43, 43, 44, 46, 47, 48, 49, 50, 51, 52, 54, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 70, 71, 72, 73, 73, 74, 75, 76, 76, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 89, 89, 90, 90, 91, 91, 92, 92, 93, 93, 93, 94, 94, 95, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 95, 95, 94, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 88, 88, 87, 86, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 73, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 52, 51, 50, 49, 48, 47, 46, 46, 44, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 19, 18, 17, 16, 15, 13, 12, 11, 10, 9, 8, 6, 5, 4, 2, 1, 0, -1, -3, -4, -6, -8, -9, -11, -13, -15, -17, -18, -19, -20, -22, -23, -24, -26, -27, -28, -29, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -47, -48, -49, -50, -51, -52, -53, -54, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -69, -70, -71, -72, -73, -73, -74, -75, -75, -76, -77, -78, -78, -79, -79, -80, -81, -81, -82, -82, -83, -83, -84, -85, -85, -86, -86, -87, -88, -88, -89, -90, -90, -91, -92, -92, -93, -93, -94, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -91, -91, -90, -90, -89, -89, -88, -88, -87, -86, -85, -85, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -61, -60, -59, -58, -57, -56, -55, -54, -53, -53, -52, -51, -49, -48, -48, -47, -46, -45, -44, -43, -42, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -15, -13, -13, -11, -10, -9, -9, -7, -6, -5, -4, -3, -2, 0, 0, 2, 3, 5, 7, 9, 11, 13, 15, 17, 18, 20, 21, 22, 24, 25, 26, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 47, 47, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 60, 61, 63, 64, 65, 65, 67, 67, 68, 69, 70, 71, 71, 72, 73, 74, 74, 75, 76, 76, 77, 77, 78, 79, 79, 80, 80, 81, 81, 82, 82, 83, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 89, 90, 90, 91, 91, 92, 92, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 93, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 86, 86, 85, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 71, 70, 69, 68, 67, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 58, 57, 56, 55, 54, 54, 53, 51, 51, 50, 49, 48, 47, 47, 46, 45, 44, 43, 42, 41, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 27, 27, 25, 24, 23, 22, 21, 20, 19, 18, 17, 15, 15, 13, 12, 11, 10, 9, 8, 7, 5, 4, 3, 2, 1, 0, -1, -2, -4, -5, -7, -8, -10, -12, -14, -15, -17, -18, -19, -21, -22, -23, -24, -25, -26, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -72, -73, -74, -75, -76, -76, -77, -78, -79, -79, -80, -81, -81, -82, -83, -83, -84, -85, -85, -86, -86, -87, -88, -88, -89, -90, -90, -91, -92, -92, -93, -93, -94, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -93, -93, -93, -92, -92, -91, -91, -90, -90, -89, -89, -88, -87, -86, -86, -85, -84, -83, -82, -81, -80, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50};
int myPWM_W_values[3600] = {99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 94, 94, 94, 94, 93, 93, 93, 92, 92, 91, 91, 91, 90, 90, 90, 89, 89, 88, 88, 87, 86, 86, 85, 84, 83, 81, 81, 79, 78, 77, 76, 75, 74, 73, 72, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 46, 45, 44, 43, 42, 41, 40, 39, 37, 37, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 14, 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 0, 0, -1, -2, -4, -5, -7, -9, -10, -12, -14, -15, -17, -18, -20, -21, -22, -24, -25, -26, -27, -28, -29, -30, -32, -33, -35, -36, -37, -38, -39, -41, -42, -43, -45, -46, -47, -49, -50, -52, -53, -55, -56, -57, -58, -59, -60, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -73, -73, -74, -75, -75, -76, -77, -78, -78, -79, -80, -81, -81, -82, -82, -83, -84, -84, -85, -85, -86, -86, -87, -88, -89, -89, -90, -91, -92, -92, -93, -93, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -91, -91, -91, -90, -90, -89, -89, -88, -88, -87, -87, -86, -86, -85, -85, -84, -83, -83, -82, -81, -80, -80, -79, -78, -77, -76, -76, -74, -74, -73, -72, -71, -70, -70, -69, -68, -67, -67, -66, -65, -64, -63, -62, -62, -61, -60, -59, -59, -58, -57, -56, -55, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -39, -38, -37, -35, -34, -33, -32, -31, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -17, -17, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 3, 4, 5, 7, 8, 9, 11, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 50, 51, 52, 53, 55, 56, 57, 59, 60, 60, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 79, 80, 81, 82, 83, 83, 84, 85, 86, 86, 87, 88, 89, 90, 91, 91, 92, 93, 93, 94, 94, 95, 95, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 89, 88, 87, 87, 86, 86, 85, 84, 84, 82, 82, 81, 79, 79, 77, 76, 75, 74, 73, 72, 71, 71, 69, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 48, 47, 46, 45, 44, 43, 42, 41, 41, 39, 38, 38, 37, 35, 35, 34, 32, 32, 31, 29, 29, 27, 27, 26, 25, 24, 23, 22, 21, 20, 19, 19, 18, 17, 16, 15, 15, 14, 13, 12, 11, 10, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, -2, -3, -4, -6, -7, -9, -11, -12, -14, -15, -17, -18, -19, -20, -21, -23, -24, -25, -26, -27, -28, -29, -31, -32, -33, -34, -35, -36, -37, -39, -40, -41, -42, -44, -45, -46, -47, -49, -50, -51, -52, -54, -55, -56, -57, -58, -60, -60, -61, -62, -63, -65, -65, -66, -67, -68, -69, -70, -71, -72, -72, -73, -74, -75, -76, -76, -77, -78, -79, -79, -80, -80, -81, -82, -83, -83, -84, -85, -85, -86, -87, -87, -88, -89, -90, -91, -92, -93, -93, -94, -94, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -95, -94, -94, -93, -93, -93, -92, -92, -92, -91, -91, -91, -90, -90, -89, -89, -89, -88, -88, -87, -87, -86, -86, -85, -85, -84, -84, -83, -82, -81, -79, -78, -77, -76, -75, -74, -73, -72, -71, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -62, -60, -59, -58, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -46, -45, -44, -43, -42, -40, -39, -38, -36, -35, -34, -33, -31, -30, -29, -28, -27, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -3, -1, -1, 0, 1, 2, 2, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 16, 16, 18, 19, 19, 20, 21, 23, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31, 33, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 48, 49, 50, 51, 53, 55, 56, 57, 58, 59, 60, 62, 62, 63, 65, 66, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 79, 80, 81, 82, 82, 83, 84, 85, 85, 86, 87, 88, 88, 89, 90, 91, 92, 92, 93, 94, 94, 94, 95, 95, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 93, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 86, 85, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 71, 70, 69, 68, 67, 66, 65, 64, 63, 63, 62, 61, 60, 59, 58, 57, 56, 55, 55, 54, 53, 52, 51, 51, 50, 49, 48, 47, 47, 45, 44, 44, 43, 42, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30, 29, 28, 27, 25, 25, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, -2, -3, -4, -6, -7, -9, -11, -12, -14, -15, -16, -18, -19, -20, -21, -22, -23, -24, -25, -27, -28, -28, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -57, -59, -60, -61, -62, -62, -63, -64, -65, -66, -67, -67, -68, -69, -70, -71, -71, -72, -73, -73, -74, -75, -75, -76, -76, -77, -78, -78, -79, -80, -80, -81, -82, -82, -83, -84, -85, -85, -86, -87, -88, -89, -89, -90, -91, -92, -92, -93, -94, -94, -95, -95, -95, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -98, -97, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -93, -93, -92, -92, -91, -91, -91, -90, -90, -89, -89, -88, -88, -87, -86, -86, -85, -84, -83, -82, -81, -79, -78, -77, -76, -75, -74, -73, -72, -72, -70, -70, -68, -68, -66, -66, -65, -63, -62, -62, -61, -60, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -46, -45, -44, -43, -41, -40, -39, -38, -36, -35, -34, -33, -31, -30, -29, -28, -27, -26, -25, -24, -23, -21, -21, -19, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -8, -6, -6, -5, -4, -3, -2, -2, 0, 0, 1, 1, 3, 4, 5, 6, 7, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 30, 32, 32, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 47, 48, 49, 50, 52, 53, 55, 56, 57, 58, 59, 60, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 71, 72, 73, 74, 75, 76, 76, 77, 78, 79, 79, 80, 81, 82, 82, 83, 83, 84, 85, 85, 86, 86, 87, 88, 88, 89, 90, 90, 91, 92, 92, 93, 93, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 93, 93, 93, 92, 92, 91, 91, 91, 90, 90, 89, 89, 88, 88, 87, 86, 86, 85, 84, 83, 82, 81, 80, 80, 78, 77, 77, 76, 75, 74, 73, 72, 71, 70, 70, 68, 68, 67, 66, 65, 65, 63, 63, 62, 61, 60, 59, 59, 58, 57, 56, 55, 54, 53, 52, 52, 51, 50, 49, 47, 46, 45, 44, 43, 42, 40, 39, 38, 37, 35, 34, 33, 31, 30, 29, 28, 26, 25, 24, 23, 21, 20, 19, 18, 17, 16, 15, 14, 12, 12, 10, 9, 8, 7, 6, 4, 3, 2, 1, 0, -1, -2, -3, -5, -7, -8, -10, -11, -13, -14, -16, -17, -18, -19, -20, -21, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -38, -39, -41, -42, -42, -43, -45, -46, -47, -47, -49, -50, -52, -53, -54, -55, -56, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -73, -73, -74, -75, -76, -77, -78, -78, -79, -80, -81, -81, -82, -83, -84, -84, -85, -86, -86, -87, -88, -89, -90, -90, -91, -92, -93, -94, -94, -94, -95, -95, -96, -96, -96, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -98, -98, -97, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -95, -94, -94, -94, -94, -93, -93, -93, -92, -92, -92, -91, -91, -91, -90, -90, -89, -89, -89, -88, -87, -87, -86, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -42, -41, -40, -39, -38, -37, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -22, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -7, -6, -5, -3, -3, -1, -1, 0, 0, 2, 3, 5, 7, 8, 9, 11, 13, 15, 17, 18, 19, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 44, 45, 46, 48, 49, 50, 52, 53, 54, 55, 57, 58, 59, 60, 61, 63, 63, 65, 66, 67, 67, 69, 70, 70, 71, 72, 73, 74, 74, 75, 76, 77, 78, 78, 79, 80, 80, 81, 81, 82, 83, 83, 84, 84, 85, 86, 86, 87, 87, 88, 89, 89, 90, 91, 92, 92, 93, 94, 94, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 93, 93, 93, 92, 92, 91, 91, 90, 90, 90, 89, 89, 88, 88, 88, 87, 86, 86, 86, 85, 84, 84, 83, 82, 82, 81, 80, 79, 78, 78, 76, 76, 75, 74, 73, 73, 72, 71, 70, 69, 69, 68, 67, 66, 65, 64, 64, 63, 62, 61, 61, 60, 59, 58, 58, 57, 56, 55, 54, 53, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 39, 38, 37, 36, 35, 34, 32, 31, 30, 29, 28, 27, 26, 24, 24, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, -2, -3, -4, -6, -7, -9, -10, -12, -13, -14, -15, -17, -17, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -39, -40, -41, -42, -43, -44, -45, -47, -48, -50, -51, -52, -54, -55, -56, -57, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -70, -70, -72, -72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -81, -82, -83, -83, -84, -85, -86, -87, -87, -88, -89, -90, -91, -91, -92, -93, -93, -94, -94, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -98, -97, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -91, -91, -90, -90, -89, -89, -88, -88, -87, -87, -86, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -52, -51, -50, -49, -48, -47, -46, -45, -44, -44, -43, -42, -40, -40, -39, -38, -36, -36, -35, -33, -32, -31, -30, -29, -29, -27, -26, -25, -24, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -14, -13, -12, -11, -11, -9, -9, -8, -7, -6, -5, -4, -3, -3, -1, -1, 0, 1, 2, 3, 4, 6, 8, 9, 11, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 52, 53, 54, 55, 56, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 67, 68, 69, 70, 71, 72, 72, 73, 74, 75, 76, 76, 77, 78, 78, 79, 80, 80, 81, 82, 82, 83, 84, 84, 85, 86, 86, 87, 88, 88, 90, 91, 91, 92, 93, 94, 94, 94, 95, 95, 96, 96, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 90, 90, 90, 89, 89, 88, 88, 88, 87, 87, 86, 86, 85, 85, 84, 83, 82, 81, 81, 79, 78, 77, 76, 75, 74, 73, 72, 72, 70, 70, 69, 68, 67, 66, 65, 64, 63, 62, 62, 60, 59, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 40, 39, 38, 37, 36, 35, 33, 32, 31, 30, 28, 27, 26, 25, 24, 23, 21, 21, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10, 10, 8, 7, 6, 6, 4, 4, 3, 2, 1, 0, 0, -1, -2, -3, -4, -5, -7, -8, -8, -10, -11, -12, -14, -14, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -30, -32, -32, -33, -34, -35, -36, -37, -38, -39, -40, -42, -42, -44, -45, -46, -48, -49, -50, -51, -53, -54, -56, -57, -58, -59, -60, -62, -63, -63, -65, -66, -66, -68, -69, -69, -70, -71, -72, -73, -74, -75, -76, -76, -77, -78, -79, -80, -80, -81, -82, -83, -84, -84, -85, -86, -86, -87, -88, -89, -90, -90, -91, -92, -92, -93, -93, -94, -95, -95, -95, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -96, -96, -96, -96, -95, -95, -94, -94, -94, -93, -93, -92, -92, -91, -91, -90, -90, -89, -89, -88, -88, -87, -86, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -56, -55, -54, -53, -52, -51, -51, -50, -49, -48, -47, -46, -45, -45, -44, -43, -41, -41, -40, -38, -37, -36, -35, -34, -33, -31, -30, -29, -28, -27, -26, -25, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -2, -2, 0, 0, 1, 2, 4, 5, 7, 8, 9, 11, 13, 14, 15, 16, 18, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 36, 38, 38, 40, 41, 42, 43, 44, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 60, 61, 62, 63, 64, 65, 66, 67, 67, 68, 69, 70, 71, 71, 72, 73, 73, 74, 75, 75, 76, 76, 77, 78, 78, 79, 80, 80, 81, 82, 82, 83, 84, 84, 85, 86, 87, 87, 88, 89, 90, 91, 92, 92, 93, 93, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 74, 73, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 61, 61, 60, 59, 58, 56, 56, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 42, 41, 40, 39, 38, 36, 35, 34, 33, 32, 30, 29, 28, 27, 26, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 10, 9, 8, 8, 6, 6, 5, 4, 3, 2, 1, 0, 0, 0, -1, -2, -3, -5, -6, -7, -9, -10, -11, -13, -14, -15, -17, -18, -19, -20, -22, -23, -24, -25, -26, -27, -28, -29, -31, -32, -32, -34, -35, -36, -37, -38, -39, -41, -42, -42, -44, -45, -46, -48, -49, -51, -52, -53, -55, -56, -57, -58, -59, -60, -62, -63, -64, -65, -66, -67, -68, -69, -69, -70, -71, -71, -72, -73, -74, -74, -75, -76, -77, -78, -79, -80, -80, -81, -82, -83, -83, -84, -85, -85, -86, -86, -86, -87, -88, -89, -90, -90, -91, -92, -92, -92, -93, -93, -94, -94, -94, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -91, -91, -90, -90, -89, -88, -87, -87, -87, -86, -85, -85, -84, -83, -82, -81, -80, -79, -78, -78, -77, -76, -75, -74, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -65, -64, -63, -62, -61, -61, -60, -59, -58, -57, -57, -56, -55, -54, -53, -52, -51, -49, -48, -47, -46, -45, -43, -42, -41, -40, -39, -38, -37, -36, -34, -33, -32, -31, -29, -28, -27, -26, -25, -23, -22, -21, -20, -19, -18, -17, -15, -15, -13, -12, -11, -9, -8, -7, -5, -5, -3, -3, -2, -1, 0, 0, 2, 5, 7, 8, 9, 11, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 60, 61, 62, 64, 65, 65, 67, 67, 68, 69, 70, 71, 72, 73, 74, 74, 75, 76, 77, 78, 79, 80, 80, 81, 82, 83, 83, 84, 84, 85, 86, 87, 87, 89, 90, 91, 91, 92, 92, 93, 93, 94, 94, 95, 95, 96, 96, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99};
int myPWM_U_values_base[3600] = {-46, -45, -44, -43, -42, -40, -39, -38, -37, -35, -34, -33, -32, -31, -29, -29, -27, -26, -25, -23, -22, -21, -20, -18, -17, -16, -14, -13, -12, -11, -9, -7, -6, -5, -4, -2, -1, 0, 1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 25, 26, 27, 28, 29, 30, 30, 31, 32, 33, 33, 34, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 62, 63, 64, 65, 66, 66, 67, 68, 69, 70, 71, 72, 73, 74, 74, 75, 76, 77, 78, 78, 79, 80, 81, 82, 83, 83, 84, 85, 86, 86, 87, 88, 88, 89, 89, 90, 90, 91, 91, 92, 92, 93, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 85, 85, 84, 83, 83, 82, 81, 81, 80, 79, 78, 78, 77, 76, 75, 74, 74, 73, 71, 70, 69, 68, 67, 66, 65, 64, 62, 61, 59, 58, 57, 55, 54, 52, 51, 49, 48, 46, 45, 43, 42, 40, 39, 38, 37, 35, 34, 33, 31, 30, 30, 28, 27, 26, 25, 24, 23, 22, 21, 20, 20, 19, 18, 17, 16, 15, 14, 14, 13, 12, 11, 10, 9, 9, 8, 7, 6, 6, 5, 4, 3, 2, 2, 1, 0, 0, 0, -1, -2, -3, -3, -4, -5, -5, -6, -7, -7, -8, -9, -10, -10, -11, -12, -12, -14, -14, -15, -16, -16, -17, -18, -19, -20, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -35, -36, -37, -39, -40, -41, -43, -44, -46, -48, -49, -51, -52, -54, -55, -56, -58, -59, -60, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -72, -73, -74, -75, -75, -76, -77, -77, -78, -79, -79, -80, -81, -81, -82, -82, -83, -83, -84, -84, -85, -85, -86, -86, -87, -87, -88, -88, -89, -89, -89, -90, -90, -91, -91, -91, -92, -92, -93, -93, -93, -94, -94, -94, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -96, -96, -96, -96, -95, -95, -94, -94, -94, -93, -93, -92, -92, -92, -91, -91, -90, -90, -89, -89, -88, -88, -87, -86, -86, -85, -85, -84, -83, -83, -82, -81, -80, -80, -79, -78, -77, -76, -75, -74, -73, -71, -70, -69, -67, -66, -64, -63, -61, -60, -58, -56, -54, -52, -50, -49, -46, -45, -43, -41, -39, -37, -35, -33, -32, -30, -28, -26, -25, -23, -21, -19, -18, -16, -15, -13, -12, -10, -9, -7, -5, -4, -2, -1, 0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 83, 84, 85, 86, 86, 87, 88, 89, 89, 90, 90, 91, 91, 92, 92, 93, 93, 93, 94, 94, 95, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 94, 94, 93, 93, 92, 91, 91, 90, 89, 89, 88, 87, 86, 86, 85, 84, 83, 82, 81, 80, 80, 79, 78, 77, 77, 76, 75, 74, 73, 72, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 42, 42, 41, 40, 38, 37, 37, 35, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 24, 23, 22, 21, 20, 19, 18, 17, 17, 16, 15, 14, 13, 12, 12, 10, 10, 9, 8, 7, 6, 5, 4, 4, 3, 2, 1, 0, 0, -1, -1, -2, -3, -3, -4, -5, -5, -5, -6, -7, -7, -7, -8, -9, -9, -10, -10, -11, -11, -12, -13, -13, -13, -14, -15, -15, -16, -17, -17, -18, -19, -20, -20, -21, -22, -23, -24, -25, -26, -27, -29, -30, -32, -34, -36, -38, -40, -42, -45, -46, -48, -50, -51, -53, -54, -56, -57, -58, -59, -60, -60, -61, -62, -63, -64, -64, -65, -66, -67, -67, -68, -68, -69, -69, -70, -71, -71, -72, -72, -73, -73, -74, -74, -75, -75, -76, -76, -77, -77, -78, -78, -79, -79, -79, -80, -80, -81, -81, -82, -82, -82, -83, -84, -84, -84, -85, -85, -86, -86, -87, -87, -88, -88, -88, -89, -89, -89, -90, -90, -90, -91, -91, -91, -92, -92, -93, -93, -93, -94, -94, -95, -95, -96, -96, -97, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -91, -90, -90, -89, -89, -88, -88, -87, -86, -86, -85, -84, -84, -83, -83, -82, -81, -80, -79, -79, -78, -77, -76, -75, -74, -72, -71, -69, -68, -66, -64, -63, -60, -59, -56, -54, -52, -50, -48, -47, -45, -44, -42, -41, -39, -38, -37, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -19, -17, -17, -16, -15, -14, -13, -12, -11, -10, -9, -7, -7, -6, -5, -4, -3, -2, -1, -1, 0, 0, 0, 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 17, 19, 22, 26, 29, 32, 36, 38, 40, 42, 43, 45, 46, 47, 48, 49, 51, 52, 52, 53, 54, 55, 56, 57, 58, 59, 60, 60, 61, 62, 63, 64, 65, 65, 67, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 79, 80, 81, 82, 83, 84, 85, 86, 87, 87, 88, 89, 90, 90, 91, 91, 92, 92, 93, 93, 94, 94, 94, 95, 95, 96, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 94, 94, 93, 93, 92, 91, 91, 90, 89, 88, 87, 86, 85, 84, 83, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 57, 56, 55, 54, 53, 52, 51, 50, 48, 47, 46, 45, 44, 43, 42, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 28, 27, 26, 25, 24, 23, 21, 21, 19, 18, 17, 16, 15, 14, 12, 11, 10, 8, 7, 6, 5, 4, 2, 1, 0, -1, -2, -3, -4, -5, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -20, -21, -22, -23, -24, -25, -26, -26, -27, -28, -29, -30, -31, -31, -32, -33, -34, -35, -36, -37, -37, -38, -39, -40, -41, -42, -42, -43, -44, -45, -46, -47, -48, -48, -49, -50, -51, -52, -53, -54, -55, -55, -56, -57, -58, -59, -60, -60, -61, -62, -63, -64, -65, -65, -66, -67, -68, -69, -70, -70, -71, -72, -73, -74, -74, -75, -76, -77, -78, -78, -79, -80, -80, -81, -82, -83, -83, -84, -84, -85, -86, -86, -87, -87, -88, -89, -89, -90, -90, -91, -91, -91, -92, -92, -93, -93, -93, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -95, -94, -94, -93, -93, -93, -92, -92, -92, -91, -91, -90, -90, -90, -89, -89, -88, -88, -87, -87, -86, -86, -85, -85, -84, -84, -83, -83, -82, -81, -81, -80, -80, -79, -78, -78, -77, -76, -75, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -64, -62, -61, -60, -58, -56, -54, -52, -50, -49, -46, -45, -42, -40, -39, -37, -35, -33, -32, -31, -29, -28, -26, -25, -24, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -12, -10, -10, -9, -8, -7, -6, -5, -4, -4, -3, -2, -1, 0, 0, 0, 1, 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 20, 22, 22, 23, 24, 26, 27, 28, 29, 30, 31, 33, 34, 35, 37, 39, 40, 42, 43, 45, 47, 49, 51, 52, 54, 56, 58, 59, 61, 62, 64, 65, 66, 67, 68, 69, 70, 72, 73, 73, 74, 75, 76, 76, 77, 78, 79, 79, 80, 80, 81, 82, 82, 83, 83, 84, 84, 85, 86, 86, 86, 87, 87, 88, 88, 89, 89, 89, 90, 90, 91, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 96, 96, 96, 95, 95, 94, 93, 93, 92, 92, 91, 90, 89, 89, 88, 87, 86, 85, 84, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 69, 69, 67, 67, 65, 64, 63, 62, 61, 59, 58, 57, 56, 55, 54, 53, 51, 50, 49, 48, 47, 45, 44, 43, 42, 41, 39, 38, 37, 36, 35, 34, 32, 31, 30, 29, 27, 26, 25, 24, 22, 22, 20, 18, 17, 16, 15, 13, 12, 11, 9, 8, 7, 5, 3, 2, 1, 0, -1, -2, -3, -5, -6, -7, -8, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -19, -21, -21, -22, -23, -24, -25, -26, -26, -28, -28, -29, -30, -31, -31, -32, -33, -34, -35, -35, -36, -37, -38, -39, -40, -40, -41, -42, -43, -43, -44, -45, -46, -47, -47, -48, -49, -50, -51, -52, -52, -53, -54, -55, -56, -56, -57, -58, -59, -60, -61, -61, -63, -63, -64, -65, -66, -67, -68, -68, -70, -71, -72, -72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -81, -82, -83, -84, -84, -85, -86, -87, -87, -88, -88, -89, -90, -90, -91, -91, -92, -92, -92, -93, -93, -94, -94, -94, -95, -95, -95, -95, -96, -96, -96, -96, -97, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -92, -92, -91, -91, -90, -90, -90, -89, -88, -88, -87, -87, -86, -85, -85, -84, -83, -83, -82, -81, -81, -80, -79, -78, -78, -77, -76, -75, -74, -73, -72, -71, -71, -69, -68, -67, -66, -65, -63, -62, -61, -59, -58, -56, -55, -53, -52, -50, -49, -47, -46, -44, -43, -41, -40, -39, -37, -36, -34, -33, -32, -31, -30, -29, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -16, -14, -14, -13, -12, -11, -11, -10, -9, -8, -7, -7, -6, -5, -4, -3, -3, -2, -1, -1, 0, 0, 1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 12, 13, 14, 14, 15, 16, 17, 18, 18, 19, 20, 21, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 42, 44, 45, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 61, 62, 64, 65, 66, 67, 68, 69, 70, 71, 71, 72, 73, 74, 75, 75, 76, 77, 77, 78, 79, 79, 80, 81, 81, 81, 82, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 88, 89, 89, 90, 90, 90, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 93, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 88, 87, 86, 86, 85, 85, 84, 83, 83, 82, 81, 80, 80, 79, 78, 77, 76, 75, 74, 73, 72, 70, 69, 68, 67, 66, 64, 62, 61, 59, 58, 56, 54, 52, 50, 49, 47, 45, 43, 41, 39, 37, 36, 34, 32, 31, 29, 27, 25, 24, 22, 20, 18, 17, 16, 14, 12, 11, 9, 8, 6, 5, 4, 2, 1, 0, -1, -2, -3, -4, -6, -7, -8, -10, -10, -12, -12, -14, -15, -16, -17, -18, -19, -20, -22, -23, -23, -25, -26, -27, -28, -28, -30, -30, -31, -32, -33, -35, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -53, -53, -55, -56, -57, -57, -59, -60, -61, -62, -63, -63, -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -82, -83, -84, -85, -85, -86, -87, -87, -88, -89, -89, -90, -91, -91, -91, -92, -92, -93, -93, -94, -94, -94, -95, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -98, -97, -97, -97, -96, -96, -96, -95, -95, -94, -94, -93, -93, -92, -92, -91, -90, -90, -89, -88, -87, -87, -86, -85, -84, -83, -83, -82, -81, -80, -79, -79, -78, -77, -76, -75, -75, -73, -73, -72, -71, -70, -69, -68, -68, -66, -65, -65, -64, -63, -62, -61, -60, -59, -58, -56, -55, -54, -53, -52, -51, -50, -49, -48, -46, -46, -45, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -25, -23, -23, -21, -21, -20, -19, -18, -17, -16, -15, -14, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20, 20, 22, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30, 32, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 50, 51, 52, 53, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 67, 69, 69, 70, 71, 72, 72, 73, 74, 74, 75, 76, 76, 77, 77, 78, 79, 79, 80, 80, 81, 82, 82, 82, 83, 84, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 88, 89, 89, 90, 90, 90, 91, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 95, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 81, 81, 80, 79, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 66, 65, 63, 61, 60, 58, 55, 53, 51, 49, 46, 44, 42, 40, 38, 35, 34, 32, 30, 29, 27, 26, 24, 23, 21, 20, 19, 18, 17, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 4, 4, 3, 2, 1, 0, 0, -1, -1, -3, -3, -4, -5, -5, -7, -7, -8, -9, -10, -11, -12, -13, -13, -15, -15, -17, -17, -19, -19, -20, -21, -22, -23, -24, -25, -26, -28, -29, -30, -31, -32, -33, -34, -36, -37, -38, -39, -41, -42, -43, -45, -46, -47, -49, -51, -52, -53, -55, -56, -58, -59, -60, -62, -63, -65, -66, -67, -69, -70, -71, -73, -74, -75, -76, -77, -78, -79, -80, -81, -82, -83, -84, -84, -85, -86, -87, -87, -88, -89, -89, -90, -90, -91, -91, -92, -92, -93, -93, -94, -94, -94, -95, -95, -95, -96, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -96, -96, -96, -95, -95, -94, -93, -93, -92, -91, -91, -90, -89, -88, -87, -86, -85, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -62, -61, -60, -59, -58, -57, -56, -55, -53, -52, -51, -49, -48, -47, -46, -45, -44, -42, -42, -40, -39, -38, -37, -36, -34, -34, -32, -31, -30, -29, -28, -27, -26, -24, -23, -22, -21, -20, -19, -17, -16, -15, -14, -13, -11, -11, -9, -8, -6, -5, -4, -3, -1, 0, 0, 1, 2, 4, 5, 6, 8, 9, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 24, 25, 26, 27, 28, 29, 29, 31, 31, 32, 33, 34, 35, 35, 36, 37, 38, 39, 40, 41, 41, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54, 54, 55, 56, 57, 58, 59, 60, 60, 61, 62, 63, 64, 65, 65, 66, 67, 68, 69, 69, 70, 71, 71, 72, 73, 74, 75, 76, 76, 77, 78, 78, 79, 80, 80, 81, 82, 82, 83, 84, 84, 85, 85, 86, 86, 87, 88, 88, 89, 89, 90, 90, 91, 91, 91, 92, 92, 93, 93, 94, 94, 94, 94, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 95, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 91, 91, 90, 90, 90, 89, 89, 88, 88, 88, 87, 87, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 79, 78, 78, 77, 76, 76, 75, 74, 73, 73, 72, 71, 70, 69, 68, 66, 65, 64, 62, 61, 59, 58, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 38, 36, 35, 33, 32, 30, 29, 27, 26, 25, 24, 23, 22, 20, 20, 18, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 9, 8, 7, 6, 5, 4, 4, 3, 2, 1, 1, 0, 0, -1, -2, -2, -3, -4, -5, -5, -6, -7, -8, -8, -9, -10, -11, -12, -12, -13, -14, -15, -16, -17, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -29, -30, -31, -32, -34, -35, -36, -38, -40, -41, -43, -45, -46, -48, -50, -52, -54, -55, -56, -58, -60, -61, -62, -64, -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -75, -76, -77, -78, -78, -79, -80, -80, -81, -82, -82, -83, -83, -84, -84, -85, -85, -86, -86, -87, -87, -88, -88, -89, -89, -89, -90, -90, -91, -91, -91, -92, -92, -93, -93, -93, -94, -94, -94, -95, -95, -95, -96, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -96, -96, -95, -95, -94, -94, -93, -92, -92, -91, -91, -90, -89, -88, -87, -86, -86, -85, -84, -83, -83, -82, -81, -80, -78, -77, -76, -76, -75, -74, -72, -71, -70, -69, -68, -67, -66, -64, -63, -62, -61, -60, -58, -57, -56, -55, -54, -52, -51, -50, -49, -48};
int myPWM_V_values_base[3600] = {99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 95, 95, 94, 94, 94, 93, 93, 92, 92, 91, 90, 90, 89, 89, 88, 87, 87, 86, 85, 85, 84, 83, 82, 82, 81, 80, 80, 79, 78, 77, 77, 76, 75, 75, 74, 74, 73, 72, 72, 71, 70, 70, 69, 68, 68, 67, 67, 66, 65, 65, 64, 63, 63, 62, 61, 61, 60, 59, 58, 58, 57, 56, 56, 55, 54, 53, 53, 52, 51, 50, 49, 48, 48, 47, 46, 45, 44, 43, 42, 41, 41, 40, 38, 38, 36, 36, 35, 34, 33, 32, 30, 29, 28, 27, 26, 25, 24, 22, 21, 20, 18, 17, 16, 15, 13, 12, 11, 9, 8, 7, 5, 4, 2, 1, 0, -1, -2, -4, -5, -6, -8, -9, -10, -11, -12, -14, -14, -16, -17, -17, -19, -20, -21, -21, -23, -23, -25, -25, -26, -27, -28, -29, -30, -31, -31, -33, -33, -34, -35, -36, -37, -37, -39, -39, -40, -41, -42, -43, -43, -44, -45, -46, -46, -47, -48, -49, -50, -50, -51, -52, -53, -53, -54, -55, -56, -57, -57, -58, -59, -60, -61, -61, -62, -63, -64, -65, -65, -66, -67, -68, -68, -69, -70, -71, -72, -72, -73, -74, -75, -75, -76, -77, -78, -78, -79, -80, -80, -81, -82, -82, -83, -84, -85, -85, -86, -86, -87, -88, -88, -89, -89, -90, -90, -91, -91, -92, -92, -93, -93, -94, -94, -94, -95, -95, -96, -96, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -92, -91, -91, -91, -91, -90, -90, -90, -89, -89, -89, -88, -88, -88, -87, -87, -86, -86, -86, -85, -85, -84, -84, -84, -83, -83, -82, -82, -82, -81, -81, -80, -80, -79, -79, -78, -78, -78, -77, -77, -76, -76, -75, -75, -74, -74, -73, -72, -72, -71, -70, -70, -69, -68, -67, -66, -66, -65, -63, -63, -62, -60, -59, -58, -56, -55, -54, -52, -51, -49, -48, -47, -45, -43, -42, -40, -39, -38, -36, -35, -33, -32, -31, -30, -29, -27, -26, -25, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 6, 8, 8, 9, 10, 11, 12, 14, 14, 16, 16, 18, 19, 20, 21, 22, 23, 25, 26, 27, 29, 30, 32, 33, 34, 36, 38, 40, 41, 43, 44, 46, 48, 50, 51, 53, 54, 56, 57, 58, 60, 61, 62, 63, 64, 66, 66, 67, 68, 69, 70, 71, 72, 73, 74, 74, 75, 76, 76, 77, 78, 79, 79, 80, 81, 81, 82, 83, 83, 84, 85, 85, 86, 86, 87, 88, 88, 89, 89, 90, 90, 91, 91, 92, 93, 93, 94, 94, 95, 95, 96, 96, 96, 97, 97, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 97, 97, 96, 96, 96, 95, 95, 94, 94, 93, 92, 92, 91, 91, 90, 90, 89, 89, 89, 88, 88, 88, 87, 87, 86, 86, 86, 85, 85, 84, 84, 83, 83, 83, 82, 81, 81, 80, 80, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 73, 73, 72, 71, 70, 68, 67, 65, 62, 60, 58, 56, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 44, 43, 42, 41, 40, 40, 39, 38, 37, 36, 36, 35, 34, 33, 32, 31, 31, 30, 28, 28, 27, 25, 24, 23, 22, 21, 19, 18, 17, 15, 14, 12, 11, 10, 8, 7, 6, 4, 3, 2, 0, 0, -1, -3, -4, -5, -6, -8, -9, -10, -11, -13, -14, -16, -18, -20, -22, -24, -25, -27, -28, -30, -31, -32, -33, -35, -35, -37, -38, -39, -39, -40, -42, -42, -43, -44, -45, -45, -46, -47, -48, -48, -49, -49, -50, -51, -51, -52, -53, -53, -54, -55, -55, -56, -57, -57, -58, -59, -60, -60, -61, -62, -63, -63, -64, -65, -66, -66, -68, -69, -69, -70, -71, -72, -73, -75, -75, -76, -77, -79, -80, -81, -82, -83, -84, -84, -85, -86, -87, -88, -88, -89, -90, -90, -91, -92, -92, -92, -93, -93, -94, -94, -95, -95, -95, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -96, -95, -95, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -92, -91, -91, -91, -90, -90, -90, -89, -89, -89, -88, -88, -87, -87, -86, -86, -86, -85, -85, -84, -84, -83, -83, -82, -82, -81, -81, -80, -80, -79, -79, -78, -78, -77, -77, -76, -76, -75, -75, -74, -73, -73, -72, -72, -71, -70, -69, -69, -68, -67, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -49, -48, -47, -46, -44, -43, -42, -41, -40, -39, -38, -36, -35, -34, -33, -32, -31, -29, -29, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 36, 37, 39, 40, 41, 43, 45, 46, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 60, 62, 62, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 72, 73, 74, 74, 75, 76, 76, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 87, 87, 88, 88, 88, 89, 89, 90, 90, 91, 91, 92, 92, 93, 93, 94, 94, 95, 95, 96, 96, 97, 97, 97, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 97, 97, 97, 96, 96, 95, 95, 95, 94, 94, 93, 93, 92, 92, 92, 91, 91, 90, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 77, 77, 76, 76, 75, 74, 74, 73, 72, 71, 71, 70, 69, 68, 67, 66, 66, 65, 63, 63, 62, 61, 60, 58, 57, 56, 55, 53, 52, 51, 49, 48, 47, 45, 43, 42, 40, 39, 37, 35, 33, 32, 30, 28, 26, 25, 23, 21, 20, 18, 16, 15, 13, 11, 10, 8, 6, 5, 4, 2, 0, 0, -1, -3, -4, -5, -6, -8, -9, -10, -11, -12, -14, -15, -16, -17, -18, -20, -20, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -36, -38, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -74, -75, -76, -77, -78, -79, -80, -82, -83, -84, -85, -86, -87, -87, -88, -89, -90, -91, -91, -92, -92, -93, -93, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -92, -92, -91, -91, -90, -90, -89, -89, -88, -88, -87, -86, -86, -85, -85, -84, -83, -83, -82, -81, -81, -80, -79, -79, -78, -78, -77, -76, -76, -75, -74, -74, -73, -73, -72, -72, -71, -70, -70, -69, -68, -68, -67, -66, -66, -65, -64, -64, -63, -62, -62, -61, -60, -60, -59, -58, -57, -56, -56, -55, -54, -53, -52, -52, -51, -50, -49, -48, -47, -46, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -26, -26, -24, -23, -22, -21, -20, -19, -18, -16, -15, -14, -13, -12, -10, -9, -8, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 29, 30, 31, 32, 33, 35, 36, 38, 39, 40, 41, 42, 44, 45, 46, 48, 49, 50, 51, 52, 53, 55, 56, 56, 58, 59, 60, 61, 62, 63, 64, 65, 65, 66, 67, 68, 69, 70, 70, 71, 72, 72, 73, 74, 75, 75, 76, 77, 77, 78, 78, 79, 80, 80, 81, 81, 82, 82, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 89, 89, 90, 90, 90, 91, 91, 92, 92, 93, 93, 93, 94, 94, 95, 95, 95, 96, 96, 97, 97, 97, 97, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 90, 89, 89, 88, 88, 88, 87, 87, 87, 86, 86, 85, 85, 85, 84, 84, 83, 83, 83, 82, 82, 81, 80, 80, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 74, 74, 73, 72, 72, 71, 70, 69, 68, 68, 67, 66, 65, 64, 62, 61, 60, 59, 57, 55, 54, 52, 51, 49, 47, 45, 43, 41, 40, 38, 36, 34, 33, 31, 29, 28, 26, 25, 24, 23, 21, 20, 19, 17, 17, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 4, 4, 3, 2, 1, 0, 0, -1, -2, -3, -4, -5, -6, -7, -7, -9, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -34, -35, -36, -37, -38, -39, -40, -42, -43, -44, -45, -46, -47, -48, -50, -51, -52, -53, -55, -56, -57, -58, -59, -61, -62, -63, -64, -65, -67, -68, -69, -71, -71, -73, -74, -75, -76, -77, -78, -79, -80, -81, -82, -83, -84, -85, -86, -87, -88, -88, -89, -90, -90, -91, -92, -92, -93, -93, -94, -95, -95, -95, -96, -96, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -93, -93, -92, -92, -91, -90, -90, -89, -89, -88, -87, -87, -86, -86, -85, -84, -83, -83, -82, -81, -81, -80, -79, -79, -78, -77, -77, -76, -76, -75, -74, -74, -73, -72, -72, -71, -71, -70, -70, -69, -68, -67, -67, -66, -66, -65, -64, -64, -63, -62, -62, -61, -60, -60, -59, -58, -58, -57, -56, -55, -55, -54, -53, -52, -52, -51, -50, -49, -48, -47, -47, -46, -45, -44, -43, -42, -41, -41, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -27, -26, -25, -24, -22, -21, -20, -19, -17, -15, -14, -13, -11, -10, -9, -7, -6, -4, -3, -1, 0, 0, 2, 3, 5, 6, 7, 9, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31, 32, 33, 34, 35, 35, 37, 37, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 48, 48, 49, 50, 51, 52, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 60, 61, 62, 63, 64, 64, 65, 66, 67, 67, 68, 69, 70, 71, 71, 72, 73, 74, 74, 75, 76, 77, 78, 78, 79, 80, 80, 81, 82, 82, 83, 84, 84, 85, 86, 86, 87, 87, 88, 89, 89, 90, 90, 91, 91, 92, 92, 93, 93, 94, 94, 94, 95, 95, 96, 96, 96, 97, 97, 97, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 95, 95, 95, 95, 94, 94, 93, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 90, 89, 89, 89, 88, 88, 87, 87, 87, 86, 86, 86, 85, 85, 84, 84, 84, 83, 83, 82, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 78, 77, 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, 70, 70, 69, 68, 67, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 55, 53, 52, 50, 49, 47, 46, 45, 43, 41, 39, 38, 37, 35, 34, 32, 31, 30, 29, 27, 26, 24, 24, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 11, 11, 10, 9, 7, 7, 5, 5, 4, 3, 2, 1, 0, 0, -1, -2, -2, -4, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -16, -17, -19, -19, -21, -22, -23, -24, -25, -26, -28, -29, -30, -31, -33, -34, -36, -37, -39, -40, -42, -44, -45, -47, -49, -51, -52, -53, -55, -56, -57, -59, -60, -61, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -72, -73, -74, -75, -76, -76, -77, -78, -78, -79, -80, -81, -81, -82, -82, -83, -84, -84, -85, -85, -86, -87, -87, -88, -88, -89, -89, -90, -91, -91, -92, -92, -93, -93, -94, -94, -94, -95, -96, -96, -96, -97, -97, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -97, -97, -97, -96, -96, -95, -95, -94, -93, -93, -92, -92, -91, -91, -90, -89, -89, -88, -87, -87, -86, -86, -85, -84, -84, -83, -82, -82, -81, -80, -79, -79, -78, -77, -77, -76, -75, -74, -74, -73, -72, -71, -71, -70, -69, -69, -68, -67, -66, -66, -65, -64, -63, -62, -62, -61, -60, -59, -58, -57, -56, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -40, -40, -38, -37, -36, -35, -34, -32, -31, -30, -29, -27, -26, -24, -23, -22, -20, -18, -16, -15, -14, -12, -11, -9, -7, -5, -4, -3, -1, 0, 1, 2, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31, 32, 33, 34, 35, 36, 36, 37, 39, 39, 40, 41, 41, 42, 43, 44, 45, 46, 46, 48, 48, 49, 50, 51, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 61, 62, 63, 64, 65, 66, 67, 68, 68, 70, 70, 72, 72, 73, 75, 76, 77, 78, 78, 80, 81, 81, 82, 83, 84, 85, 86, 87, 87, 88, 89, 89, 90, 91, 91, 92, 92, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 90, 89, 89, 88, 88, 87, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 81, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 72, 72, 71, 70, 70, 69, 68, 68, 67, 66, 65, 64, 63, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 40, 39, 38, 37, 36, 35, 33, 32, 31, 30, 28, 28, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 8, 6, 6, 5, 4, 3, 2, 1, 0, 0, 0, -1, -2, -3, -4, -5, -5, -7, -7, -8, -9, -10, -10, -12, -12, -13, -14, -15, -16, -17, -18, -19, -20, -20, -21, -22, -23, -24, -25, -26, -27, -28, -30, -31, -32, -33, -35, -36, -37, -38, -39, -41, -42, -44, -45, -47, -48, -49, -51, -52, -53, -55, -56, -57, -58, -59, -60, -62, -63, -63, -64, -65, -66, -67, -68, -69, -70, -70, -71, -72, -72, -73, -74, -74, -75, -76, -76, -77, -78, -78, -79, -79, -80, -81, -81, -82, -82, -83, -84, -84, -84, -85, -85, -86, -86, -87, -87, -88, -89, -89, -89, -90, -90, -91, -91, -92, -92, -93, -93, -94, -94, -95, -95, -95, -96, -96, -97, -97, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -93, -93, -93, -92, -92, -91, -91, -91, -90, -90, -89, -89, -88, -88, -88, -87, -87, -86, -86, -86, -85, -85, -84, -84, -83, -83, -82, -82, -81, -81, -80, -80, -79, -79, -78, -78, -77, -76, -76, -75, -75, -74, -73, -72, -72, -71, -70, -69, -69, -68, -67, -66, -65, -64, -63, -62, -62, -60, -59, -58, -57, -56, -54, -53, -52, -51, -49, -47, -46, -44, -43, -41, -40, -38, -36, -34, -33, -31, -29, -27, -26, -24, -22, -21, -19, -18, -16, -14, -12, -10, -9, -7, -6, -4, -3, -1, 0, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 13, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 35, 36, 37, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 58, 59, 61, 62, 63, 63, 64, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 85, 86, 87, 88, 88, 89, 90, 91, 91, 92, 92, 93, 93, 94, 95, 95, 95, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 91, 90, 89, 89, 88, 88, 87, 87, 86, 85, 85, 84, 83, 83, 82, 81, 80, 80, 79, 79, 78, 77, 77, 76, 75, 75, 74, 73, 73, 72, 72, 71, 70, 70, 69, 68, 68, 67, 66, 66, 65, 65, 64, 63, 62, 62, 61, 60, 60, 59, 58, 57, 56, 55, 55, 54, 53, 52, 52, 51, 50, 49, 48, 47, 46, 45, 44, 44, 42, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 26, 26, 24, 23, 23, 21, 20, 19, 18, 17, 16, 15, 13, 12, 11, 10, 9, 8, 6, 6, 4, 3, 2, 1, 0, 0, -2, -3, -4, -5, -6, -7, -9, -9, -11, -11, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -24, -25, -26, -27, -28, -29, -31, -32, -33, -34, -35, -37, -38, -39, -41, -42, -43, -44, -46, -47, -48, -49, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -65, -66, -67, -68, -69, -70, -70, -71, -72, -73, -73, -74, -75, -75, -76, -77, -77, -78, -79, -79, -80, -80, -81, -81, -82, -83, -83, -84, -84, -85, -85, -86, -86, -87, -87, -88, -88, -89, -89, -89, -90, -90, -91, -91, -92, -92, -93, -93, -93, -94, -94, -94, -95, -95, -96, -96, -96, -97, -97, -97, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -93, -92, -92, -92, -91, -91, -91, -90, -90, -89, -89, -89, -88, -88, -88, -87, -87, -87, -86, -86, -85, -85, -85, -84, -84, -83, -83, -83, -82, -82, -81, -81, -80, -80, -80, -79, -79, -78, -78, -77, -76, -76, -75, -75, -74, -73, -73, -72, -71, -70, -70, -69, -68, -67, -66, -65, -64, -63, -61, -60, -59, -57, -56, -54, -53, -51, -49, -47, -45, -44, -42, -40, -39, -37, -35, -34, -33, -31, -29, -28, -27, -25, -24, -23, -21, -20, -19, -18, -17, -16, -15, -13, -13, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 4, 6, 6, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 26, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 50, 51, 52, 54, 55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 86, 87, 88, 89, 89, 90, 91, 91, 92, 93, 93, 94, 94, 95, 95, 96, 96, 96, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99};
int myPWM_W_values_base[3600] = {-52, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -69, -70, -71, -72, -73, -74, -75, -76, -77, -78, -78, -79, -80, -81, -82, -82, -83, -84, -85, -85, -86, -87, -87, -88, -89, -89, -90, -90, -91, -91, -92, -92, -93, -93, -93, -94, -94, -94, -95, -95, -95, -95, -96, -96, -96, -96, -97, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -93, -93, -92, -92, -91, -91, -90, -90, -89, -88, -88, -87, -86, -86, -85, -84, -83, -83, -82, -81, -81, -80, -79, -79, -78, -77, -77, -76, -75, -74, -74, -73, -73, -72, -71, -71, -70, -69, -69, -68, -67, -67, -66, -65, -64, -64, -63, -62, -62, -61, -60, -59, -59, -58, -57, -57, -56, -55, -54, -54, -53, -52, -51, -51, -49, -49, -48, -47, -46, -46, -45, -44, -43, -42, -41, -41, -40, -39, -38, -37, -36, -35, -34, -34, -32, -31, -31, -29, -29, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -15, -14, -13, -12, -11, -9, -8, -7, -6, -5, -3, -2, -1, 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 17, 18, 20, 21, 22, 24, 25, 26, 28, 29, 31, 32, 34, 36, 37, 39, 40, 42, 44, 45, 47, 48, 50, 51, 52, 53, 54, 55, 55, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 65, 66, 66, 67, 67, 67, 68, 69, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 73, 74, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, 80, 81, 82, 82, 83, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 89, 89, 90, 90, 91, 91, 92, 93, 93, 94, 95, 96, 96, 97, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 97, 97, 97, 97, 96, 96, 96, 96, 96, 95, 95, 95, 95, 95, 94, 94, 94, 93, 93, 93, 93, 92, 92, 92, 91, 91, 91, 90, 90, 89, 89, 89, 88, 88, 87, 87, 80, 80, 79, 78, 78, 77, 76, 76, 75, 74, 73, 73, 72, 71, 70, 69, 68, 67, 65, 64, 63, 62, 61, 59, 57, 56, 54, 53, 51, 50, 48, 46, 45, 43, 41, 40, 39, 37, 36, 34, 33, 32, 30, 29, 28, 27, 26, 24, 23, 22, 21, 19, 19, 17, 16, 15, 14, 13, 12, 10, 9, 8, 7, 6, 5, 4, 2, 1, 0, 0, -1, -3, -4, -5, -6, -7, -9, -10, -11, -13, -15, -16, -17, -19, -20, -22, -24, -26, -27, -29, -31, -33, -35, -37, -39, -41, -42, -45, -47, -49, -50, -52, -54, -56, -58, -59, -61, -63, -64, -65, -67, -68, -69, -71, -72, -73, -74, -75, -76, -78, -78, -79, -81, -81, -82, -83, -84, -85, -85, -86, -87, -87, -88, -89, -89, -90, -90, -91, -91, -92, -92, -93, -93, -93, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -94, -94, -93, -93, -92, -91, -91, -90, -89, -89, -88, -87, -87, -86, -85, -84, -83, -83, -82, -81, -80, -80, -79, -79, -78, -77, -76, -76, -75, -74, -73, -73, -72, -71, -71, -70, -70, -69, -68, -67, -67, -66, -65, -65, -64, -63, -63, -62, -61, -60, -60, -59, -58, -58, -57, -56, -55, -55, -54, -53, -53, -52, -51, -50, -50, -48, -48, -47, -46, -45, -44, -44, -42, -42, -41, -40, -39, -38, -37, -36, -35, -34, -32, -31, -30, -29, -28, -26, -25, -24, -22, -21, -19, -18, -16, -15, -13, -11, -9, -8, -6, -5, -3, -2, 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20, 21, 22, 24, 25, 26, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 61, 62, 62, 63, 64, 65, 66, 66, 67, 68, 68, 69, 70, 70, 71, 72, 73, 73, 74, 74, 75, 76, 76, 77, 77, 78, 78, 79, 80, 80, 80, 81, 82, 82, 83, 83, 83, 84, 84, 85, 86, 86, 86, 87, 87, 88, 88, 88, 89, 89, 90, 90, 90, 91, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 94, 95, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 91, 91, 91, 90, 90, 89, 89, 89, 88, 88, 87, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 77, 77, 76, 75, 74, 74, 73, 73, 72, 71, 70, 69, 69, 68, 67, 66, 64, 64, 63, 61, 60, 58, 58, 56, 55, 54, 52, 50, 49, 48, 46, 45, 43, 42, 41, 39, 38, 37, 36, 35, 34, 32, 31, 30, 29, 28, 27, 26, 24, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, -2, -2, -4, -5, -6, -7, -8, -9, -10, -11, -13, -14, -15, -16, -17, -19, -21, -22, -23, -25, -27, -28, -31, -32, -34, -37, -38, -41, -43, -45, -48, -50, -53, -55, -57, -59, -61, -62, -64, -66, -67, -68, -70, -71, -72, -73, -74, -75, -76, -76, -77, -78, -79, -79, -80, -80, -81, -82, -82, -83, -83, -84, -85, -85, -86, -86, -87, -87, -87, -88, -88, -88, -89, -89, -90, -90, -91, -91, -91, -91, -92, -92, -92, -93, -93, -94, -94, -94, -94, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -96, -96, -95, -95, -94, -94, -93, -93, -92, -91, -91, -90, -89, -89, -88, -87, -86, -86, -85, -84, -84, -83, -82, -82, -81, -80, -79, -79, -78, -77, -76, -76, -75, -74, -74, -72, -72, -71, -70, -70, -69, -68, -67, -67, -66, -65, -64, -63, -63, -62, -61, -60, -59, -59, -58, -57, -56, -55, -55, -54, -53, -52, -51, -50, -49, -48, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -36, -35, -34, -33, -32, -31, -30, -28, -27, -25, -24, -22, -21, -19, -17, -16, -14, -12, -10, -8, -6, -4, -3, -1, 0, 2, 4, 6, 8, 9, 11, 12, 14, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28, 30, 31, 32, 33, 34, 36, 37, 39, 40, 41, 42, 43, 45, 45, 47, 48, 49, 50, 51, 52, 54, 54, 56, 57, 57, 59, 60, 61, 62, 62, 63, 64, 65, 66, 67, 68, 68, 69, 70, 71, 72, 72, 73, 74, 75, 76, 76, 77, 78, 79, 79, 80, 81, 81, 82, 83, 83, 84, 85, 86, 86, 87, 87, 88, 88, 89, 90, 90, 90, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 95, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 93, 93, 92, 92, 92, 91, 91, 90, 89, 89, 89, 88, 87, 87, 86, 86, 85, 84, 84, 83, 82, 82, 81, 80, 80, 79, 78, 78, 77, 76, 75, 75, 74, 73, 72, 71, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 59, 58, 57, 56, 55, 53, 52, 51, 50, 49, 48, 46, 45, 44, 43, 42, 40, 39, 38, 37, 36, 35, 34, 33, 32, 30, 30, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 2, 0, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -18, -19, -20, -21, -23, -24, -25, -27, -28, -30, -32, -33, -35, -37, -38, -40, -42, -44, -46, -48, -50, -52, -54, -56, -58, -59, -61, -63, -64, -65, -66, -68, -69, -70, -71, -71, -72, -73, -74, -75, -75, -76, -77, -77, -78, -78, -79, -80, -80, -81, -81, -82, -82, -83, -83, -84, -84, -84, -85, -85, -86, -86, -86, -87, -87, -88, -88, -88, -89, -89, -89, -90, -90, -90, -91, -91, -91, -92, -92, -92, -93, -93, -93, -93, -94, -94, -94, -95, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -97, -97, -97, -96, -96, -96, -95, -95, -94, -94, -94, -93, -93, -92, -92, -92, -91, -91, -90, -90, -89, -89, -88, -88, -88, -87, -87, -86, -86, -85, -85, -84, -84, -83, -83, -82, -82, -81, -81, -80, -80, -79, -79, -78, -77, -77, -76, -75, -75, -74, -73, -73, -72, -71, -70, -70, -69, -68, -67, -66, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -50, -49, -48, -46, -46, -44, -43, -41, -40, -39, -37, -36, -35, -33, -31, -30, -28, -27, -25, -24, -22, -20, -19, -17, -16, -14, -12, -10, -8, -6, -5, -3, -1, 0, 1, 3, 4, 5, 7, 9, 11, 12, 14, 15, 17, 18, 20, 22, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 49, 50, 51, 52, 53, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 69, 71, 71, 72, 73, 74, 75, 76, 77, 77, 78, 79, 80, 81, 82, 82, 83, 84, 85, 85, 86, 87, 87, 88, 89, 89, 90, 90, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 95, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 95, 95, 94, 94, 94, 93, 93, 92, 91, 91, 90, 90, 89, 88, 88, 87, 86, 86, 85, 84, 83, 83, 82, 81, 80, 80, 79, 79, 78, 77, 77, 76, 75, 75, 74, 73, 73, 72, 71, 71, 70, 69, 68, 68, 67, 66, 66, 65, 65, 64, 63, 62, 61, 61, 60, 59, 58, 58, 57, 56, 55, 55, 54, 53, 52, 52, 51, 50, 49, 48, 47, 47, 46, 45, 44, 44, 42, 41, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 31, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 17, 16, 15, 14, 13, 12, 10, 9, 8, 7, 6, 4, 3, 2, 0, 0, -1, -2, -3, -5, -6, -7, -8, -10, -11, -12, -13, -15, -16, -17, -19, -19, -21, -22, -24, -25, -26, -28, -30, -31, -33, -35, -36, -38, -39, -41, -42, -44, -46, -47, -49, -50, -52, -54, -55, -56, -57, -58, -60, -61, -62, -64, -64, -66, -66, -67, -68, -69, -70, -71, -71, -72, -73, -73, -74, -75, -75, -76, -77, -77, -78, -78, -79, -79, -80, -80, -81, -81, -82, -82, -82, -83, -83, -84, -84, -85, -85, -85, -86, -86, -86, -87, -87, -87, -88, -88, -89, -89, -89, -90, -90, -90, -90, -91, -91, -91, -92, -92, -92, -93, -93, -93, -94, -94, -94, -94, -95, -95, -95, -95, -95, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -92, -92, -92, -91, -91, -90, -90, -90, -89, -89, -88, -88, -87, -87, -87, -86, -86, -85, -85, -84, -84, -83, -83, -82, -82, -81, -80, -80, -80, -79, -78, -78, -77, -77, -76, -75, -74, -74, -73, -72, -71, -70, -70, -69, -68, -67, -66, -64, -63, -62, -61, -60, -58, -57, -55, -54, -52, -50, -49, -47, -46, -44, -42, -41, -40, -38, -37, -35, -34, -32, -31, -30, -29, -27, -26, -25, -24, -22, -21, -20, -19, -18, -17, -16, -15, -13, -12, -11, -10, -9, -7, -7, -5, -4, -3, -2, -1, 0, 0, 1, 3, 4, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 18, 20, 21, 23, 24, 26, 28, 29, 31, 33, 35, 37, 39, 41, 43, 45, 46, 48, 51, 52, 54, 55, 57, 59, 61, 62, 64, 65, 66, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 83, 84, 85, 86, 86, 87, 87, 88, 88, 89, 89, 90, 91, 91, 91, 92, 92, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 97, 97, 97, 96, 96, 95, 95, 95, 94, 93, 93, 92, 92, 91, 90, 90, 89, 88, 88, 87, 86, 85, 85, 84, 83, 82, 82, 81, 80, 79, 79, 78, 78, 77, 76, 75, 75, 74, 73, 73, 72, 71, 71, 70, 69, 69, 68, 67, 67, 66, 65, 64, 64, 63, 62, 62, 61, 60, 59, 58, 58, 57, 57, 56, 55, 54, 53, 53, 52, 51, 50, 49, 48, 48, 47, 46, 45, 45, 43, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30, 29, 28, 27, 25, 24, 22, 21, 19, 18, 17, 15, 13, 12, 10, 8, 7, 5, 3, 2, 1, 0, -2, -3, -5, -6, -8, -9, -10, -12, -13, -14, -15, -17, -18, -19, -21, -22, -23, -24, -25, -27, -28, -29, -30, -32, -33, -34, -35, -36, -38, -39, -40, -41, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -63, -64, -65, -66, -67, -68, -68, -69, -70, -70, -71, -72, -72, -73, -73, -74, -75, -75, -76, -77, -77, -78, -78, -79, -79, -80, -81, -81, -82, -82, -83, -83, -84, -84, -85, -85, -85, -86, -86, -87, -87, -88, -88, -89, -89, -89, -90, -90, -90, -91, -91, -92, -92, -92, -93, -93, -93, -93, -94, -94, -94, -94, -95, -95, -95, -96, -96, -96, -96, -96, -97, -97, -97, -97, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -95, -95, -95, -95, -94, -94, -94, -93, -93, -92, -92, -92, -91, -91, -91, -90, -90, -89, -89, -89, -88, -88, -87, -87, -87, -86, -86, -85, -85, -84, -84, -84, -83, -82, -82, -82, -81, -81, -80, -79, -79, -78, -78, -77, -77, -76, -76, -75, -74, -74, -73, -72, -72, -71, -70, -69, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -57, -56, -55, -54, -52, -51, -50, -48, -47, -46, -44, -43, -41, -40, -39, -38, -36, -35, -34, -33, -32, -31, -30, -29, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 2, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 19, 20, 21, 23, 25, 26, 28, 30, 32, 33, 36, 38, 40, 42, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 64, 66, 67, 68, 69, 71, 72, 72, 73, 74, 75, 76, 77, 77, 78, 79, 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 87, 88, 88, 88, 89, 89, 90, 90, 90, 91, 91, 92, 92, 92, 92, 93, 93, 94, 94, 94, 94, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 97, 97, 96, 96, 96, 95, 95, 94, 93, 93, 92, 92, 91, 90, 90, 89, 88, 87, 87, 86, 85, 85, 84, 83, 82, 82, 81, 80, 79, 79, 78, 77, 76, 76, 75, 74, 73, 72, 72, 71, 70, 69, 69, 68, 67, 66, 66, 65, 64, 63, 62, 62, 61, 60, 59, 58, 57, 57, 56, 55, 54, 53, 52, 51, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 32, 31, 30, 28, 27, 25, 24, 23, 21, 19, 18, 16, 14, 12, 11, 8, 6, 5, 3, 1, 0, -1, -3, -5, -7, -8, -10, -11, -13, -15, -16, -18, -19, -20, -22, -23, -25, -26, -28, -29, -30, -32, -33, -35, -36, -37, -38, -40, -41, -42, -44, -45, -46, -47, -49, -50, -51, -52, -53, -54, -55, -57, -58, -59, -60, -61, -62, -63, -64, -64, -66, -66, -67, -68, -69, -70, -71, -71, -72, -73, -74, -75, -75, -76, -77, -78, -78, -79, -80, -81, -82, -82, -83, -84, -84, -85, -85, -86, -87, -87, -88, -89, -89, -90, -90, -91, -91, -92, -92, -92, -93, -93, -93, -94, -94, -95, -95, -95, -95, -96, -96, -96, -96, -97, -97, -97, -97, -97, -97, -98, -98, -98, -98, -98, -98, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, -98, -98, -98, -98, -98, -97, -97, -97, -97, -96, -96, -96, -96, -95, -95, -95, -94, -94, -94, -93, -93, -92, -92, -91, -91, -91, -90, -90, -89, -88, -88, -88, -87, -86, -86, -85, -85, -84, -83, -83, -82, -81, -81, -80, -80, -79, -78, -77, -77, -76, -75, -75, -74, -73, -72, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -63, -62, -60, -59, -58, -57, -56, -55, -54, -53, -51, -50, -49, -48, -46, -45, -44, -43, -42, -41, -40, -39, -37, -36, -35, -34, -33, -31, -31, -30, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 18, 20, 21, 22, 24, 25, 26, 27, 29, 30, 32, 33, 35, 36, 38, 40, 42, 43, 45, 47, 50, 51, 53, 55, 56, 58, 59, 61, 63, 63, 65, 66, 67, 69, 69, 71, 71, 72, 73, 74, 74, 75, 76, 76, 77, 78, 78, 79, 79, 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 84, 85, 85, 86, 86, 86, 87, 87, 88, 88, 88, 89, 89, 89, 90, 90, 90, 91, 91, 91, 92, 92, 92, 92, 93, 93, 93, 94, 94, 94, 95, 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 92, 92, 91, 91, 91, 90, 90, 89, 89, 88, 88, 88, 87, 86, 86, 86, 85, 84, 84, 84, 83, 83, 82, 81, 81, 80, 80, 79, 79, 78, 77, 77, 76, 75, 75, 74, 73, 73, 72, 71, 70, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 61, 60, 58, 57, 56, 55, 54, 53, 52, 50, 49, 48, 47, 46, 44, 43, 42, 40, 39, 38, 36, 35, 33, 32, 31, 29, 27, 26, 24, 23, 21, 19, 17, 16, 14, 13, 11, 9, 8, 6, 4, 2, 1, 0, -1, -3, -4, -6, -7, -9, -11, -13, -15, -16, -17, -19, -20, -22, -24, -25, -27, -28, -29, -31, -32, -34, -35, -37, -38, -39, -41, -42, -43, -45, -46, -47, -48, -50, -51};

int offset = -5;                   int offset_base = 245;
int PhaseShift = 135; /*or -135*/  int PhaseShift_base = -130;

//Controller parameter Arm Master
int limit_1 = 108;
int limit_2 = -87;
double sollWinkel_arm = 0;
double arm_speed;
double sum_arm_speed;
int integrator_arm;
int i = 0;
int e = 0;
double last_angle_arm;
int gravity = 0;
int gravity_val[]= {-2, 0, 4, 8};
int g = 1;
int vp_duty;
int m = 0;
int d = 0;

//Controller parameter Base
double base_speed;
double sum_base_speed;
double last_angle_base;
double base_speed_setpoint = 30; //RPM
int j = 0;

//Communication
 uint16_t angle_send_arm;
 uint16_t angle_send_base;

 //HMI
int MODE = 0;
const int button_MODE    = 27;     
const int ledPin_MODE    = 25;      
const int button_SETTING = 26;     
const int ledPin_SETTING = 24;     
// variables will change:
int buttonState_MODE = 0;         // variable for reading the pushbutton status
int buttonState_SETTING = 0;         // variable for reading the pushbutton status
bool pressed = false;
bool pressed_SETTING = false;

//Interrupts
extern "C" {
  void CCU40_0_IRQHandler(void) //Motor control
  { sensor[0].getAngleValue(nAngle[0]); //base
    sensor[1].getAngleValue(nAngle[1]); //arm  
    //Serial.print("Base:"); Serial.print(nAngle[0]); Serial.print("\t Arm:");Serial.println(nAngle[1]);
    //Base
    int angle_table_base = (nAngle[0]+180)*10+PhaseShift_base+offset_base;
       if (angle_table_base >= 3600) {angle_table_base -=3600;} 
       if (angle_table_base <  0000) {angle_table_base +=3600;} 
     pwm_U_base = myPWM_U_values_base[angle_table_base];  analogWrite(U_base, 127 + duty_base*pwm_U_base/100); 
     pwm_V_base = myPWM_V_values_base[angle_table_base];  analogWrite(V_base, 127 + duty_base*pwm_V_base/100);
     pwm_W_base = myPWM_W_values_base[angle_table_base];  analogWrite(W_base, 127 + duty_base*pwm_W_base/100); 
    //Arm
    int angle_table = (nAngle[1]+180)*10+PhaseShift+offset;
       if (angle_table >= 3600) {angle_table -=3600;} 
       if (angle_table < 0000) {angle_table +=3600;} 
     pwm_U = myPWM_U_values[angle_table];     analogWrite(U, 127 + duty_arm*pwm_U/100); 
     pwm_V = myPWM_V_values[angle_table];     analogWrite(V, 127 + duty_arm*pwm_V/100);
     pwm_W = myPWM_W_values[angle_table];     analogWrite(W, 127 + duty_arm*pwm_W/100);     

    if(abs(nAngle[1]-last_angle_arm)  < 300){sum_arm_speed += nAngle[1]-last_angle_arm;} 
    if(abs(nAngle[0]-last_angle_base) < 300){sum_base_speed += nAngle[0]-last_angle_base;} 
     last_angle_arm  = nAngle[1];      i++;
     last_angle_base = nAngle[0];      j++;

  }
  void CCU42_0_IRQHandler(void) //System control
  { 
//calculate speeds    
    arm_speed = sum_arm_speed / i;  
      i=0; sum_arm_speed = 0; 
    base_speed = sum_base_speed / j*766; //RPM 
      j=0; sum_base_speed = 0;
/*++++++++++++++++++++++++++++++++++++++++++++++    ++++++++++++++++++++Base++++++++++++++++++++++++    +++++++++++++++++++++++++++++++++++++++++++++++*/  
//maniac speed - MODE4
  if(MODE == 4){
      m++;
      if(m > 2000) {
        m = 0;
        base_speed_setpoint = 10*random(3,8);
      }
  }      
//Base (speed controller)
  duty_base += (base_speed_setpoint - base_speed) * 0.05; //Serial.println(base_speed);
  //Ausgabe
    if(duty_base > 0){PhaseShift_base = -135;}   //direction
    if(duty_base < 0){PhaseShift_base =  135;}  //direction
    duty_base = constrain(abs(duty_base),0,80); 
    
/*++++++++++++++++++++++++++++++++++++++++++++++    ++++++++++++++++++++Arm+++++++++++++++++++++++++    +++++++++++++++++++++++++++++++++++++++++++++++*/
//Limiter (always active), prevents the pilot from falling to low
        if (nAngle[1] > limit_1){duty_arm = (limit_1-nAngle[1])*20;} //one sided P controller 
  else  if (nAngle[1] < limit_2){duty_arm = (limit_2-nAngle[1])*20;} //one sided P controller 
// free moving area
  else { 
//Gravity (always active)   
    if      (nAngle[1] > 15) {duty_arm =  gravity;}
    else if (nAngle[1] <  5) {duty_arm = -gravity;}
    else                      duty_arm = 0;
//Pushing pilot out of top (always active)
    if (-10 < nAngle[1] && nAngle[1] < 35) {e++;}
    else {e=0;}
    if (e > 800 && nAngle[1]  > 10) {duty_arm = 5;}
    if (e > 800 && nAngle[1] <= 10) {duty_arm = -5;}    
    }                  
//sine controller - MODE 2
   if(MODE == 2){
    if(nAngle[1] < 10) {sollWinkel_arm = map(sin((nAngle[0]+110)/360*2*3.14159265359),-1,1,-80,-30);}
    if(nAngle[1] > 10) {sollWinkel_arm = map(sin((nAngle[0]+110)/360*2*3.14159265359),-1,1, 101, 51);}
    integrator_arm   = constrain (integrator_arm + (sollWinkel_arm-nAngle[1]),-1000, 1000); // I Anteil der Lageregelung wird begrenzt
    duty_arm = (sollWinkel_arm-nAngle[1])*10\
             +  arm_speed*-300;  
             //+  integrator_arm * 0.05;
   }
// idle mode (PD control) - MODE 3, keeps the pilot in top position to set up a new game
  if(MODE == 3){
    if(nAngle[1] < 5) {sollWinkel_arm += 0.1;}
    else if(nAngle[1] > 15) {sollWinkel_arm -= 0.1;}
    else sollWinkel_arm = 10;
    duty_arm = (sollWinkel_arm-nAngle[1])*10 + arm_speed*-50;  
  }

//Virtual players - uncomment if needed
  //calculate new forces every 90 degree
  //Beginner
    //if((nAngle[0] > 60 && nAngle[0] < 62) || (nAngle[0] > 150 && nAngle[0] < 152) || (nAngle[0] > -122 && nAngle[0] < -120) || (nAngle[0] > -30 && nAngle[0] < -32)) {vp_duty = 20*random(0, 6);}
  //Expert
    if((nAngle[0] > 60 && nAngle[0] < 62) || (nAngle[0] > 150 && nAngle[0] < 152) || (nAngle[0] > -122 && nAngle[0] < -120) || (nAngle[0] > -30 && nAngle[0] < -32)) {vp_duty = 20*random(4, 6);}
  //GOAT
    //if((nAngle[0] > 60 && nAngle[0] < 62) || (nAngle[0] > 150 && nAngle[0] < 152) || (nAngle[0] > -122 && nAngle[0] < -120) || (nAngle[0] > -30 && nAngle[0] < -32)) {vp_duty = 120;}

  //Virtual player green 
         if (nAngle[1] < 10) {if (nAngle[0] > 7 && nAngle[0] < 22 && nAngle[1] < -75 ) {duty_arm = vp_duty;}}
    else if (nAngle[1] > 10) {if (nAngle[0] > -173 && nAngle[0] < -158 && nAngle[1] > 100 ) {duty_arm = -vp_duty;}}
 //Virtual player yellow 
         if (nAngle[1] < 10) {if (nAngle[0] > 97 && nAngle[0] < 112 && nAngle[1] < -75 ) {duty_arm = vp_duty;}}
    else if (nAngle[1] > 10) {if (nAngle[0] > -83 && nAngle[0] < -68 && nAngle[1] > 100 ) {duty_arm = -vp_duty;}}
  //Virtual player pink
         if (nAngle[1] > 10) {if (nAngle[0] > 7 && nAngle[0] < 22 && nAngle[1] > 100 ) {duty_arm = -vp_duty;}}
    else if (nAngle[1] < 10) {if (nAngle[0] > -173 && nAngle[0] < -158 && nAngle[1] < -75 ) {duty_arm = vp_duty;}}
  //Virtual player red
         if (nAngle[1] > 10) {if (nAngle[0] > 97 && nAngle[0] < 112 && nAngle[1] > 100 ) {duty_arm = -vp_duty;}}
    else if (nAngle[1] < 10) {if (nAngle[0] > -83 && nAngle[0] < -68 && nAngle[1] < -75 ) {duty_arm = vp_duty;}}
        
//drive Arm power stage (always active)
    if(duty_arm > 0){PhaseShift = 135;}   //direction
    if(duty_arm < 0){PhaseShift = -135;}  //direction
    duty_arm = constrain(abs(duty_arm),0,120); //constain to prevent motor from overheating

//Communication Serial1
  angle_send_arm =  int((nAngle[1]+180)*100);
  angle_send_base = int((nAngle[0]+180)*100);
  Serial1.print(angle_send_arm); Serial1.print("\t"); Serial1.println(angle_send_base);
  }
  void CCU43_0_IRQHandler(void) //HMI
  {
    buttonState_MODE = digitalRead(button_MODE);
    buttonState_SETTING = digitalRead(button_SETTING);
 /*++++++++++++++++++++++++++++++++++++++++++++++    ++++++++++++++++++++MODE+++++++++++++++++++++++++    +++++++++++++++++++++++++++++++++++++++++++++++*/
    if (buttonState_MODE == LOW && pressed == false) {
      digitalWrite(ledPin_MODE, HIGH);
      pressed = true;
      MODE++; if(MODE > 3){MODE = 0;}
      //0 -> SPEED setting
      //1 -> GRAVITY setting
      //2 -> Autonomous mode
      //3 -> Idle Mode
      //4 -> maniac speed
    }else if (buttonState_MODE == LOW && pressed == true){
      //do nothing, wait (debounce)
    }else {
      // turn LED off:
      digitalWrite(ledPin_MODE, LOW);
      pressed = false;
    }
/*++++++++++++++++++++++++++++++++++++++++++++++    ++++++++++++++++++++SETTING+++++++++++++++++++++++++    +++++++++++++++++++++++++++++++++++++++++++++++*/
    if (buttonState_SETTING == LOW && pressed_SETTING == false) {
      digitalWrite(ledPin_SETTING, HIGH);
      pressed_SETTING = true;
          switch (MODE) {
              case 0: // SPEED setting 30 - 40 - 50 
                base_speed_setpoint += 10; if(base_speed_setpoint > 50){base_speed_setpoint = 30;}
                break;
              case 1: // GRAVITY setting -2 - 0 - 4 - 8 
                gravity = gravity_val[g]; 
                g++;
                if(g > 3){g = 0;}
                break;
            }
    }else if (buttonState_SETTING == LOW && pressed_SETTING == true){
      //do nothing, wait (debounce)
    }else {
      // turn LED off:
      digitalWrite(ledPin_SETTING, LOW);
      pressed_SETTING = false;
    }
  }
}

void setup() { 
  Serial.begin(115200);
  Serial1.begin(115200);
//Sensor  
  sensor[0].begin(SPICh1,PIN_SPI1_MISO,PIN_SPI1_MOSI,PIN_SPI1_SCK,PIN_SPI1_SS0,sensor[0].TLE5012B_S0); //Sensor 1
  sensor[1].begin(SPICh2,PIN_SPI2_MISO,PIN_SPI2_MOSI,PIN_SPI2_SCK,PIN_SPI2_SS0,sensor[1].TLE5012B_S0); //Sensor 2
//BLDC
  pinMode(U, OUTPUT);  setAnalogWriteFrequency(U,20000);
  pinMode(V, OUTPUT);  setAnalogWriteFrequency(V,20000);
  pinMode(W, OUTPUT);  setAnalogWriteFrequency(W,20000);
  pinMode(EN_U, OUTPUT);  digitalWrite(EN_U, HIGH);
  pinMode(EN_V, OUTPUT);  digitalWrite(EN_V, HIGH);
  pinMode(EN_W, OUTPUT);  digitalWrite(EN_W, HIGH);
  
  pinMode(U_base, OUTPUT);  setAnalogWriteFrequency(U_base,20000);
  pinMode(V_base, OUTPUT);  setAnalogWriteFrequency(V_base,20000);
  pinMode(W_base, OUTPUT);  setAnalogWriteFrequency(W_base,20000);
  pinMode(EN_U_base, OUTPUT);  digitalWrite(EN_U_base, HIGH);
  pinMode(EN_V_base, OUTPUT);  digitalWrite(EN_V_base, HIGH);
  pinMode(EN_W_base, OUTPUT);  digitalWrite(EN_W_base, HIGH);
//HMI
  pinMode(ledPin_SETTING, OUTPUT);
  pinMode(button_SETTING, INPUT);
  pinMode(ledPin_MODE, OUTPUT);
  pinMode(button_MODE, INPUT);
    
//Setup Interrupt settings
  XMC_CCU4_SLICE_COMPARE_CONFIG_t pwm_config = {0};
    pwm_config.passive_level = XMC_CCU4_SLICE_OUTPUT_PASSIVE_LEVEL_HIGH;
    pwm_config.prescaler_initval = XMC_CCU4_SLICE_PRESCALER_128;
//Setup interrupt1
    XMC_CCU4_Init(CCU40, XMC_CCU4_SLICE_MCMS_ACTION_TRANSFER_PR_CR);
    XMC_CCU4_SLICE_CompareInit(CCU40_CC43, &pwm_config);
    XMC_CCU4_EnableClock(CCU40, 3);
    XMC_CCU4_SLICE_SetTimerPeriodMatch(CCU40_CC43, 200); // Adjust last Value or Prescaler
    /* Enable compare match and period match events */
    XMC_CCU4_SLICE_EnableEvent(CCU40_CC43, XMC_CCU4_SLICE_IRQ_ID_PERIOD_MATCH);
    /* Connect period match event to SR0 */
    XMC_CCU4_SLICE_SetInterruptNode(CCU40_CC43, XMC_CCU4_SLICE_IRQ_ID_PERIOD_MATCH, XMC_CCU4_SLICE_SR_ID_0);
    /* Configure NVIC */
    /* Set priority */
    NVIC_SetPriority(CCU40_0_IRQn, 10);
    /* Enable IRQ */
    NVIC_EnableIRQ(CCU40_0_IRQn); 
    XMC_CCU4_EnableShadowTransfer(CCU40, (CCU4_GCSS_S0SE_Msk << (4 * 3)));
    XMC_CCU4_SLICE_StartTimer(CCU40_CC43);
//Setup Interrupt2
  XMC_CCU4_Init(CCU42, XMC_CCU4_SLICE_MCMS_ACTION_TRANSFER_PR_CR);
  XMC_CCU4_SLICE_CompareInit(CCU42_CC43, &pwm_config);
  XMC_CCU4_EnableClock(CCU42, 3);
  XMC_CCU4_SLICE_SetTimerPeriodMatch(CCU42_CC43, 2000); // Adjust last Value or Prescaler
  /* Enable compare match and period match events */
  XMC_CCU4_SLICE_EnableEvent(CCU42_CC43, XMC_CCU4_SLICE_IRQ_ID_PERIOD_MATCH);
  /* Connect period match event to SR0 */
  XMC_CCU4_SLICE_SetInterruptNode(CCU42_CC43, XMC_CCU4_SLICE_IRQ_ID_PERIOD_MATCH, XMC_CCU4_SLICE_SR_ID_0); 
  /* Configure NVIC */
  /* Set priority */
   NVIC_SetPriority(CCU42_0_IRQn, 5);
  /* Enable IRQ */
  NVIC_EnableIRQ(CCU42_0_IRQn); 
  XMC_CCU4_EnableShadowTransfer(CCU42, (CCU4_GCSS_S0SE_Msk << (4 * 3)));
  XMC_CCU4_SLICE_StartTimer(CCU42_CC43);
//Setup Interrupt3
  XMC_CCU4_Init(CCU43, XMC_CCU4_SLICE_MCMS_ACTION_TRANSFER_PR_CR);
  XMC_CCU4_SLICE_CompareInit(CCU43_CC43, &pwm_config);
  XMC_CCU4_EnableClock(CCU43, 3);
  XMC_CCU4_SLICE_SetTimerPeriodMatch(CCU43_CC43, 20000000); // Adjust last Value or Prescaler
  /* Enable compare match and period match events */
  XMC_CCU4_SLICE_EnableEvent(CCU43_CC43, XMC_CCU4_SLICE_IRQ_ID_PERIOD_MATCH);
  /* Connect period match event to SR0 */
  XMC_CCU4_SLICE_SetInterruptNode(CCU43_CC43, XMC_CCU4_SLICE_IRQ_ID_PERIOD_MATCH, XMC_CCU4_SLICE_SR_ID_0);
  /* Configure NVIC */
  /* Set priority */
  NVIC_SetPriority(CCU43_0_IRQn, 1);
  /* Enable IRQ */
  NVIC_EnableIRQ(CCU43_0_IRQn);           
  XMC_CCU4_EnableShadowTransfer(CCU43, (CCU4_GCSS_S0SE_Msk << (4 * 3)));
  XMC_CCU4_SLICE_StartTimer(CCU43_CC43);
}

void loop() {
 
}

Credits

Infineon Team

Infineon Team

30 projects • 56 followers

Comments