English 中文(简体)
Interfacing PIC Microcontroller with Java on PC using USB
原标题:

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?

最佳回答

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.

问题回答

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.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签