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

ULN2803 with the pic 16f877

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







ULN2803 with the pic 16f877
PostPosted: Tue Sep 09, 2008 1:05 am     Reply with quote

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








PostPosted: Tue Sep 09, 2008 1:37 am     Reply with quote

You are using the wrong programming language. The CCS compiler expects C, not BASIC.
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