Interface with MCU using FTDI UART

Bluetooth, USB, UART, Storage, etc.
uha666
Posts: 13
Joined: Tue Aug 18, 2015 4:51 pm

Interface with MCU using FTDI UART

Postby uha666 » Tue Jan 19, 2016 11:59 am

Hi,

I'm having trouble interfacing with the MCU using a FTDI interface. I connect the board and it power the MCU but everytime i try to connect the C# API gives me a message that:

Code: Select all

 A first chance exception of type 'Bitalino.Exception' occurred in BITalino_x86.dll
BITalino exception: The computer lost communication with the device.


I'm also using the uncommented line Bitalino dev = new Bitalino("COM21");, being 21 the com port detected for the FTDI.

What seems to be the problem?

Regards.

BITalino
Site Admin
Posts: 567
Joined: Tue Aug 27, 2013 3:47 pm

Re: Interface with MCU using FTDI UART

Postby BITalino » Tue Jan 19, 2016 4:03 pm

Hi there,

Please refer to the following links for additional details regarding the use of an FTDI with BITalino:
https://www.youtube.com/watch?v=GvwMtHKWxgI
http://forum.bitalino.com/viewtopic.php?t=143

One of the reasons for this issue might the the DTR on the FTDI connected to the RST pin on BITalino.

Let us know how this solution works out for you; if the issues continue we'll try to provide additional feedback.

Best regards,
The BITalino Team

uha666
Posts: 13
Joined: Tue Aug 18, 2015 4:51 pm

Re: Interface with MCU using FTDI UART

Postby uha666 » Tue Jan 19, 2016 6:18 pm

Hi,

Tried with the RST pin connected and disconnected and result is the same.

My adapter is a FTDI FT232RL.

I'm using the plugged kit of bitalino and did not break any components.

Regards

BITalino
Site Admin
Posts: 567
Joined: Tue Aug 27, 2013 3:47 pm

Re: Interface with MCU using FTDI UART

Postby BITalino » Wed Jan 20, 2016 1:49 pm

Hi there,

Got it... given that you haven't break off the Bluetooth module, the problem should then be related with the fact that the UART is being shared by the FTDI and BT blocks.

In order to get the FTDI to work you'll need to break off the BT block in order to have a single interface using the UART at a time. Once the Bluetooth is broken off you can solder header pins to the BT and to the MCU to allow plug & play interfacing of the blocks.

IMPORTANT: When using the FTDI you are advised to have the 3.3V line disconnected (the GND is needed), otherwise it may introduce inverse currents through one of the voltage regulators causing it to fry:
http://forum.bitalino.com/viewtopic.php?t=302#p820

BEWARE: With the USB connection you have an indirect connection to the mains and when using the pre-gelled electrodes on ECG and EMG sensors, you are creating low impedance contact areas with the body; in the unlikely event for example of a thunderstorm that causes a power surge, there is a possibility that hazardous currents may reach the body.

Best regards,
The BITalino Team

ole.traupe
Posts: 43
Joined: Tue Jun 17, 2014 10:50 am

Re: Interface with MCU using FTDI UART

Postby ole.traupe » Mon Oct 10, 2016 2:26 pm

I hope it's ok that I post my question here as it is highly related. I would like to interface the MCU of my Plugged (r)evolution BT with this USB FTDI cable, as I wish to use the 3D printed housing and have little space for additional boards:

https://www.flikto.de/products/ftdi-cab ... c-3-3v-i-o

I read around the forum about UART connections and found that
- I shouldn't need to connect the STAT pin, as it has an internal pull-up -- and I noticed that this new board does not even have a STAT connector anymore (but an additional GND in that place), so I shouldn't need to worry here
- I also might not need to connect the RST -- which is no longer part of this line of 6 soldering holes
- I should not connect the DVCC, as I might damage the power supply of my board -- particularly as this USB cable yields 5 V VCC
- I probably won't connect CTS, as it is pin 6 on the board, which is not connected in the demo video on Youtube

So should I just connect GND (1st pin), RX, and TX? Would that work?

I always wondered, whether STAT on the BITalino is actually CTS (clear to send), and RST might be RTS (request to send). But I guess, the story isn't that simple, right?

Btw, this setup will be operated from a mobile PC, so neither line noise nor the danger of a surge will be an issue


EDIT: Do I need to solder anything on the MCU board in this case?

cazevedo
Posts: 18
Joined: Tue Feb 25, 2014 2:17 pm

Re: Interface with MCU using FTDI UART

Postby cazevedo » Thu Oct 13, 2016 11:28 am

Hi there,

If you don't want to use the flow control you can simply connect the GND, RX and TX pins.
If you want to use the flow control also connect the FTDI RTS pin to the BITalino CTS pin and the FTDI CTS pin to the BITalino GND pin. This because the BITalino only makes use of the CTS pin, since the amount of commands sent on the MCU direction are so few that don't justify the use of this pin.
If you want to power the system using the FTDI instead of powering it through the battery, just make sure that the VCC output is 3.3V and then connect the VCC pin.
Notice that since you are using a BITalino Revolution board, the UART pinout has the same order as a standard FTDI.

Anything that you feel that isn't clear please ask.

Best regards,
Carlos Azevedo

ole.traupe
Posts: 43
Joined: Tue Jun 17, 2014 10:50 am

Re: Interface with MCU using FTDI UART

Postby ole.traupe » Thu Oct 13, 2016 2:08 pm

Thanks for the clear advice, Carlos!

So as the VCC of the cable is 5V I will always power via battery. And from what I read I will definitely want to use flow control.

ole.traupe
Posts: 43
Joined: Tue Jun 17, 2014 10:50 am

Re: Interface with MCU using FTDI UART

Postby ole.traupe » Fri Oct 14, 2016 5:11 pm

So I connected:

FTDI | MCU
GND -> GND
CTS -> GND
VCC -> nothing
TXD -> RX
RXD -> TX
RTS -> CTS

https://www.sparkfun.com/datasheets/Dev ... 0Cable.pdf

"The computer lost communication with the device." (on trying to read the BITalino version; first command after creating the device)

But realized that I would have to configure flow control in the C++ code and disconnected RTS for a quick try. Still nothing.

Image

EDIT: Note that the connection between the BT block and the MCU is removed (kept it for stability reasons) and that the power block ist still connected, as I left out VCC.
[...]
Ok, also disconencted CTS, but still nothing. I understand correctly, that the default BITalino code is not using flow control? Does it matter that this is a rather oldish version of the API?

Code: Select all

      dcb.BaudRate = CBR_115200;
      dcb.fBinary = TRUE;
      dcb.fParity = FALSE;
      dcb.fOutxCtsFlow = FALSE;
      dcb.fOutxDsrFlow = FALSE;
      dcb.fDtrControl = DTR_CONTROL_DISABLE;
      dcb.fDsrSensitivity = FALSE;
      dcb.fOutX = FALSE;
      dcb.fInX = FALSE;
      dcb.fNull = FALSE;
      dcb.fRtsControl = RTS_CONTROL_DISABLE;
      dcb.ByteSize = 8;
      dcb.Parity = NOPARITY;
      dcb.StopBits = ONESTOPBIT;

ole.traupe
Posts: 43
Joined: Tue Jun 17, 2014 10:50 am

Re: Interface with MCU using FTDI UART

Postby ole.traupe » Tue Oct 18, 2016 8:47 am

Any further ideas?

If what I did is basically corrrect, then there are 3 options, I guess:
- MCU is broken
- cable is broken or bad quality or diverges from its specs
- I failed at soldering

cazevedo
Posts: 18
Joined: Tue Feb 25, 2014 2:17 pm

Re: Interface with MCU using FTDI UART

Postby cazevedo » Wed Oct 19, 2016 10:57 am

Hi there,

In fact the the API didn't account the use of the flow control and so the tests were performed only using the Tx, Rx and GND connected.
So what is happening is that the RTS pin of the FTDI stays high when the flow control is disabled in the C++ API. So in this case the computer is able to send the version command but the BITalino never sends back the response.
To solve this issue I already changed the BITalino C++ API on GitHub and activated the flow control.
So this should solve your problem and also allow the use of the flow control.

If you experience further problems with this setup please feel free to ask.

Best regards,
Carlos Azevedo


Return to “I/O”




cron