Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

manipulating a device attached to a serial port

Status
Not open for further replies.

paulytrick

Technical User
Feb 6, 2002
5
GB
Hi,

I am about to undertake a very ambitios project with a group of friends purely to advance our own knowledge..

We are going to see if we can get a pc to switch house hold lights on and off through a device attached to the serial port on a PC.

Would this be possible?

My friends and I have worked in the IT industry for some time, 1 has an electronics degree and I plan to write a front end in VB to control the switches for the lights.

Now I`m not asking any of you to do any of this for me, but information seems to be thin on the ground.
I would be very grateful if anyone could offer any advice or point me in the direction of any information relating to anything like this.

Thanks.
 
This is possible. The problem you need to address is the hardware that you wish to use for controling the lights ie relay. I develop interfaces for PLC communications which in turn operate relay boards. I have also interfaced with third party devices that use a serial communication port from a PC for data. There is also DeviceNet products that use both serial, RF, IR, and ethernet communications to control such things as lights, thermostats, cameras, motion detectors, keypads, cardreaders, etc etc. If you have some more specific hardware/firmware ideas I will be able to give you a better idea of what you are up against.
 
Try looking at they have a number of interfaces that would do the trick.

I am planning on doing something similar (when I can afford a house :( ). Good luck! Troy Williams B.Eng.
fenris@hotmail.com
 
Ok, thanks for your input,

We`re very much in the planning process so far and None of us have really done anything like this before but I`ve been doing my home work (good planning is veeeery important as I`m sure you`re all aware) and I get the feeling this project is going to have quite a learning curve.

Thanks again for your help, I`m gonna go have a look at that site now then after a bit more research, We`re gonna put our heads together and see where we stand.

Thanks again.

Paul.
 


Foada, I have a very limited understanding of electronics but the basic idea of what we are trying to acheive is to build a box with a bunch of relays in it which will be used to interrupt the power flow to the lights in a house.
to switch them on and off.
To do this, We are going to start in the living room.
In the living room, i have 2 light switches which both operate the same light. We plan to introduce an intermediate swich (controled by a relay in the box) so that all 3 switches can be used to control the lights indipendantly of each other.

(I`m not telling you all this because i think you don`t know how a 3 switch circuit works, I`m just telling you to put a picture in your head of what we are trying to acheive)

I plan to hook other lights / power sockets up to the box and operate the flow of power to them in a similar manner.

We have also set these fundamental goals.

1, It must be safe for everyday use, no one likes a lot of volts passing through them and we all have to stay as safe as possible at all times.

2, the sockets/lights being controled by the relays must be able to continue to operate normally if the relays are taken away for any reason ie, the pc falls over or one of the relays in the box breaks down.

3, the project must be kept as simple as possible at all times (not going to be easy by the looks of things) at the end of the day, none of us are experts in the field of what we are trying to achieve

We are prepared to learn as we go, thats why we decided to start this project, to gain knowledge and practical understanding about something we know little about.

Any info/suggestions/flames will be welcomed :)
 
Well you are not asking too much yet. It will be safe for every day use, any time you isolate high voltage(110/220) household normal wiring by using a low voltage(12/24)relays the user will at no time be interacting with the high voltage. To handle the failsafe operation you are looking at 2 different situations. It sounds to me that you are going to have to parallel the light switch and series the outlets. This is going to mean some wiring at the circuit living room, meaning that most household wiring is done in such a way that a room or two will be on the same breaker. This means your 2 light switches and your outlets most likely are fed from the same breaker. You will have to tap into the wiring with your device so that the power feed is sent into the device as well as the 2 switches. At this point you will need to parallel tie the device to the lights and series tie the outlets. You would then need 2 relays in your device one that acts like another light switch and one that has its normally closed contact interupting the outlets. This would give you a way to turn on the lights and to kill power to the outlets. If your device fails(which we know will never happen) the 2 light switches would still work and the power to the outlets will be there. Does this make sense? Let me know if this helps or if it just raises more questions.

Later Anything is possible, the problem is I only have one lifetime.
 
What you are trying to do is used in most disco's, club's, stage lighting rig's etc on a daily basis. The system is called DMX (Digital MultipleX) and is basically a two wire serials comms, Where each device is assigned an address (0 - 511) and the device can be controlled by sending a byte sequence to it something like
|startbits|addressbyte(s)|commandbyte(s)|stopbits|
MIDI control also uses a similar arrangement.

for your project you could work along a similar line and for the electronics and comms decoding a good place to start would be with Arizona Microchips PIC Microcontrollers, with these you could control several devices from one input. They are quite simple to program and relatively easy to interface to power electronics (Triacs & Relays). I have worked on a similar project using basic (in DOS) by POKEing and PEEKing byte values direct to the device memory address. With Windows OS versions you have to be aware that you are writing to a virtual port and the OS may not allow direct control of the actual hardware (NT Win2k).

Anyway best of luck. As a learning tool it will serve well as you can look forward to many failures and a great sense of achievement when somethimgs works.

Abstract Lighting for DMX info:

Chris.
 
Hi,

It makes a lot of sense and it also raises a few questions, most of which we would have probably come across anyway as the planning details took shape.

I`m sure both the above answers are going to save us a lot of head scratching as we figure out the problems we are going to face.

What I`m going to do now is look at getting pc to talk to the box with relays in.

I`ve been using VB for about 6 months now and i realise this is not very long at all.
Most of what is possible in VB is still beyond my reach, I know it`s going to be difficult and I know it`s going to take a lot of dedication and work but I`m going to put the effort in.

Would using the mscomms control be sufficient to control relays in a box?

I`ve had a look round to find something similar but most of the apps i see that are written in vb are to read data from the port.

I`ve not looked at the mscomms controls and because i`ve been busy with one thig and another and i`ve never had anything to do with mscomms before.

Thanks again for your input etc, I`m off to check out that site then read up on comms decoding.
 
You can use the MScomm control to send data to your relays as long as the 'blackbox' has some sort of controller for serial communication(kinda obvious I know, but you know..).The other control from VB that might interest you would be the WinPort control, but then your device would need to be able to interface with a network. Anything is possible, the problem is I only have one lifetime.
 
Paul,

I have a small app in the works that acts as a sort of teaching aid for learning what the MSComm object sends and receives data as. It lets you enter a string of data and then send it out the comm port. You can then read the data from the comm port. It allows you to vary the data bits setting for the port as well as if the port sends string or binary data. If you are interested let me know. It is not completely done but it is functional. Let me know.
Anything is possible, the problem is I only have one lifetime.
 
I have done a project similar to this. It wasn't for switching lights on and of - but is was for manipulating high voltage (10,000V DC!). I used VB to write the front end with the MSComm control. From a programmers point of view this control is quite difficult to use - serial comms is really a sequential low-level thing - and in this case it's been presented in a high level event based object. Anyway - if you are concise and well stuctured with your code it will save you time later on and once you get it working it's easy to add stuff to your protocol.

You might want to consider writing the control end as well with a PIC or AVR microcontroller. It is much easier to specify the protocol yourself and write both ends than it is to have to explain it to someone else - and then agree on it.

Good luck.

Quros
 
Hi,

I`ve decided to use a pic chip to control the relays, The app your working on sounds great foada, Please let me know when it`s done.

Everything is taking shape nicely and the friend who is putting the board together assures me that all is going well.


Anyway, stuff to do and all that, I will keep you up to date with how we are going (and probably be back to ask for more help :])
 
You might want to take a look at for their microcontroller. It uses an object model similar to VB... Troy Williams B.Eng.
fenris@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top