Bluetooth dongle comms

Hi All

I am busy planning a platform (400mm x 400mm) for a couple of experiments (mainly AI) that I would like to do.

I intend using a PC as the brains (program in C++, VB or whatever) BUT the platform must not be connected using wire.

Therefore there needs to be bi-directional RF communications between the platform and the brains.

As I am Electronically Challenged (to put it mildly), this is where I am stuck.

What I would like to do is use a pair of USB Bluetooth dongles, one on the PC and the other connected to a 40 pin PIC16F877A processor to do the comms for the platform.

I have choosen the dongle route after having fried a number of (expensive) modules and home-grown boards and even 2 PC Motherboards.

On the PC side, there should not be any problem BUT how do I do the platform side?

I have choosen the PIC as I have both the PICKIT1 and PICKIT2 programmers as well as PICBasic and there are at least 32 pins available to use for inputs and outputs on the 40 pin PIC16F877A units.

At this stage, I do not even want to think about analog data or video. Maybe in the future when I start to work on object recognition or similar.

This project is more about robotics programming than actual robotics construction (I have my own lathe and mill so the construction side is not a big issue in my life) but without the communications issue being solved, there is no way forward.

This is actually project number 3, the first 2 were dumpstered after blowing up the PCs. Both times while trying to get the communications working using home-grown RF comms boards.

Is anyone able to provide guidence or a solution?

All the best

Madman

You might notice a common

You might notice a common theme with Mr. robologist’s recommendations: none of them involve connecting the PIC μC directly to a USB device.

It doesn’t take much apparent effort for a PC to act as a USB host, but there’s actually a lot going on behind the scenes. A little 8-bit μC would struggle to pull off all the management protocols that are required to act as a USB hub, especially if it needed to manage other tasks as well. It may well be possible to pull it off with a PIC16F877A, but microchip have released a series of μCs that actually have a USB controller built into them. Better yet, stick with USB on the PC side and use a more streamlined interface on the robot’s end.

Various solutions : Aircable

Various solutions : Aircable is one thing I’ve seen on a robot but not personally used. Their USB to serial that should work appears to be on sale for $109. This would require RS232 serial at the microcontroller and a USB connection on the PC.

Sparkfun has their Bluesmirf unit that could work too. I have an earlier version of this but have not used it except maybe once. Note this device would require TTL serial at the microcontroller, or else an added RS232 conversion circuit would be needed. The PC side would use this USB Bluetooth unit.

I’ve used XBee connections in the past, worked great. Sparkfun has a few boards again, this one at the microcontroller, this one at the PC end, then pick a couple XBee radios to use with them. Again, TTL serial needed at micro end, or else might use this board for RS232 serial.

 

The bluesmirf works great

The bluesmirf works great and it’s what I’ve used with processing and a picaxe. I use a usb dongle on the host machine . The main prob I’ve had with this setup is the initalestablishment of the com link, but once thats resolved, com is easy to do.

 

The other module that I’ve used that would require a serial converter on the pc side is the um96 module. This was seemed easier to coonnect two divices together…you can get a prebuilt serial level converter or build one yourself with a max232 chip.

I’ve tried these rf link boards buth ave yet to get them to connect at all…and have since given up on them for the moment.

Thanks for the guidance

Hi All,

Thanks for the guidance and recomendations.

I have had a look at all of them and IMHO :

The AIRcable Serial3 (most expensive at $79.00) looks like the safest and simplest option (direct RS232 connection).

The BlueSMiRF unit (at $49.95) will need all sorts of conversion units (RS232 to TTL) to correct voltage discrepancies.

The XBee unit (although the cheapest at $22.95) will need all sorts of support circuitry etc. This unit is the only one that mentions something about an AT command set but I suspect that they all need some sort of AT commands to set the units up. This should be relatively easy to do from the PIC on bootup or reconnection.

Now if I have it correct, the AIRcable unit should be the easiest to interface with the PIC16F877A unit as all it needs is TX and RX signals (and of course V+ and V- )

"ALL" that is needed is to work out a syncronization protocol and we are on the way.

Any comments on this would be appreciated.

 

 

It would be helpful to know
It would be helpful to know what specific board the 16F877A is to be used with, as searchs of PICKit 1 and PICKit 2 turn up a variety of possibilities.

If you’re connecting the

If you’re connecting the bluesmirf directly to the pic, you shouldn’t need to do anything other than connect rx/tx/5v/gnd as it’s ttl…my understanding was that you’d be using the usb key on the comp and a second device(bluesmirf) for the pic… This is what I use and it works pretty well. Not sure where you got the idea that you’d need extra components to connect it to a pic…

The AT command set is the standard for serial com…google it and you’ll find tons of info on it. Back in the day I used it to configure and connect via oldschool modems to bbs boards…thats pre WWW for you youngins… :smiley:

Specific board/direct connection

Hi Robologist /Voodoobot

I have a “spider” board that I want to use. Basically, it holds the PIC, crystal & caps, power led & reset switches and leads all the ports out to individual pins, all nicely ordered. Even has inline programming connections. (not too sure how to add attachments yet so look at the schematic here and layout here) Note: the layout shows screw terminal connectors and not pins but they are interchangable.

Its definitely not the smallest option but that is ok. This is not meant to be an exercise in miniaturization.

The nice thing is that you simply plug the sensor boards, h-bridge driver boards or anything else needed to interface to the PIC using leads.

I have also thought of modifying the layout so that opto-isolators can be put between the PIC pins and the pins that you connect things to. Currently these are protected by 220 ohm resistors.

To convert a pin from “input” to “output”, you swing the opto-isolator thru 180 degrees. I saw that idea on a Vellerman serial breakout board (that I also blew up!!!)

The opto-isolators will make the board construction more complicated because there will have to be either a lot of cross-link wires soldered in or the board will have to be double sided.

Oh well, install the free Eagle 4.14 software (again).

For example, a USB plug (to take the AIRcable unit) would have 4 wires, V+, V- connected to the power bus on the spider board and T, RX going to 2 pins in whatever port I decide on and would be on its own board.

In fact, each sensor or driver will be on its own board. I think it will make recovery from “blue smoke” a whole bunch easier and the opto-isolators will make it a whole bunch less costly…

One question though, on the schematic , it shows pins 25 and 26 as TX and RX (terminating in JP5). Are these the pins to connect to the AIRcable unit or will any pins do?

If you have to play around with individual bits of the byte received (or sent), things get complicated and the dog gets beaten into the ground instead of getting a pat on the head. ;>}. If pins 25/26 are the ones to use, that means that port c only has 6 “useable” pins. Oh well, we will have to work around that slight inconvenience.

I dare say that if more inputs/outputs are needed, we can always use multiplexing, I2C or similar but that is WAY WAY in the future.

The platform will use some 12v batteries out of a couple of UPS’s which got a “slight” lightning zap to the controler boards.

Drive motors will be hacked windscreen wiper motors. May be interesting to get the oscilation to become full rotary motion and isolating the -ve connections from the casing so that I can reverse them without a big flash. No really serious issues there.

I’m not sure whether to use wheels (go-kart or small atv - 6"/150mm dia) or tracks (have no idea where to even start looking for them

Ok, enough from me, supper is calling (or more importantly, the wife)

All the best

Aubrey

I’m not versed in the pic as

I’m not versed in the pic as much as the picaxe, but I believe that yes, the rx/tx would connect to the airCable device. I don’t think you can use any pin for serial com.

One thing I’m curious about is why the opto isolators, I mean for the motors, I understand, but it adds undue complexity.

 

 

Technically you can use any

Technically you can use any I/O pins you want for serial comms, but that would mean "the dog gets beaten into the ground" as you put it =3

The RX/TX pins are the ones you have to use if you want to utilise USART, which makes serial comms significantly easier since the PIC handles virtually everything for you.

You are using a “bare” PIC,

You are using a “bare” PIC, with no RS232 chip, so the Aircable unit would be a bad choice. The PIC by itself has TTL serial, that is, serial levels at 0 to 5 volts, not RS232 levels of +9 volts to -9 volts.

The bluesmirf and XBee units would allow direct connection to the PIC TX and RX (and ground) pins, no conversion needed, since the PIC board does not have an RS232 level shifter.

opto-isolator

I agree about the complexity.

However if a short happens, the processor is toast.

If everything is isolated you can do what you like and the worst that can happen, apart from smoking the periferal board is that you will blow the isolator.

In effect the main processor will be as idiot proof as it can be.

Definite problem

This is "typical" of the issues that I have encountered - incompatable voltages!

Let me ask this question :

If I have a USB plug on the spider board connecting directly to the TX and RX pins on the PIC and insert a standard Bluetooth dongle into the plug, would the 2 be compatable from a hardware point of view?

I know that there are many different libraries available for the PIC and hopefully I will be able to programatically configure the Bluetooth dongle to connect to the one on the PC.

Thereafter, everything (handshaking, synconization, data transferal etc) is done programatically which, for me, is a managable issue (and fun!).

Maybe there is a PIC series that has this sort of functionality built into the onboard OS.

I do not want to use the RF PIC range because none of them come with an arial, you have to provide one. (pain!)

The Bluetooth USB dongle is standard issue on most cell phones these days. I have 3 and there are many available from pawn shops at reasonable prices.

"Technically"

Thanks for the input TeleFox.

Question:

I assume that USART is a set of functions / protocols that “ease the pain” of comms.

Is it also able to detect a specific machine (ie. my PC) via the USB dongle and only process data coming from that machine?

As Rudolph mentioned, USART

As Rudolph mentioned, USART is a hardware module available on certain PIC models such as the 16F877A. It has a few useful features such as a baud rate generator, an output/input parallel<->serial shift register, and a complement of interrupt and error flags.
Thanks to the transmit/receive shift registers you only have to worry about sending/receiving one byte at a time, rather than having to code a routine to perform the conversion and output process for you, like you would if you were to implement serial comms on any generic I/O pin. Add in the functionality of the baud rate generator and you really save a significant amount of main program code, which can then be used for managing and directing data on the bot side.

As for detecting your PC I can only assume that you’d need some sort of ID authentication when the two Bluetooth devices start communicating. On the PIC side of things most PICs have the ability to be programmed with an identifier code, which can be used as a key as it can only be modified when you are flashing the program onto the PIC.

USB info

Quote "If I have a USB plug on the spider board connecting directly to the TX and RX pins on the PIC and insert a standard Bluetooth dongle into the plug, would the 2 be compatable from a hardware point of view?"

USB is yet another serial voltage and communications standard that is not TTL serial. So it would be bad to try to connect a USB plug directly to the TTL serial lines I see located close to the 7805 voltage reg on your “spider board” layout.

TTL serial - basic 0 to 5 volts signalling

RS-232 serial - +9 volts to -9 volts signalling

USB - differential 2 line 0 to 2.8 and 3.6 to 0.3 volt signalling, unrecognizalbe at TTL logic levels.

USB Bluetooth dongles are great for the PC end, but not so for the PIC end of the connection. If you want Bluetooth serial at the PIC, please use the Bluesmirf unit, TTL serial ready.

Oh Well

Life is like that!!!

Just when you think the answer is close…

Why can things not all operate on the same voltages?

OK, I do know the answer - different technologies…

Thanks Rudolph,

Thanks Rudolph, Telefox.

Unfortunately (as robologist pointed out), there seems to be a difference in operating voltages!

Does anyone know of a chip that does the conversion for you? (similar to the "RS232" level adjustors)

As for the detection, someone suggested that a set of DIP switches could be used. Similar to setting up a gate remote.

Basically, you would set up the switches on the remote unit which would monitor incoming signals untill it gets a "connection request". He suggested 2 bytes, 01010101 10101010 with a 3rd byte being the DIP setting. If the 3rd byte matches the DIP setting, the connection is validated and the PIC "locks" onto the PC until it powers down.

Or maybe hardcode it…

Use it or Loose it!

Installed Eagle andtried to load the schematic of the spider board.

CORRUPTED!!!

So now I have to do it again. What else is new?

Now that would not be so bad IF I could remember how to do it!!!

I decided to start with the power supply.

Placed a 2 pin connector (where the battery will be connected eventually) and 2 voltage regulators.

Selected the "Wire" button and drew connections between the +ve connector pin and the "in" pin on the voltage regulator.

Decided to move the voltage regulator so I selected the "Move" button and moved it.

Guess what! The wire was not connected to ANYTHING.

I seem to remember having a similar problem the first time around.

And from what I can remember, getting busses and nets to connect is just as obscure.

The good news is that I have found a youngster who can etch single sided boards. Stays a few streets away.

Unfortunately, the little sod wants to charge an arm and a leg to do the schematic and route it.

Oh well, print out the pdf and read it.

Thats fun. Or frustration. Maybe they are interchangable!

While I don’t see any reason
While I don’t see any reason why you can’t keep posting your progress in here, it might be advantageous to create a new robot page to keep track of your work. You’ll still have an open discussion running underneath where people can add to it, but you’ll have the benefit of the main robot section at the top of the page where you can post the current project status, along with diagrams and photos etc.
Just hit up ‘My Pages’ in the top menu bar, then ‘My Robots’ to start a new project page.