FT232RL usb-to-serial-uart used for a multi-IO port IC.

Thread Starter

q12x

Joined Sep 25, 2015
2,227
I have this board: FT232RL-usb-to-TTL or serial-uart-module - pinout.
FT232RL-usb-to-serial-uart-module - pinout.jpg
From what I read, TTL and UART is the same thing? or at least very close in functionality? I originally bought it as a usb to TTL.
The FT232RL IC datasheet.
---[ -I want to use my C# to command a number of In/Out pins]---
Im thinking maybe this module can bridge between my C# and some multi-IO port IC?
First of all ,-if is possible-? I never worked with such a thing. I only have it, (exactly for this purpose).
Second, your kind suggestions how to implement it, what multiplexer to use and the rest of the hardware.
I have a list of all my IC's , and some of my friends here, already have that list, but I can put it again if requested.
Thank you !
and happy holidays to everyone !
 
Last edited:

Thread Starter

q12x

Joined Sep 25, 2015
2,227
Good Morning ericgibbs,
I did watched that movie. Not really helpful for my direction.
So, I want a direct link from my PC to a number of In/Out pins. No uC (microController) in between.
Is it possible this way? Or uC is a must?
I give it a search through my ICs and I find a couple multiplexers - - you tell me what is good and what is not good.
  1. 4514-CD4514 10/10 24PIN DIP Logic 4 to 16 Line Decoder/Demultiplexer__________________________________(not sure...because its a DEmultiplexer)
  2. 74138-74LS138 10/10 16PIN DIP 1-OF-8 DECODER/DEMULTIPLEXER_______________________________________(not sure...because its a DEmultiplexer)
  3. 74157-74LS157 10/10 16PIN DIP 2-INPUT MULTIPLEXER (switch 4 signal lines at once, AB,A-B,A/B inputs)__(not sure....hmm?)
  4. ADC0832 10/10 8PIN DIP 8-Bit A/D Converter with 8-BIT resolution Multiplexer serial --in &--out__________(im thinking...maybe?)
  5. ADC0808 20/20 28PIN DIP 8-Bit A/D Converter with 8-Channel Multiplexer paralel //in &//out_____________(im thinking...maybe?)
I dont have that many Multiplexer ICs after all.
Theoretically, I need a serial in/paralel out (--in& //out).
serial in, to pick up the signal from this FT232RL IC and convert it into // to multiple IO pins.
That's my thought.
 
Last edited:

Thread Starter

q12x

Joined Sep 25, 2015
2,227
Or maybe to link directly a Shift Register to FT232RL IC ?
This is what I have:
  1. 4021-CD4021BE 10/10 16PIN DIP 8-STAGE SHIFT REGISTER with 8//&1--inputs and 3--output Proteus ready
  2. 74164-74LS164 9/10 14PIN DIP 8-bit shift register serial-in/parallel-out
  3. 74194-74LS194 11/11 16PIN DIP 4-bit Shift Register parallel-in/parallel-out Bi-directional +1 peScartz
  4. 74595-74LS595 10/10 16PIN DIP 8bit Shift Register serial-in/parallel-out with Output Latches
  5. 4015-CD4015 x1 peScartz 4-Bit Shift Register Static serial-in/parallel-out
  6. 744094-74HCT14094D=74HC4094 x1 14PINS SMD 8-bit shift register & store bus register serial-in/serial-out or parallel-out
 

Thread Starter

q12x

Joined Sep 25, 2015
2,227
I also have a
  • MCP23017 2/10 28PIN DIP 16-Bit I2C I/O Expander with Serial Interface
And I made a BIG board with multiple of these MCP23017, but I have to program an arduino that will split the signal, then MCP23017 is spliting it again, and then show the correct output.
My idea is to have a direct connection between my C# and the outputs. Not to program the uC in arduino board.
I remember I did this thing in the 90's or 2000's with a LPT (printer) paralel port, in the old PC's.
I really liked that procedure and I want it again !
Maybe there is an IC that is doing exactly this thing? I dont care how expensive it is.
I want it to be as I described. And not a board, but an IC. Any these types of boards are VERY expensive. Ill make the board, is no probl for me.
Clear as mud?
 

LesJones

Joined Jan 8, 2017
4,511
The output side of the FT232RL is 8 bit serial data so you need to convert that to parallel data for waht you seem to require. If you require up tp 8 on/off signals you can use a UART ic. (I don't know it they are still available.) You could build a UART using TTL or CMOS logic but it would require quite a lot of ICs. I you require more than 8 parallel outputs it would be more complicated.
FTDI also make an IC that converts USB to 8 bit parallel data. The IC is an FT245RL. It would be cheaper to use a microcontroller to do what you require as most microcontrollers contain a UART.
Les.
 

Thread Starter

q12x

Joined Sep 25, 2015
2,227
It would be cheaper to use a microcontroller to do what you require as most microcontrollers contain a UART.
I have this uC : (the naked smd IC, without any boards)
  1. ATmega328P x10 32PIN SMD/SSOP32/TQFP32 8-bit AVR Microcontroller
http://www.rjhcoding.com/avrc-uart.php
It looks that this one has this UART function inside it. And I have 10pcs of it. Hmmm.
Very interesting is that a few days ago, I opened a very high level discussion on Arduino forums, exactly about this problem, and their approach was to upload a special program into Arduino, that was decoding the serial COM commands send from my C# app. We managed to make it work actually, in about 2-3 days. It was hard but we did it. The problem is that the program in C# only accepts manual input and (we) could not automate it from a button press for example. Basically you need a start and end character and the command in between: <3H> for example will lit up (HIGH) a LED on arduino pin3 set as output in that special arduino code.
We did NOT use this FT232RL ! This is my morning idea, somehow to get around that hard comunication protocol we started to make there. I thought, maybe there are easier ways. And it pop this idea in my mind with this FT232RL board that I actually have it.
Hmmmm....
So probably I should talk with arduino guys about this NEW direction, using the UART in the ATmega328P , correct ? Say yes or no.
 

LesJones

Joined Jan 8, 2017
4,511
The ATmega328P should do what you want if it has enough I/O pins for your requirements. You did not say how many lines you need. I can't comment on programming in C as I am very poor at C programming. (I mostly use assembler.)
Les.
 

Thread Starter

q12x

Joined Sep 25, 2015
2,227
The ATmega328P should do what you want if it has enough I/O pins for your requirements. You did not say how many lines you need.
I didnt know this detail and is not very handy specified, I had to dig a bit in its datasheet to find it.
I believe is having 23 I/O from its total of 32pins. I'd say is pretty high number ! I know a couple of them are dedicated analog pins. But from an Arduino UNO R3 perspective(where this chip is mostly used), I have quite a good number of I/O pins.
I dont know how many pins I want since the projects can vary over time, today I need only 1, tomorrow 30. Who knows.
Its always best to have options and to have a way to expand.
But from the IC alone I/O perspective as you put it, I think 23 is more than sufficient.
1735215784632.png
 
Last edited:

Ya’akov

Joined Jan 27, 2019
10,226
I think you are trying to use what you have but I will still mention the CH347, which is a cheap, multliprotocol USB → Serial adapter that includes a mode offering 8 GPIOs. You can get a BoB for under $5.00USD, like this one. It not only provides the GPIO, it also does UART x 2, SPI, I²C, and JTAG. The drivers are open source.

1735216905469.jpeg
 
There isn't much to a UART to parallel converter with an ATmega328 as long as the data is properly encoded.

Let's say you want to control 16 IO:

a) Write 4 bits to UART using your USB to UART device.

b) Read 4 bits on ATmega328 then use lookup table to decode to 16 IO.

c) ATmega328 digital write 16 IO high or low.

Another option is to use an Esp32 or Pi Pico with MicroPython REPL shell. This way all you need to do is connect a USB cable directly to the IC. Then you can save the encoded C# command (again 4 bits) to a text file then have Python read the text file every 100mS or so and write the appropriate IO.

If you want, I can provide the full ATmega328 code but you'll need to specify how many IO you want to control and any timing constraints. If you want the MicroPython approach instead, you'll have to settle for pure Python skeleton code as I don't have any chips on hand.
 

Thread Starter

q12x

Joined Sep 25, 2015
2,227
I think you are trying to use what you have but I will still mention the CH347, which is a cheap, multliprotocol USB → Serial adapter that includes a mode offering 8 GPIOs. You can get a BoB for under $5.00USD, like this one. It not only provides the GPIO, it also does UART x 2, SPI, I²C, and JTAG. The drivers are open source.
1735218028185.png
Hi @Ya'akov
Im glad you understand my pov. But Im building with what I have, only the exorbitant expensive stuff that can be easily built at home. Thats my mentality.
Ok, I like your board.
- Does it plug directly into my USB ? or I still need FT232RL to put it first and in it this CH347 board?
- It has 8 I/O's, Great. But can they be extended to a larger number of I/O's ? And how? Ideally with shift registers or my MCP23017?
- Does it do what I mean? Write code in my C#, sent it to COM5, this CH347 takes it, and just work, like that, opening one of its 8 I/O's ?
No uC involved? Directly from PC to I/O?
Is easier to ask these elementary questions to someone who put his hands on it. I trust you more than any tutorial. Haha. Because you come with experience and with some untold bugs or attention marks.
Its over 5$ - look at the price, and that is without transport. This is from your link. Add transport another 3 or 4$ and we have a 10$.
Ill have to search for cheaper sellers/providers because they vary, and I may get lucky. But Ill not buy anything yet. Im making my homework at the moment. Asking first, buying later. Haha.
1735221305127.png
 
Last edited:

Thread Starter

q12x

Joined Sep 25, 2015
2,227
The FT232R IC datasheet.
The FT245R IC datasheet.
Hmmm - I already have that FT232RL IC on the board !!!
I believe these 2 are doing -probably- the same thing. I looked into their respective datasheets and I cant say for sure which is better. It looks they are specialized ICs - doing a series of functions the other doesn't + a bunch of universal functions all do it. Its my first impression after a very light reading - I didn't go too deep into it. I fly like an eagle over the surface, peaked at them and say it here.
Probably FT232RL is older and FT245R is newer ??? That's why you suggested, maybe?
 

Thread Starter

q12x

Joined Sep 25, 2015
2,227
My FT232RL IC on the board that I have.... what should I add to it to :
1-make it/see it work?
2-expand it with a multi I/O port IC ? Can it be a shift register IC? I have plenty of them, eager to be on the first line.
---
Hmmmm...I find this interesting page: https://ftdichip.com/software-examples/code-examples/csharp-examples/
It looks I will need a *.dll from FTDI company, the makers of this IC, to be able to drive it directly from my C# app. Very interesting !!!
 
Last edited:

MrChips

Joined Oct 2, 2009
34,628
FT232 and multi I/O port are two different things.

If you want to interface with multiple I/O bits, use serial/parallel shift registers. You don't need FT232 USB to do this.
 
Here is ATmega328 receiver code which reads a string of 8 bits over UART then writes each output high or low. Keep in mind you can't use pin 0 or 1 with this method.

Transmitter:
void setup() {
    Serial.begin(9600);
}

void loop() {
    Serial.println("00000001");
    delay(1000);
    Serial.println("00000011");
    delay(1000);
    Serial.println("00000111");
    delay(1000);
    Serial.println("00001111");
    delay(1000);
    Serial.println("00011111");
    delay(1000);
    Serial.println("00111111");
    delay(1000);
    Serial.println("01111111");
    delay(1000);
    Serial.println("11111111");
    delay(1000);
}
Receiver:
void setup() {
    Serial.begin(9600);
    for (int pin = 2; pin <= 9; pin++) {
        pinMode(pin, OUTPUT);
        digitalWrite(pin, LOW);
    }
}

void loop() {
    if (Serial.available() > 0) {
        String bits = Serial.readStringUntil('\n');

        for (int i = 0; i < bits.length() && i < 8; i++) {
            int pin = i + 2;
            if (bits[i] == '1') {
                digitalWrite(pin, HIGH);
            } else if (bits[i] == '0') {
                digitalWrite(pin, LOW);
            }
        }
        printPinStates();
    }
}

void printPinStates() {
    Serial.println("Current state of pins:");
    for (int pin = 2; pin <= 9; pin++) {
        int state = digitalRead(pin);
        Serial.print("Pin ");
        Serial.print(pin);
        Serial.print(": ");
        Serial.println(state == HIGH ? "HIGH" : "LOW");
    }
    Serial.println();
}
Output:
Current state of pins:
Pin 2: LOW
Pin 3: LOW
Pin 4: LOW
Pin 5: LOW
Pin 6: LOW
Pin 7: LOW
Pin 8: LOW
Pin 9: HIGH

Current state of pins:
Pin 2: LOW
Pin 3: LOW
Pin 4: LOW
Pin 5: LOW
Pin 6: LOW
Pin 7: LOW
Pin 8: HIGH
Pin 9: HIGH

Current state of pins:
Pin 2: LOW
Pin 3: LOW
Pin 4: LOW
Pin 5: LOW
Pin 6: LOW
Pin 7: HIGH
Pin 8: HIGH
Pin 9: HIGH
 

Ya’akov

Joined Jan 27, 2019
10,226
Hello.

- Does it plug directly into my USB ? or I still need FT232RL to put it first and in it this CH347 board?
It is a USB→UART/SPI/I²C/JTAG/GPIO device. It plugs into USB on one end, and provides connections to busses running those protocols on the other, or to the 8 pins that do GPIO. The FT232RL is redundant, the CH347T is a superset of it.

- It has 8 I/O's, Great. But can they be extended to a larger number of I/O's ? And how? Ideally with shift registers or my MCP23017?
There are a variety of way you could extend the number of GPIOs. The one I would use, unfortunately, would be another purchase though not of anything expensive. There are a variety of GPIO extender/Mux ICs and BoBs that use them. Typically, they will use a 4-bit address to provide selection from among 16 GPIOs or analog signals. You would take five of the the GPIOs and use for for addressing and one for the signal. Then, select an address by setting the bits of the four, and use the signal from the fifth.

This scheme could be used with discrete logic, if you have the parts to build something like it. It would be relatively "free" from your parts supply though more expensive than if you bought the parts to make one compared to an extender/mux chip.

- Does it do what I mean? Write code in my C#, sent it to COM5, this CH347 takes it, and just work, like that, opening one of its 8 I/O's ?
You use a CH347 library with your C# program, and talk to the chip. It connects the program to the I/O interfaces on the board. I don't use C# so the particulars of the library and the exact capabilities provided would be a matter to research.

Here is the documentation for development on the WCH website. It is a zip file and contains a lot of information. It includes a C++ example program, and a developer's guide. I have read of a C# library for the DLL in the example, but as I said, I don't do C# so I can't help with that part.

No uC involved? Directly from PC to I/O?
Yes, no MCU is required, the chip handles all USB→<protocol> connections directly.
 

meth

Joined May 21, 2016
298
From what I read, TTL and UART is the same thing? or at least very close in functionality?
Short note from me: TTL and UART are completely different things. TTL is a type of digital logic, transistor to transistor logic, which for example compared to CMOS has different voltage levels for 1 and 0.
UART is communication protocol.

UART operates on TTL voltage levels.
 

Ya’akov

Joined Jan 27, 2019
10,226
Short note from me: TTL and UART are completely different things. TTL is a type of digital logic, transistor to transistor logic, which for example compared to CMOS has different voltage levels for 1 and 0.
UART is communication protocol.

UART operates on TTL voltage levels.
This is correct, but he is referring to the vernacular name of a USB connected serial adapter that operates at TTL instead of RS-232 levels. Like many common usages, this one can be confusing and it would be nice if it was more rigorous, but it’s not.
 
Top