Programmable Relay Module

Rampz

Well-known member
This isn't a cry for help at the moment, I own and run and electronic security business for the last 30 odd years and we always one way or another need relay modules of one sort or another, and there's never the required one available.
So I thought with my newly gained knowledge and past experience with PCB design and circuits I thought I would produce some simple relay boards.
They in the first instance will have a couple of output leds, an optocoupler input configured so it can be positive or negative trigger at 12v and a double pole relay as an output.
Then through programming it can be delay on, delay off, standard switch with debounce, special timing functions a number of times or whatever.
Just simple code required.
I just couldn't find anything available and with such a low component count I thought why not.
I will post the circuit and Gerber file later if anyone is interested.
 

oracacle

Senior Member
With the exception of the programmable delay, those board exist.
They are mainly designed for interfaceing with micro controllers. All that you would actually need to design is the microcontroller side.
AZDelivery 16 Channel Relay Module DC 12V with Optocoupler Low Level Trigger Relay Module Board compatible with Arduino Including E-Book! : Amazon.co.uk: Computers & Accessories
Thinking of it, no need to re-invent the wheel, use somem of the relays as the input buffer to the controller and the the other as the output side This is just a coding excersise really.
 

Rampz

Well-known member
Thanks Oracacle, I have seen those boards, often its down to size and wanting to switch mains 230v with some current, the other side of my business is as a company of electrical contractors and the boards you show really don't fit with what we require, we often building control systems with voltages from 24 to 400v. I need robust systems often ending up with multiple timer modules and still struggling to get the features required.
The board shown I assume would still need a picaxe for example and like you say just simple coding.
I wanted something compact and the whole system, normally only need one high current output, timing being the most useful feature
 
Last edited:

oracacle

Senior Member
400v @ what current, is the biggest question, also AC, single phase, 3 phase or DC
Those are going to be big relays, they will need to be driven correctly, yeah you can opto couple (assuming normal voltage inputs) the input, but the drving the ouput may need to require a little more inventiveness. Specially if correct isolation is to be maintained.

This project could easily run away, even just on the coding side. How do you plan on mkaing the timing/counting/input changes? hard coded or a user interface so that you can have a general unit that can be setup on site wihout the need for a computer? How many I/Os? The sky is the limit. Just bare in mind, it could be tricky to get 2 accuratly timed events. Interupt routines are a little restrictive as well, as you can only have one ISR for any interrupt on the system, but it should be possible to work out where it came from within the ISR
 

Rampz

Well-known member
Oracacle

At worst 400v in 3 phase systems without a neutral, 230v in single phase and 4 wire 3 phase systems, control current max 5A, i have experience of driving many output devices with transistors, mosfets and such, as an electrical technician with over 30 years experience i can handle correct isolation and creep distances etc.

The module will be as a standard and coded as required based on the application, it will be hard coded by me, but most of my electricians have laptops so they can alter code if required during installation or if timing tweeks are required.

Timing events will be very slow inputs mostly human inputs very slow for picaxe, so counter based loops will be able to check a max of 2 inputs very well i would think, if its a control system i'm building i will code to suit the problem, like you say could well be limitations

I'm only looking at basic control, nothing like the complexity that is common place on here

I have seen system/modules that can have user change setting confirmed by flashing leds etc, but feel unless there is a LCD its going to be hard and like you say would soon run away
 

hippy

Technical Support
Staff member
Sounds like the perfect job for a PICAXE, even if in its simplest form it is 'doing nothing' just taking a signal in and driving a relay from that. The scope to add one-shot, power-up, turn-on and turn-off delays, minimum on and off times, inverting signalling, can make it very easy to tailor to fit a particular task.

With I/O exposed it can even be used as a stand-alone PICAXE board with built-in relay control.
 

Rampz

Well-known member
Sounds like the perfect job for a PICAXE, even if in its simplest form it is 'doing nothing' just taking a signal in and driving a relay from that. The scope to add one-shot, power-up, turn-on and turn-off delays, minimum on and off times, inverting signalling, can make it very easy to tailor to fit a particular task.

With I/O exposed it can even be used as a stand-alone PICAXE board with built-in relay control.
Hippy

I have done the pcb design and the gerber files that have gone for production, when i have them built and tested i will amend the gerber file to allow any unused I/O to be brought to a connector and remove my company details and post the files for anyone to use
 

Rampz

Well-known member
I have bulit the relay module and am currently testing it.

I used part of my previous code written by you all to provide a timed response to a button press and that worked fine, so to work on my own code.

I went for a toggle relay by which the output changes each time the button is pressed

Code:
start0:
#picaxe 08m2
#no_data


'CONSTANTS
symbol Btn = pinc.3        'c.3 is input momentary switch
symbol Relay = C.4        'C.4 is Relay output
symbol Green = C.1        'C.1 to Green power led
symbol Red = C.2            'C.2 to Red led follows relay


'Initialisation
init:                     'to make sure all ouput off at the start
    low Red
    low Relay

main:


    do: Loop Until btn = 1        'loops waiting for button to be pressed
    pause 300

    toggle Relay            'toggle relay when button has been pressed
    toggle Red                'toggle relay when button has been pressed
    do: loop until btn = 0        'loops till button is released


goto main

start1:                    'flash green led using multi tasking
    do
    high Green
    pause 100
    low Green
    pause 100
    loop
i have used multi tasking to flash the power led all the time, i found some explanation of "Do: Loop until" in a post where Hippy had replied and got that working for me.

I would like to be able to add
Code:
sertxd("my text",13,10)
to show button pressed, relay on, relay off etc just so i can see actions taking place but can't work out where to put the code, maybe with the "Do: Loop until" there isn't a place for it?
 

hippy

Technical Support
Staff member
I would turn your toggling main loop into two separate on and off halves so it will be easier to know where you are -
Code:
init:
  Low Relay
  Low Red
  SerTxd("Started", CR, LF)
  SerTxd("Relay Off", CR, LF)

main:

  Do : Loop Until btn = 1 ; Wait for push to turn on
  Pause 300
  High Relay
  High Red
  SerTxd("Relay On", CR, LF)
  Do : Loop Until btn = 0

  Do : Loop Until btn = 1 ; Wait for push to turn off
  Pause 300
  Low Relay
  Low Red
  SerTxd("Relay Off", CR, LF)
  Do : Loop Until btn = 0

  Goto Main
 

Rampz

Well-known member
Thank you Hippy, that works really well, and like you say you can see just where you are in the program with the terminal, took me a while to figure out it had to be set to 4800 baud, i thought since i am multi tasking it was running faster, but no seems i need to be set as 4mhz
 

hippy

Technical Support
Staff member
i thought since i am multi tasking it was running faster, but no seems i need to be set as 4mhz
It's a bit complicated. The PICAXE itself will be running at 16MHz, but it will still give the impression it is running at 4MHz and your code should generally treat it as such.
 

Rampz

Well-known member
Next on my list of options for my programmable relay will be a pulse count option, where a loop will count to say 30 seconds and at the end reset a counter, if during the loop i get pushes of the btn which will increment the counter each time till i reach say 2 the the relay will change state for say 1 second, i will play with code and get back to you all when and if it all goes wrong, as a result of you all i have some ideas to try, thank you all again.
 

Rampz

Well-known member
If anyone is interested i have attached the PDF of the circuit schematic i am using for my programmable relay, i do have the gerber files for it but looking at other people that have posted their PCB layout work it makes mine look like a kids attempt, seems pcb design has a way to go for me too :)
 

Attachments

Rampz

Well-known member
Thanks Technoman

For me I will normally use the circuit fed from a stable 12v -13.8v supply, in the past I have used 555 timers with DC motors and false triggering issues from transients.
A varistor across the supply would give some protection.
I'll have a read of the document you have supplied a link to.

Interesting article, I already use p-channel fets for reverse polarity protection where volt drop can be an issue, on this occasion a diode is fine.
If I need more current I would parallel p-channel fets to keep the volt drop low at higher current.
 
Last edited:
Top