Detecting USB connection
Basil
Posts: 380
Hi All,
In my application, I want to be able to talk to a PC over serial (via FTDI chip on the normal prop pins).
The problem I have is. When USB cable is NOTconnected, the prop resets whenever the program trys to send data to the serial port and gets itself into an endless cycle.
I want to be able to check is the USB cable is plugged in and boot in a different 'mode' if it is.
Is it possible to read the state of the RESn pin?
What im getting at is:
When USB cable is connected, this brings RESn low then high causing a reset on the rising edge, correct?
While the USB stays connected, RESn stays high during the reset. If I can read this pin then I can check if the prop has just been reset because of USB connection, or if it was a normal power on (in which case RESn would be low)
Does this sound dooable? I am at work so don't have all the datasheets with me...
Alec
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Alec
My our page
Post Edited (Basil) : 8/26/2008 1:06:34 AM GMT
In my application, I want to be able to talk to a PC over serial (via FTDI chip on the normal prop pins).
The problem I have is. When USB cable is NOTconnected, the prop resets whenever the program trys to send data to the serial port and gets itself into an endless cycle.
I want to be able to check is the USB cable is plugged in and boot in a different 'mode' if it is.
Is it possible to read the state of the RESn pin?
What im getting at is:
When USB cable is connected, this brings RESn low then high causing a reset on the rising edge, correct?
While the USB stays connected, RESn stays high during the reset. If I can read this pin then I can check if the prop has just been reset because of USB connection, or if it was a normal power on (in which case RESn would be low)
Does this sound dooable? I am at work so don't have all the datasheets with me...
Alec
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Alec
My our page
Post Edited (Basil) : 8/26/2008 1:06:34 AM GMT
Comments
This is a well-known and oft-cited issue. See this thread for the reasons behind the problem and a solution. Short (but not very satisfactory) answer: put a 2.2K pullup on A30. If the board is your own design, modify it to include a 74LVC2G07 open-collector buffer pair between the USB chip and the Propeller, powered from the FT232R's VCCIO.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Post Edited (Phil Pilgrim (PhiPi)) : 8/26/2008 3:34:01 AM GMT
Thanks for the link.
I had actually seen that in my searches. I don't actually mind the reset, in fact it makes some part of my code easier.
The main reason for my asking is to find out if there was a way to detect if USB is connected upon powerup.
If there is no way to check the status of the RESn pin on powerup (without the prop resetting) then the only way I can think of is in fact to add that resistor mentioned in the link you gave, then send a serial query down the line to a GUI on the PC
If there is a response then obviously something is connected. If not, then there isnt.
My problem now is I don't know how to implement a time out. eg, send 'hello'. If 'im here' is not recieved back within 5 seconds, then no connection, continue with program.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Alec
My our page
Put the 2.2K pullup on A30 and a weak (~47K) pulldown on A31. When your program starts, poll A31. If it's high, you know the USB cable is connected. If it's low, check it several more times to ascertain that the PC is not sending data. If it stays low, chances are there's no USB dongle connected.
If what you really want to know is whether the PC and the USB dongle/cable are connected, omit the pullup on A30. If A31 is low, don't raise A30, or you'll reset the Prop if just the dongle/cable is connected.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
I was hoping to avoid using an extra pin but If I can't avoid it...
Thanks [noparse]:)[/noparse]
Alec
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Alec
My our page
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Thanks phil, Looks like im going to have some ugly 1/4w resistors sticking out of my nice SMT board :P
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Alec
My our page