2
\$\begingroup\$

I'm developing a circuit on a breadboard and using PIC18F4550 microntroller (supports USB connection) but I just wonder how I can connect it to the PC.

Should I get a type A to type A cable, cut it from one side and connect the internal wires (D+ and D-) to the microcontroller?

Or is there a specific connector for that purpose? I got a male type A USB connector but looks like it can only be used with PCBs.

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

A proper device-side connector would be USB-B: USB-B (full size), mini-USB-B or micro-USB-B. Then you can use a standard USB A (computer side) to USB B (microcontroller side) cable.

There's a large amount of USB connectors.

I've never seen one made for breadboard, and that's not a coincidence:
Breadboard and USB are a bad combination. While low-speed USB might work, Full-Speed USB, which your PIC supports, is 12 Mbit/s, and that's got an analog bandwidth that really doesn't play well with breadboard.

You'll have to build a small PCB on which you solder the connector, and on which you also connect pin headers to plug into your breadboard.
In a pinch, you can of course cut any USB cable that plugs into your PC (don't buy a USB A-to-A cable - just get any thrown away USB cable). USB cables have colors that are standardized, so it's easy to solder pin headers to them.

Again, that might work, but I'd advise you to not try to do USB on breadboard, unless you really like debugging things that work sometimes and sometimes not, and stray signals all over the place.

I'd recommend buying a small microcontroller board that has the microcontroller soldered as well as a USB connector, and pin headers for plugging into breadboard underneath. For example, something like this:

Nucleo-32 eval board

(which you can buy from many places).

There's really very little reason to use a PIC18F4550 (wow, that ancient thing costs like 6€!): There's cheaper, faster, less power-hungry, more RAM, more flash devices, like the microcontroller soldered onto the board above. The whole board is 3€ more expensive than your PIC18F4550, and comes with USB, and a USB Programmer, and multiple LEDs, and honestly: Programming complex software¹for a PIC18 is really annoying compared to using FreeRTOS or mbed to develop your application on a modern, well-supported ARM microcontroller.

I can only stress how sensible it is to not implement a USB stack yourself — there's just so many things you can do wrong, and PIC18 is not really the perfect platform to learn USB handling on - especially not on breadboard, where you can't know whether it's the fault of your firmware, or of the bad signal quality, that things don't work.


¹ and you'll do that – handling USB on these RAM-minimal PIC18s isn't easy!

\$\endgroup\$
6
  • \$\begingroup\$ Thank you very very much for your comprehensive answer. Well, unfortunately I happened to use PIC18F4550 and already finished programming its firmware and I have too little time to use another model and start from the beginning :( It's working fine in Proteus simulator; I just hope things will go as fine when I implement the circuit. Maybe next time I'll consider using something newer and easier like the one you mentioned; it really looks pretty good. Thanks very much for your tips. Regarding the USB cable, just to be sure, will a type A to type A USB cable be good? cutting it from one side? \$\endgroup\$
    – Doua Ali
    Dec 5, 2020 at 21:19
  • \$\begingroup\$ Regarding the breadboard, I can see it is not convenient for USB connections and I'll certainly use a PCB later on, but for preliminary testing can the breadboard any good? I don't care very much about the high speed as the data is small enough and can take some time to send. Can I use the breadboard for now? Thanks a million! \$\endgroup\$
    – Doua Ali
    Dec 5, 2020 at 21:23
  • 3
    \$\begingroup\$ Unfortunately USB link speeds are fixed and they are either 1.5 Mbit/s or 12Mbit/s depending on which one you decided to use, and that does not depend on how slow and seldom you want to send small amounts of data. If the link does not work, it does not work for any amount of data sending. \$\endgroup\$
    – Justme
    Dec 5, 2020 at 21:32
  • \$\begingroup\$ @Justme Thanks a lot for your reply. Excuse me, what do you mean by '"if the link does not work"? You mean because a breadboard will slow down or hinder the data transfer? \$\endgroup\$
    – Doua Ali
    Dec 5, 2020 at 21:39
  • \$\begingroup\$ Yes thats what he means. \$\endgroup\$
    – Passerby
    Dec 6, 2020 at 2:49
0
\$\begingroup\$

Theoretically a breadboard is too noisy and high capacitance for high speed usb (including full speed). But in practice it works as long as you aren't trying to push it to the limits. A project with a pic18f using usb on a breadboard. https://www.waitingforfriday.com/?p=451

Your options are to get a breadboard friendly usb B (mini or full size or c) connector module from the typical sources, get a breadboard friendly usb B full size through hole connector, or a through hole and make your own with some protoboard (as the project linked above does)

You can also do what you suggested and cut a cable apart. Connect it to a long header so you can plug it in, or solder it directly to the pic usb pins.

Your other option is to make or get a pcb made for your project. The costs are minimal (like 10 to 20 shipped for 10 boards) though slow boat shipping is probably longer considering the current global shipping situation.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.