views:

1014

answers:

3

HI! I want to interface PIC18F4550 with Java program and make it cross-platform initially. There are only one way I now Java has is javacomm. But i want it to be USB because not every laptop has RS232 port nowadays. Waht are the ways of interfacing PIC with Java you can suggest to make it really cross-platform and avoid writing driver for every new OS?

+2  A: 

First the disclaimer: I have not done this with a PIC and Java, only with an AVR32B with VB on the pc.

If you implement a USB CDC class device on the microcontroller USB interface and connect it to your pc USB HOST it will enumerate and appear as a new COM: port. This is then treated by the application as a normal serial port. I used the standard windows driver USBSER.SYS.

I presume that microchip provide example source code for their USB peripheral to allow it to operate in different device classes. (I know that Atmel do for the AVR32 families)

Ian
+1 good answer - you should always look to interface as high up the software stack as you can, rather than trying to explicitly work at the USB level.
Paul R
+1  A: 

Arduino's approach should be adaptable to your needs: a microcontroller with hardware UART coupled with a FTDI USB-to-TTL chip, then use rxtx to access the resulting serial port on "100+" platforms.

This approach seem to work well: communicating and programming the arduino is very easy under Linux, Windows, and OS X.

freespace
This would be a bit of a waste of money/board real estate as the PIC used here has its own built-in USB 2.0 controller.
Ian
Very-very interesting project! Never heard about it!
Dmytro Leonenko
@Ian: agreed. Though I feel I should point out I described arduino's approach as an example of such a setup, not as a formulae for @melco-man to follow. A combination of your answer with mine would yield an optimal answer.
freespace
I agree with @Ian and @freespace, this is *not* the way to do it, this time with that processor.
kenny
+1  A: 

Why did you accept the answer above? I agree with @Ian's comment there.

The PIC18F4550 and its friends have onboard USB. It is easy and there are plenty of examples out there to put a virtual serial port in the PIC firmware. Another other is an HID device, again plenty of PIC firmware examples.

Don't add more hardware to the pudding.

kenny