HW 8 channel SERVO/MOTOR output on 18F4431 (Oshonsoft)

Thread Starter

camerart

Joined Feb 25, 2013
3,853
Hi,
I tried changing Timer 1 and 2 priorities, also commenting out each interrupt, with no effect.

I changed some registers and TMR1H now increments at TMR1L overflow, and now the INDEX increments, also LATB increments but doesn't show on 'Microcontroller view' in SIM, and doesn't move a SERVO when 'live.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,853
Hi,
My mate is working on the BASE SLAVE, and has passed it to me to modify it for REMOTE SLAVE use. I tested the BASE SLAVE program, which works as far as we've got, but has similar issues as the REMOTE SLAVE.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,853
There is an Include xxx.bas.
Does it have an effect on some settings?
Hi J,
I haven't got used to INCLUDES and PROCEDURES yet, as they often catch me out.
I see a couple of disables, that I've been playing with, but I think they are ok?
C.
-------------------------------------------------------------------
'18F4431 32MHz XTL BASE_SLAVE RX_QEI 100123

Define CONFIG1L = 0x00
Define CONFIG1H = 0x06 '8mHz x4 =32
Define CONFIG2L = 0x0c
Define CONFIG2H = 0x20
Define CONFIG3L = 0x04
Define CONFIG3H = 0x80
Define CONFIG4L = 0x80 'Set for HVP
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40

'OSH config
Define CLOCK_FREQUENCY = 32
Define SINGLE_DECIMAL_PLACES = 2
Define STRING_MAX_LENGTH = 20

'------------- TARGET SETUP ------------------
'Define SEROUT_DELAYUS = 1000 'In Program not here &

ANSEL0 = %00000000
ANSEL1 = %00000000

Disable High
Disable Low

TRISA = TRISAinit
TRISB = TRISBinit
TRISC = TRISCinit
TRISD = TRISDinit
TRISE = TRISEinit

'SET BITS ON/OFF before TRIS!
Const LATAinit = %00000000 'ON/OFF
Const LATBinit = %00000000
Const LATCinit = %00000000
Const LATDinit = %00000000
Const LATEinit = %00000000 'POSS MCLR RE3

'SET PIN IN/OUT 18F4431
Const TRISAinit = %11011000 '7=OSC, 6=OSC, 4=QEIB 3=QEIA 0=TEMP SEROUT
Const TRISBinit = %00000000 'SERVO OUT
Const TRISCinit = %01000100 '6=1-slave4431_cs, 2=MOSI
Const TRISDinit = %00100000 '6=led, 7=led, 5=synch
Const TRISEinit = %00000000
---------------------------------------------------------------

C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,853
Hi,
I'v been looking through old programs, (I've got millions) and found this line: [ RCON.IPEN = 1, This MUST be included when using INTERRUPTS ]
It got me looking into the 10.0 INTERRUPTS section of the 18F4431 D/S, and there are many settings, that could be used. hopefully, I'll figure out how to set these 2x interrupts?
C.
 

jjw

Joined Dec 24, 2013
823
You could disable the high priority interrupt at the beginning of the low interrupt, if you think it is the problem.

On low interrupt
Disable high
...
...
Enable high
Resume
 

Thread Starter

camerart

Joined Feb 25, 2013
3,853
You could disable the high priority interrupt at the beginning of the low interrupt, if you think it is the problem.

On low interrupt
Disable high
...
...
Enable high
Resume
Hi J,
I've tried that also the reverse enable routine, and been juggling settings from 10.0 INTERRUPT in the D/S, but so far, haven't got the outputs at PORTB, since adding the working SERVO program into the wroking before SERVO program, it has only happened since they were combined.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,853
Hi J,
I got the REMOTE SLAVE to work in the SIM, and there's signs of life on the SERVO when 'live':)
I removed the INCLUDE (never liked them) and did the TRIS's as I remember.
I'm sure my mate will put it back (he likes them) ;) C
 

Attachments

Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,853
Hi,
#111 shows SIM, but live it's a fail!
The servos fix, but at any angle, and can be moved to a new angle. All channels seem the same.
Here's an oscillator view of the frequency between channels, and 1x channel time, including the program times. Ch0 is slightly narrower, but all of the rest are the same. So no control!
C
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,853
Hi,
I can see that some of my replies are incorrect e,g, this program uses CCP1 (Irealise this but) I've been looking at TMR1.
Also
I'm going to re-check how the PWM works.
There is a lot to figure out in the 10.0 INTERRUPT section of the D/S, so I'm going to have to keep reading it for a while. I searched this forum for similar SERVO information and found my earlier ones, that I will also re-reads.
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,853
Hi,
I carried on this theme on ETO, and have been asked this:
" can you confirm that doing CCPR1 = 0x55AA writes 0x55 to CCPR1H and 0xaa CCPR1L? "
I tried, but was only able to write to it in 2x BYTEs.
C
 

ericgibbs

Joined Jan 29, 2010
21,626
hi C,
In that error box msg I posted it says ' it's not a valid Byte constant' which means you can only load a Byte not a Word.

What is the problem in using the High and Low Byte Commands.?

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,853
hi C,
In that error box msg I posted it says ' it's not a valid Byte constant' which means you can only load a Byte not a Word.

What is the problem in using the High and Low Byte Commands.?

E
Hi E,
I was specifically asked " can you confirm that doing CCPR1 = 0x55AA writes 0x55 to CCPR1H and 0xaa CCPR1L? " and also asked to check with you, this question.

Here is a section from the program,
==========================================
CCP1CON = %00001000 '& h8 'CCP1 pin low and high on match - will be first pulse
CCPR1 = frame '2000 'start pulse in 0.25mS (2000 clock cycles) [ FRAME compiles 2000 doesn't!!!!!!!!
PIE1.CCP1IE = 1 'enable CCP1 interrupts
=============================================
As can be seen, CCPR1 + frame, which is a WORD.
So to me this won't work, do you agree?
C
 
Top