Interference problem

Hello

I have an 18 standard project board working as an external alarm control panel, with four infra-red beams connected to it and some LED's and a light switching relay.

Day mode is fine, when you break a beam you get the corresponding LED change and the internal buzzer

Night time operation is as above but switches lights as well.

B.0 is the output that switches the lights on.

The cable to the beams is about 120 m of 0.5 duct grade telephone cable.

The beams are NC 5V to the C inputs that are connected to 0v by the on board 10K resistor.

For a future relay to operate lights where the beams are we have a pair of wires that is connected to the board but has nothing connected to it, about 120m length.

The problem is when one of the beams opens at night (the beam going open circuit in alarm) the panel crashes and just the day/night LED (B.7) flashes very fast, once the beam closes the panel goes back to normal.

The way to stop the fault is to disconnect the unconnected 120m remote relay wire from B.0 and the local relay and LED's operate each and every time and the system is totally reliable.

So it appears that when I apply 0v to an unconnected cable just after a zone is open everything crashes.

The local relay does have a diode fitted, I make several of these each year and they work and are working very reliably in all different locations.

The wire in question has no faults on it and draws no current when connected.

In the short term there is no problem as the wire is staying disconnected; but do I need decoupling capacitors across the C inputs or what when I want to use it?

I have posted the code below so you can see how it should work.

Any suggestions would be gratefully received.




Code:
#PICAXE 18M2
start0:
' this version of code amended For  8-9-17
'4 Beams NC to 5V+ . LDR to 5V+, Panel has on board isolation switches for each zone
'Day/Night LED, Lights on LED and 4 zone led's 

symbol LIGHTS1 = B.0    			; lights relay 1 all outputs are neg high
symbol buzzer1 = B.1    			; Buzzer output 
symbol zone1led = B.2    			; Zone 1 LED
symbol zone2led = B.3    			; Zone 2 LED 
SYMBOL zone3led    = B.4 			; Zone 3 LED
SYMBOL zone4led    = B.5 			; Zone 4 LED

SYMBOL day_or_night_LED  = B.7 		; Day/Night LED, on at night
SYMBOL Zone1	= pinC.2    		; trigger from detector 1
SYMBOL Zone2	= pinC.5    		; trigger from detector 2
SYMBOL Zone3	= pinC.6    		; trigger from detector 3
SYMBOL Zone4	= pinC.7    		; trigger from detector 4
symbol TIMEPOT = C.0    			; potentiometer input for lights on time on board 
symbol LDR     = C.1    			; LDR for night operation to 5V+


SYMBOL Night_Day_Setpoint = 38 		;LDR to + 5v

SYMBOL lights_on  = b0  			; reserved for bit flags
symbol lights1_on = bit0			; flag = 1 if the zone 1 lights on
symbol lights2_on = bit1			; flag = 1 if the zone 2 lights on
symbol lights3_on = bit2			; flag = 1 if the zone 3 lights on
symbol lights4_on = bit3			; flag = 1 if the zone 4 lights on
SYMBOL time_for_lights = b2   		; how long to leave the lights on
symbol night_or_day     = b3  		; reading from the LDR
symbol light_loop 	= b4  		; loop control when lights are activated
symbol light_count	= b5  		; count how long to leave the lights on
symbol light1_count     = b6  		; zone 1 lights on while >0
symbol light2_count     = b7  		; zone 1 lights on while >0
symbol light3_count     = b8  		; zone 1 lights on while >0
symbol light4_count     = b9  		; zone 1 lights on while >0


'======================================================================
Init:
' set all B pins as outputs and low
		let dirsB = %11111111
		let pinsB = %00000000
		

Main:
' Main program loop
' 1 buzz subroutine is required
'
' we will loop forever
	DO

' read the time for lights to be on (from pot)   	
		readadc TIMEPOT ,time_for_lights
		readadc LDR ,night_or_day
' depending on whether it is night or day act differently
		if night_or_day <  Night_Day_Setpoint then
' NIGHT time operation - lights and buzzer
' plus keep looping here while another loop has been broken
			lights_on = 0
			light_loop = 0
			light_count = 0 
			
			do							; Zone NC to 5V+ so 1 is clear
				if Zone1 = 0 then  			; test if zone 1 is (still) active
					high LIGHTS1     			; turn on the zone 1 lights
					gosub buzz1 				; sound the zone 1 buzzer
					lights1_on = 1  			; set the zone1 activity flag      
					light1_count = time_for_lights   ; keep the zone 1 "timer" at max until zone 1 cleared
				end if
				if Zone2 = 0 then  			; test if zone 2 is (still) active
					high LIGHTS1
					gosub buzz1
					lights1_on = 1
					light1_count = time_for_lights
				end if
				if Zone3 = 0 then  			; test if zone 3 is (still) active
					high LIGHTS1
					gosub buzz1
					lights1_on = 1
					light1_count = time_for_lights
				end if
				if Zone4 = 0 then
					high LIGHTS1
					gosub buzz1
					lights1_on = 1
					light1_count = time_for_lights
				end if
				
				IF lights_on > 0 THEN 		; check if ANY zone is active     
					light_loop = 1  		; set the general alarm flag
					pause 500      		; wait a while
					
					IF light1_count>0 THEN     	; if the zone 1 "timer" is active
						DEC light1_count		; then decrement the remaining period     	
					ELSE 
						LOW LIGHTS1     		; otherwise if zone 1 timer at zero  
						lights1_on = 0    	; turn lights off and clear activity flag
					ENDIF
					IF light2_count>0 THEN
						DEC light2_count
					ELSE 
						;LOW LIGHTS1
						lights2_on = 0
					ENDIF
					IF light3_count>0 THEN
						DEC light3_count
					ELSE 
						;LOW LIGHTS1
						lights3_on = 0

					ENDIF
					IF light4_count>0 THEN
						DEC light4_count
					ELSE 
						;LOW LIGHTS1
						lights4_on = 0
					ENDIF
				ELSE
					light_loop = 0
					
				
				ENDIF
			
' now check whether to keep looping here
' if the light counter is set but is less than the duration check then keep looping
				
			loop while light_loop = 1
		else
' DAY time operation - just sound the buzzer
			
		      if Zone1 = 0 then gosub buzz1 ;only one buzzer output
			if Zone2 = 0 then gosub buzz1 ;triggered by each beam
			if Zone3 = 0 then gosub buzz1 
			if Zone4 = 0 then gosub buzz1
		end if
	LOOP
'======================================================================
buzz1:			; buzz on off 4 times 
	high Buzzer1   
	pause 500
	low Buzzer1
	pause 500
	high Buzzer1   
	pause 500
	low Buzzer1
	pause 500
	high Buzzer1   
	pause 500
	low Buzzer1
	pause 500
	high Buzzer1   
	pause 500
	low Buzzer1
	pause 500
	return  
	
	
	start1: ;For LED indicators on panel
	Main2:
	if night_or_day <  Night_Day_Setpoint then high day_or_night_led
else low day_or_night_led endif ; this gives a day night LED on the panel
					; yellow LED on at night
		
	if zone1 = 0 then low zone1led ; this has 4 LED's to show zone status
else high zone1led endif	; green LED on if zone clear
	
	if zone2 = 0 then low zone2led
else high zone2led endif
	
	if zone3 = 0 then low zone3led
else high zone3led endif
	
	if zone4 = 0 then low zone4led 
	else high zone4led
endif

	goto main2
 

Circuit

Senior Member
120 m of cable is rather a long antenna to connect directly to the PICAXE chip. I would be inclined to use opto-isolators on such cable lengths.
 

Jeremy Harris

Senior Member
Any chance that you can tie the long wire either high or low with a reasonable value resistor (low enough in value to stay within the limits of whatever may drive it, but high enough to get rid of a fair bit of the induced pick-up noise)?

Whether you use a pull-up or pull-down resistor depends on the application, but I've run DS18B20 sensors over long cables by increasing the normal pull up resistor to 2k2, rather than 4k7.
 

Circuit

Senior Member
Any chance that you can tie the long wire either high or low with a reasonable value resistor (low enough in value to stay within the limits of whatever may drive it, but high enough to get rid of a fair bit of the induced pick-up noise)?

Whether you use a pull-up or pull-down resistor depends on the application, but I've run DS18B20 sensors over long cables by increasing the normal pull up resistor to 2k2, rather than 4k7.
I had considered suggesting that; a very sensible approach to longer interface cable management and one that works often as you say...but 120 metres in an unspecified environment that is generating glitches? I again recommend isolating the cable optically which should sort the problem out in almost any environment. One also has to consider that this is specified as an alarm system as well and that requires a higher level of robustness and immunity from interference.
 

BESQUEUT

Senior Member
I had considered suggesting that; a very sensible approach to longer interface cable management and one that works often as you say...but 120 metres in an unspecified environment that is generating glitches? I again recommend isolating the cable optically which should sort the problem out in almost any environment. One also has to consider that this is specified as an alarm system as well and that requires a higher level of robustness and immunity from interference.
+1 : I totally agree
That said : many alarm system use a "terminal resistor" parallele with the switch, and some 2 resistors to detect sabotage.
In fact they use an analog read and a threshold to detect alarm.

For example, here are the values and schematics for a
DSC ALARM
 
Any chance that you can tie the long wire either high or low with a reasonable value resistor (low enough in value to stay within the limits of whatever may drive it, but high enough to get rid of a fair bit of the induced pick-up noise)?

Whether you use a pull-up or pull-down resistor depends on the application, but I've run DS18B20 sensors over long cables by increasing the normal pull up resistor to 2k2, rather than 4k7.
Thank you for this answer, which is the easiest for me to try.

So that I understand:

You would connect the wire to +12v via 2.2K then B.0 switches it to 0V when activated
or do you connect it to + and 0v via 2.2 k resistors that then switch out the negative resistor when in alarm.

I have transistorised relays that will easily respond to this voltage level, thanks to Ebay.

Hope I am not being too thick.
 

hippy

Technical Support
Staff member
The beams are NC 5V to the C inputs that are connected to 0v by the on board 10K resistor.
It's not clear how everything is wired, especially as we appear to have moved on to talking about connecting 12V to the PICAXE in post #6.

A quick circuit diagram would help.
 

Jeremy Harris

Senior Member
The pull up (for an active low) needs to be connected between the Picaxe pin and the Picaxe power rail (5 V normally), not 12 V, as that's way outside the the Picaxe acceptable voltage range. 2k2 should work OK, I think.
 
I am using a Picaxe 18, standard project board with a 12 volt supply to the board and 5V regulator for the Picaxe.

I missed when you said 5V supply to the Picaxe and thought the 12 volts to the board,DOH!

B.6 the unused output can follow the same as B.0, have a 2.2K connected to the 5V and then my remote relay can be 5 volt triggered.

Thank you, I will try this when I go back to site next week.
 
Just a quick update that may help anyone else with long cable runs.

I returned to site to complete the last stage of the works and they had been experiencing "no triggers" sometimes from the beams in the mean time, so reliability was not perfect.

I took Jeremy's advice and reduced the 10K resistors between 0v and the Picaxe inputs to 2.2K, I also fitted a 0.1 capacitor between each input and 0v.

I refitted the offending wire on the 0v B.0 output that was causing the original problem and tested the system all afternoon as we were on site.

Total reliability now, so lower resistance can make a big improvement with long cable runs.

Thank you all for your help.
 
Top