PB and microcontroller comms w/USB

Just starting out? Need help? Post your questions and find answers here.
koehler
User
User
Posts: 58
Joined: Sat May 03, 2003 7:46 am

PB and microcontroller comms w/USB

Post by koehler »

Hi All,

I've been away for years, and never did anything with PB in the area I now need.
I need to mock-up some datalogging/comms apps with a remote microcontroller via USB.
A number of folks have used VB as their language of choice, and are so recommending it.
I'm pretty sure PB has a decent capability to do this, but thought I'd post to make sure.

Any comments are appreciated.
User avatar
kenmo
Addict
Addict
Posts: 2032
Joined: Tue Dec 23, 2003 3:54 am

Re: PB and microcontroller comms w/USB

Post by kenmo »

Depends if you want to interact with the microcontroller as a "real" USB peripheral, which will show up as a new device, or if communication over a virtual COM port is suitable for you.

The first is more difficult and I'm not sure if anyone has implemented it in PureBasic...

The second one is surprisingly simple using PB's SerialPort library. I have used this with success twice, once for a school project using a Texas Instruments processor and a FTDI "UART over USB" chip, and again for a home project using a $30 Arduino (I think it also uses a chip by FTDI). Both show up as simple COM ports in Windows after installing a tiny driver.

Depending on your sampling rate, this might be fine for data acquisition. I did notice data loss at rates above maybe 100k baud, but I didn't investigate it much. Not sure if it was fault of the controller, the driver, my PC, or just desynchronization.
morosh
Enthusiast
Enthusiast
Posts: 329
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: PB and microcontroller comms w/USB

Post by morosh »

User_Russian has developped a library for HID
http://www.purebasic.fr/english/viewtop ... ry#p337928

but never tried it (comments in russian)
PureBasic: Surprisingly simple, diabolically powerful
koehler
User
User
Posts: 58
Joined: Sat May 03, 2003 7:46 am

Re: PB and microcontroller comms w/USB

Post by koehler »

Thanks guys, sounds like I am in luck! :D
Post Reply