控制串行端口上的各个引脚

发布于 2024-08-31 23:53:44 字数 659 浏览 8 评论 0原文

我知道串行端口通过串行发送单个位流来工作。我可以编写程序从该引脚发送和接收数据。

然而,串行端口连接上还有很多其他引脚通常不会使用,但从文档来看,它们似乎都具有某种用于信号发送而不是数据传输的功能。

是否有可能以任何方式导致不用于直接数据传输的其他引脚被单独控制?如果是这样,我将如何去做呢?

编辑:更多信息

我正在使用在英特尔酷睿 i7 870 处理器上运行 Windows 7 64 位的现代 CPU。我使用串行到 USB 端口,因为我无法直接使用 USB 端口执行任何操作,而且我的计算机没有配备串行端口,而且出于某种莫名其妙的原因,我周围有一堆这些 USB 到串行端口适配器。

我的目标是控制多个步进电机(每转 200 步,4 相电机)。我的简单电路接受单个高脉冲并将其解释为导致电机旋转一步的命令。电路本身将处理电源和相位切换。我希望使用数据传输引脚发送旋转信号(我们可以通过引脚改变高脉冲的数量和高脉冲的频率来控制位置和速度,但是没有真正的脉冲宽度调制)。

我有很多电机要控制,但不需要同时控制它们。我希望使用其余的引脚,并通过一个简单的组合逻辑电路来运行它们,以识别正在移动的电机以及移动的方向。这是电源开关电路的一部分。

数据传输引脚将在某个低端频率下正常工作。但是,我想控制其他引脚,以允许我发出可靠的开或关信号(它们不会很快翻转,只有当我切换到控制另一个电机时才会改变)。

I know that serial ports work by sending a single stream of bits in serial. I can write programs to send and receive data from that one pin.

However, there are a lot more other pins on the serial port connection that normal aren't used but from documentation all seem to have some sort of function for signalling as opposed to data transfer.

Is it possible in any way to cause the other pins that are not used for direct data transfer to be controlled individually? If so, how would i go about doing that?

EDIT: more information

I am working with a modern CPU running windows 7 64-bit on an intel core i7 870 processor. I'm using serial to usb ports because its imposable for me to do anything directly with a usb port and my computer does not come with serial ports and also for some inexplicable reason i have a bunch of these usb to serial port adapters lying around.

My goal is to control mutipul stepper motors (200 steps per rotation, 4 phase motors). My simple circuitry accepts single high pulses and interprets it as a command to cause the motor to rotate one step. The circuit itself will handle the power supply and phase switching. I wish to use the data transfer pin to send the rotation signals (we can control position and velocity by altering the number of high pulses and frequency of high pulses through the pin, however there is no real pulse width modulation).

I have many motors to control but they do not need to be controlled simultaneously. I hope to use the rest of the pins and run them through a simple combination logic circuit to identify which motor is being moved and which direction it is to move in. This is part of the power switching circuitry.

The data transfer pin will operate normally at some low end frequency. However, i want to control the other pins to allow me to give a solid on or off signal (they wont be flipping very quickly, only changes when i switch to controlling another motor).

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

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

发布评论

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

评论(7

雨夜星沙 2024-09-07 23:53:45

根据 Hans Passant 的建议,我建议您使用 Arduino 而不是 USB 转串口转换器。 "Duemilanove" 是一款基于 Arduino 的开发板,提供 6 个 PWM 输出(以及 8 个其他数字 I/O 和 6 个模拟)。一些更专业的板可能更便宜(Arduino Pro Mini,批量 15 美元,需要一些焊接)。

Based of the suggestion of Hans Passant , I'd like to suggest that you use an Arduino instead of an USB-to-serial converter. The "Duemilanove" is an Arduino-based board that provides 6 PWM outputs (as well as 8 other digitial I/Os and 6 analog). Some more specialized boards might be even cheaper (Arduino Pro Mini, $15 in volume, some soldering required).

木緿 2024-09-07 23:53:45

使用握手引脚发送数据可以很好地工作,尽管可能不适用于多任务操作系统,但它只是非常处理器密集型(因为需要不断轮询端口)并且需要一些定制电缆。事实上,在过去,这正是 Laplink 通过串行连接获得如此高传输速率的原因(以及为什么要获得这些速率,您需要特殊的“Laplink”电缆)。您需要链接双方了解正在发生的情况并能够处理自定义通信。 Laplink 将通过两个普通 UART 引脚发送数据包,同时尝试通过握手引脚从数据包的另一端发送数据。如果未使用正确的电缆(或者通过握手引脚发送时存在其他问题),则没有问题 - 所有数据都会正常发送。

嵌入式开发人员可能知道这就是“位碰撞”(通常在小型嵌入式系统上没有专用的 UART 电路),为了使串行通信正常工作,他们必须以正确的时序切换通用 I/O 引脚。可以在 UART 的握手引脚上执行相同的操作。但正如我所说,如果需要完成其他工作,可能会对系统造成损害。

Using the handshaking pins to send data can work very well, though probably not on a multitasking OS, it's just very processor intensive (because the port needs to be polled constantly) and requires some custom cables. In fact, back in the day, this is exactly how Laplink got such high transfer rates over serial connections (and why to get those rates you needed a special 'Laplink' cable). And you need both sides of hte link to be aware of what's going on and be able to deal with the custom communications. Laplink would send a packet of data over both the normal UART pins while trying to send data from the other end of the packet over the handshaking pins. If the correct cable wasn't used (or there was some other problem with sending over the handshaking pins) there was no problem - all the data would just get send normally.

Embedded developers might know this as 'bit banging' - often on small embedded systems there's no dedicated UART circuitry - to get serial communications to work they have to toggle a general I/O pin with the correct timing. The same can be done on a UART's handshaking pins. But like I said, it can be detrimental to the system if other work needs to be done.

铁轨上的流浪者 2024-09-07 23:53:45

您只能使用 DTR 和 RTS,但有四种可能的状态。您确实需要注意另一端的设备使用 TTL 电平。如果您需要的话,在此链接的末尾Serial有有关硬件的提示。

当您说高频时,您想到的是哪种数据速率?你有什么类型的串口?使用计算机背面的旧 9 针连接器,您可以达到的最佳速度约为 115Kbps。我使用 USB 适配器进行了测试,可以通过端口推动接近 1Mbps 的速度。

You can use DTR and RTS only, but that is four possible states. You do need to be careful that the device on the other end uses TTL levels. At he end of this link Serial there are tips on hardware if you need it.

What kind of data rate are you thinking of when you say high frequency? What kind of serial port do you have? With the old 9 pin connectors on the back of the computer the best you can do is around 115Kbps. With a USB adapter I have done test where I could push close to 1Mbps through the port.

趴在窗边数星星i 2024-09-07 23:53:45

以下是 Microsoft 的一篇文章,详细介绍了如何使用串行端口:

http://msdn.microsoft.com/en-us/library/ms810467.aspx

它提到了用于直接控制DTR线的EscapeCommFunction。

在您查看此信息之前,我和其他人一样认为串行端口不适合您的应用程序。

Here's an article from Microsoft that goes into great detail on how to work with serial ports:

http://msdn.microsoft.com/en-us/library/ms810467.aspx

It mentions EscapeCommFunction for directly controlling the DTR line.

Before you check out this information, I'm joining in with the others that say a serial port is inappropriate for your application.

温柔戏命师 2024-09-07 23:53:45

我花了 3 个小时试图找到你问题的答案,似乎没有“简单的方法”可以从计算机获取简单的布尔信号......
但是,总有办法,而且jet,就像听起来一样简单(甚至可能很愚蠢),您是否考虑过使用音频插孔连接器作为输出?,它是立体声的,因此您将有2个可用的输出,编程将没那么难。而且你不需要购买昂贵的东西来让它发挥作用。
如果您还需要输入,只需拆卸鼠标...并将传感器桥接到伺服系统,这可能是最便宜和最简单的方法...

另一种方法是使用 LED 进行数字锁定、大写-键盘上的 dspl-lock 和 dspl-lock,这些可以使用软件激活,您只需要使用便宜的外部键盘,并使用这 3 个 LED 的连接器即可。

I´ve been trying to find an answer to your question for 3 hours, seems like there is no "simple way" to get a simple boolean signal from a computer...
But, there is always a way, and jet, as simple (maybe even stupid) as this may sound, have you considered using the audio jack connector as an output?, It is stereo so you would have 2 outputs available,the programming would is not that difficult. and you don#t need to buy expensive shit to make it work.
If you also need an input, just disassemble a mouse... and bridge the sensors to the servos, probably the most cheap and easiest way of doing it...

Another way would be using the leds for the Num-lock, caps-lock and the dspl-lock on the keyboard, these can be activated using software, and you just need to take a cheap external keyboard, and use the connectors for these 3 leds.

深爱成瘾 2024-09-07 23:53:45

您正在描述可能是一个并行端口 - 您可以在其中一次设置所有位模式 - 然后切换 xmit 线将其全部发送...

you are describing maybe a parallel port - where you can set bit patterns all at once - then toggle the xmit line to send it all...

东京女 2024-09-07 23:53:45

让我们从“自下而上”的角度看一下:

串口引脚
串行端口上的引脚可以连接到“控制器”或直接连接到处理器。为了使处理器能够访问(控制)引脚,引脚与处理器之间必须存在电气连接。如果没有,处理器或程序都无法控制引脚。

使用串行控制器
控制器(例如 USART)将连接在串行端口和处理器之间。控制器可以起到将8个并行数据位转换成串行位流的作用。总体而言,控制器必须提供对端口引脚的访问才能控制它们。如果没有,则无法访问引脚。 控制器必须连接到处理器,以便在连接控制器时控制引脚。

处理器和串行端口
假设您要控制的引脚已连接到处理器,则处理器必须能够访问它们。有时它们被映射为物理地址(例如 ARM 处理器),或者它们可能连接到端口(例如 intel 8086)。程序将通过指针或使用 ai/o 指令访问引脚。在某些处理器中,I/O 端口必须先启用并初始化才能使用。

操作系统的支持
这里有一个大问题:如果您的平台有操作系统,则操作系统必须提供访问串行端口引脚的服务。这些服务可以是驱动程序或 API 函数调用。如果操作系统不提供服务,则无法访问串口引脚。

来自操作系统的许可
假设操作系统支持串行端口,您的程序现在必须有权访问该端口。在某些操作系统中,权限可能仅授予root 或驱动程序,而不授予用户。如果您的帐户没有访问密码的权限,您将无法读取它们。

编程语言的支持
最后,编程语言必须支持该端口。如果该语言不提供对该端口的支持,您可能必须更改语言,甚至使用汇编语言进行编程。

访问串行端口的“未使用”引脚需要对平台进行广泛的研究。并非所有平台都有串行端口。串行端口访问取决于平台,并且可能会在不同平台上发生变化。

问另一个更详细的问题,您将得到更详细的答案。请提供您正在使用的平台和操作系统类型。

Lets take a look from the "bottom up" point of view:

The serial port pins
Pins on the serial port may be connected to a "controller" or directly connected to the processor. In order for the processor to have access (control) the pins, there must be an electrical connection from the pins to the processor. If not, the processor nor the program can control the pins.

Using a serial controller
A controller, such as a USART, would be connected between the serial port and the processor. The controller may function as to convert 8 parallel data bits into serial bitstream. In the big picture, the controller must provide access to the port pins in order for them to be controlled. If it doesn't, the pins can't be accessed. The controller must be connected to the processor in order to control the pins if a controller is connected.

The Processor and the Serial port
Assuming that the pins you want to control are connected to the processor, the processor must be able to access them. Sometimes they are mapped as physical addresses (such as with an ARM processor), or they may be connected to a port (such as the intel 8086). A program would access the pins via a pointer or using a i/o instruction. In some processor, the i/o ports must be enabled and initialized before they can be used.

Support from the OS
Here's a big ticket item: If your platform has an Operating System, the Operating System must provide services to access the pins of the serial port. The services could be a driver or an API function call. If the OS doesn't provide services, you can't access the serial port pins.

Permission from the OS
Assuming the OS has support for the serial port, your program must now have permission to access the port. In some operating systems, permission may only be granted to root or drivers and not users. If your account does not have permission to access the pins, you are not going to read them.

Support from the Programming Language
Lastly, the programming language must have support for the port. If the language doesn't provide support for the port you may have to change languages, or even program in assembly.

Accessing the "unused" pins of a serial port require extensive research into the platform. Not all platforms have serial ports. Serial port access is platform dependent and may change across different platforms.

Ask another, more detailed question and you will get more detailed answers. Please provide the kind of platform and OS that you are using.

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