Computer Interface (USB)

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wanted to interface my AVR to my computer(an Apple) with a USB. I was going to try and use USBMOD3 module. If anyone has any websites or tutorials on USB programming(for Mac OS), USB protocol, the USBMOD3(besides the datasheet) and USB modules in general, and RS232/RS422/RS485 serial communication for the AVR?

My question might be kind of confusing so please ask to clarify the parts that are.

Thanks in advance.

Life Is Like A Bucket Of Chicken.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My first question would have been that do you want to have direct USB connection to AVR with USB hardware so you can do whatever you wish like be a USB mass storage device or USB sound card device, or is it okay if the PC sees the connection as an USB serial port only.

USBMOD3 has FT232BM chip, it is a USB serial port. Plug it it, PC sees a serial port, AVR connects to the module via logic level USART.

Most (but not all) USB-RS232 converters have FT232BM plus the required RS232 level translator, so if USBMOD3 costs $50, you can have the exact same functionality with less than $10 cable, you only need to have a regular 9-pin RS232 port (with level translator) on AVR side to connect to. So the difference basically is that you just have two level translators like MAX232 between AVR and FT232BM, one on your AVR side and one inside the USB-serial adapter.

You can also buy FT232BM chips and connect it directly to AVR serial port, and have USB connector sticking out on the board.

The level translators might slow you down, so maximum speed would be in the order of 120 or 250kbps, but the FT232 chip itself goes up to 500kbps 1Mbps or so.

If even more speed is required, there is FT245 which has an 8-bit bus + 4 handshake lines, and can transfer even more. It still looks like a USB serial port like FT232.

I have not used AVRs with built-in USB connectivity, but you can make them look like anything you want, so they are not limited to be USB serial ports only.

Edit: so basically, you don't need to know anything about USB protocol or USB programming if you use those FTDI chips. You only need to know about serial port programming on the PC (and AVR if FT232 is used). If you want USB AVR, then you need to know USB protocol, USB programming, making drivers, whatever, plus handling it all on the AVR side.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the money saving tip.

Do you have any information on port programming with ANSI C on Apple computer?

Life Is Like A Bucket Of Chicken.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Macs have a FreeBSD based kernel called Darwin - I used man pages to build my serial port routines on FreeBSD.

If I recall, it was simpler than in Windows using Win32 calls.

So either man pages or google for "posix serial port". I think Linux differs a bit from FreeBSD, but I guess so does Darwin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

FTDI has "virtual com port" drivers for their USB devices. Versions for Win, Mac, etc. Once installed, you can open them as a basic com port.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
FTDI has "virtual com port" drivers for their USB devices. Versions for Win, Mac, etc. Once installed, you can open them as a basic com port.

Jim

Thanks for clarifying - the USB serial ports will look like any other normal serial port and can be used like any other normal serial port.

Still it does not remove the fact that user must learn how to open and use serial ports.

In windows, you open it like a file and use special serial port calls provided by Win32 API on the file handle to setup things, and use write and read functions. There may be ready made wrappers or DLLs or components in C# or other programming languages to make things easy for you. Free Pascal and Lazarus have Delphi compatible serial port component available.

In Linux and BSD variants, you open it like a file and use special serial port IOCTL calls to setup things and use write and read functions. Again, there may be wrappers to simplify things, like Gambas programming language has a component for serial port.