View previous topic :: View next topic |
Author |
Message |
blinky465
Joined: 03 Jan 2006 Posts: 8
|
Getting started with USB |
Posted: Tue Jan 03, 2006 7:27 pm |
|
|
I'm planning a usb-driven 240v switching device, which is to eventually be software programmable (a bit like a really simple time-based PLC).
I'd like to make the device(s) link together similar to a daisy chain - where one device can either plug into a PC (as a master device) or another device of the same time (so it acts as a slave device).
I've put together some ideas at http://www.multiedge-net.co.uk/usb_outline_brief.zip about the daisy chain effect and how it would be handled in software.
The theory has held up in the past, when I've linked Siemens Logo PLC units together via RS232. Has anyone any experience of something similar, or does anyone have any comments?
Thanks, Chris |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Tue Jan 03, 2006 7:54 pm |
|
|
This is not likely to work. There are a range of problems such as two diode volt drops per slave device, USB max cable length, loss of signal integrity with each PCB / Cable layout.
There are a range of alternatives such as RS485, RS422 that will provide you a bus based solution. My preferred approach would be to use Ethernet. This is a relatively low cost but extremely scalable technology. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
blinky465
Joined: 03 Jan 2006 Posts: 8
|
USB signal loss |
Posted: Wed Jan 04, 2006 2:04 am |
|
|
I'd heard that there was a limit to the maximum length to USB connections, and assumed there would be signal loss of distance. I like the idea of reusing the USB sockets on each device, instead of using a "hybrid" connection method; my original plan was to include RS232 serial connectors as well, but then the USB socket would be redundant on all except the "master" device.
Would the same design work if a signal booster or USB repeater or similar was included in every device, on the outgoing signal ? |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: USB signal loss |
Posted: Wed Jan 04, 2006 2:26 am |
|
|
blinky465 wrote: | I'd heard that there was a limit to the maximum length to USB connections, and assumed there would be signal loss of distance. I like the idea of reusing the USB sockets on each device, instead of using a "hybrid" connection method; my original plan was to include RS232 serial connectors as well, but then the USB socket would be redundant on all except the "master" device.
Would the same design work if a signal booster or USB repeater or similar was included in every device, on the outgoing signal ? |
A USB signal booster or repeater is a USB hub. This enables you to build a star based network of devices. In the USB world you really have only a single master (the USB host) and multiple slaves. Note that PICs with inbuilt USB capabilities can only be USB slave devices. USB is really limited to a PC peripheral technology, other niche implementations exist, such as printers interfacing directly to disital camera via USB, but in this case the printer is emulating a host device. It is not viable to implement a USB host capability on current generation PICs. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
blinky465
Joined: 03 Jan 2006 Posts: 8
|
Please excuse my ignorance.... |
Posted: Wed Jan 04, 2006 5:09 am |
|
|
Sorry if I've oversimplified things - I'm just getting used to miniaturing things and replacing relay switches with transistors, and PLCs with microchips!
Would introducing a couple of transistors (as you would relay switches on a "scaled up" model) allow the signal to be boosted? Would transistors be quick enough for low-speed USB1.0 signalling?
(updated document http://www.multiedge-net.co.uk/usb_outline_brief.zip)
Or should I just bite the bullet and stick to RS232/serial comms between the devices and have the first device in the chain convert this data to send it back to the PC via USB?
(the second, third and subsequent devices use their USB ports as "pass-through" connectors for sending data back to the PC). |
|
|
Ttelmah Guest
|
|
Posted: Wed Jan 04, 2006 6:14 am |
|
|
No.
USB, is bidirectional. Each wire can be carrying signals in both directions, according to where in the 'transaction' you are. Hence you cannot just add transistors.
Swtching to RS232 or 485 (preferable to my mind), would be a sensible solution.
You won't be using the USB ports at all on the latter devices in this case.
Best Wishes |
|
|
blinky465
Joined: 03 Jan 2006 Posts: 8
|
Back to the drawing board |
Posted: Wed Jan 04, 2006 7:10 am |
|
|
Looks like it's back to the drawing board!
Thanks for the help - I'll post back here when I've something else drawn up.... |
|
|
hillcraft
Joined: 22 Sep 2003 Posts: 101 Location: Cape Town (South africa)
|
CAN-BUS |
Posted: Wed Jan 04, 2006 10:08 am |
|
|
USB is a pain.
Why don't you use CAN-BUS. I have created an task specific Industial PLC that communicates with the PC via RS232. The controller then communicates with 1 - many slave units. One can of course change the RS232 interface to a USB interface. My system does not need to be connected to a PC all the time so using RS232 is fine. |
|
|
blinky465
Joined: 03 Jan 2006 Posts: 8
|
Re: CAN-BUS |
Posted: Wed Jan 04, 2006 10:54 am |
|
|
hillcraft wrote: | USB is a pain. |
You're not kidding!
I originally thought about using RS232, as this is what I've used in the past for PLC integration. But I've also noticed now that some laptops, for example, are omitting serial connectors, in favour of more USB ports.
I suppose it should be easy enough to use a USB-to-serial board to interface with the PC. http://www.beyondlogic.org/usb/ftdi.htm
hillcraft wrote: | My system does not need to be connected to a PC all the time so using RS232 is fine. |
My (leading) device is driven in realtime, entirely from software, so needs to remain connected to the PC. I just thought that USB would provide a quick and easy connection method *for the user*.
Forgetting all about USB for a minute, is there any problem with the transistor based design "as is" (http://www.multiedge-net.co.uk/usb_outline_brief.zip) for RS232 communications? I thought RX and TX were single direction communications? |
|
|
Guest
|
Various issues |
Posted: Wed Jan 04, 2006 11:13 am |
|
|
RS232 RX and TX lines are unidirectional. You must remember that you shouldn't try to use USB in real time via HID. Windows services HID when it feels like it.
Yes RS232 via a laptop is a problem. USB to RS232 bridge controller also have their issues. They cannot support non-standard baud rates and they tend to fall asleep. I have ended up purchasing a PCMCIA RS232 card to get around these issues.
You must also remember that CAN-BUS has proved to be very robust in Automotive and Industrial applications. Microchip / CCS support for CAN-BUS is superb. Another thing is that CAN-BUS already has the worst of the signalling / protocol issues sorted.
My vote is without a doubt for CAN-BUS. |
|
|
blinky465
Joined: 03 Jan 2006 Posts: 8
|
Re: Various issues |
Posted: Wed Jan 04, 2006 11:39 am |
|
|
Anonymous wrote: | My vote is without a doubt for CAN-BUS. |
I think what I was originally trying to describe fits the can-bus principle (http://www.mjschofield.com/canworks.htm) albeit using a non-standard messaging format.
I forgot about the HID being serviced whenever Windows feels like it. My devices aren't absolutely time critical, but I suspect I'd want them to respond to signals every 1/8th or even 1/16th of a second (about 60-120 ms).
I'll have a look into CAN-BUS, thanks for the pointer... |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
[OT] FTDI new chip |
Posted: Wed Jan 04, 2006 12:19 pm |
|
|
Speaking of FTDI, about a month ago they cme ot with a new chip. It has an on-board EEPROM and oscillator. It costs $4.50, if i remember correctly. The package is 28-TSSOP. I haven't tried it out yet, but chips ank EV-kits are available. |
|
|
blinky465
Joined: 03 Jan 2006 Posts: 8
|
Forget USB for now.... |
Posted: Wed Jan 04, 2006 12:56 pm |
|
|
When I've used signal lines for low voltage control, "echo and ignore" is nice and simple for non-critical apps. If I go back to the idea of using serial communication (forgetting about USB for now) would the design at http://www.multiedge-net.co.uk/rs232_outline_brief.zip hold up? |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Wed Jan 04, 2006 1:40 pm |
|
|
The system you are describing in the text sounds like a ring, where secondary the node just re-transmits the message, unless this secondary itself is an addressee. The drawings, you show, look like a linear bus. So, I might be somewhat confused. However,..
The RS232 system (bus) you have depicted will work fine for the one-way communication from the master to the secondaries. You will not even need the diodes for this. However, is several secondaries try to talk to the master at the same time, you will get a bus collision. Unfortunately, RS232 itself doesn't have the methods for the arbitration of collisions, because it was designed for point-to-point communication.
My advice would be to go with CAN. You can even avoid writing the firmware for the secondaries, because you could use SLIO chips such as MCP25050. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: Forget USB for now.... |
Posted: Wed Jan 04, 2006 10:10 pm |
|
|
blinky465 wrote: | When I've used signal lines for low voltage control, "echo and ignore" is nice and simple for non-critical apps. If I go back to the idea of using serial communication (forgetting about USB for now) would the design at http://www.multiedge-net.co.uk/rs232_outline_brief.zip hold up? |
I don't like this solution. What this does is introduce multiple single points of failure. As one contributor has already mention, USB-to-RS232 dongles have their own issues. I have several applications in the field that use this class of dongle and they are a continuing on going support challenge. Works fine when shipped but problems are introduced when the customer changes brand of dongle or upgrade O/S or plugs some other device into the system, or have over extended the USB power budget for some other device, or the moon is half full or......
My first preference would be Ethernet and for your application (no dongle required) I would use UDP - virtually every notebook today ships with an Ethernet port. The IP stack is ubiquitious allowing you to use it with any operating system and not be tied to a specific OS/driver dependancy which is the case today with all USB solutions. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|