Thank you Mister_e, that did help out. The running frequency is now 8KHz. I ran a small bit of code below.
Code:
'-------------------------------------------------------------------------'
' PIC Defines Specific to PIC Basic Pro '
'-------------------------------------------------------------------------'
' 1. Use internal system clock
@ DEVICE PIC16F684, INTRC_OSC_NOCLKOUT
' 2. Turn watchdog timer on
@ DEVICE PIC16F684, WDT_OFF
' 3. Power on time on
@ DEVICE PIC16F684, PWRT_ON
' 4. Turning off the master clear input
@ DEVICE PIC16F684, MCLR_OFF
' 5. Brown out detect on
@ DEVICE PIC16F684, BOD_ON
' 6. Data EE Read protect is off
@ DEVICE PIC16F684, CPD_OFF
' 7. Code protect is off
@ DEVICE PIC16F684, PROTECT_OFF
'-------------------------------------------------------------------------'
' Hardware Defines Specific to PIC Basic Pro '
'-------------------------------------------------------------------------'
define ADC_BITS 10 'Set A/D coverter to use 10 bits
define ADC_SAMPLEUS 50 'Set A/D sample time as 50us
DEFINE OSC 8 'Change clock speed to 8Mhz
OSCCON = %01110000 'Change internal osc to 8MHz
'-------------------------------------------------------------------------'
' Define Program Variables '
'-------------------------------------------------------------------------'
R VAR BYTE
ScaledX VAR BYTE
ScaledY VAR BYTE
ShortX VAR BYTE
ShortY VAR BYTE
Slope VAR WORD
AnalogLow VAR WORD 'Digital value for an analog low signal
AnalogHigh VAR WORD 'Digital value for an analog high signal
CurrentSpeed VAR WORD
DUTY VAR WORD
ExtLimit VAR WORD 'Stored value of the extend limit setting
JoyX VAR WORD
JoyY VAR WORD
RetLimit VAR WORD 'Stored value of the retract limit setting
Position VAR WORD 'Analog value of the internal potentiometer
Seeking VAR WORD
Speed VAR WORD
'-------------------------------------------------------------------------'
' Define I/O and EEPROM Definitions '
'-------------------------------------------------------------------------'
data @0,word 768 'Set default extend limit
data @2,word 256 'Set default retract limit
AnalogHigh = 768 'Set analog high signal level
AnalogLow = 256 'Set analog low signal level
ExtLimit = 750
Retlimit = 50
'-------------------------------------------------------------------------'
' Initialise PIC Hardware '
'-------------------------------------------------------------------------'
CMCON0 = 7 'Turn comparators off
ADCON0.7 = 1 'Set A/D Values to be right justified
ADCON0.0 = 1 'Turn on A/D Converter
ANSEL = %00110111 'Turn on select analog registers
TRISA = %00001111 'Turn on select register inputs
TRISC = %00111111 'Turn on select register inputs
PR2 = 249
CCP1CON = %11001100
CCPR1L = 0
PIR1.1 = 0
T2CON.0 = 0
T2CON.1 = 0
T2CON.2 = 1
WHILE (PIR1.1 = 0)
WEND;
TRISC = %00000011
'-------------------------------------------------------------------------'
' Start of Main Program '
'-------------------------------------------------------------------------'
Main:
WHILE(1)
CCP1CON.7 = 1
DUTY = 300
CCP1CON.4 = DUTY.0
CCP1CON.5 = DUTY.1
CCPR1L = DUTY >> 2
PAUSE 1000
DUTY = 0
CCP1CON.4 = DUTY.0
CCP1CON.5 = DUTY.1
CCPR1L = DUTY >> 2
PAUSE 200
CCP1CON.7 = 0
DUTY = 300
CCP1CON.4 = DUTY.0
CCP1CON.5 = DUTY.1
CCPR1L = DUTY >> 2
PAUSE 1000
DUTY = 0
CCP1CON.4 = DUTY.0
CCP1CON.5 = DUTY.1
CCPR1L = DUTY >> 2
PAUSE 200
WEND
END
This ran a few times on the motor back and forth, and then ruined one of the driver chips on the board shorting my pcb out. This is an update of where I am at the moment. I starting trouble shooting on it now, so hopefully if anyone finds a solution so will I. One of the things that might be hurting me is a electro cap on the 5V rail (I know duh) or a very high uF cap on the +12V rail for the 2 H-bridges running DC brush motors. (Again, I can't believe I forgot these) I'm also attaching the schematic as this might help some see something in the hardware. I really appreciate all of the help so far guys. Thank you
Anthony
Bookmarks