What does it take to use a usb?

  • Thread starter GiTS
  • Start date
  • Tags
    Usb
In summary, the conversation discusses the feasibility of using a microcontroller like PIC to record audio onto a USB memory stick or SD memory chip. The speaker mentions using MicroChip 18Fxxx PICs as USB slaves with sample code available, but needing a USB host to communicate with memory sticks. They also mention the complexity of USB communication and suggest using a USB-to-UART interface chip instead. The possibility of using SD cards for storage is also discussed.
  • #1
GiTS
135
0
Is it possible for a microcontroller like PIC to use a USB memory stick?

I wanted to make a small microphone that will record onto USB memory stick or those SD memory chips that go into cameras.

I know nothing of how flash memory works on a technical level but I imagine you have to send commands like start/stop recording.

Please enlighten me as I cannot find information.

Thank you,

-GITS
 
Computer science news on Phys.org
  • #2
I've used MicroChip 18Fxxx PICs as USB slaves, but you need a USB host to talk to memory sticks and most everything else. Microchip has sample code for the slave operation, which for me was nearly impenetrable until I found a bit of a working example -- I think at Sparkfun. I've not looked into sample host code, but they may have that as well...best to rummage around their support site.
 
  • #3
Thank you for the information. Wow, a host controller is big. I don't get why there has to be so much to it. It's got 5 pins and some combination of signals has to be able to tell it to write. I'll have to do more research and post it. Maybe someone else is interested in this and would like to share. I mean small cameras write on SD so there has to be a way to make the host smaller.
 
  • #4
Memory cards like the SD don't usually have native USB interfaces. I think they are more of a bus-like thing, but I haven't worked with them. I also should look into the USB host thing -- as you say, how can it be so hard? Well...Every step forward in technology is accompanied by a backward step in convenience...almost anything I can think of doing would work fine with a bi-directional parallel printer port.
 
  • #5
Then you have to handle the file system
The easiest way I found was to use fat and a 32Mb limit, format a card in a PC and create a single file with a fixed name. Then just dump the filesystem header bytes. You can write this fixed header structure from your microcontroller rather than implement a full filesystem
 
  • #6
I'm more familiar with Atmel's ARV microcontrollers, so here's my proposal to make an audio-recording device:

If you want removable storage, pick up an SD card breakout board. SD is a little easire to connect to an MCU since it doesn't need any drivers or ontrollers, just a handful of pull-up resistors. Connect it to an AVR MCU (i.e. Atmega8) via the SPI interface (MOSI-MISO-SCK-SS'). Connect an analog microphone to one the the ADC pins on the MCU. You will have uncompressed audio at your ADC pin.

However, that uncompressed audio will be nothing but a pile of zeros and ones; you will have to decide what you want to do with them.
 
  • #7
schip666! said:
-- as you say, how can it be so hard?

I like to use the PIC32's, many of which have USB support. Each time I look at using USB communication I always end up just going with a FTDI chip. I tried learning all about USB once and found that its extremely complicated, even with a bunch of sample code. In the end I decided it was better to spend the $3 on a USB->UART interface chip and just be done with it.

Writing data to a SD card is much easier than writing to a USB drive. There's a ton of sample code out there for this for just about all the latest PIC micros. It only requires basic SPI communication as mentioned above.
 
  • #8
I haven't played with this myself, but here's a relevant article:
http://electronicdesign.com/article/digital/interfacing-a-usb-flash-drive-to-a-pic-microcontro.aspx
 
Last edited by a moderator:

1. What is a USB and how does it work?

A USB (Universal Serial Bus) is a type of technology used for connecting devices, such as computers and smartphones, to transfer data or charge the device. It works by sending data through four wires within the cable: two for power and two for data transmission.

2. Do all devices have USB ports?

No, not all devices have USB ports. Older devices, such as some printers and cameras, may use different types of ports for data transfer. However, most modern devices, including computers, laptops, and smartphones, will have at least one USB port.

3. Can I use any USB cable to connect my devices?

No, not all USB cables are created equal. Make sure to check the type of USB port on your device and use a cable with a matching connector. Some devices may also require specific types of USB cables, such as USB 3.0 or USB-C, for faster data transfer speeds.

4. Are there any precautions I should take when using a USB?

Yes, there are a few precautions you should take when using a USB. Avoid using damaged or frayed cables as they may cause data loss or damage your device. You should also be cautious when plugging in a USB from an unknown source, as it may contain viruses or malware that can harm your device.

5. How do I safely remove a USB from my device?

To safely remove a USB, you should first close any open files or programs that are using the USB. Then, locate the "safely remove hardware" icon on your computer's taskbar or menu bar and click on it. Select the USB device you want to remove and wait for the notification that it is safe to remove. Once you see the notification, you can safely unplug the USB from your device.

Similar threads

Replies
14
Views
2K
Replies
7
Views
2K
  • Computing and Technology
Replies
5
Views
2K
Replies
1
Views
1K
Replies
19
Views
2K
  • Computing and Technology
Replies
15
Views
4K
Replies
9
Views
1K
  • Electrical Engineering
Replies
14
Views
3K
  • Electrical Engineering
Replies
18
Views
3K
Replies
4
Views
2K
Back
Top