PICAXE for controling relays via RS232

Sean87

Member
Hello everyone,

It is my first post here and I hope I can learn a lot from you. I got to know about PICAXE from a friend and he told me it is easy to use and more cost effective than other microcontrollers.

I am working on a self project. What I need to do is control (enable, disable) a number of 8 DPST relays via RS232. That is I have a program in visual C# that have 8 buttons and only 1 button can be enabled at a time.

So the idea is by clicking a button a relay will go Enabled (and if before clicking that button a relay was already ON, it will be OFF before the new relay goes ON). Writing and transmiting the serial code in C# would not be a problem for me.

All I want to know (at the moment :D) is what kind of PICAXE will be my best option to start with?

Thanks,
Sean.
 
Last edited:

xtech007

Senior Member
Welcome to the forum!

Well, you are in the right place if you want to learn.
Not sure in your experience on microchips. But reading the manual will help you to understand a little better how the forum might suggest their opinions!

First you might want to see how many inputs and outputs you might need at the moment for this particular project. I suggest reading manual 1 section 1 page 27 forward. keep in mind that later you might need more inputs or outputs.

On the RS232 part, I'm sure you can use Serin and serout options (manual 2 page 197) Lots of explanations, and also the corresponding diagrams for the pc to picaxe communication!

Now on the buttons side (inputs) you also have valuable info on manual 3 page 26, same on the relays ( outputs) Lots of reading !!!

My personal preference is the 28X1 chip lots of fun with it!
Good luck !!
 

william47316

New Member
the pins command especially on picaxe with 8 outputs can use a byte variable to turn a pattern of outputs on or off,
if you get the computer program to send (perhaps inverted) binary via serial eg to turn the relays off you send a 255 serial character and to turn relay 8 on and the rest off will be 127 and so forth do a NOT in the picaxe to invert it and set the pins to the inverted variable
for example
11111111 (255) turn all relays off
01111111 (127) turn relay 8 on rest off
10111111 (191) turn relay 7 on rest off
and so forth

Code:
main:
serin (pin), (baudmode), ("RELPIN"), b1 'require the quailifier RELPIN and a byte of serial
b2 = not b1 'invert the input serial
let pins = b2 'set the output bus to the inverted variable
pause 20
goto main
 
Last edited:

hippy

Ex-Staff (retired)
When using a PC program to control a PICAXE, when using SERIN, you need to ensure that the PICAXE is ready to receive data from the PC which can be an extra complexity which is not desirable.

A PICAXE which supports HSERIN and background receive can often overcome this requirement and that is what I would favour. The PICAXE-20X2 is what I'd choose in this case.
 

Sean87

Member
When using a PC program to control a PICAXE, when using SERIN, you need to ensure that the PICAXE is ready to receive data from the PC which can be an extra complexity which is not desirable.

A PICAXE which supports HSERIN and background receive can often overcome this requirement and that is what I would favour. The PICAXE-20X2 is what I'd choose in this case.
Thanks a lot I was thinking of the same situation.

And thanks to other guys. I will see how it will go and I'll be back with questions if I couldn't figure out something.
 

Sean87

Member
I have ordered picaxe 20x2, I have just another question that is what relay driver chip woul you think I will need for controling 8 relays?
 

fritz42_male

Senior Member
ULN2803 is always a good starting point. 8 Darlington arrays in a single chip. Used by Rev-ed on a number of their kits.
 
Top