Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] PIC18F877A Stepper Motor Controller, Proteus Simulation

Status
Not open for further replies.

imedx86

Newbie level 2
Newbie level 2
Joined
Jun 3, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
10
stepper motor.png

that is the pattern and the code to vary the speed of a stepper motor with push-button how do this function with ADC thank you


Code:
char a,b;
void interrupt()
{
if(intcon.rbif)
{
if(portb.b4==0) {a++;}
if(portb.b5==0) {a--;}
if(a==10) a=9;
if(a==0)  a=1;
}
intcon.rbif=0;
}
speed();void speed()
{
for(b=0;b<a;b++)
delay_ms(50);
}
TRISB=0xF0;
PORTB=0;
INTCON=0b10101000;
a=1;
for(;;)
{
while(portc.b0==0)
{
portb= 0x08;                speed();
portb= 0x0C;                speed();
portb= 0x04;                speed();
portb= 0x06;                speed();
portb= 0x02;                speed();
portb= 0x03;                speed();
portb= 0x01;                speed();
portb= 0x09;                speed();
}
while(portc.b1==0)
{
portb= 0x09;                speed();
portb= 0x01;                speed();
portb= 0x03;                speed();
portb= 0x02;                speed();
portb= 0x06;                speed();
portb= 0x04;                speed();
portb= 0x0C;                speed();
portb= 0x08;                speed();
}}}
 
Last edited:

set some levels in between 0 an 1024. then compare the read value with these levels and assign values to variable b. for example if you want 10 different speeds as in your program one level should be of size 93 (1024/11) and they are 0-93, 93-186, 186-279 etc. Now get the current ADC reading compare it with the levels . if its in the first level then assign variable b=1 and so on. if you have any doubts about the ADC programming let me know.
 

hi, i m just a beginner in Mikro C if you are free and want to help by do a programme for me thank you in advance
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top