Thanks guys for your prompt advice. I have implemented your mods. I thought it might be the outputs from the darlington driver but alas no.
I am trying to interpret digital signals from a midi device which uses a ULN2803A driver. The idea is that when particular notes are detected the Picaxe -28X2 then switches the relevant relays on and off, either singularly or in pairs, triples etc.
I can get it to work on single notes but the problem occurs when multiple notes are detected.
At the moment LED's on the PIC output go on when a note (event) has been read. No relays are fitted yet.
The program seems to work in principle but I have noticed that when 2 or more events are detected they do not always provide the right output condition. I have noticed that if I shorten the program and only detect certain groups of events it seems to work OK. Also , sometimes an outpput LED may light up fleetingly suggesting that the event has been read but the event doesn't latch even though the code say's high B.1( fot instance) .
I initially thought that the PIC speed was the problem so I have fitted a 10Mhz resonator allowing to to run at 40Mhz.
I have tried to follow the manual regarding interrupt routines and think I understand it. I must admit though I do find the hintsetup and setintflags a bit of an headache to understand.
However, I have dioded an hardware interrupt on INT0 to check when any (upto 5) inputs are triggered then gosub to the interrupt routine to read pinsC condition into a variable b2. This is then used in the relevant subroutine to latch the appropraite outputs.
To help you understand the relvant interrupt code is as follows:-
init:
setfreq em40
input B.0 ; INT0 to check for any input event
output A.0 ; set A.0 as output pin
hintsetup %00000001 ; setup hardware interrupt on B.0
setintflags %00000001, %00000001 ; set hardware Int0 to interrupt
let dirsB = %11111110
let dirsA = %000000001
goto mainloop
interrupt: ;check to see if any input is selected
b2 = pinsC ;read pinsC and put in varialbe b2
hint0flag = 0
hintsetup %00000001
setintflags %00000001, %00000001 ; reset hintflags
return
Is it correct or have I missed the point somewhere?
Sorry for the long post, but this problem is really streching my patience..... Any advice/suggestions would be most appreciated.
Cheers,
Alan