[comp.sys.cbm] Commodore 64: How do you control a simple AC relay?

geller@bnrmtv.UUCP (Phil Geller) (10/31/87)

I want to use a Commodore 64 to turn an AC device on and off.
It seems like this is a simple task, that could be accomplished
with off-the-shelf hardware.  My problem is that I know next to
nothing about Commodores and the peripherals available for them.
From reading the manual it seems like I could connect the user port
to a CIA chip, which would then control a relay.  If at all possible,
I would much rather go out and buy something that is already designed.
Does anybody know where I can find this sort of hardware, and an
approximate cost?


Phil Geller
Voice:  (415) 940-2376 
UUCP:   ...{hplabs | amdahl | ames}!bnrmtv!geller
mail:   BNR, P.O. Box 7277, Mountain View, CA 94039-7277

tomb@hplsla.HP.COM (Tom Bruhns) (11/03/87)

Re:  Turning AC power on/off from a C64.  Gosh, this should be easy.
I don't know of existing hardware to do it -- but there probably is
some.  If there isn't, and there is a market for it, seems like an
opportunity.  There are plenty of parallel lines available out of the
various connectors on back.  In fact, you could probably drive a
relay directly from the cassette port, since it provides switched
power enough to drive the cassette (that assumes you don't want to
use a cassette in this system you're putting together -- also assumes
a single channel).  You said you are looking for an already-built
solution; are you willing to put one together if none exists?  Also,
how much power/current are you trying to control, and how fast must it
be?  (Is a relay fast enough, or do you need electronic switching?)

Tom Bruhns
uucp: !hplabs!hplsla!tomb

ralph@ncrcae.Columbia.NCR.COM (Ralph Hightower) (11/04/87)

BSR has home control products for lamps, appliances, switches, etc.  Radio
Shack has these items for sale (but no computer interface as far as I
know).  DAK catalogs (Drew Alan Kaplan vanity initials company) frequently
has that system available with various computer interfaces; but I don't
have DAK's address.  TENEX Computer Express has the X-10 Powerhouse system
which is claimed to be BSR compatible.  Sears may have it also.

This is not an product endorsement or advertisement, just information.

TENEX Computer Express
PO Box 6578
South Bend IN 46660-6578
Information: 1-219-259-7051

-- 
            ralph@ncrcae.Columbia.NCR.COM   <Ralph M. Hightower>
            NCR Corp., Engineering & Manufacturing - Columbia, SC
          Home of THE USC! (Oldest Public Funded University in USA)
    South Carolina had a University 49 years before California was a state; 

thfisher@watmath.UUCP (11/05/87)

In article <2955@bnrmtv.UUCP> geller@bnrmtv.UUCP (Phil Geller) writes:
>I want to use a Commodore 64 to turn an AC device on and off.
>It seems like this is a simple task, that could be accomplished
>with off-the-shelf hardware.  My problem is that I know next to
>nothing about Commodores and the peripherals available for them.
>From reading the manual it seems like I could connect the user port
>to a CIA chip, which would then control a relay.  If at all possible,
>I would much rather go out and buy something that is already designed.
>Does anybody know where I can find this sort of hardware, and an
>approximate cost?

The circuit to turn one AC device on and off is trivial.  It requires a couple
of off-the-shelf chips and a few resistors (plus of course the connector to
fit the computer:-).  I don't remember the circuit off hand, but if you
are interested, I can post a schematic and a simple program to run it.
As for price, you should probably be able to pick up the parts for <$10.

>Phil Geller
>Voice:  (415) 940-2376 
>UUCP:   ...{hplabs | amdahl | ames}!bnrmtv!geller
>mail:   BNR, P.O. Box 7277, Mountain View, CA 94039-7277

Terry Fisher

-- 
watmath!thfisher                              //
                                           \\//-\miga user.
The meek shall inherit the earth because everyone else is leaving.
Disclaimer: Would you claim these ideas? Neither do I.

georgek@csd4.milw.wisc.edu (George R Kasica) (11/06/87)

Distribution:usa



The X-10 advertised in the Tenex catalog is indeed compatible with the
Radio Shack modules, and DAK ones as well.

===[George Kasica]===

georgek

bowen@sunybcs.uucp (Devon E Bowen) (11/08/87)

In article <15408@watmath.waterloo.edu> thfisher@watmath.waterloo.edu (Terry Fisher) writes:
>
> I don't remember the circuit off hand, but if you
> are interested, I can post a schematic and a simple program to run it.
>
>Terry Fisher

Please do...
                                   Devon Bowen (KA2NRC)
                                   University of Buffalo

*********************************************************
uucp:	   ..!{ames,boulder,decvax,rutgers}!sunybcs!bowen
Internet:  bowen@cs.Buffalo.EDU
BITNET:    bowen@sunybcs.BITNET
*********************************************************

thfisher@watmath.waterloo.edu (Terry Fisher) (11/14/87)

In article <6388@sunybcs.UUCP> bowen@joey.UUCP (Devon E Bowen) writes:
>In article <15408@watmath.waterloo.edu> thfisher@watmath.waterloo.edu (Terry Fisher) writes:
>>
>> I don't remember the circuit off hand, but if you
>> are interested, I can post a schematic and a simple program to run it.
>>
>>Terry Fisher
>
>Please do...
>                                   Devon Bowen (KA2NRC)
>                                   University of Buffalo
>
>*********************************************************
>uucp:	   ..!{ames,boulder,decvax,rutgers}!sunybcs!bowen
>Internet:  bowen@cs.Buffalo.EDU
>BITNET:    bowen@sunybcs.BITNET
>*********************************************************

Okay, here it is. Enjoy!!!
If you have any questions, let me know and I'll try to help.

The following circuits will switch AC circuits.  The first
will handle resistive loads (ie light bulbs)

                   ---v---
+5 ---------------+|     |+----\/\/---------+------------out
                   |     |     /            |                load
   10kohm      /--+| MOC |+   180ohm        |         +--out 
      \   b |-+c   | 3010|               |--+         |
OUT -\/\/---|     +|     |+--------------|            |
            |-+e   -------        gate   |--+         +--in
     2n2222 ^  \                            |               110 vac
                |                      /    +------------in
GND ------------+                   triac
                           (Radio Shack 276-1000)
                            (will handle 6 amps)


For inductive loads (ie motors) the following circuit should be used.

                                           v0.2 uF 160V (note this is not a
                                     +-----||--------+ /  connection)
                   ---v---           |               |/
+5 ---------------+|     |+----\/\/--+--\/\/-----+---)--------out
                   |     |     /           \     |   |            load
   10kohm      /--+| MOC |+   180ohm    1.2kohm  |   |     +--out 
      \   b |-+c   | 3010|                    |--+   |     |
OUT -\/\/---|     +|     |+-------------------|      |     |
            |-+e   -------               gate |--+   |     +--in
     2n2222 ^  \                                 |   |           110 vac
                |                           /    +---+--------in
GND ------------+                        triac
                                (Radio Shack 276-1000)
                                 (will handle 6 amps)


NOTE:  the triacs will require heat sinking.  

When building either of these circuits, make sure that everything is connected
properly before connecting it to the computer.  If you make a mistake, you
can say good-bye to your C-64.

Also it would be a good idea to enclose the circuit when finished in order to
prevent someone from touching one of the high voltage connections.

The OUT pin on the schematic should is one of PB0-PB7 on the user port.
You will need a 12/24 .156in spacing card edge connector.  

Sample program:

10 REM PROGRAM TO TOGGLE TURN ON/OFF THE AC CIRCUIT.
20 REM BY TERRY FISHER
30 : 
40 OUT = 0: REM THIS ASSUMES THAT OUT IN THE CIRCUIT IS CONNECTED TO PB0
50 :        REM IF YOU USE A DIFFERENT PB LINE, SET OUT EQUAL TO THE
60 :        REM PB LINE USED.  IE. IF PB3 WERE USED CHANGE OUT = 0 TO
70 :        REM OUT = 3
80 POKE 56579,255
90 POKE 56577,0
100 PRINT "PRESS ANY KEY TO TOGGLE OUTPUT"
110 GET A$: IF A$ = "" THEN 60
120 X = PEEK 56577
130 IF (X AND 2^OUT) = 0 THEN POKE 56577, X + 2^OUT
140 IF (X AND 2^OUT) <> 0 THEN POKE 56577, X - 2^OUT
150 GOTO 100
 
You could connect up to 8 of these circuits to the c-64 at one time.
The program would need to be altered some to take care of the extra
ouput lines.



Another method of switching circuits is to use a relay.  A simple relay
controller to control a relay follows

+5 -------------------+ 1n4001
                      |   \   +------+-------------------- + 10-25 volts to
     10kohm           |    \  |      |                       activate the
      \         b  |--+ c     __     )                 +-- - relay
OUT --\/\/---------|          /\     ( coil of relay   |
                   |--+ e     --     )                 |
               /      |       +------+                 |
         2n2222       |  b |--+ c                      |
                      +----|                           |
                           |--+ e                      |
                    2n3055    |                        |
GND --------------------------+------------------------+

The program above will also work with this circuit
Also note that the 2 relay connections that get connected to the circuit
to be switched are not shown in the above diagram.  The above circuit
turns the relay on and off.


If you are really interested in interfacing your c64 to the outside world,
you should get the C-64 Interfacing Bluebook.  I don't know where to get it,
but I have used mine extensively. (these circuits are simelar to ones in
the VIC-20 Interfacing Bluebook.)


DISCLAIMER.  I am posting these circuits for your benifit.  I cannot be
held responsible for any damage done to your computer by improperly
connecting it to high voltages.  While these circuits are not extremely
complicated, if they are connected improperly, they could damage the
computer, and posibly cause electrical shock to someone if they were
to touch live wires.

IF YOU DO NOT KNOW WHAT A TRANSISTOR, OR A DIODE IS, YOU PROBABLY SHOULD
NOT BE BUILDING THESE CIRCUITS.  GET SOMEONE WHO KNOWS WHAT HE IS DOING
TO BUILD THEM FOR YOU.

-- 
watmath!thfisher                              //
                                           \\//-\miga user.
The meek shall inherit the earth because everyone else is leaving.
Disclaimer: Would you claim these ideas? Neither do I.

grr@cbmvax.UUCP (George Robbins) (11/15/87)

In article <15543@watmath.waterloo.edu> thfisher@watmath.waterloo.edu (Terry Fisher) writes:
> 
> The following circuits will switch AC circuits.  The first
> will handle resistive loads (ie light bulbs)
 
GAAK!!! - there are readily available devices known as "Solid State Relays"
that allow you to switch 117 Volts from a DC logic level.  They may be more
expensive then do-it-yourself versions, but that 117 VAC can get real nasty
if you f**k up.

Looking in the current Mouser Electronics Catalog (1-800-992-9943) I
find a both solid state relays and digitial I/O panels.

The solid state relays (Page 153-154) are available in various power and
voltage ranges - you probably want the ME433 or 519-RP units, which run
from $15 to $30.

There is also a modular digital I/O system (Page 151) with an 8-module
mounting board for $70 and AC-OUTPUT, AC-INPUT, DC-OUTPUT AND DC-INPUT
modules listed for $17.50.  If you want to experiment or set up a permenant
control for multiple devices, this would be a good bet.

-- 
George Robbins - now working for,	uucp: {ihnp4|rutgers|allegra}!cbmvax!grr
but no way officially representing	arpa: out to lunch...
Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)