Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Controlling Tic via Bluetooth


#1

Hi,

I was wondering if anyone has tried out to address the Tic controller via Bluetooth/serial communication?

My plan is to connect a hc05 Bluetooth module to the TIC825.

Would anyone happen to know whether it matters which GND pad of the Tic I am connecting the BT module to? I wanted to use the GND pad next to the TX pad.

Many thanks,

Helge


#2

Hi,

in the meantime I have connected (and paired) HC05 module, with two resistors (2k and 1k) „around“ the TX pad from the Tic.

I have been compiling the recommended code for testing as per chapter 12. I have updated line 181 of the code into /dev/rfcomm0

After initiating the code, I am getting the following message:

Read timeout: expected 4 bytes, got 0

I think this happens when attempting to read the Tic variable, see lines 147 and following.

Is there anything wrong in principle?

Many thanks!

Helge


#3

Hello.

We have not heard of anyone trying to control the Tic via a Bluetooth module, but it should be possible to do that. All the ground pins are internally connected for a majority of our boards, including the Tic board, so it does not matter which GND pin you use.

It sounds like you are using the code under the “Example serial code for Windows in C” section in the Tic’s user’s guide and might have a voltage divider connected to the Tic’s TX pin, is that correct? The Tic will probably see 3.3V from the HC-05 as high, but it is not guaranteed. (The HC-05 operates at 3.3V and not at 5V like the Tic.) I suggest using a bidirectional logic level shifter (like this one).

Can you post pictures clearly showing how you have everything connected, including the connections between the Bluetooth module and Tic? What baud rate did you set your HC-05 and code to? Also, can you post your settings for the Tic? You can save the settings file using the “Save settings file…” option in the File menu in the Tic Control Center.

- Amanda


#4

Hi Amanda,

Many thanks for kind response, will provide the details as suggested tomorrow.

I actually now managed to move the stepper motor, just commented out all code lines where data is supposed to be received from the Tic. I guess that already proves that it is possible to handle the controller also via Bluetooth - which is fantastic! :wink:

Best, Helge


#5

Hi Amanda,

So, here are the details:

  • I am on Ubuntu 18.04 and used the code for Linux (chapter 12.5 of the user guide)
  • This is the code, with modification of the port (rfcomm0)serialcode.cpp (5.9 KB)
  • I have been compiling the coder with:
    g++ serialcode.cpp $(pkg-config libpololu-tic-1 --cflags --libs)
  • Tic825 and HC-05 are connected as shown in the pptConnection.pptx (32.3 KB)
  • Baud rate are on both sides 9600
  • I (believe) have not changed any settings, and made sure that the Tic’s control mode set to “Serial / I²C / USB, see uploaded filetic_settings.txt (971 Bytes)

As mentioned in my previous post, sending commands to the Tic seems to work, reading from the Tic causes error. I have already ordered a level shifter as suggested by you.

Many thanks!
Helge


#6

Hello, Helge.

It looks like you are using the code from the “Example serial code for Linux and macOS in C” section of the Tic’s user’s guide, and you have changed /dev/ttyACM0 to /dev/rfcomm0 while leaving everything else the same.

Since sending commands to the Tic is working but receiving responses is not working, I recommend that you carefully check the connections between the Tic’s TX line and the HC-05’s RX line. Please post some photographs of your connections here so we can check them too.

Another thing to try would be to increase the serial receive timeout. There is a line of the code that sets options.c_cc[VTIME] to 1, which means 100 ms. Maybe your Bluetooth system needs more time than that to deliver the serial command and its response. You could try changing that to a larger number like 50 (5000 ms).

By the way, if you don’t need to read data from the Tic in your final application, you could just disconnect the Tic’s TX line and use the system as is.

–David


#7

Hello David,

I have updated VTIME to 50, and now it is working!!!

BTW, you are right, for my application I would not need it, but was curious to get it working.

Many, many thanks for looking into!

Helge


#8

I am glad that you were able to get it working. Now that it’s working, you might consider reducing your timeout since it might be annoying if your program waits for 5 seconds whenever there is a communication issue.

Also, since your code does not use the Tic library, you can simply compile it by running:

g++ serialcode.cpp

–David


#9

Update: with „stty -F /dev/rfcomm1“ I was able to figure out that with the termios commands I am addressing only the rfcomm1 port, but not the speed of communications between the HC05 and the Tic. Seems like the HC-05 does not care about the baud rate setting on the reception side. However baud rate settings „outbound“ of the HC-05 need to match the Tic. Outbound settings of the HC-05 can be easily changed via minicom tool.

HI David,

In principle all fine, the new driver is up and running. Via the client, I can move the stepper motor, via Bluetooth (I have connected a HC-05 BT module to the serial pads of the Tic (as described in my previous posts).

I have set the baudrate of the Tic (using the TICGUI) and the HC-05 module to 115200. All fine.

Now…running your code example in the user guide, I can change the baud rate as much as I like, but is has no impact, I can still move the stepper motor. I do not understand the logic.

I wonder what I am actually changing with termios library commands, if anything at all. Would I affect the BT transmission, or the output from the HC-05, or the baud rate setting of the Tic? (Which I doubt)

Would you have any idea?

Best, Helge