Scott Rossi wrote/ schreef:

> I'm wondering if the port commands in MC/REV are what can be used to control
> hardware -- specifically, to open and close a relay which controls other
> gear.  If anyone has built anything like this, perhaps they wouldn't mind
> passing along some of the details of how this would be constructed.
It is not difficult:
If you only need 8 inputs and/or outputs you can use this (if you want to
use the parallel port it's even easier.)

--------------
1. With a UART
--------------
I tried this one. It costs some money and time (and some soldering skills),
but then you really have something. I don't know how technical you are, so
please ask if you don't understand something.

The general idea is to connect this device to your serial port, the UART
converts serial (bit by bit on one line) to 8 parallel connections. And you
need some security, so the scheme is like this:

PC (serial port) -- optocoupler (safety first) -- baudrate generator
                                               -- UART - output 1 - LED1
                                                       - output 2 - LED2
                                                       - output 3 - etc.
                                                       - output 4
                                                       - output 5
                                                       - output 6
                                                       - output 7
                                                       - output 8
Then you need to connect your relays (eventually with an open- collector
output) to the outputs.

----------------
2. Parallel port
----------------
Haven't tried this one, but should work also.
PC (parallel port) - data0
                   - data1
                   - data2
                   - data3
                   - data4
                   - data5
                   - data6
                   - data7
These data connectors can't deliver much power, so you'll need some
transistors to drive the relays.

I also am not sure about whether the values stay at the outputs after
writing by the computer, or that they have to be written every now and then
to stay.

---------------
3. The software
---------------
The software part is relatively easy. By writing a byte to both of these
devices, the outputs give the byte pattern. Example:
Write a 167 to the port (bin:10100111), then the bit pattern is like:
output1/data0: 1
output2/data1: 0
output3/data2: 1
output4/data3: 0
output5/data4: 0
output6/data5: 1
output7/data6: 1
output8/data7: 1
(or the reverse, I don't know, but that doesn't matter that much, just play
around a bit)

So the software would be a library like:

on initSoftware
  open file COM1: for write
end initSoftware

on writeByte decNumber
  global writtenBitPattern
  write numToChar(decNumber) to COM1:
  put baseConvert(decNumber,10,2) into writtenBitPattern
end writeByte

on writeBitpattern pattern
  writeByte baseConvert(pattern,2,10)
end writeBitPattern

on writeBit bitNumber bitValue
  global writtenBitPattern
  put bitValue into char bitNumber of writtenBitPattern
  writeBitPattern writtenBitPattern
end writeBit

on closeSoftware
  close file COM1:
end closeSoftware

Didn't test it, but should be something like this. A button to flash a LED
(connected to output2) every half-second would be something like:

on mouseUp
  initSoftware
  writeByte "0" -- everything off
  repeat until the mouse is down
    writeBit "2" "1"
    wait 500 milliseconds
    writeBit "2" "0"
    wait 500 milliseconds
  end repeat
  closeSoftware
end mouseUp

The LED would flicker as long as the mouse is down.

--------
WARNING:
--------
Everything you do here is for your own risk. This is important:
- don't short circuit your data outputs, you'll blow you port controller
- check first with the Internet or data sheets to see what power the outputs
can give
- always try to first create you hardware and the connect it: the chance is
small, but if you're out of luck you blow your port controller when you
connect hardware while the computer is running.
- try to find someone in your neighbourhood who knows about all this

> Thanks & Regards,
> 
> Scott
Regards, / Groeten,
Sjoerd

Reply via email to