Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic18f2550 based usb project

Status
Not open for further replies.

Noman Yousaf

Full Member level 4
Joined
Nov 19, 2003
Messages
210
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,774
hi all
i want to use pic18f182550 for USB communication.
Actually i want to generate my own data stream.
I have a joy pad which is USB. first i want to analyse the data, comes from joy pad by pressing several buttons on it then i want to generate same data stream by PIC18F2550.
for analyzing, i have USB monitor. I want to know that how i can generate the data? Can someone give me any C or Assembly code examples?
thanks in advance.
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,332
Helped
387
Reputation
774
Reaction score
396
Trophy points
83
Activity points
14,400
The issue you will face is that the SIE in the PIC18F family of devices can be used as the 'device' end of the USB connection only.
From what you have said, I understand that you want the PIC to be the USB host to the joy pad - if so then you will need to use some other USB host chip that then communicates (UART, SPI, Parallel, I2C, whatever) with the PIC.
Once you have that data the you can easily use the PIC's SIE to communicate back to to som other host.
Susan
 

Noman Yousaf

Full Member level 4
Joined
Nov 19, 2003
Messages
210
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,774
well i want to know if i use PIC18F2550 and attach with barcode scanner via USB and link its UART to computer via RS232 port, can i get the value from scanner to hyper terminal?
If yes, then how can i do it?
any hint to write code in C or even in assembly?

- - - Updated - - -

Can i use USB to serial converter (FT232BM based) for this pupose? if yes then how. I just want to get USB based barecode scanner's data to 16X2 dotmatrix LCD via PIC or any other common MCU. USB2rs232_converter.jpg
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,069
It sounds as though you wish the PIC18 to act as a USB host to the barcode reader
this is not possible the PIC18 can only act as a device
consider using a PIC24
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,332
Helped
387
Reputation
774
Reaction score
396
Trophy points
83
Activity points
14,400
A couple of things:
1) you have not been told twice that the PIC18f series cannot be used as a USB host, only as a USB device
2) the FT232 devices are used as the USB device as well as they typically connect to the USB host (often a PC) and output either RS232 or TTL level voltages to a UART
3) if you want to use the USB SIE on any PIC device, then you need to get the Microchip USB library code for the device family. It is one of the few cases where you really don't want to try to write your own code to interact with the peripheral. You can then write your own C code (or assembler if you REALLY feel the need) to make the USB library calls.
To do what you want, you might find some other USB chip that will act as a host to the barcode scanner, but you probably want to look at the PIC24 series for an MCU with host capabilities. You will also need to do some research into the USB protocol that the bar code scanner uses and then set up the PIC24 USB library accordingly and write your app over the top of that.
Susan
 

Noman Yousaf

Full Member level 4
Joined
Nov 19, 2003
Messages
210
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,774
thanks all to guide me.
need more guideline.
can i use arduino usb host shield for my purpose?
if yes then can i use shield directly to AVR ATMEGA8 or should use arduino it self with?
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,332
Helped
387
Reputation
774
Reaction score
396
Trophy points
83
Activity points
14,400
I can't really answer those questions as I have no experience with the AVR Atmega8 and you don't tell us which Arduino model or shield you are talking about - they can all be very different.
However you will need a USB connection with 'host' capability (often these come with OTG capability but you only need the host part). Whether that is in the device itself or if you need a shield then that requires reading the various data sheets.
You will also need the USB software library code that comes with the USB interface.
Then you will need to understand the protocol used by the barcode scanner and be able to set that up in the USB library (probably CDC or HID) and also write the code that the barcode scanner is expecting to tell it to read and/or accept the information in the correct format from the barcode scanner when it does a scan.
The LCD display part should not be a problem for the arduino as I think there are a number of shields that can be used or you can connect a display up to the I/O ports of the base device. Again you will probably need library code to drive the display.
(By the way, I note that you started this thread talking about a joy pad with several buttons but then switched to a barcode scanner. It really helps to ask questions that relat to your actual probelm.)
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top