Control technology

2001-06-27 Thread Hugh Senior

Has anyone used metaCard to control external devices? The need is to flash
various combinations of LED's and beep on right / left speakers (don't ask!)

Many thanks.

/H

Hugh Senior

The Flexible Learning Company
Consultant Programming  Software Solutions
Fax/Voice: +44 (0)1483.27 87 27
Email: [EMAIL PROTECTED]
Web: www.flexibleLearning.com

Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to [EMAIL PROTECTED], not this list.




Re: Control technology

2001-06-27 Thread Kevin Miller

On 27/6/01 8:25 am, Hugh Senior [EMAIL PROTECTED] wrote:

 Has anyone used metaCard to control external devices? The need is to flash
 various combinations of LED's and beep on right / left speakers (don't ask!)

I haven't done it, but it should be easy enough to do if its a serial device
- you need to figure out what format it needs, then you can simply read and
write from the ports.

Kevin

Kevin Miller [EMAIL PROTECTED] http://www.runrev.com/
Runtime Revolution Limited - Power to the Developer!
Tel: +44 (0)131 718 4333.  Fax: +44 (0)1639 830 707.


Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to [EMAIL PROTECTED], not this list.




Re: Control technology

2001-06-27 Thread Sjoerd Op 't Land

Kevin Miller wrote/ schreef:

 On 27/6/01 8:25 am, Hugh Senior [EMAIL PROTECTED] wrote:
 
 Has anyone used metaCard to control external devices? The need is to flash
 various combinations of LED's and beep on right / left speakers (don't ask!)
Yes, I have. There are two solutions for this I know:
--
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 LED's (eventually with an open- collector
output) to the outputs. With the open- collector connections you can also
use this device for various other things.


2. Parallel port

Haven't tried this one, but should work also.
PC (parallel port) - data0
   - data1
   - data2
   - data3
   - data4
   - data5
   - data6
   - data7
I don't know what power these data connectors can supply, so if it's not
enough, you need to use some transistors too to connect the LED's.

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

Hope this helps
Sjoerd


Archives: http://www.mail-archive.com/metacard@lists.runrev.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to [EMAIL PROTECTED], not this list.