[PIC] Using dsPIC3of control step motor

Status
Not open for further replies.
These can be replaced


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
if (LATD == 0b0001) LATD = 0b0010;
    else if (LATD == 0b0010) LATD = 0b0100;
    else if (LATD == 0b0100) LATD = 0b1000;
    else if (LATD == 0b1000) LATD = 0b0001;
    else LATD = 0b0001;
 
 
 
if (LATD == 0b0001) LATD = 0b1000;
    else if (LATD == 0b0010) LATD = 0b0001;
    else if (LATD == 0b0100) LATD = 0b0010;
    else if (LATD == 0b1000) LATD = 0b0100;
    else LATD = 0b0001;



by these


Code C - [expand]
1
2
3
4
5
6
7
if(LATD == 0x08)LATD = 0x01 
else LATD <<= 1;
 
 
 
if(LATD == 0x01)LATD = 0x08 
else LATD >>= 1;



//or


Code C - [expand]
1
2
3
4
5
6
7
if((LATD & 0x0F) == 0x08)LATD = LATD & 0xF1 
else LATD <<= 1;
 
 
 
if((LATD & 0x0F) == 0x01)LATD = LATD & 0xF8
else LATD >>= 1;

 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…