Servo controller 8

I have been working on building an ROV. The system uses the following components
PIC 16F877A
RS232 to 485 convertors
Pololu Servo controller
standard speend controller (15Amp each)
So basically the PIC converts joystick analogue signals into digital which then passes the the data to the onboard USART, transmits to the ROV is then coverted into PWM by the Servo controller to drive the motors.
Here’s the problem…the A/D conversion takes place ( I can see the changes from the hooked up LCD) the Pololu controller recieves the data (green LED flashes), but there is no movement at the attached the servo.
I have used the mini SC protocol

TABLE_INDEX		EQU	0x021		; Index to table strings
COUNT			EQU	0x022		; A counter
DELAY			EQU	0x023		; Used in DELAYxxx routines
X_DELAY			EQU	0x024		; Used in X_DELAYxxx routines
COUNT2			EQU	0x025
Hundreds		EQU	0x026
Tens			EQU	0x027
Ones			EQU	0x028
BIN			EQU	0X029
Result1			EQU	2AH		;16bits for result data store
Result2			EQU	2BH
Result3			EQU	2CH
Result4			EQU	2DH
Preamble		EQU	2EH		;pre-code for transmition
MOTOR1			EQU	.9		;motor number1 for transmition
MOTOR2			EQU	.10
MOTOR3			EQU	.11
MOTOR4			EQU	.12
PREAMBLE		EQU	.255
w_temp			EQU	0xA0		; variable used for context saving
;w_temp1		EQU	0xA1		; reserve bank1 equivalent of w_temp 
;*****************************************************************************
; Program start
;*****************************************************************************
;*****************************************************************************
; This is the Periperal Interrupt routine. Should NOT get here
;*****************************************************************************
ORG     0x000             ; processor reset vector

	nop			 			 ; nop required for icd
  	goto    START             ; go to beginning of program


	ORG     0x004             ; interrupt vector location

;*****************************************************************************
; Initialize processor registers
;*****************************************************************************
START					; POWER_ON Reset (Beginning of program)

		
		BSF    	STATUS,RP0			;Bank1
		MOVLW   B'11111111' 
		MOVWF   TRISA				;PortA is input

		MOVLW   B'00000000'		
		MOVWF   TRISB				;PortB is output for 8 bit LCD
		BSF	OPTION_REG, NOT_RBPU 		; Disable PORTB pull-ups

		MOVLW   B'01111111'
		MOVWF   TRISC				;PortC is I/O RS232 & data select for LCD
		
		MOVLW	B'00000000'			;Set PortD as input for light switches etc
		MOVWF	TRISD
		
		MOVLW	D'25'				;SET UP BAUD RATE 9600 4MHZ
		MOVWF	SPBRG	
		MOVLW	B'10100110'			;SET UP TRXT REGISTER
		MOVWF	TXSTA
		MOVLW	B'10010000'			;SET UP RCV REGISTER
		MOVWF	RCSTA
		

		MOVLW   B'01001011'     	
		MOVWF   ADCON1				;PortA bits 0-7 ANALOGUE WITH REF ON AD2 & AD3

		BCF	STATUS, RP0			; Select bank 0

		BSF     STATUS,6        		;BANK3
		BCF     EECON1,7         		;Data memory on.
		BCF     STATUS,5
		BCF     STATUS,6        		;BANK0 return
		
		CLRF	STATUS				; Do initialization, Select bank 0
		CLRF	INTCON				; Clear int-flags, Disable interrupts
		CLRF	PCLATH				; Keep in lower 2KByte
		CLRF	PORTD				; ALL PORT output should output Low.
		CLRF	PORTB
	

		MOVLW	.127				;Set intial central settingd for motors
		MOVWF	Result1	
		MOVLW	.127
		MOVWF	Result2	
		MOVLW	.127
		MOVWF	Result3	
		MOVLW	.127
		MOVWF	Result4	
		CALL	DELAY1
		CALL	LCDINIT				; Initialize LCDisplay
	

;*****************************************************************************
;program start
;=============================================================================	
		
BEGIN		
		;Call	TABLE_MSG2
		;Call 	DELAY1_P
		;Call	LCDCLEAR	
					
		MOVLW		B'01000001'		;Select chan 0 and start conversion
		MOVWF		ADCON0
		CALL		DELAYANA
		BSF		ADCON0.GO			
WAIT_CH0	BTFSC		ADCON0,GO
		GOTO		WAIT_CH0
		MOVFW		ADRESH	
		CALL		EXCH1                          ; swap last result with new one
		CALL 		TRANSMIT1				
		MOVWF		BIN
		Call		BIN2BCD
		MOVLW		00H
		CALL		LCDSDDA		; Position cursor leftmost on first line
		MOVFW		Hundreds
		CALL		LCDPUTCHAR
		CALL		DELAY1
				MOVLW		0X001
				CALL		LCDSDDA
				MOVFW		Tens
				CALL		LCDPUTCHAR
				CALL		DELAY1
				MOVLW		0X002
				CALL		LCDSDDA
				MOVFW		Ones
				CALL		LCDPUTCHAR
				CALL		DELAY1
				CLRF		ADRESH
	
TRANSMIT1	

			MOVFW	PREAMBLE
			MOVWF	TXREG
			BTFSC	STATUS,TXIF
			MOVFW	MOTOR1
			MOVWF	TXREG
			BTFSC	STATUS,TXIF
			MOVFW	Result1
			MOVWF	TXREG
			BTFSC	STATUS,TXIF
			RETURN

I know the servo controller works because it works fine with the PC test program. The osciliscope also tells me that the signals are being generated, what I do see however is that at the servo signal pin there is no change in the signal duration?

HELP! :frowning:

Hello.

I recommend that you simplify your program a lot. Just send a single, hard-coded command until you get it to work. Since you have an oscilloscope, it should be easy to see if the command is actually getting sent as you intend.

- Jan

Thanks…I’ll give it a try. What I did try was send hard coded data to the USART i.e. 255, 9, 50 and then a delay followed by 255,9, 240…I also tried different motor numbers…but I had no joy.

What do you expect to accomplish with the second command you send? Also, 9 is a strange servo number to be testing with. Why not start with 0? You have an oscilloscope and you have a working reference from your PC, so you should be able to just focus on one command and see what is different between what the PC is sending and what your PIC is sending.

- Jan

Many thanks for your help.
I have solved the problem :smiley: It was to do with the file Result1 not being cleared i.e. it was sending the value 127 all of the time…I added one instruction “CLRF” and that sorted all my woes out!!! Unbelievable…just goes to show, couldn’t see the wood from the trees.