![]() |
| | #1 |
| Registered User Join Date: Jun 2009 Location: Santarem, Portugal
Posts: 9
| I am a newbie C#, VB and PHP programmer and I know also some stuff in C++. I started to play around with hardware last week when i had to fix some stuff in my mouse and i kinda liked it so: I picked a old usb mouse cable and a old motherboard fan, then i stripped the usb cable, conected usb white wire to fan red wire and usb blue wire to black wire and fan is now working (i think the usb has only 5 volts because its a 12volts fan so its working at half of the speed). There are two wires left, orange and green, i presume they are the wires that used to send data from mouse to the computer, here is a pic of the little stuff i made: http://www.techcoders.net/mywk/usb.jpg I want to do a software that first detects if it plugged in (is it possible to send a number through the orange or green wire then it reads it? if its the correct number it means the fan is plugged in), then it will increase or decrease the voltage of the blue or white wires! (It can be C# or C++) Thanks In Advance, Best Regards, Mywk |
| Mywk is offline | |
| | #2 | |
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,783
| I suppose you need to write a driver, then. And if you are doing it for Windows, it has to be C. You can forget C# for anything hardware-related.
__________________ Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System I dedicated my life to helping others. This is only a small sample of what they said: "Thanks Elysia. You're a programming master! How the hell do you know every thing?" Quoted... at least once. Quote:
| |
| Elysia is offline | |
| | #3 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,680
| You'll need something like this USB Experiment Interface Board > Maplin and this Jan Axelson's Lakeview Research Or perhaps even this Arduino - HomePage |
| Salem is offline | |
| | #4 |
| Registered User Join Date: Jun 2009 Location: Santarem, Portugal
Posts: 9
| Hey, @Salem I will actually try to find that here where i live (Portugal), thats seems interesting. @Elysia I can't find any article about building drivers or such, do you have any? Is USB Experiment Interface Board really needed? Can't i just build the USB hardware myself then code the drivers? |
| Mywk is offline | |
| | #5 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,680
| You could, but at the least you would probably need some kind of USB interface chip on your homebuilt kit. Even dumb RS232 typically needed a UART chip to do the grunt work of converting serial bits into useful bytes. USB is much more complicated that that. If you can find a simple kit then use it (and study everything in detail). Inventing the whole thing using TTL logic would be hard work. |
| Salem is offline | |
| | #6 | |
| Registered User Join Date: Jun 2009 Location: Santarem, Portugal
Posts: 9
| Quote:
With the kit will i be able to develop my own driver (with C) so i can use my device without the kit? References, links or ebooks, all information will be greatly apretiated! Thanks once again | |
| Mywk is offline | |
| | #7 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,680
| > With the kit will i be able to develop my own driver (with C) so i can use my device without the kit? It comes with a DLL, so you can write normal user-space programs to drive the board. > I will buy the kit however it arrives in only ~10 days since it comes from UK. Can't you find the same (or similar) from a local supplier? |
| Salem is offline | |
| | #8 | |
| Registered User Join Date: Jun 2009 Location: Santarem, Portugal
Posts: 9
| Unfortunately not in Portugal, not even similar, anyway i emailed Maplin asking for re-sellers near and why does it takes so long to export a item to here. Quote:
My aim is to be able to do my own hardware for computer without having to use stuff that i can't build myself, I'm available to learn no matter how difficult it is. | |
| Mywk is offline | |
| | #9 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| A UART (serial port) has some 3-15 registers depending on the design of the UART. It takes a couple of dozen lines of code to communicate with a serial port. A USB controller has a whole bunch extra registers over a serial port, and the communication is much more complex (although a fair bit of it is implemented in hardware, so the software layer need not concern itself with it). Generally, USB drivers consist of several layers, where there is a USB chipset driver at the bottom, which handles the low level communication with the specific chipset components - sending and receiving packets of data and determining when new devices are plugged in, what type of device it is. THere are various generic driver models at the top [such as a generic keyboard or mouse driver]. In the middle is the device specific driver - it takes for example mouse data and translates it to "standard windows mouse information". There may be more levels in some cases, such as a USB hard-disk would have the USB chipset driver at the bottom, a disk-specific driver next, then the generic disk driver layer, and a layer or two of file-system componets before it gets to the OS generic parts. Edit: And I'm 99.9% sure that you can not regulate the voltage on a USB port. It is 5V unless the device is drawing too much current (which would probably end up with the system shutting the port down to prevent damage to your system). -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. Last edited by matsp; 06-14-2009 at 05:29 PM. |
| matsp is offline | |
| | #10 | |
| Registered User Join Date: Jun 2009 Location: Santarem, Portugal
Posts: 9
| Quote:
I did some more research and you are actually right, i can't regulate the voltage of the USB port, however i can power the fan using external 12v power adapter then regulate the amount of volts the fan will receive with my device. May i just simply develop a chip that when HOST (my computer) sends data to the chip it will change the voltage for one of my options? (example i have velocity 4v,6v,8v and 12v in a self made circuit) I don't have much electronic experience and i like this forum so please don't ask me to ask somewhere else since i want to use C and do my own driver and so on. Something interesting i found while searching, but actually i think it can't help me much (you can find it interesting anyway): Coding4Fun : Controlling Your Festive Lights with the .NET Micro Framework | |
| Mywk is offline | |
| | #11 | |
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,783
| Out of interest, how much current can the USB host deliver maximum? It is possible to change the voltage yourself with some circuitry, but you can never change the maximum wattage you draw from the port.
__________________ Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System I dedicated my life to helping others. This is only a small sample of what they said: "Thanks Elysia. You're a programming master! How the hell do you know every thing?" Quoted... at least once. Quote:
| |
| Elysia is offline | |
| | #12 | ||
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
Quote:
Using USB, which is a packet-based port, to control a voltage level is like walking three blocks around to get next door. There are chips already available for pulse-width-modulation of 12V devices using I2C (aka SMBus). These devices are simple, use a very simple protocol, and can be used directly to do what you want to do. The only slight difficulty is that it takes a bit of effor to get this OUT of the PC - but you could implement I2C with a parallel port. Of course, in either case, you will need to write a driver. That's C, and in Windows, it requires a Windows Driver Kit (WDK, formerly known as DDK). [And of course, if you take over the parallel port, you will need to stop the printer driver(s) from using the port. I think the simple approach would be to disable the device in Windows Device Manager - that will not actualy disable the device itself - it will just make Windows understand that it shouldn't be using that port. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | ||
| matsp is offline | |
| | #13 | |
| Registered User Join Date: Jun 2009 Location: Santarem, Portugal
Posts: 9
| I just payed the USB Experiment Interface Board from Maplin and it will be here in 3~4 days, it will give me a more advanced knowledge about how USB actually works, however from what i know it already has a driver so i won't be able to make my own. Quote:
Thanks, Mywk | |
| Mywk is offline | |
| | #14 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| No, I mean the parallel port that used to be the standard printer several years ago, before USB. It is normally a 25-pin female D-Sub connector at the back of the machine. Modern machines, particularly laptops and small machines may not have a parallel port these days. Of course, if you are getting one of those boards, it has a couple of PWM pins - but it seems like 5V maximum, so it will still not run your 12V fan at full speed. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #15 | |
| Registered User Join Date: Jun 2009 Location: Santarem, Portugal
Posts: 9
| Quote:
| |
| Mywk is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Printers On USB | (TNT) | A Brief History of Cprogramming.com | 1 | 03-10-2002 11:48 AM |