LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 10-06-2010, 10:16 PM   #1
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Rep: Reputation: 0
usb->parallal adapter I/O trickery


I know this subject has been beaten to death... but... I'm trying to be inventive here.

I have a few USB-Parallel adapter based on the Prolific 2305 chip. As far as I can tell from the documentation, it only works in some sort of a high speed printer data mode as a character device... you can't access the IO lines directly... but I would really like to play around with some output... and I think I have a scheme that will simulate a true parallel port.

I am hoping to write a small program that listens to a pipe for 1 byte of data. Each time a byte is written this program will continuously send that byte out to the usb->parallel adapter until the next byte arrives, at which point it will begin writing that new byte. repeating this process indefinitely...

I'm assuming that this printer protocol likely has control words and I am willing to filter them out with a cap or something.. My hardware requirements are very loose aI just want to turn on and off fans and lights... I can ignore up to 200ms or so of delay

Do I have a chance in hell of this working?
 
Old 10-07-2010, 01:19 AM   #2
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
after a little more reading it looks like the PL2305 chip does support a unidirectional mode... so there is no strobing between tx and rx... this leads me to believe that what i want is entirely possible.
 
Old 10-09-2010, 12:12 PM   #3
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 7,921

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
Quote:
Originally Posted by flyznest View Post
I know this subject has been beaten to death... but... I'm trying to be inventive here.

Do I have a chance in hell of this working?
No harm in being inventive . . . Not a chance in hell of it working. Just try not to blow too much on the way.
 
Old 10-09-2010, 04:16 PM   #4
Elv13
Member
 
Registered: Apr 2006
Location: Montreal,Quebec
Distribution: Gentoo
Posts: 825

Rep: Reputation: 128Reputation: 128
I would also like if someone point me/us to a USB->parallel adaptor that allow I/O pins to be set manually from C code just like onboard DB25 ports. There is no reasons in the universe it can not exist.
 
Old 10-09-2010, 04:47 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,738

Rep: Reputation: 1753Reputation: 1753Reputation: 1753Reputation: 1753Reputation: 1753Reputation: 1753Reputation: 1753Reputation: 1753Reputation: 1753Reputation: 1753Reputation: 1753
The only device I know about is:
http://hackaday.com/2009/09/22/intro...-bitbang-mode/
http://m8051.blogspot.com/2010/05/ft...ng-python.html
 
Old 10-10-2010, 02:25 PM   #6
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by business_kid View Post
No harm in being inventive . . . Not a chance in hell of it working. Just try not to blow too much on the way.
Edit: I got it mostly working... read entire thread

hahaha.. well... I blew about 4 hours... no money... and as you suggested I didn't get too far. But i'll post my findings anyway in case someone else decides to have a go at it.

I did a quick search online for the usblp source code and found this:
http://www.sharms.org/blog/category/...related-posts/

bingo... there were all the ioctl's already done for me.. so I split this into 3 separate programs.. one to set unidirectional mode(hint.. the int for uni mode is 1), one to read back the current settings, and one for soft reset.

First I put it into unidirectional mode, t and read back the settings. I was indeed in uni mode.

Then I did a: "#echo U > /dev/usblp0". Using a logic probe I looked at each of the data pins. 00010000. Thats a "DLE"(Data Link Escape) character.. The only way to clear that is to send a reset. I tried a few other letters and even a "hello world" string... same results. One more note... If you issue the echo command more than 3 times redirected to /dev/usblp0, it will lock up... doesn't matter if you use 1 character or the entire xorg.conf... same results.

One website I found suggests that the DLE is the prefix to the data stream.... so... using a piece of jumper wire I toggled the ACK line... it reset to all zeros... still no data...

Another interesting note... if you issue more than 2 consecutive resets without sending data, the thing seems to lock up...

Finally, someone gave me an old laptop with a parallel port so I didn't need this... there is my 4 hours of contribution. I might come back to it some day but for now I have other things to do.

Last edited by flyznest; 10-14-2010 at 12:23 PM. Reason: status changed
 
Old 10-12-2010, 06:14 PM   #7
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
SUCCESS!!!!! (kinda)

I took this thing to work and was messing with it over lunch today... I decided that if this thing was using the ieee-1284 protocol, maybe I should read said protocol...

http://zone.ni.com/devzone/cda/tut/p/id/3466

so... This basically says that the printer strobes the "BUSY" line to indicate when its ready for more data... so...

I hooked my little rig up... sent a reset, followed by a set... then sent an "#echo U > /dev/usblp0"... and I got my same "00010000". then I took a jumper wire and jumped BUSY to ground... nothing. hmm.

Then I read back through my notes and saw that if I momentarily jumped "ack" to ground, it would clear the LED's to all 0's... so I did so and everything was 0... then I momentarily jumped BUSY to ground... BINGO!!! I HAVE MY DATA. and it latched too!!!

then lunch ended... but I am very very close to getting this working You're gonna eat your words, business_kid
 
Old 10-12-2010, 07:21 PM   #8
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
got a few more minutes to play. Connected busy and ack together and tested what happens if they are treated as one pin...

sent a reset, sent an "echo U > /dev/usblp0", jumpered to ground... MY DATA!!

so... I tried just leaving them permanently grounded... reset, "echo..."... worked the first time, worked the second time, and it hung on reset the third time... hmmmm... tried it a bunch more times and the results were very inconsistent. Sometimes it would work, and sometimes it wouldn't. I'm starting to wonder if I'm gonna have to use data line P4(remember the 00010000?) as a trigger for a transistor or something to ground those pins.

its probably worth mentioning that even if I do continue to spend time to get this working, it will only be good for really slow I/O, and data line P4 will be very noisy.
 
Old 10-13-2010, 12:18 AM   #9
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
solution #1

so... i have a solution that I believe will work. it involves a single NPN transistor. tie ACK and BUSY together and connect them to the collector, Base goes to p4(or D4.. whatever you may call it), emitter goes to one of the ground lines. I might also have to add an RC network to cause a small delay.. we'll see. My adapter must have some internal current limiting because I was using jumpers without any resistors with no problem.

I don't know when I will get a chance to try this... maybe tomorrow... maybe not... If there is anyone reading this besides me(doubtful) and you feel brave enough to try... tell me how it works out... but if you destroy your adapter then don't blame me.
 
Old 10-13-2010, 04:23 PM   #10
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
It works!!!

IT WORKS!! IT WORKS!! IT WORKS!! IT WORKS!! IT WORKS!! IT WORKS!! IT WORKS!! IT WORKS!! IT WORKS!! IT WORKS!!

so... I got my hands on a 2N3904 transistor(2N2222 would be just as good). Base to D4, Emitter to ground, Collector tied to ACK and BUSY. plugged my adapter into the USB port and I couldn't reset it... so I pulled the transistor off, plugged the USB back in.. set it up, reset it, then hooked the transistor back up... sent a character to /dev/usblp0 and bingo... there it was... tried a reset... hung... so there is apparently something going on during reset that the transistor screws up... I need a delay to bypass this..

I picked out some HUGE values of R and C... I wanted enough of a delay to see it charge and trigger(for testing purposes). 100uf and 1M ohm... I put this delay on the base... and IT WORKS! IT WORKS! IT WORKS!

I only set it to uni mode one time when I first plug it in. After that, just send a reset between each character. For some reason it frequently requires 2 resets. I believe this is a byproduct of my ridiculous RC values.... So... what I need to do now is start shrinking the RC value until I can make the thing practical to use. One note.. because of the delay, the reset, and the momentary 00010000 state... I'm gonna be pushing it to get this thing useful at 1khz.

but IT WORKS!! IT WORKS!! IT WORKS!! IT WORKS!! IT WORKS!!
 
Old 10-13-2010, 07:51 PM   #11
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
got a few free minutes at the end of today... had a stack of caps from .1uf to 22uf... 10uf was as far as I could drop without seeing the reset glitch. thats gonna be slower than 20hz which is ok for lights and dc motors but I wanna see if i can get it faster. Using discrete logic i could probably trigger off of a combination of things and eliminate the reset problem without the need for the delay... I'll save that for another day.
 
Old 10-14-2010, 07:04 AM   #12
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 7,921

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
I did read it, although I wondered at myself:-).

I don't have your circuit, but a data line is not guaranteed to stay below the 0.6 or so volts that starts to turn on a 2n3904. Just adding a diode in series might help. As for the delay capacitor, remember when it's charged, and you switch off, the charge remains. Best to bleed it off to V+ with a diode which only turns on when V+ is low.

The place to go with this stuff is alt.sci.repair or whatever replaced it.
 
Old 10-14-2010, 02:09 PM   #13
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by business_kid View Post
The place to go with this stuff is alt.sci.repair or whatever replaced it.
Yeah... I thought about hitting the news groups but I saw quite a few people asking about these adapters in different Linux forums so figured it was worth a try...

Quote:
Originally Posted by business_kid View Post
I don't have your circuit, but a data line is not guaranteed to stay below the 0.6 or so volts that starts to turn on a 2n3904. Just adding a diode in series might help.
Now that you mention it, the LED's on my data lines do sometimes glow very dim when I first plug in the adapter, before I send the first reset... I wonder if this is actually the cause of a good bit of the problems... I can't believe I hadn't thought of that.

THX
 
Old 10-14-2010, 08:17 PM   #14
flyznest
LQ Newbie
 
Registered: Oct 2010
Posts: 12

Original Poster
Rep: Reputation: 0
yep.. diode fixed up a few reliability issues. the thing is actually starting to work pretty well... parts list is up to 1 transistor, 1 diode, 1 cap, and 1 resistor.
 
Old 10-15-2010, 02:34 AM   #15
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 7,921

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
mark this solved, then
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting USB Network Controller (SR9600 USB To Fast Ethernet Adapter) on FC10 katrok Linux - Hardware 1 06-26-2009 08:31 PM
Fedora 9 and Network Adapter 3COM OfficeConnect Wireless 11g Compact USB Adapter mpharkin Linux - Newbie 1 09-20-2008 05:18 AM
Help implementing ssh trickery brokenpromises Programming 2 02-28-2008 09:05 PM
I have a USB Linksys Wirless-B USB Adapter (WUSB11v4) installation issues! tickerprice2684 Linux - Wireless Networking 2 01-29-2007 11:07 AM
USB problems: Memorex USB stick 256MB and PSX to USB adapter by Radio Shack Knuckles T15 Linux - Hardware 1 05-19-2004 06:58 PM


All times are GMT -5. The time now is 09:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration