如何打开/关闭并行端口上的数据引脚?

发布于 2024-10-10 03:05:40 字数 199 浏览 1 评论 0原文

我想简单地打开和关闭某些数据引脚,以便它们可以控制一组继电器。我不是在问硬件位(应该很容易),但我不知道从哪里开始编写软件。我不想要一个可以向设备发送字节的高级库 - 我真的想打开/关闭某些引脚。

我正在运行 Linux,并且想在 Java 中执行此操作,那么我只需要一个库吗?如果该库有良好的文档并且易于使用,那就太好了,但如果没有,那么简短的示例代码将帮助我入门。

I want to simply switch certain data pins on and off, so that they can control a set of relays. I'm not asking about the hardware bit (should be easy), but I don't know where to begin writing the software. I don't want a high level library that can send bytes to a device - I literally want to switch on/off certain pins.

I'm running Linux and I want to do this in Java, so would I just need a library? It would be nice if the library has good documentation and is easy to use, but if not then a short example code will help me get started.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

时光是把杀猪刀 2024-10-17 03:05:40

有一个非常易于使用的 API,称为 ParalPort:

http://www.oocities .com/Juanga69/parport/index.html?20112

这很简单,你可以使用“write(int oneByte)”,在“oneByte”中你发送一个8位字,打开和关闭引脚你想要的,根据这个图:

     Bit | Pin # | Printer DATA
    -----+-------+--------------
      7  |   9   |   DATA 7
      6  |   8   |   DATA 6
      5  |   7   |   DATA 5
      4  |   6   |   DATA 4
      3  |   5   |   DATA 3
      2  |   4   |   DATA 2
      1  |   3   |   DATA 1
      0  |   2   |   DATA 0

There's a pretty easy-to-use API called ParalelPort:

http://www.oocities.com/Juanga69/parport/index.html?20112

Its very easy, you could use "write(int oneByte)", where in the "oneByte" you send a 8 bit word, turning on and off the pins you want, according to this diagram:

     Bit | Pin # | Printer DATA
    -----+-------+--------------
      7  |   9   |   DATA 7
      6  |   8   |   DATA 6
      5  |   7   |   DATA 5
      4  |   6   |   DATA 4
      3  |   5   |   DATA 3
      2  |   4   |   DATA 2
      1  |   3   |   DATA 1
      0  |   2   |   DATA 0
清音悠歌 2024-10-17 03:05:40

转至 https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_SMI-Site/en_US/-/USD/ViewProductDetail -Start?ProductRef=JAVACOMM-3.0.1-LX-SP-GF@CDS-CDS_SMI 并下载 Linux 版本。

JavaComm 用户指南位于:http://java.sun.com/products /javacomm/reference/docs/API_users_guide_3.html

当然,您需要一些外部电子设备来从 PPort 输出进行转换,然后触发继电器。根据这些继电器将要触发的内容(有问题的负载),您将烧毁您的电脑。

如果我是你,我会考虑像 Arduino 板 这样的东西,它允许你写入输出并提供你的电脑和你想要控制的东西之间有一些电气隔离。

Go to https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_SMI-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=JAVACOMM-3.0.1-LX-SP-G-F@CDS-CDS_SMI and download the version for Linux.

JavaComm user guide is here: http://java.sun.com/products/javacomm/reference/docs/API_users_guide_3.html

Of course you will need to have some external electronics to convert from the PPort output to then trigger the relays. Depending on what these relays are going to trigger (The load in question) you will blow your PC.

If I were you I would consider something like an Arduino board that will allow you to write to outputs as well as provide you some electrical isolation between your PC and what you are trying to control.

酒解孤独 2024-10-17 03:05:40

请先将光耦合器之类的东西连接到并行端口引脚。然后从那里连接一个晶体管或 MOSFET 来驱动继电器。确保继电器上有反向电流保护二极管。

please attach something like an opto-coupler to the parallel port pins first. then from there, attach a transistor or mosfet to drive the relays. make sure the relays have reverse current protection diodes on them.

葬花如无物 2024-10-17 03:05:40

来自 http://www.ti.com/product/ULN2803A

ULN2803A 器件是 50 V、500 mA 达林顿晶体管阵列。该器件由八个 NPN 达林顿对组成,具有高压输出
用于开关感性负载的共阴极钳位二极管。每个达林顿对的集电极电流额定值为 500 mA。达林顿对可以并联以获得更高的电流能力。

您必须将 com 引脚连接到输出 + 电压引脚才能正常工作。预计电压下降 1.3V。这可以直接连接到并行端口(如果需要,可以使用串联电阻)。必须连接计算机、电磁阀电源和 ULN2803A 接地。还有许多其他器件可用,但该器件采用 DIP 封装,使原型设计变得更加容易。
吉尔

From http://www.ti.com/product/ULN2803A:

The ULN2803A device is a 50 V, 500 mA Darlington transistor array. The device consists of eight NPN Darlington pairs that feature high-voltage outputs with
common-cathode clamp diodes for switching inductive loads. The collector-current rating of each Darlington pair is 500 mA. The Darlington pairs may be connected in parallel for higher current capability.

You must connect the com pin to your output + voltage pin for it to work. Expect a 1.3V drop. This can be directly connected to the parallel port (you may use a series resistor if you want). The computer, solenoid power, and the ULN2803A grounds must be connected. There are many other devices available but this is in a DIP package making prototyping an easier task.
Gil

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文