To get Pulse width modulation I have used the help of a comparator. As
I could not find a method to get triangular signal, I have just assumed it. Probably one of the most controversial decisions, for me during this project, was giving 5V, 10/3 V, 5/3 V and 0 V as the data inputs to a mux. I have spent a lot of time on surfing the net and going through some articles for that and finally found that it can be done. Part 1 of the circuit makes sure that the input M works iff the Speed is set at 00. Only then the mux would allow the value of M. For any other input of speed, I made sure that input M is not considered. This is because, I have assumed the motor as a car. In a car, we put the reverse gear iff the car is at a halt or we put the 1st gear from the reverse gear iff the car is at a halt. Similarly if someone suddenly makes M=1 from M=0 when the speed is set at 11, the motor gets damaged. Hence the mux.