Page 1 of 1
Sending signals via USB?
Posted: Tue Feb 03, 2009 2:30 pm
by treebolt
I'm in an electronics class and I thought it would be awesome for a class project if I could build a circuit that my computer can interact with via USB cable. I've never done anything like this before. I was wondering if it was at all possible to use Purebasic to change the voltages on the USB pins.
Posted: Tue Feb 03, 2009 6:55 pm
by Mahan
First of all the usb interface is a simple (hi-speed) serial communications bus/interface. You've got vcc (+5v), ground, data in and data out. There is no option for changning voltages on the usb itself. Secondly usb-controllers are abstracted by modern OS'es.
I've heard many people that use the HID-standard to get an easy to talk to device on USB (Hid is short for human interface device and basically you tell the computer that you are a keyboard or mouse kind of thing). Google for HID +USB to know more about it.
If your ultimate goal is to change voltages with usb you should look at wellemans kits. I've seen one kit that implements several low-voltage inputs and outputs and that is controlled by usb + a dll on the pc-side. Using this kit and interfacing PureBasic to the .dll would give you the possibility to change voltages and stuff through PB. and even to make readings from the circuit into your pb program.
edit:spelling.
edit2: Oh and btw electronics tend to be very expensive in the beginning. It like if you do an error or bug you don't get an error message and just need to rewrite stuff. It's more like things going *pooof* and black smoke fills your room, and then you have to go to the store. Guess why I started programming after toying with electronics as a kid

Posted: Tue Feb 03, 2009 8:07 pm
by treebolt
Thanks for the help, Mahan.
I'm actually 2 semesters from finishing my associate electronics degree so there's no turning back now haha.
I understand about the +5V / ground / I / O, If i can just figure out an easy way to change the USB output voltage on the one pin then I can design a circuit to work with that.
I'll look into the tips you gave, thanks again! =)
Posted: Tue Feb 03, 2009 8:58 pm
by aaron
treebolt wrote:I understand about the +5V / ground / I / O, If i can just figure out an easy way to change the USB output voltage on the one pin then I can design a circuit to work with that.
There is no way to 'change the voltage level' on just one pin of the USB. The signals are called D+ and D-... they are a differential serial line. The PC sends a packet of information down this line every 1ms when there is an active device on the other side. It doesn't have direct pin control over the levels.
You can use something like the FTDI FT245 if you just need some generic I/O, or the FT232R if you need serial control.
http://www.ftdichip.com/ Sparkfun (
http://www.sparkfun.com/commerce/produc ... ts_id=7841) has some great breakout boards that will save you time.
Posted: Tue Feb 03, 2009 10:01 pm
by SFSxOI
Pin1=+5VDC, pin2=data-, pin3=data+, pin4=ground
you could use something like the PIC USB-capable microcontroller (maybe the PIC18F4550). Also, theres a page here with some interfacing stuff and some free sample code written in liberty basic (somewhere on the page, a little messy...shouldn't be too hard to convert to PureBasic) >
http://www.schmalzhaus.com/UBW/
the link that aaron posted above is good for stuff too
Posted: Tue Feb 03, 2009 10:20 pm
by utopiomania
http://www.velleman.be/ot/en/product/view/?id=351346
Comes with a dll that takes care of all the important (but uninteresting low level) stuff for you.
Posted: Tue Feb 03, 2009 11:16 pm
by infratec
Hi,
the easiest way is to connect a R/2R ladder to the databits of a parallel-port.
Than you can 'print' your values and you can generate 256 different voltagelevels.
http://en.wikipedia.org/wiki/Resistor_Ladder
The pins of the parallel port are 2 to 9 (bit0 to bit7)
If you need USB, than use a USB to parallel cable.
Bernd
Posted: Wed Feb 04, 2009 3:10 pm
by treebolt
Wow, thanks for all the great tips everyone ^_^
Posted: Tue Feb 10, 2009 8:30 am
by mueckerich
Sorry for the late response, hope this will still help you.
Try the IO-Warrior
http://www.codemercs.com/index.php?id=41&L=1