PDA

View Full Version : PropStick Question



crgwbr
09-06-2007, 10:36 PM
I have a propstick usb communicating (or trying to) with a app I wrote in python via the propstick's on board usb connector. Basically, whats happening, is when the python app opens the com port, the propeller resets before it can receive any data.
Now for the really odd part, sometimes it works perfectly. Yesterday, it was working fine, but today, the problem listed above happens consistently. Any idea why this could be happening?

Thanks a bunch,
Craig

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Blog: Prog | Electro | Mech (http://progelectromech.blogspot.com/)

I would love to change the world, but they won't give me the source code

People say that if you play Microsoft CD's backwards, you hear satanic things, but that's nothing, because if you play them forwards, they install Windows.

I spent a minute looking at my own code by accident. I was thinking "What the heck is this guy doing?"

Mike Green
09-06-2007, 10:53 PM
The Propeller is supposed to reset when you open the com port (when DTR goes true). Have a look at the Propstick USB documentation (the schematic). The DTR line from the FTDI chip is connected through a capacitor to a transistor that switches the reset line. Normally DTR would go true by default when you open a com port and you can turn it on and off explicitly (but don't ask me how).

crgwbr
09-06-2007, 11:42 PM
Thanks for the reply Mike. Is there any way to prevent DTR from going true?

Thanks,
Craig

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Blog: Prog | Electro | Mech (http://progelectromech.blogspot.com/)

I would love to change the world, but they won't give me the source code

People say that if you play Microsoft CD's backwards, you hear satanic things, but that's nothing, because if you play them forwards, they install Windows.

I spent a minute looking at my own code by accident. I was thinking "What the heck is this guy doing?"

Phil Pilgrim (PhiPi)
09-07-2007, 12:38 AM
There is one thing you could try, but I'd give about a 10% chance of working. There's a program you can download from FTDI called "MProg". It lets you reprogram the USB chip's internal EEPROM. One of the settings is the polarity of the DTR line. If you reverse this polarity so DTR is normally high, but goes low when asserted, it will start out high, then go low when your Python program starts up, and the Prop should not reset — assuming that DTR just gets asserted and not toggled several times. Of course, when your Python program exits, DTR will deassert, and the line will go high, resetting the Prop.

If you do this, you may still be able to reprogram the Prop without changing it back, depending on the timing margins. In any event, the change is reversible, so it might be worth a try.

-Phil

crgwbr
09-07-2007, 12:54 AM
Thanks for the reply Phil. I have used Mprog many times before; I tried your suggestion, but unfortunately, it didn't work. It did stop the Prop Tool from finding the propeller, but it my program still reset the prop when opening the com port.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Blog: Prog | Electro | Mech (http://progelectromech.blogspot.com/)

I would love to change the world, but they won't give me the source code

People say that if you play Microsoft CD's backwards, you hear satanic things, but that's nothing, because if you play them forwards, they install Windows.

I spent a minute looking at my own code by accident. I was thinking "What the heck is this guy doing?"

Phil Pilgrim (PhiPi)
09-07-2007, 12:55 AM
Here's something else to try. (Disclaimer: I'm not a Python programmer, so I may not have a clue what I'm talking about.) Looking at the pySerial docs, you can create the port object with a port name of "None". This prevents a port from being opened when the port object is created. Then you can do a setDTR(0), which should keep DTR from being asserted. Then set the port parameter to the desired port name, and invoke the open() method.

-Phil

crgwbr
09-07-2007, 02:03 AM
Well, Phil, it looks like once again, I get to keep my job because of your help. Thanks a lot! I had to make a few minor altercations, but you had the main idea. Basically, I had to call it like this:

Ser = serial.Serial()
Ser.baudrate = 9600
Ser.port = i
Ser.open()
Ser.setDTR(0)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Blog: Prog | Electro | Mech (http://progelectromech.blogspot.com/)

I would love to change the world, but they won't give me the source code

People say that if you play Microsoft CD's backwards, you hear satanic things, but that's nothing, because if you play them forwards, they install Windows.

I spent a minute looking at my own code by accident. I was thinking "What the heck is this guy doing?"