| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| help me Guest
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				| ULN2803 with the pic 16f877 |  
				|  Posted: Tue Sep 09, 2008 1:05 am |   |  
				| 
 |  
				| hello i need some help. I am still writing on the source code to conect the stepper motor and ULN2803 with the pic 16f877.
 I try to show a motor rotate forward , backward , left , right and stop with five swicth
 
 The following is my code. Could you tell me where is the problem?
 
 this code
 
 
  	  | Code: |  	  | #define _PIC16F877_ // Use PIC16F877 device 
 #ifdef _PIC16F877_
 #if defined(__PCM__)
 #include <16F877.h>
 #fuses HS,NOWDT,NOPROTECT,NOLVP
 #define TxD PIN_C6 // Define Transmitted Data
 #define RxD PIN_C7 // Define Received Data
 #define CLOCK_SP 20000000 // Clock Speed(Hz)
 #use delay(clock=20000000)
 #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
 #endif
 
 #include <input.c>
 
 #BYTE port_b = 6
 
 #define FOUR_PHASE TRUE
 
 #ifdef FOUR_PHASE
 
 BYTE const POSITIONS[4] = {0b0101,
 0b1001,
 0b1010,
 0b0110};
 #else
 BYTE const POSITIONS[8] = {0b0101,
 0b0001,
 0b1001,
 0b1000,
 0b1010,
 0b0010,
 0b0110,
 0b0100};
 #endif
 
 void main ()
 trisb =$00
 trisa =$ff
 adcon1 = 7
 lamp       var portb
 sw1        var portc.0
 sw2        var portc.1
 sw3        var portc.2
 sw4        var portc.3
 sw5        var portc.4
 lamp=0
 while(1)
 if(!sw1) then
 gosub speed1
 pause 50
 endif
 
 if(!sw2) then
 gosub speed2
 pause 50
 endif
 pause 10
 wend
 end
 
 speed1:
 lamp =$08
 pause 200
 while(sw2)
 lamp = lamp >> 1
 if lamp = $00 then lamp = $08
 pause 200
 wend
 return
 
 speed2:
 lamp =$01
 pause 200
 while(sw1)
 lamp = lamp << 1
 if lamp = $10 then lamp = $01
 pause 200
 wend
 return
 | 
 |  |  
		|  |  
		| Guest 
 
 
 
 
 
 
 
			
			
			
			
			
			
			
			
			
 
 | 
			
				|  |  
				|  Posted: Tue Sep 09, 2008 1:37 am |   |  
				| 
 |  
				| You are using the wrong programming language. The CCS compiler expects C, not BASIC. |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |