pinsc

sid

Senior Member
I've made a circuit with a 28x1 that switchs 16 relays on/off and it all works fine except when I use the command
Code:
let pinsc =%00000100
or
Code:
let pinsc =%00000010
if I use the code
Code:
let pinsc =%00000110
or any other combination where outputs 1&2 are both on then the outputs both work, but when I use code with either output on its own they don't work ???????
I've used the same code with another 28x1 and got the same result
Am I being incredibly dumb or is this a quirk of portc pins ?
I would be grateful if someone would put me out of my misery

full version of program (minus the other 12 options for clarity) is as follows...
Code:
symbol switchs=w0
symbol counter=b1

startup:
let dirsc=%11111111
let pinsc=%00000000

start:
counter=0
readadc10 2,switchs
if w0>1010 and w0<1025 then route1
if w0>950  and w0<965  then route1A
if w0>925  and w0<930  then route2
if w0>830  and w0<845  then route2A
if w0>685  and w0<700  then route3
if w0>505  and w0<515  then route3A
if w0>315  and w0<320  then route4
if w0>265  and w0<275  then route4A
if w0>230  and w0<235  then route5
if w0>145  and w0<165  then route6
if w0>125  and w0<130  then route7
if w0>80   and w0<90   then route7A
goto start 

route3A:
counter =counter+1
if counter=10 then start
let pins  =%00000000
let pinsc =%00000110
pause 200
pinsc=0
goto route3A
 

Technical

Technical Support
Staff member
let pinsc =%00000110
pause 200
pinsc=0

This looks wrong - you are pulsing the relays on/off at very high frequency, which will rapidly damage relays...
 

sid

Senior Member
Not really, this is just a test program to make sure all the output pins and relays do what they're supposed to do, all the other relays work fine and I've swapped them about so I know it's not the relays.
I was using a delay of 2 sec but after numerous downloads got bored so shortened the delay to speed things up a bit.
 

Technical

Technical Support
Staff member
Not the pause 200, look at what happens during the 'goto route3a' line. During the time taken to process this line and and process the counter lines the relay is pulsed off for a very small amount of processing time once per loop in the ten loops. This is bad design. Put the relays off commands just after start: instead.

The relay switching when both on implies a hardware fault - look for a solder brdige between the output pins.
 

hippy

Ex-Staff (retired)
Also reduce your code to a bear minimum whilst testing so any other problems there may be in your code or configuration do not affect the testing. This will cycle all outputs one at a time ...

Do
dirsc = %11111111
pinsc = %00000000 : Pause 1000
pinsc = %00000001 : Pause 1000
pinsc = %00000010 : Pause 1000
pinsc = %00000100 : Pause 1000
pinsc = %00001000 : Pause 1000
pinsc = %00010000 : Pause 1000
pinsc = %00100000 : Pause 1000
pinsc = %01000000 : Pause 1000
pinsc = %10000000 : Pause 1000
Loop

If all outputs work as expected then it's something else in your code which is causing a problem. If it doesn't work as expected look for shorts and wiring errors.
 

sid

Senior Member
Also reduce your code to a bear minimum whilst testing so any other problems there may be in your code or configuration do not affect the testing. This will cycle all outputs one at a time ...

Do
dirsc = %11111111
pinsc = %00000000 : Pause 1000
pinsc = %00000001 : Pause 1000
pinsc = %00000010 : Pause 1000
pinsc = %00000100 : Pause 1000
pinsc = %00001000 : Pause 1000
pinsc = %00010000 : Pause 1000
pinsc = %00100000 : Pause 1000
pinsc = %01000000 : Pause 1000
pinsc = %10000000 : Pause 1000
Loop

If all outputs work as expected then it's something else in your code which is causing a problem. If it doesn't work as expected look for shorts and wiring errors.
Many thanks Hippy, tiny tiny piece of copper shorting accross tracks between these two relays, I thought I'd checked but obviously not well enough, we live and learn.
 
Top