Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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)

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.

You need to use JNI to make calls to the WIN32API directly. I was using JNA (JNI wrapper) library to make the implementation easy and made a DLL to export easier and direct methods in Visual C++ 2010. You can also create other libraries (DLL/SO) using the same interface to other systems like OSX and Linux.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top