PDA

View Full Version : USB confused (running out of hair)



cncmachineguy
- 22nd May 2011, 14:48
I am running out of hair to pull out. I think USB must be the most desired/least explained thing in the embedded world!!!

Ok, thats off my chest now. I have spent a good part of yesterday and today trying to figure out how to do anything. Now I have some questions maybe someone knows the answers to. The idea started like this: let me whip up a GUI in liberty basic to gather info from a PIC. I have been wanting to do this for some years now.

So I figure out there is no direct way to do this in LB. But I CAN talk to a DLL I think. So then I take a look at RealBasic. Very cool program it seems, but again no direct way. Most searches end up at BUY this plugin from monkeybread and all will be good. But then as I am chasing down how plugins work for RB, and why do we need them, I figure out a plugin is just a convienet way to gain access to DLL's.

So then I start thinking, do any of the USB solutions provided over at PBP have DLL's? for instance if using HID, is there a DLL associated with that? Or are the DLL's part of Winblows? Then I run across CDC. Yet another animal I think. What I think I understand is this makes the USB connection appear as a com port to the PC app. So I start to try and verify this, and of course I am chasing down yet another 1000 links/threads/posts, all claiming to be the answer, but to what question?

The most definative thing I have found is using CDC I can talk to hyperterminal.

So finally for the question (thanks for reading this far). If I want to develop an APP, using Liberty Basic, Real basic, Python, or whatever, what is the app trying to talk to? I get that the HID builder thing creates VB files, but I don't want to use VB.

Also, what do I want, CDC,HID, how to choose? Most all of the things I want to do are data transfer back and forth. Does any of this make sense??

dhouston
- 22nd May 2011, 15:23
While there are some PICs that have a USB stack, You'll lose any remaining hair trying to figure out how to implement pure USB on both ends of the connection.

Save your hair and do it the easy way. FTDI, Silicon Labs and Prolific (others??) make USB-serial chips that send receive via USB and convert it to serial (a la RS232) on the embedded end. All provide free drivers for Windows, Linux and OSX that appear as Virtual Serial Ports on the PC end so all you have to do is write code (on both ends) to handle serial comms.



http://www.ftdichip.com/
http://www.silabs.com/Pages/default.aspx
http://www.prolific.com.tw/eng/Products.asp?ID=59

If you are not designing your own board, there are inexpensive, external adapters that do the same thing.



http://www.byterunner.com/byterunner/category=USB+to+Single+Serial+Adapters/exact_match=exact


As for VB/HID

If you really insist on pure USB, there have been threads here on that. Jan Axelson's web site is also quite helpful. There are methods for interfacing under Windows but you are pretty much on your own for Linux and OSX.



http://lvr.com/


http://ssimplyhair.com/toupee.aspx



As for PC programming, look at PureBasic. It's cross platform and both far more powerrful and far less complicated than any you mentioned. However, it does not do pure USB.


http://www.purebasic.com/

cncmachineguy
- 22nd May 2011, 16:38
Thanks Dave. Yes the FTDI route is by far the easiest. In fact I even have some chips for that. But sometimes, giving up board space for a chip seems crazy, if nut just impractical.

Now if CDC is the equalvalient to usb->serial, but done in the PC, well that gets closer, even close enough for me.

Oh, and thanks for the toupee link, I may need it soon :)

My analogy to FTDI:

120Vac->12Vdc output battery charger->12Vdc battery->inverter (120Vac output)->PC powersupply->12Vdc output for MOBO.

To build a UPS, would it not be easiest to go from battery to MOBO?

dhouston
- 22nd May 2011, 17:15
Now if CDC is the equalvalient to usb->serial, but done in the PC, well that gets closer, even close enough for me.Well, according to AN1164 (http://ww1.microchip.com/downloads/en/AppNotes/01164a.pdf) you can do that but a quick scan of the first few pages convinces me that USB-serial chips (onboard or external) are still the best choice, by far.

mister_e
- 22nd May 2011, 19:27
If you really insist on pure USB, there have been threads here on that. Jan Axelson's web site is also quite helpful. There are methods for interfacing under Windows but you are pretty much on your own for Linux and OSX.



http://lvr.com/



http://ssimplyhair.com/toupee.aspx


The second one is a real must :D

AAwwww come on guy, don't be lazy, leave the FTDI for students.... there's everything you need to do real USB here.

dhouston
- 22nd May 2011, 19:40
AAwwww come on guy, don't be lazy, leave the FTDI for students.... there's everything you need to do real USB here.Au contraire - USB is for the students who need to learn the nitty gritty. I've made it to 70 with all my hair by taking the easy way out.:D

I bought Jan Axelson's USB Complete when she first released it and quickly decided I would avoid real USB forevermore.

I develop for Windows, Linux & OSX and the USB-serial chips (or external adapters) are the only practical way to handle all three.

cncmachineguy
- 22nd May 2011, 20:04
Steve, I agree, sort of. Everything to do USB is here for the PIC side. As for the PC side, maybe everything is here. If one wants to develop in C of VB, I think everything is prolly here. Well, If I want to work in C, "I" prolly wouldn't be here. So if thats needed, then its not all here. And VB? well what flavor?? 6 and .net? Maybe I am just too stubborn, but as a hobby, I have NO plans to buy anything from them guys. Nor am I going to get the exppress version (which may not work).

It seems I need to look further into CDC. but NOT for pic32 as the app note Dave linked would suggest.

If I find the energy to keep persuing this, I will hop back on the CDC for dummies thread and ask zillions of questions there. In the mean time, How does 1 go about accessing the "port"from their app if using CDC? I know it will be app specific, but whats the process? Does it become COMx and just use regular serial commands to use it?

mackrackit
- 22nd May 2011, 20:10
With CDC the PC will think it is talking to a "regular" com port. COMxx

Here is another example that might be of use...
http://www.picbasic.co.uk/forum/content.php?r=272-USB-SD-LOGGING

cncmachineguy
- 22nd May 2011, 21:21
Dave, that is a great example of both USB and sd card reading/writing. So can I assume there is a LB part also?

mackrackit
- 23rd May 2011, 01:57
Nope, no LB or any other custom thing on the PC for this one. In practice for me this is only plugged into a PC when real time trouble shooting a system so a terminal program like the one that comes with MCS is fine.

dhouston
- 24th May 2011, 03:31
.... there's everything you need to do real USB here.How about the modem control signals (DTR, RTS, etc.) with CDC?