Use Core2 USB port for serial communication

Hi
Is it possible to use the Core2 USB port (the one used also for flashing) to communicate with a PC (of course with an USB-Serial converter and suitable driver instead of the FT230X Basic UART driver)?

Michael

Hi Michael,

Of course it is possible :wink: You can do by VSC by clicking on the icon in the bottom left corner “open CORE2 serial console” or you can use any terminal and set the appropriate baud rate.

Regards,
Hubert.

Hi Hubert
thanks for your answer. I use already the Core2 serial console in VSC for printing out debug info. But I want to use another program, concrete the MPUTeapot Demo. What is the appropriate baud rate? Have I to switch the FT230X Basic UART driver to something else?

Michael

Hi Michael,

a piece of code to visualize quaternion data in the MPUTeapot Demo is already present in Web IDE. Just select “8. self-balancing telepresence MPU9250 DMP (CORE2)”. There is a class IMU, where line to visualize quaternion data is commented - quatVisualisation(); . Just uncomment this, and everything should work fine over USB Serial port (micro USB port and baudrate 115200) with a driver “FT230X Basic UART”.

A comfortable way for sending serial data to the computer is using UART from hSens 3 or 4 port together with, for example, hc-05 bluetooth to serial converter. After connecting to this module you have another serial port in your system that you can use for sending data for teapot demo.

void quatVisualisation()
{
	static uint8_t teapotPacket[14] = { '$', 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0x00, '\r', '\n' };
	static int i = 0;

	if (i == 0) {
		hFramework::Serial.init(115200);
		i = 1;
	}

	teapotPacket[2] = 0xff & (mpu.qw >> 24);
	teapotPacket[3] = 0xff & (mpu.qw >> 16);
	teapotPacket[4] = 0xff & (mpu.qx >> 24);
	teapotPacket[5] = 0xff & (mpu.qx >> 16);
	teapotPacket[6] = 0xff & (mpu.qy >> 24);
	teapotPacket[7] = 0xff & (mpu.qy >> 16);
	teapotPacket[8] = 0xff & (mpu.qz >> 24);
	teapotPacket[9] = 0xff & (mpu.qz >> 16);
	hFramework::Serial.write(teapotPacket, 14);
	teapotPacket[11]++; // packetCount, loops at 0xFF on purpose
}
float IMU::getAngle()
{
	float retval = 0.0;
	if (1 == hSens2.pin1.interruptWait()) {
		while (mpu.fifoAvailable()) {
			if (mpu.dmpUpdateFifo() == INV_SUCCESS) {
				// computeEulerAngles can be used -- after updating the
				// quaternion values -- to estimate roll, pitch, and yaw
				mpu.computeEulerAngles();
				retval = mpu.roll;
				quatVisualisation();
			}
		}
	}
	return retval;
}

Hi Dominik
I tried that but does not work.
In my device manager (Windows 10) there was an USB device "FT230X Basic UART shown but no serial Com port. The Teapot demo exits with an ArrayIndexOutOfBoundsException while executing

Serial.list()[0]

In Zadig I have th WinUSB (v6.1.7600.16385) as driver. Flashing and receiving data in the VSC console works.
Any ideas?

Michael

Hi Michael,

it’s Windows driver related issue. Maybe try to remove the driver and install once more, or try with USB Serial (CDC) driver in Zadig. Let me know about results.

Best,
Dominik

I tried with an USB Serial driver (don’t know which one), but than I can’t communicate with Core2 (no connection). So I reverted that.
What about using an original FTDI driver? Which chip is used in Core2?

Michael

CORE2 contains FT230X chip. You should see a serial port in Windows just after connecting CORE2 to your computer. Your system should detect FTDI chip automatically.

If I remove the driver which works with VSC and reconnect the USB cable a Serial USB driver is installed automatically by Windows which seems to work with processing (at least the port (com3) is opened).
Trying to open a Core2 serial console I get the following message:

C:\MT\Downloads\_Diverses\Husarion\_myCode\MPU6050-2>"C:\Users\MichaelT\.vscode\HusarionTools\bin\ninja" console [0/1] cmd.exe /C "cd /D 
C:\MT\Downloads\_Diverses\Husarion\_myCode\MPU605...extensions\husarion.husarion-1.5.8\sdk\tools\win\core2-flasher --console"unable to open FTDI device: -4 (usb_open() failed) FAILED: MakeFiles/console
cmd.exe /C "cd /D C:\MT\Downloads\_Diverses\Husarion\_myCode\MPU6050-2 && C:\Users\MichaelT\.vscode\extensions\husarion.husarion-1.5.8\sdk\tools\win\core2-flasher --console" ninja: build stopped: subcommand failed.

For programming CORE2 through VSC standard FTDI serial driver doesn’t work - this is why you have to use zadig at first to install a new driver. Serial console inside VSC works, because we added support for this to VSC. This serial port is not visible in Windows.

To summarize:
a) standard FTDI driver: COM port under Windows available, but not programming
b) WinUSB driver: COM port in Windows is not available (but is available inside VSC), and offline programming through USB works

Ah, ok that is what I see, thanks for pointing that out.
Is there a possibility to have both? :wink:

As far as I understand it is not possible to use both driver with 2 different USB ports:
one standard FTDI driver for serial communication over e.g. hExt.serial
one WinUSB driver for programming Core2
correct?

For Windows users I would recommend using external USB to UART converter (eg. with FTDI chip) and connect this to one of available UART interface (hSens3, hSens4 or hExt).

Then you will:
a) program through USB Serial port (micro USB) in CORE2
b) send data to MPUTeapot Demo through hExt/hSens3/hSens4