Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Simple switch on/off signal trough USB?

Status
Not open for further replies.
I have no direct experience with USB. However, check out "Wiznet" They appear to have some good products to get you started. It's on my list of things to do as well.
 
I have no direct experience with USB. However, check out "Wiznet" They appear to have some good products to get you started. It's on my list of things to do as well.

Wiznet is more of an internet page/uC gismo...This will do what the OP needs
 
What would be the best way to make a computer "aware" of a
switch state using usb?
I imagine I would have to use uC and maybe FTDI chip/cable.
So what is the best/simplest way to start?

Hi there,

Since you talk about FTDI chips lets start there if you dont mind.
A typical FTDI USB to serial port will give you a serial port connected to the USB. You can then read and write to that port the same way you would with a regular serial port, so it would be the more simple RS232 protocol.

If you wanted to go straight USB, you'd probably have to use a controller that is designed to work with USB and program it to read a port (your switch). You'd have to download representative code that interfaces with the USB and add your own code to service one or more ports. Note this second method is going to be a bit harder to achieve than the method above with the RS232.

Either way you choose, you can then service one switch, two switches, or ten thousand switches as well as do lots of other things.
 
A usb bitwacker is cheap and provides IO channels
 
  • Like
Reactions: 3v0
You can look up bit-banging a FT232RL. you can do a lot with it and people have even successfully made an SPI interface. There was even a article written recently on the spark fun website which you can find here :)
 
Last edited:
The USB bitwhacker as mentioned by EternityForest will require that you write no code for the PIC. Yes none, zip.

There is even a basic program for the PC that show you how to use it.

You can buy one from sparkfun here for $25 or build it yourself for under $10 if you can get your hands on a programmed PIC.
 
Hey guys, came across this and it was exactly what I was looking for. I needed to find help with something though... I need to figure out how to make a hardwire switch interact with the chip... example:

The bitwacker chip hooked up via usb to a computer
I want to have a Magnetic Reed Switch, be able to hookup directly to the board to send a simple "closed" "open" signal to the chip....


Use example: having a computer know the exact time a door opens and closes with the magnetic reed switch (the kind used in alarm systems)

I want to simply wire the two ends of the switch to two terminals into the board, but i wouldn't know which ones would send a simple open/closed signal that the computer could see in real time.

It HAS to be accurate to within 1/60th of a second. I know this maybe too much of a question but I figured I'd ask. Anyone have any thoughts? I'm a n00b at this, so sorry for that.
 
It HAS to be accurate to within 1/60th of a second. I know this maybe too much of a question but I figured I'd ask. Anyone have any thoughts? I'm a n00b at this, so sorry for that.

That could kill your idea, USB isn't known for it's fast response times, it's not even interrupt driven (on the PC side).

I would imagine there are examples for switches at the Bitwacker website, and I expect it to send a complete byte of data from a full port - you just use the one you want.
 
USB isn't known for it's fast response times, it's not even interrupt driven (on the PC side).
You should be able to get the latency down to the USB frame rate (if you have control over the device firmware), which is 1ms for full- & 125us for high-speed. Interrupt & isochronous pipes can specify max 'guaranteed' latency as well.

So USB itself isn't necessarily the problem - it might be e.g. that the serial port rx data is being queued so that a multi-byte packet can be sent. I know that some of the FTDI chips can have their latency timer set to 2ms which should allow the pin statuses to be known to the nearest ~2ms.

So you're right - it's not amazingly responsive - but it can still be very usable.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top