MX015 - Basic USB Communications for PIC

Forum to discuss articles which have been published in Matrix Multimedia's article zone. If you have any comments or questions regarding the articles please post them here.

Moderators: Benj, Mods

Please rate this article out of 5: (1 being the worst and 5 being the best)

1
0
No votes
2
0
No votes
3
0
No votes
4
0
No votes
5
1
100%
 
Total votes: 1

User avatar
Benj
Matrix Staff
Posts: 14566
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4596 times
Been thanked: 4239 times
Contact:

MX015 - Basic USB Communications for PIC

Postby Benj » Wed Feb 25, 2009 1:23 pm

Article: http://www.matrixmultimedia.com/resourc ... php?id=379

If you have any questions for the author or comments on the article, please post them below.
These users thanked the author Benj for the post:
jose (Mon Sep 12, 2011 12:14 am)
Rating: 5.26%
 

randomrichard
Posts: 41
Joined: Thu Oct 16, 2008 11:01 am
Has thanked: 21 times
Been thanked: 7 times
Contact:

Re: USB Comms using EB006 / HP488 Programmer Boards

Postby randomrichard » Fri Mar 11, 2011 11:46 pm

Hello
Thanks for the tips on configuring the 18F4550. I now have no problem with sending or receiving bytes using its USB serial port. However, I can't get past a difficulty with your 'USB serial string demo.fcf' example. In the Flowcode4 example I downloaded the "Read String from USB" macro properties has '100,test, 64' in the Parameters box and 'x' in the Return value: (STRING) box. Now that's three parameters and a byte value so if I press OK F4 says there is an error, not surprisingly. I tried replacing those entries with '100, 64', and 'test', but that didn't work either although it compiled OK. Help , please.

User avatar
Benj
Matrix Staff
Posts: 14566
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4596 times
Been thanked: 4239 times
Contact:

Re: USB Comms using EB006 / HP488 Programmer Boards

Postby Benj » Mon Mar 14, 2011 1:52 pm

Hello,

I have looked at the example and fixed it so it will work correctly with the current version of the component.
Attachments
USB Serial String Demo.fcf
(8.5 KiB) Downloaded 757 times
These users thanked the author Benj for the post:
randomrichard (Mon Mar 14, 2011 3:43 pm)
Rating: 5.26%
 

randomrichard
Posts: 41
Joined: Thu Oct 16, 2008 11:01 am
Has thanked: 21 times
Been thanked: 7 times
Contact:

Re: USB Comms using EB006 / HP488 Programmer Boards

Postby randomrichard » Mon Mar 14, 2011 3:44 pm

Ben
Thanks for your help. It works fine now and I should be able to work out why. Now for the two-way comms...

Richard

jose
Flowcode V4 User
Posts: 26
Joined: Sat Nov 01, 2008 12:11 am
Has thanked: 7 times
Been thanked: 10 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby jose » Thu Aug 25, 2011 1:21 am

Hello Ben,
Do you have any example for a PC USB keybord?
Or can you give some tips how to..?
Thanks

User avatar
Benj
Matrix Staff
Posts: 14566
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4596 times
Been thanked: 4239 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby Benj » Thu Aug 25, 2011 10:09 am

Hi Jose,

Have you seen this topic?

viewtopic.php?f=29&t=8724&p=26392

jose
Flowcode V4 User
Posts: 26
Joined: Sat Nov 01, 2008 12:11 am
Has thanked: 7 times
Been thanked: 10 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby jose » Fri Aug 26, 2011 12:24 am

Hello Ben,
I see now, thanks.
I'm having trouble communicating with the pc: detects but does not recognize the USB device (?)
I could not find the article "communicating with the PC" referred to in MX015.pdf, to have some help about hyper terminal and USB

jose
Flowcode V4 User
Posts: 26
Joined: Sat Nov 01, 2008 12:11 am
Has thanked: 7 times
Been thanked: 10 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby jose » Fri Aug 26, 2011 9:41 am

Ben,
Will it be possible for you to give a small exemple of reading a key from a PC USB keyboard into a variable?
It will be a great help
Thanks

User avatar
Benj
Matrix Staff
Posts: 14566
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4596 times
Been thanked: 4239 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby Benj » Fri Aug 26, 2011 9:58 am

Hello Jose,

Does the device appear in the device manager as an unknown device or does it go into the HID section as a HID device?

If your getting the unknown device problem then its likely that either your configuration or clock speed is off. Could you post up your program and I will have a look for you.

Regarding reading a key from the keyboard into a variable, would this be on the PC? You mention hyperterminal, do you instead want a serial keyboard rather then a HID keyboard?

Communicating with a PC article is available here.
viewtopic.php?f=26&t=4793

jose
Flowcode V4 User
Posts: 26
Joined: Sat Nov 01, 2008 12:11 am
Has thanked: 7 times
Been thanked: 10 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby jose » Wed Aug 31, 2011 1:19 pm

Hello Ben,
I was using a 4 MHz crystal, then i change it to 24MHz and it is working (some times not)
the file i'm using is your Ex2.keyboard. i will try others configuration speeds.

The example I need is to connect a real USB keyboard to the chip and read hex or decimal key value to a variable and then display it on a LCD or something else

Thanks
jose

User avatar
Benj
Matrix Staff
Posts: 14566
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4596 times
Been thanked: 4239 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby Benj » Thu Sep 01, 2011 3:04 pm

Hello Jose,

Im afraid connecting a USB device such as a keyboard to a chip is not possible as USB host hardware is required. Devices supporting the USBotg peripheral should allow this but the Flowcode components do not currently support USBotg so you may have to refer to one of the Microchip examples. I have a Flowcode example program for reading a PS2 style keyboard if this is any good to you.

jose
Flowcode V4 User
Posts: 26
Joined: Sat Nov 01, 2008 12:11 am
Has thanked: 7 times
Been thanked: 10 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby jose » Thu Sep 01, 2011 4:25 pm

Hi Ben,
Ok i will try with Microchip examples.
I guess you mean PS2_key and PS2_key2 files, i have those but they gives this error:
" Error: Unresolved external function:'sendByte(unsigned char)". The strange thing is that i remove all references to "sendByte and error remains.
If you solved this or have any other file, yes please..
Thank you

User avatar
Benj
Matrix Staff
Posts: 14566
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4596 times
Been thanked: 4239 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby Benj » Thu Sep 01, 2011 4:35 pm

Hello,

Here are the most recent source files I have for the PS2 keyboard. The C file has to be in the same directory as the Flowcode project file to work correctly.
Attachments
PS2_Keyboard.c
(5.54 KiB) Downloaded 577 times
PS2_Key2.fcf
(5.5 KiB) Downloaded 605 times

User avatar
Benj
Matrix Staff
Posts: 14566
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4596 times
Been thanked: 4239 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby Benj » Thu Sep 01, 2011 4:39 pm

Just had a quick compile and gotten the same sendByte error message. I will have a look through and see if I can dig out this function.

jose
Flowcode V4 User
Posts: 26
Joined: Sat Nov 01, 2008 12:11 am
Has thanked: 7 times
Been thanked: 10 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby jose » Mon Sep 05, 2011 7:43 pm

Hi Ben,
I finished this litlle ps2 keyboard program
viewtopic.php?f=26&t=8870

Regards
jose

User avatar
Benj
Matrix Staff
Posts: 14566
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4596 times
Been thanked: 4239 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Postby Benj » Tue Sep 06, 2011 9:59 am

Hi Jose,

Looks great many thanks for sharing :D