Bluetooth RS232 and EasyC Pro

Our team acquired a Startech USBBTOOTH1 (USB to Class 1 Bluetooth Adapter) and a ICRS232BT1 (RS-232 Serial to Class 1 Bluetooth Adapter).

We have managed to get a Bluetooth RS232 connection to Hyperterminal, but neither EasyC nor the EasyC Loader will recognize the Bluetooth port name - it shows up as Bluetooth Serial Port (COMxx) in the Device Manager. We have different versions of USB-to-RS232 converters and they work fine with EasyC.

At least we can use the Bluetooth RS232 to download telemetry data from the robot to Hyperterminal (and from there to Excel) during driving tests.

Anyone else using Bluetooth successfully with EasyC?

Maybe our problem is with the Bluetooth Adaptor and supplied “Bluesoleil” software … perhaps a different Bluetooth adaptor will work.

Ok, so here is the deal, easyC doesn’t like COM ports above like 10+. So what you need to do is goto the device manager and change the port number to something below 10. Also, I wouldn’t recommend using bluetooth to program your robot as it will be SLOWWWW.

I’m not sure that the Bluetooth would be any slower than serial. Bluetooth 2.0+ is rated at 3Mbit/s, while even slower 1.2 is rated at 1 Mbit/s. Compare this to the speed of the serial port (what speed does IFILoader like to use? 115200? thats 10 times slower than Bluetooth 1.2 even.)

Just my 2 cents.

Jacob

I understand where you are coming from but, based on your logic USB-to-Serial should be equal to the speed of a on board RS-232 UART but it’s not. Emulation and error correction eats cycles and will slow down the output. I’ve tested two different Bluetooth modules and it was slowwww.

For one-way telemetry received by Hyperterminal the Bluetooth serial port works like a charm. The port also opens with a serial port monitor program, IFILoader, etc.

Your solution doesn’t work for me (on several computers). I even tried the utility at Serial-Port-Mapper.com - no joy. Whatever I try, the EasyC error is “Failed to open port #2 (#3, etc)”.

I hesitate to ask, but given the other programs that do work successfully - what API call or Active/X control are you using to open the port?

Still hopeful!

mike

The easyC Loader is largely based on the IFI Loader for COM selection it should work the same. Are you using loader setup to change to the correct com port? Do you have a Bluetooth module plugged into the serial port on the robot and using a virtual serial port on a laptop with builtin bluetooth?

I am going into the EasyC terminal window - it is defaulting to COM10 (the last one used) then I choose COM3.

You are correct about the hardware setup - Bluetooth RS232 device on the robot programming port, communicating with a Bluetooth dongle in a USB port on the laptop. Bluesoleil software provides the Bluetooth connectivity, and serial port service - the software preallocates a range of ports (8, I think) for Bluetooth devices, you can see these in the Device Manager. Mine start numbering at COM10, because the lower ports were already assigned to USB-Serial cables. (Thinking this was the problem, I also tried a computer where lower-than-COM10 was assigned - still no EasyC success).

When the Bluetooth radio link is established and the virtual serial port connected, the Bluesoleil app pops up a message saying which port (COMXX) has been assigned.

In the Registry HKLM/System/CurrentControlSet/Enum/Root/PORTS contains entries for the Bluetooth ports. HKLM/HARDWARE/DEVICEMAP/SERIALCOMM contains a key \Device\Serial9 whose value is COM10.

Unfortunately I don’t have access to a bluetooth laptop today I’ll check on it tomorrow and get back to you.

I wrote a Visual Studio program to list the available COM ports and open them to receive telemetry via the Bluetooth device - it works fine. I’ll post it here later.

Now I would like to use the Serial Port 2 on the robot to output telemetry … because it’s a pain switching the serial cable on the Programming Port back and forth from the PC serial cable and Easy/C, to the Bluetooth RS232 device on the robot.

It would help if I could change the default port for printf output, to Serial Port 2. Is there a way to do that?

Another way would also help (this would be a new Easy/C feature) to have the loader fire up my program rather than the Terminal window.

Other teams might find this Visual Basic program useful. It was developed using Visual Studio 2008.

(I hope the Easy/C developers can use it to find out why Easy/C won’t open the Bluetooth serial port, as explained in my previous posts. It might also help with their comments on data throughput … we find that the data is received very quickly and accurately as long as we don’t output data so often that the robot controller’s time limits aren’t exceeded and the Code Error light comes on.)

We use it, together with our Bluetooth serial adaptor, to produce instant line charts in Excel following a telemetry run. Obviously this requires Microsoft Excel be installed on your computer.

The robot code outputs data in columns, with a header line output first. For example (and this code fragment is for illustration purposes only):

int iJoystick;
int iError;
unsigned int uPWM;

print("
HEADER:
");
print("Joystick,Error,Motor
");
while (1)
{
    // read joystick value
    ...
    // compute error and motor PWM values
    ...

    // output data for telemetry
    print("%d,%d,%u
", iJoystick, iError, uPWM);
}

It is important that the number of comma-separated fields in the header line, and the number of comma-separated fields in the data lines, are the same.

The data going out the serial port would look something like this:

HEADER:
Joystick,Error,Motor
-12,10,132
-12,10,132
-14,12,145
-16,14,145

You can see this in the Terminal window of Easy/C, but there is no way to capture the data to a file.

You could open the COM port on the PC using Hyperterminal, and capture the data to a log file, but that’s lots of keystrokes and mouse-clicks to repeat on every data run. And if you try to use the same COM port as Easy/C, you will have to close Easy/C between runs to free up the COM port.

Or you could run the attached program and get the data on a different COM port - leaving the original one for Easy/C and program loading. You will need to plug the robot controller’s Program Port into a different port on the PC, during your telemetry test run.

To use the program:

  1. select the COM port and click the Open button
  2. hook up the robot controller as described above, and run it to produce data
  3. click the Excel button to copy the data to Excel. The program fires up Excel automatically, copies the data to rows and columns, creates a chart, and then makes Excel visible.

The ‘Trim Data’ button is provided so that you can restart the robot program multiple times … this results in multiple header lines in the output. Trim looks for the line containing the word HEADER: and removes that line and everything before it. This leaves only the the final header and data lines. After you Trim, then use the Excel button.

Mike

SkyTelemetry1.zip (88.7 KB)


SkyTelemetry1.zip (88.7 KB)

If your just sending bytes or recording motor values you can use motor values and user bytes 0-5 and read them via the dashboard port on the OI. Plus it legal for use at the competition. I’m sorry I didn’t get back to you sooner. I was able to test my bluetooth device on my MacBook Pro under XP and I was able to both receive terminal data and program the robot. It was extremely slow trying to program the robot controller though.

The function for user bytes is:

SetUserByte(unsigned char index, unsigned char value);