Android Question PIC18F4550 + USB

rayellam

Member
Licensed User
Longtime User
Hi All,
Im just starting on a project that requires a few parameters to be sent to a PIC18F4550 via USB from an Android running V4.1. There are 2 ways to do this.
1. Use a USB to serial converter and connect to the UART of the PIC.
2. Use a direct USB interface between PIC and Droid.

I have interfaced with a PC usingVB in the past using method 2 and all is well, no rocket science involved. But this time i want to use a Droid.

My question is has anyone got any pointers to either approach?

Regards
Ray
 

barx

Well-Known Member
Licensed User
Longtime User
Never done it but I assume it will involve the USB library ;)
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
I use bluetooth for talking to my hardware projects, including PIC and Atmel.
In this case I use the HC06.
The interface is straightforward.. the module has 4 pins.. 2 for power (vcc and gnd) and the other
two are for Rx and Tx. the output is RS485 TTL level.
Price is about $6 and you only need one module for the mController.
 

Attachments

  • btmodule.jpg
    btmodule.jpg
    12.3 KB · Views: 291
Last edited:
Upvote 0

Jaames

Active Member
Licensed User
Longtime User
Hi All,
Im just starting on a project that requires a few parameters to be sent to a PIC18F4550 via USB from an Android running V4.1. There are 2 ways to do this.
1. Use a USB to serial converter and connect to the UART of the PIC.
2. Use a direct USB interface between PIC and Droid.

I have interfaced with a PC usingVB in the past using method 2 and all is well, no rocket science involved. But this time i want to use a Droid.

My question is has anyone got any pointers to either approach?

Regards
Ray
I'm waiting for my PIC to arrive, I've done it in the past with arduino, and tried it in many combinations, btooth, usb, serial , with b4j and b4a apps and everything worked extremely well. All my old projects are made with PIC's 16F88, 16628 mostly, when I needed communication with android, I used arduino. This will be my first time to use PIC with usb . I'll post my findings here.
Good luck :)
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
when I needed communication with android, I used arduino.

Hi Jaamse,
Would you elaborate a little on this.. I never used arduino and I don't think will use it or even will need to use it.
The question: if you already have a microcontroller, why would you use arduino? why don't you communicate directly with your MCU PCB?
I do talk from my Android phone to my controllers easily using the serial lib.
 
Upvote 0

Jaames

Active Member
Licensed User
Longtime User
Hi Jaamse,
Would you elaborate a little on this.. I never used arduino and I don't think will use it or even will need to use it.
The question: if you already have a microcontroller, why would you use arduino? why don't you communicate directly with your MCU PCB?
I do talk from my Android phone to my controllers easily using the serial lib.
Because I had only 16f88 , 84 and 628 in the stock. I don't know the easy way of serial communication with them. Am I wrong?
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
If it has URAT chip like MAX232 or MAX485 then yes, you can easily communicate with it. you can use the Modbus protocol, or even many
serial ports in mControllers don't need any kind of protocol.. you only need to cross the Rx and Tx before connecting them. Another thing
you need to know (if you didn't design the PCB, you need to know the board address.. it is either selected by jump or IC switches or by sending
configuration commands.. either way it shouldn't be difficult. The MCU, whether AVR or PIC doesn't matter at all because your talking to the URAT
and that is standard communications .. you need to be carful though about the signal levels and power supply.
 
Upvote 0

Jaames

Active Member
Licensed User
Longtime User
Yes, I know that, I'm doing all my pcb's by hand, it's always 1 layer board (I don't need more layers, board size does not matter. See the image below).
I know about USART, but I need max232, which is expensive, and it is more work to do. So I'm going to do something with PIC18F2550 (28 pin device, like Atmega328 in arduino uno) which has USB 2.0 built in, no need for any extra components, except for few passive one's. And it will be easy to built and to communicate with a board.
 

Attachments

  • pcb.jpg
    pcb.jpg
    159.7 KB · Views: 323
Last edited:
Upvote 0

Beja

Expert
Licensed User
Longtime User
I don't know why you say the MAX232 is expensive.. this one gives you 3 channels and it is less then two dollars. ($1.49) and you will have 3 independent hardware channels.
It is DIP because you are working by hand, it also comes in SMT.
http://www.ebay.com/itm/like/250840119232?lpid=82

It is a small chip and will not add any space to your board that you displayed.. the connections are simple from your MCU to the MAX232, regardless of the MCU type (PIC, AVR... etc)
 
Last edited:
Upvote 0

Jaames

Active Member
Licensed User
Longtime User
I see now... It was expensive in my local shop, and that stuck in my mind, but now I can buy it on ebay and is indeed cheep as it can be...
Did you tried UART with pic mcu and btooth module?
Thanks for clearing this up for me :)
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Did you tried UART with pic mcu and btooth module?
If you want to use software UART then you don't even need the MAX232 chip, you will need to write the protocol though.. but if you
used the chip then it has everything built-in, you only need to do the proper connections and then use the MCU's instruction set
to send and receive data, transparent to the RS 232 protocol.
Bluetooth module is all about hardware connections.. but of course in the Android device side you need to modify the Bluetooth example
to fit your needs.
Sorry I can't help with specific solutions, because this will involve writing C code for the MCU and it is beyond the limits of this forum.
 
Upvote 0

Jaames

Active Member
Licensed User
Longtime User
Sorry I can't help with specific solutions, because this will involve writing C code for the MCU and it is beyond the limits of this forum.

Ok. I agree.

I think it will not be that hard, since I work with PICs on the daily basis.
I'll try max232 in the future, now I have to wait 18F2550 to arrive and to play with usb :)
 
Upvote 0

rbghongade

Active Member
Licensed User
Longtime User
For using usb port of 18f4550, you need to write a device driver which will be recognized by the host (android device in your case) as a part of firmware.
 
Upvote 0
Top