-
Sep 3rd, 2021, 07:24 PM
#1
Thread Starter
Addicted Member
[vb.net] Turn off COMPORTS and turn it on
I have a led with a resistor soldered on a USB cable with a resistor when I put it on the USB comport1 it turns on, but I would like to turn it off or reduce to almost zero the power flow in the serial port, being able to turn it on and off, I looked for some articles but always take me to ardruinos or some other type of control board, I wanted something directly on the computer to turn the comport on and off, I am aware that this is dangerous and can damage it, but I want to test this directly on the computer is there any way to do it this with visual basic?
-
Sep 4th, 2021, 03:11 AM
#2
Re: [vb.net] Turn off COMPORTS and turn it on
You can toggle the state of the RTS line very easily. This will set it HIGH on COM1:
Code:
SerialPort1.PortName = 1
SerialPort1.Open()
SerialPort1.RtsEnable = True
and closing the port will set it LOW:
Code:
SerialPort1.Close()
Make sure you use the highest value resistor that still lights your LED. Com ports can only sink and source a couple of milliamps.
EDIT: This assumes you are using a serial to USB converter that gives you all the standard serial port pins. It won't work with just a USB connection.
-
Sep 4th, 2021, 07:50 AM
#3
Thread Starter
Addicted Member
Re: [vb.net] Turn off COMPORTS and turn it on
Originally Posted by paulg4ije
You can toggle the state of the RTS line very easily. This will set it HIGH on COM1:
Code:
SerialPort1.PortName = 1
SerialPort1.Open()
SerialPort1.RtsEnable = True
and closing the port will set it LOW:
Code:
SerialPort1.Close()
Make sure you use the highest value resistor that still lights your LED. Com ports can only sink and source a couple of milliamps.
EDIT: This assumes you are using a serial to USB converter that gives you all the standard serial port pins. It won't work with just a USB connection.
well I used a cut USB cable with the led and the resistor so I assume it will work when I'm at home.
-
Sep 4th, 2021, 08:42 AM
#4
Re: [vb.net] Turn off COMPORTS and turn it on
It's not going to work without a serial to USB converter. USB is a bus, not a port.
-
Sep 4th, 2021, 05:34 PM
#5
Re: [vb.net] Turn off COMPORTS and turn it on
There is the serial bus portion of USB but there is also pins to provide ground and power for the device plugged in.
I assume he is hooking the LED to the power pin. The USB device can provide a variable amount of current, which is usually negotiated by the device.
There is probably a way to turn the power off and on programmatically, probably by enabling or disabling the USB port, but I haven't researched it.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Sep 5th, 2021, 02:20 AM
#6
Re: [vb.net] Turn off COMPORTS and turn it on
You can turn off a USB device, but I doubt there is an easy way to turn off the +5 volts on an individual USB port.
-
Sep 5th, 2021, 11:20 AM
#7
Addicted Member
Re: [vb.net] Turn off COMPORTS and turn it on
Probably one of the better options is a USB to UART cable or development board that exposes its I/O. One of the more popular manufacturers is FTDI who make a 5v and 3.3v.
Here is a link to a variety but if you google you can find them at many online stores:- https://ftdichip.com/product-categor...-cable-series/
Once you have the cable then FTDI have libraries for VB.net and C# (with examples) that allow you to control the I/O lines from a PC.
The methods include being able to configure the I/O as output and to switch them on and off
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|