Shop OBEX P1 Docs P2 Docs Learn Events
Why can't you use a cheap USB dongle to program the Propeller? - You can, but... — Parallax Forums

Why can't you use a cheap USB dongle to program the Propeller? - You can, but...

Cluso99Cluso99 Posts: 18,069
edited 2012-06-27 16:57 in Propeller 1
This gets raised often, so here goes again...
(this is my take on what happened)

Chip realised that switching programs under windoze caused the comms status pins (DTR & RTS) to be reset when the COM port was released by a program. The next program would presumably then make these signals active. Under normal circumstances, using the DTR or RTS pin (at TTL level) would cause the prop to reset. When downloading a program to the prop it is normally held in SRAM and we do not bother to program the eeprom (it has a large but limited number of program cycles). If the prop is then reset, the code in SRAM is lost.

In other chips such as the favourite Arduino, etc, these chips are always downloaded to their Flash memory (also have a limited number of program cycles). So a reset after downloading is in order.

The Prop Solution...
By inverting the DTR signal by an npn transistor and using an RC network, the prop only resets on a transition of DTR (some download programs permit RTS to be selected) from active to inactive. No reset occurs on transition from inactive to active.

So, the download program in windoze sets DTR active (does nothing), then DTR inactive (forces reset on the prop), and then the download commences. Once the download is complete (say for example in PropTool) the user can exit this program and load PST (Parallax Serial Terminal). When PropTool exits (releases the COM PORT to be precise), DTR is already inactive, so nothing happens to the prop reset. PST now takes the COM PORT and DTR still remains inactive.

This is why the PropPlug has the transistor reset circuit.

So, if you add the transistor reset circuit to a cheap USB dongle you can save the cost of an expensive PropPlug. While I have not tried it, I have been told that a series capacitor from DTR to the Props Reset will also work. In this case though, I would think that the reset will occur slightly earlier because it will occur from the DTR inactive to active transition, rather than the following active to inactive transition.

If you use a cheap USB dongle, ensure that the USB chip is operating at 3V3 and not 5V, else you will require the series protection resistors in P30 & P31 (well actually only P32 since it is the input to the prop).

Comments

  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-06-24 21:26
    It does not seem to matter if you reset on the leading edge or the trailing edge. I've used either. The problem (I think) with cheap $2 USB to serial cables is the delay between the reset and the download. The fix is a purely software one - the current proptool does *not* work. Old versions do work. Most third party IDEs do work. But the old proptool is hard to get hold of, and not every third party IDE seems actively supported, and not every IDE supports those little arrows that are IMHO an essential part of the Spin language.

    I think Jazzed's new IDE might be getting close to the mark.
  • jazzedjazzed Posts: 11,803
    edited 2012-06-24 22:21
    My own experience with this is that most Propeller boards work correctly as Cluso99 described. However I have found that some do not such as 3 different PPDBs. I found it necessary disable changes to RTS/DTR in Windows, and use application port sharing in Linux/Mac.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-06-25 08:16
    I think the short answer is that there are two kinds of manufacturers in the world. Those that insist on excellence in their products. And those that just see opportunities to fill demands with the cheapest or fastest solution one can provide.

    In the technical marketplace, the RS-232 specification is 4 or more lines. But some USB to RS232 provides just provided Tx and Rx. That was the original headache. But Cluso addresses issues of how the RS232 is handled.

    Frankly, I started with building my own transistor interface from RS232 to Propeller - so these issues in Windows and other alternatives have never occurred to me.

    You don't have to use a Parallax product. In fact, I bought a cheap USB to RS232 dongle locally and lucked out on it being compatible both in hardware and driver software. I also bought a Pololu line follower robot and the USB programmer for it has an optional choice that provides all 4 RS232 lines. It could be adapted.

    I have a Propeller specific USB device as well.

    But the reason people simply suggest buying the Parallax adapters is that you will NOT find yourself in the position of having guessed and been disappointed.

    And BTW, the Propeller only requires 3 of the 4 lines; but that is rather trivial as you just don't see a lot of 3 line devices outside of a Parallax device for dedicated Propeller use.

    The situation may be getting 'off into the weeds' by having other people producing IDEs and boards without some sort of peer review to assure they have a reliable scheme. But depending on Windows is always rather dicey. I was badly beat up by investing in a Vista computer; while W7 seems good. One never knows when M$ is going to do something foolish and pretend that nothing is wrong.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2020-03-08 17:18
    I have modified a cheap USB to serial adapter for use with the prop.
    This modification adds a transistor, a MOSFET in this case, to act similar to the PropPlug.
    See:
    SPIN Problems Using Non-Parallax USB to TTL RS-232 Adapter.

    Duane J
  • David CarrierDavid Carrier Posts: 294
    edited 2012-06-25 13:09
    The reason that the Propeller reset pin cannot be directly connected to DTR is that the reset signal is on a bidirectional open-collector pin. This means that it has a pull-up resistor that holds the device out of reset, but either it or an external device can drive the line low, to force a reset. The DTR output of a USB to serial converter is in a push-pull configuration, which means that it is always driving the output, either high or low. If it is driving the output high while someone presses the reset button on the PCB, or when a brownout condition occurs, the USB to serial converter will be driving high while another device is driving low, which can prevent the reset from occurring and may damage the converter or the Propeller.

    The transistor on the DTR line of the Prop Plug converts the push-pull output of the FT232R DTR pin to an open-collector output, which can be connected directly to the reset line. The circuit could be on the USB to serial converter, or it could be on the PCB with the Propeller microcontroller. Since their are more boards with Propeller microcontrollers than there are programming tools, it was most cost effective to put the circuit on the programming tool.

    — David Carrier
    Parallax Inc.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-06-25 16:17
    Yes David that is quite correct. The transistor circuit is a high pass filter that produces a reset pulse on either the leading or trailing edge of the DTR pulse. There are NPN and PNP transistor solutions, and there are leading edge and trailing edge circuits.

    In answer to Cluso99's question

    "Why can't you use a cheap USB dongle to program the Propeller? - You can, but..." you can't use the official propeller programming software. You have to use a third party program.

    I guess if one were to invoke giant fake moon landing conspiracy theories, one could hypothetically suggest that Parallax would make more money selling the proptool than telling people to buy a $2 device that does the same thing. So there is little incentive to fix the Proptool. Or more specifically, to undo the "fix" about 3 years ago that stopped the Proptool using these devices.

    And to that, one could counter that one of the first barriers to using a new microcontoller for a potential customer is the cost of an initial setup, and right now, the proptool costs more than the propeller chip, and if you could say that you can get into propeller programming for $15 instead of $30, that ought to be a selling point.

    On the other hand....

    The Proptool could do with some improvements anyway - intellisense, autocompletion, drop down menus for object methods, auto starting of the terminal after download, ability to use cheap $2 USB serial devices, so I'm delighted that Jazzed is doing all this because it solves many problems in one go.
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-06-25 19:51
    David: While you are completely correct regarding the open collector issue, I believe with respect, the transistor circuit was chosen because of windoze shortcomings as I described in my first post. The simple transistor circuit overcame this problem. Please confirm this with Chip (I have never asked).

    However, a simple series capacitor should (and does in some circuits) work, but would still suffer from this windoze problem.

    Drac has illustrated the cost problem. Add to this, the FT232RL chip is smt (and fairly fine pins too) and very expensive, the propplug has to be expensive. There are much cheaper solutions around today.

    Drac pointed out a further problem that I was not aware of, and that is that some of the cheap dongles do not work (plus the transistor circuit) still do not work with the latest PropTool downloader. This seems to me that some of the dongles may have varying timing delays for DTR (or RTS) and that this and the PropTool delays and the Propeller's own timing, results in the download sequence being missed. Seems that any new download software is going to require adjustable reset timing to fine tune the result. I expect windowze will throw a few spanners into the mix here too.

    If the problem were only a tiny pcb with the transistor circuit and series resistors on P30/31 then I could do this really cheap. But postage and packing cost kills it ($2.40 airmail and $1.00 for the padded bag). How on earth can a supplier in China sell you any device for $1 including postage and pack??? Seems our postal systems are being abused.
  • AribaAriba Posts: 2,690
    edited 2012-06-25 20:40
    Cluso99 wrote: »
    ...
    However, a simple series capacitor should (and does in some circuits) work, but would still suffer from this windoze problem.
    You need to invert the DTR signal before the series capacitor, then the behavior is the same as with the transistor:
    attachment.php?attachmentid=93744&d=1340682011
    The FT232 can be configured so that DTR is inverted (with the Tool FTPROG)
    Drac pointed out a further problem that I was not aware of, and that is that some of the cheap dongles do not work (plus the transistor circuit) still do not work with the latest PropTool downloader. This seems to me that some of the dongles may have varying timing delays for DTR (or RTS) and that this and the PropTool delays and the Propeller's own timing, results in the download sequence being missed. Seems that any new download software is going to require adjustable reset timing to fine tune the result. I expect windowze will throw a few spanners into the mix here too.
    ...

    This is a problem of the Windows driver and the buffer size inside the USB to serial chip. The boot protocol needs a continuos bitstream, but USB transmit in packets all 1 ms. So the chip needs to buffer some hundred bytes and the drivers needs a fast reaction if the buffer is nearly empty.
    The PropTool has some timeouts set very short, this results in aborting the loading procedure when the gaps in the bitstream gets too long. The nasty thing is that the download works often with short code, and you get the abort only with big code and long download times.

    Andy
    320 x 200 - 2K
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-06-25 21:37
    This is a problem of the Windows driver and the buffer size inside the USB to serial chip. The boot protocol needs a continuos bitstream, but USB transmit in packets all 1 ms. So the chip needs to buffer some hundred bytes and the drivers needs a fast reaction if the buffer is nearly empty.
    The PropTool has some timeouts set very short, this results in aborting the loading procedure when the gaps in the bitstream gets too long. The nasty thing is that the download works often with short code, and you get the abort only with big code and long download times.

    Ah - now that would explain a lot. So - would a solution be to give the user access to those timeout values so you could adjust them?
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-06-25 23:40
    Andy, with respect, the series capacitor without transistor, has been found to work. It just changes the edge where the reset occurs.

    Andy has thrown some more light onto this. I do now recall that larger programs were found to fail more frequently.

    PropTool has an adjustable post reset delay. By default, mine is set to 90ms.

    I agree, it is all to do with the timing and likely the USB timing. But windoze adds it bit too, by delaying and also by turning off DTR & RTS when the Com Port is released. If you are switching from PropTool to another terminal program, then if DTR (or RTS) is activated by this program, the prop will be reset, rendering the download (if only to hub) lost.
  • AribaAriba Posts: 2,690
    edited 2012-06-26 08:35
    Cluso99 wrote: »
    Andy, with respect, the series capacitor without transistor, has been found to work. It just changes the edge where the reset occurs. ..<snip>...
    .... If you are switching from PropTool to another terminal program, then if DTR (or RTS) is activated by this program, the prop will be reset, rendering the download (if only to hub) lost.

    Without inverting the DTR (or RTS) downloading of code may work, but what happens if you switch to such a Terminal program if the reset occurs on the wrong edge? You will get the reset when the Terminal opens the COM port, so you can't work with that terminal. Normally the reset occurs when the terminal is closed, what is still a bit annoying but works.

    Andy
  • David CarrierDavid Carrier Posts: 294
    edited 2012-06-26 10:14
    I can confirm that the capacitive coupling is there because some serial port controllers would assert DTR when the port wasn't open. I don't believe that the it was Windows itself that was causing the problem, because it didn't happen on every computer, but it may have been the default operation for either a driver or the controller itself. It may be possible to forgo the capacitive coupling on the FT232R USB to serial converters and have it still work on every computer, because they would all be using the same serial controller and essentially the same drivers. I haven't tried it out, so I don't know what the FT232R does with the DTR pin when the port isn't open.

    — David Carrier
    Parallax Inc.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-06-26 16:18
    On a real RS232 port the DTR will be resting at a negative voltage, say minus 12V. When you turn on the port, it should still stay at minus 12V.

    Or course, if you turn on a computer, the DTR will go from 0V to -12V and if you reset on the negative going edge that will cause a reset to the board.

    Andy's point about resetting when opening or closing a program is valid. Who knows what program is going to do what though.

    My experience is that for about a year I built boards that reset on the negative edge, then for about a year I built boards that reset on the positive edge and I didn't really notice any difference. I think the edge you use is a bit of a red herring.

    Also, changing the timing delay in the proptool makes no difference and does not fix the problem for cheap USB cables.

    I think Andy in post #9 has the answer - it is the way the data is buffered. The answer to this whole question would be to ask how it was solved in software that we know works, like PZST.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-06-27 16:57
    Just to follow up with some more experiments.

    Jazzed's IDE works out of the box for *all* the USB to serial adapters I have, including a $15 FT232 one and several unknown chipset $2 ones.

    No need to change any settings in the software. Tested with both small programs direct to ram and ones over 32k that involved a preloader and being written to the SD card.

    So if Jazzed can get Spin working on the IDE then the problem is solved :)
Sign In or Register to comment.