Now I'm facing the problems of set point settings and explained as follows
I'd like to change the set point of motor as long as I pressed the button on my motherboard PICDEM Z development board and the algorithm as follows: Since the PORTB push button is RB4 and RB5 bits, I tried to right shift the 4 bits and place in the last two bits which enable 0x03 that allows four conditions of set point
key = (PORTB >> 4) & 0x03;
switch(key){ // Heading setting initial at zero case 0: setpoint = 270; break; case 1: setpoint = 90; break; case 2: setpoint = 180; break; case 3: setpoint = 0; break; }
However, the motor doesn't work as I expected, and jump into the loop without accurate control rules? Does anybody familiar with push button relative controls? Thanks very much indeed!