Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interfacing 8051 with USB

Status
Not open for further replies.

Musketeer

Newbie level 6
Joined
Oct 11, 2016
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
144
Hello everyone o/

I'm new to microcontrollers, and the thing I want to do is to interface a 8051 with PC via USB. I mean like having a couple of LEDs connected to the mC and switching them on and off from PC...
I've searched aaaaalll over the internet! I really did, and I found many many useful info actually. I just can't get to decide with is which :roll:

As far as i could understand, I'll have to use a usb to rs232 converter, because 8051 family works well with that sort of serial communication. So is it max232 that I should use? or cp2102...
to be honest i'm a little confused, I don't really want a final answer here, I just would appreciate it if somebody could give put me in the right direction.

Thanks in advance.
 

If you want to use PC USB port to connect PC to 8051 then you have to use USB to TTL adapter. It can be CP2102 or FT232RL based.
 
I doubt 8051 alone could communicate directly with USB so you will need some kind of adapter to handle the hard work.

You need to convert TTL (from/to the 8051) to USB using something like CP2102 or FT232 but be careful of the level conversion from 5V TTL to the 3.3V logic levels some bridge devices need.

DO NOT use RS232 converters (max232 etc). They convert TTL voltages 0V/5V to +12V/-12V which is exactly what you don't want.

It will be far cheaper and easier to buy a ready made USB converter module and connect it either to the 8051 UART or better still interface it with SPI.

Brian.
 
Thank you guys.

so it's going to be something like this: right?

n3n0l0jvgnyrx8l6v0oo.jpg

btw I'd prefer to build the TTL converter on my own, since I'm supposed to learn something here :-D i couldn't find DIP chips of that kind anywhere around here tho. so i guess I'll have no other option but using a ready module
 
Last edited by a moderator:

TxD of adapter has to be connected to RxD of 8051 and RxD of adapter to TxD of 8051. Also the adapter GND has to be connected to 8051 Circuit GND.
 
There are many variants of 8051, if it's the original Intel type, it doesn't have a UART on board so you would either have to use an external one or create a software serial interface (aka 'bit-banging'). 8051 is a quite old processor, maybe 25 years since release but it has become the 'core' of many newer types that do have extra peripherals on the silicon.

If you do try for a software UART, look at SPI options first as they are easier to code and may also allow faster data transfers.

Be careful of the different voltage requirements. Connecting 5V to a 3.3V input will normally damage it and possibly overload the 5V output as well. There are numerous voltage level converter devices you can use but if this is just for experiments, you might get away with using two resistors as a voltage divider from 5V to 3.3V (1K series then 1.5K to ground) and the other way, the 3.3V might be enough to be recognized as TTL by the 8051 without extra circuitry.

Brian.
 
Hi,

what about this:

Klaus
 

thanks again guys.

The reason I was bringing up 8051 was that already have a USB 8051 programmer with a 40-pin zif socket. I also have the mC itslef which is ATMEL 89C51. If it's very important to switch to whole another mC type, then I guess I should go for PIC ones, because the built-in USB controllers? The problem with switching to another mC is that I'll need to use a actual serial port for the initial programming of that mC. neither my laptop nor my pc has it on board, that's why I prefer to use same 8051 family.

So connecting TXD of the converter to mC's RXD and converter's RXD to mC's TXD, and connecting GND and VCC and other stuff would do the job?
I also was planning to use one of these breadboard modules as the power supply, so I guess that'll be safe?

https://www.roboeq.ir/uploads/images/shop/products/L14664153017173.jpg
 

To be honest a PIC with USB would be your easiest solution, I would suggest the 18F2550 or 18F4550 would be simplest to program and use. There are many cheap USB based PIC programmers on the market but it's worth spending a little more than minimum to get a Pickit2 or Pickit3 for example:
https://www.ebay.co.uk/itm/New-PICK...474399?hash=item51d6493adf:g:LyYAAOSwDNdV1oY9

Pickit is powered from the host computers USB socket and can program almost all the Microchip families of MCU and their EEPROM products. It also has a built in debugging tool and the programming tools are available free from Microchips web site. They are included in the link above but check they are the latest versions.

Incidentally, those PICs and several others with USB modules also have on-board UARTs as well.

Brian.
 

Thanks Brian.

Actually I had that thought too, especially when I found this: https://www.rakeshmondal.info/pic18f4550-project-tutorial-part-1-USB
The problems are 1-the program costs something like 30$ around here and 2- if it's too simple chances are the teacher won't give it any credit as a genuine project (which actually is kind of a valid argument! can't cheeze the project like that :lol:) So I'll probably either stick to 8051 or build a PIC programmer to show him I've done and learnt something. like the link above. Which one sounds more reasonable to you?
 

Perhaps this would be useful as a free PIC programmer: https://usbpicprog.org/

Demonstrating that you can program a PIC then use it in a simple application would score highly as a project, especially if you made the app do something clever.

Brian.
 
So PIC it is! thank you very much for your time, much appreciated :thumbsup:
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top