[PIC] Using dsPIC3of control step motor

Status
Not open for further replies.

xuanlienbk

Newbie level 3
Joined
Nov 30, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Hanoi, Vietnam, Vietnam
Activity points
17
Now,I have to do homework.That's Using dsPIC30f4011 control step motor.I just learn about dsPIC so don't understand about it.Can you help me?
 

Please take it as your reference.^^
 

Attachments

  • dspic30f4011.zip
    83.8 KB · Views: 139
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…