Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Basic USB application to transfer batches of 128 bytes into PIC

Status
Not open for further replies.

atferrari

Well-Known Member
Most Helpful Member
PIC 18F4550 (USB capable) - Just Assembler, not C conversant myself.

I need to move lot of data into a PIC in batches of 128 bytes for futher processing by the micro. Nothing is returning to the PC.

Right now, data is in .txt files in decimal format but I could change that as needed.

Long time ago, I implemented a board (18F4550) for basic applications using USB. Software was just copy / pasted (no development from my side).

I would like to find ready-made code using the USB protocol for the transfer. I need also the minimum that could be required at the PC side to handle the transfer to the PIC.

Does anyone know what I could use? The focus of my interest is on what goes after the transfer so I look for something albeit simple but running out of the box.

Concrete suggestions appreciated.
 
If you are not too familiar with setting up the USB PIC and don't already have good proven code for that, the best "concrete suggestion" I can give is to buy a $2 USB->TTL converter module from ebay etc and that outputs TTL serial you can connect directly to any PIC USART.

You just plug that in and the PIC USART will receive 128 bytes. :)
 
If you are not too familiar with setting up the USB PIC and don't already have good proven code for that, the best "concrete suggestion" I can give is to buy a $2 USB->TTL converter module from ebay etc and that outputs TTL serial you can connect directly to any PIC USART.

You just plug that in and the PIC USART will receive 128 bytes. :)

Gracias for replying.

No, I do not have good proven code. I was considering to use the USB Bit Whacker but still do not know how to send my bytes to it. I know no languages that I could use to send them from a .txt files anyway but even then I would not know were to send them to... :(

Regarding USB converters, and sorry for the so basic question: is (USB to TTL) converter the same as (USB to RS232) one?

I tend to think it is and I've read a lot but I am still in doubt.
 
Just as a suggestion, in Hyperterminal there is the 'Transfer' option, under which is 'Send text file'.

Used that in the past with a 16F877. Worked OK. Thanks.
 
...
Regarding USB converters, and sorry for the so basic question: is (USB to TTL) converter the same as (USB to RS232) one?
...

Not really. Some ebay sellers will use both terms to describe their module, but there are two different hardware types;

1. USB to RS232. The serial voltage levels are RS232 style and have two values; -10v and +10v. No data is -10v. It is meant to connect a PC USB port to a PC serial (mouse) port.

2. USB to TTL. The serial levels are logic level, either 0v or 5v. No data is +5v, which is standard for USART use. It is meant to interface a PC USB port to any logic level serial device like a microcontroller USART.
 
2. USB to TTL. The serial levels are logic level, either 0v or 5v. No data is +5v, which is standard for USART use. It is meant to interface a PC USB port to any logic level serial device like a microcontroller USART.

Have you tried these? Do they require drivers?

I used Microchip MCP2200 and it worked fine, but it requires a driver, which is unsigned, and also registers an unnecessary second HID device for control.

I biught a similar device for Ethernet on eBay, but haven't trided it yet.
 
Not really. Some ebay sellers will use both terms to describe their module, but there are two different hardware types;

1. USB to RS232. The serial voltage levels are RS232 style and have two values; -10v and +10v. No data is -10v. It is meant to connect a PC USB port to a PC serial (mouse) port.

2. USB to TTL. The serial levels are logic level, either 0v or 5v. No data is +5v, which is standard for USART use. It is meant to interface a PC USB port to any logic level serial device like a microcontroller USART.

OK. It is clear now.

Tomorrow I am going to buy one on the counter armed with my fresh knowledge. :)

Learnt that I have to look for those built with Silab or FTDI chips (and in my case 5V outputs).

Gracias again RB!
 
Have you tried these? Do they require drivers?
...

Yes I have tried a few types. :)

There are 3 common chips they use, and WinXP and later should auto detect these USB devices and install drivers if the driver is not already on your PC (which it likely is).

They are extremely easy to use, basically the module just appears as another "COM" port on your PC.
 
There are 3 common chips they use, and WinXP and later should auto detect these USB devices and install drivers if the driver is not already on your PC (which it likely is).

They are extremely easy to use, basically the module just appears as another "COM" port on your PC.

That is great. Can you tell what the chips are? It may be easier to use chips directly rather than modules. The module probably doesn't do much except providing USB connector to the chip.
 
That one is a bit more expensive as it duplicates the other old-style "serial terminal" signals like DTR etc.

For most serial apps you don't need those signals, only two wires (serial data in and serial data out).

Here's a cheaper type with a different chip;
**broken link removed**

Or another one for $1.44(!);
**broken link removed**

**broken link removed**
 
Can you tell what the chips are? It may be easier to use chips directly rather than modules. The module probably doesn't do much except providing USB connector to the chip.

With zero experience, as you could know, on all this, but having read the datasheet for the CP2102 (SiLab): the chip has to be programmed for it to do what those boards offer.

There are some five or six application notes explaining all. One more recent (AN721, IIRC) embraces what was in two old ones. I am not sure if it is easy / simple to do. But maybe you know how to.

BTW, yesterday I went and bought mine, exactly as shown by RB (CP2102 Silab chip).

Comments:

I paid about U$D 20. What you read. But this is a special country with a President comparing our economy to Canada & Australia!! :confused: Go figure. But there is more: a daring vice minister did the same today but with the European Comunity. Feel yourself at ease, man...!

There is A REASON to publish converters as "USB TTL USART RS232". The one they showed to me had two options: DB9 connector at one end after a 232 voltages converter and a dual-line of pins connector where you can take the TTL isgnals immediately after the FTDI chip. But that was a bargain at around U$D 30. Such is life here.

The lady at the counter had no idea and I had to wait for the guy "who knows". He barely could answer anything but I knew what to look for thanks to the forum and Google.
 
With zero experience, as you could know, on all this, but having read the datasheet for the CP2102 (SiLab): the chip has to be programmed for it to do what those boards offer.
...

The $2 ones on ebay come ready to use, the default programming of the chip allows a standard USB TX and RX operation.

Reprogramming the CP2102 chip is only needed if you have some speacial purpose in mind (ie some very high non-standard baud rate). At standard PC comms baudrates the $2 devices from ebay are fully ready to use, plug-n-play. :)
 
That one is a bit more expensive as it duplicates the other old-style "serial terminal" signals like DTR etc.

For most serial apps you don't need those signals, only two wires (serial data in and serial data out).

Here's a cheaper type with a different chip;
**broken link removed**

Or another one for $1.44(!);
**broken link removed**

**broken link removed**

I'd just like to say - that looks really cool :D

I've got this terrible urge to order one, even though I don't want one!.
 
The $2 ones on ebay come ready to use, the default programming of the chip allows a standard USB TX and RX operation.

Reprogramming the CP2102 chip is only needed if you have some speacial purpose in mind (ie some very high non-standard baud rate). At standard PC comms baudrates the $2 devices from ebay are fully ready to use, plug-n-play. :)

Yes. I failed to read "customization". :(
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top