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

Post Reply

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

MX015 - Basic USB Communications for PIC

Post by Benj »

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.

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

Post by randomrichard »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: USB Comms using EB006 / HP488 Programmer Boards

Post by Benj »

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 1049 times

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

Post by randomrichard »

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

Post by jose »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Post by Benj »


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

Post by jose »

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

Post by jose »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Post by Benj »

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.
http://www.matrixmultimedia.com/mmforum ... =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

Post by jose »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Post by Benj »

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

Post by jose »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MX015 - Basic USB Communications for PIC

Post by Benj »

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.29 KiB) Downloaded 800 times
PS2_Key2.fcf
(5.5 KiB) Downloaded 829 times

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

Re: MX015 - Basic USB Communications for PIC

Post by Benj »

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

Post by jose »

Hi Ben,
I finished this litlle ps2 keyboard program
http://www.matrixmultimedia.com/mmforum ... =26&t=8870

Regards
jose

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

Re: MX015 - Basic USB Communications for PIC

Post by Benj »

Hi Jose,

Looks great many thanks for sharing :D

Post Reply