CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with step

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cuopbienquin



Joined: 17 Aug 2007
Posts: 4

View user's profile Send private message Yahoo Messenger

Problem with step
PostPosted: Thu Oct 11, 2007 7:46 am     Reply with quote

I have a problem with control step.Requirement of programing is followed:
1. When press button_direction , directional of rotation of motor is to will change
2.When press button_star/stop, motor turn on or off.
3.while motor is turning , press button_speed1,motor turn speed1
button_speed2,motor turn speed2
This code:
#include <16F877A.h>
#fuses NOWDT,PUT,XT,NOPROTECT
#use delay(clock=4000000)
#use fast_io(b)
#use fast_io(d)
#byte portb=0x06
#byte portd=0x08
#bit RB0=portb.0
#bit RB1=portb.1
#bit RB2=portb.2
#bit RB3=portb.3

//const unsigned char digital[]={0,1,2};
int i=0; int speed = 0; // ma hoa digital duoi dang mang
// Chuong trinh ngat
#int_ext
void ngat_RB0()
{
while (true)
{
if(RB0==0 )
{
i=(i+1)%3;
}
while (i!=0)
{
//change speed
if ( RB1==0)
{
speed = 50;
}
if ( RB2==0)
{
speed = 25;
}
switch (i)
{
case 1:

portd=0b00000101;
delay_ms(speed);
portd=0b00000001;
delay_ms(speed);
portd=0b00001001;
delay_ms(speed);
portd=0b00001000;
delay_ms(speed);
portd=0b00001010;
delay_ms(speed);
portd=0b00000010;
delay_ms(speed);
portd=0b00000110;
delay_ms(speed);
portd=0b00000100;
delay_ms(speed);
break;
case 2:

portd=0b00000101;
delay_ms(speed);
portd=0b00000100;
delay_ms(speed);
portd=0b00000110;
delay_ms(speed);
portd=0b00000010;
delay_ms(speed);
portd=0b00001010;
delay_ms(speed);
portd=0b00001000;
delay_ms(speed);
portd=0b00001001;
delay_ms(speed);
portd=0b00000001;
delay_ms(speed);

break;
}//end switch


}
//stop
if ( RB3 == 0 )
{
portd = 0;
}
}



}
//
//
main()
{
set_tris_b(0b00000001);
set_tris_d(0);
enable_interrupts(global);
enable_interrupts(int_ext);
ext_int_edge(H_to_L);
portd=0b00111111;
while(true)
{

}
}
Actually I simulated by Protuess but I only control button_direct and cant control ohter buttons.I hope you correct to me presvious code.Thans and the best lucky for u.
_________________
Let shared to be shared.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group