Constraints of Picaxe ICSP Programming?

zorgloub

Member
Hi Everybody,
Generally speaking, I would like to place an ICSP connector (jack2.5mm or Molex 3pin + the two usual resistances of 22K and 10K)) on my boards using a Picaxe.
This is to avoid having to remove the picaxe each time in the event of (re) programming.
Has there ever been a discussion or pattern on this?
Indeed, I suppose that during (re) programming, it would be necessary to disconnect the power supply from the rest of the circuit of the board as well as any connections to components which would be connected to the TX and RX pins of the Picaxe.

Indeed, when I use the small 08M2s, I then use the TX output as a normal digital output but also the RX input as an auxiliary input, as explained here:

Thanks...
 
Last edited:

AllyCat

Senior Member
Hi,

IMHO In-Circuit-Programming is the "normal" way of working with a PICaxe ! Sometimes the 3.5mm jack is considered too large and/or unnecessary for a "finished" project, so the "Legacy" 3 header pins (e.g. Molex) can use less board-space, or even just 3 Pads/tracks used with "Pogo Pins". Even the two pull-down resistors are partially unnecessary, I suggest a single 100k, which can remain in place whilst the normal 10k + 22k are included on an external "Programming Cable" / Interface.

Generally, it's NOT necessary to disconnect the application circuit, the main exception being if the SerOut pin is being used for a major control signal such as a motor or relay driver (because that pin is used for "handshake/verification" during programming). Nearly all the other pins will remain as inputs or tri-state (outputs) during programming, so it's only necessary to provide pull-down resistors where "floating" outputs might be an issue, for example MOSFET Gate inputs.

As I often point out on the forum, it's not just a "Programming" Interface, it's also a DEBUGGING interface (i.e. using DEBUG and/or SERTXD commands, etc.).

Cheers, Alan.
 

zorgloub

Member
Hi Alan,
We had already had the opportunity to discuss as part of the post cited above. (in AUX 08M2)
I try a diagram, which I submit to you for opinion, but I think that the resistor R19 / 10K is superfluous since the R22 / 10K is on the programming interface (?).
I imagine that it will take a jumper (or "stop" diode) to isolate the TX output from the rest of the circuit during (re) programming?

What is the need to keep this 100K resistor out of the programming?

thank you.24664
 
Last edited:

inglewoodpete

Senior Member
I try a diagram, which I submit to you for opinion, but I think that the resistor R19 / 10K is superfluous since the R22 / 10K is on the programming interface (?).
I imagine that it will take a jumper (or "stop" diode) to isolate the TX output from the rest of the circuit during (re) programming?

What is the need to keep this 100K resistor out of the programming?

thank you.View attachment 24664
R19 / 10k is not superfluous. The input pin MUST be pulled low during boot-up, even if your program's first command is "Disconnect".

It would be better to have pin C.5 normally pulled low, even if you have to use a transistor to as an inverter for the run-time input. Otherwise, use a jumper link. 100k in series with the programming pin is likely to cause problems when programming the PICAXE

Similarly, when designing a circuit, try to have pin C.0 drive a non-mechanical device like an LED rather than a relay, solenoid or motor. Mechanical load devices on C.0 can cause problems when programming the chip.
 

AllyCat

Senior Member
Hi,

As IWP indicates, R19 = 10k is actually "Wrong" because it forms a voltage divider with R21 (22k) and will block the programming voltage. R19 should be around 100k and then RX might be any suitable value (from zero ohms upwards), depending on the "AUX" input (level/impedance) and if you want the AUX input to be functional when the programming cable is connected.

If the circuit attached to the TX pin will be "Damaged" by Logic Levels during programming, then yes you must use a "switch", such as a jumper, to block the signals (and a diode is NOT likely to do this). But it's much better to choose something else for the function of the TX pin (such as a LED), or there are various "tricks" to put several functions on another pin, and/or to use c.0 as an input or c.3 and even c.5 as "outputs".

Cheers, Alan.
 

zorgloub

Member
Thanks already for your interventions.

OK Alan, I have now seen and understood where to place the 100K pull-down resistor you were talking about.
I was mistakenly seeing it in series with the RX input.

1_ Why 100K when the original interface only offers R10K?

2_ With this 100K resistor included on the circuit, is the usual 10K pull-down resistor from the removable programming interface still needed?
I assume that the 22K series resistor of this interface is still needed as a serial "protection".

3_ The AUX input does not have to be functional during (re)programming, but obviously it is functional during normal use of the circuit.
The serial Rx of my previous diagram does not seem necessary (especially if the serial R22K of the programming interface is there).

4_ Any idea of the internal PullUp value of the 08M2?

5_ I read that it would be possible, with various "tricks" to modify the DIRections in/out of the pins (C.0 in input and C.3/C.5 in output)?
Would you have already made a Post on these tricks? I am interested and curious ... thanks already!

6_ I corrected the schematic. OK as is?

Thanks24665
 

AllyCat

Senior Member
Hi,

1. The (total) "original" pull-down resistance is 32k, i.e. 10k + 22k. But a higher value is better because of the other tricks we're doing (e.g. using the internal pullup resistor). Also you must NOT put a 10k on the PICaxe side of the 22k because it attenuates the drive voltage to 10k / 32k = 31%. With 100k you still get 100k / 122k = 82% on the input pin, which should be sufficient.
2. Yes a series resistor of around 22k is required somewhere between the (USB) Programming Adapter and the PICaxe Serial Input pin for protection (current-limiting).
3. The selection (value) and position of the resistors will determine whether you must unplug the Adapter before the AUX input will work correctly. With well-chosen values it should work whether the adapter is plugged in, or not.
4. The nominal internal Pullup resistance is about 35k, but the data sheet implies it might be as high as 200k. But I doubt if it would ever be above 100k in practice.
5. The "inputs" can be used as "weak outputs" (e.g. to drive a transistor base of FET gate) by activating the internal Weak Pullup resistors. C.0 is a reasonably "normal" I/O pin, so its "direction" (i.e. Input or Output) can be changed (using the DIRS command). Also, C.0 is the (High Impedance) DAC (Digital To Analogue Converter) output which can be read by the READDAC command.
6. Yes that should work, provided that R23 is not too low (say > 220 ohms).

Cheers, Alan.
 

zorgloub

Member
Thank you Alan for your well-structured answers.

One last little clarification though, regarding the Disconnect command.
I read in the manuals: "PICAXEs very frequently observe the serial download port in case a computer tries to start downloading a new program.
However, if you want to use this port to do serial communications (using the serRXD command), it is necessary to disable this periodic check. "

Does picaxe thus consider that there is a download request when the Rx port is in the HIGH or LOW state?
Indeed, I have a doubt because with this 100K resistor at the input of Rx, it forms a divider bridge with the internal pullUp of the order of 100K and we end up, in normal operation, with a voltage close to Vcc/2 on C.5(RX). In other words, a HIGH state.
I would therefore say that there is a request to download a new program in the case where Rx is LOW!

So, when does the Picaxe consider that there is a request to download a new program? (Rx = High or Low?).

Thank you for your kind availability!
 

AllyCat

Senior Member
Hi,

The PICaxe serial input is "Idle Low", which is why the pull-down resistance is required when no Programming adapter is plugged in. The "Programming" request is a High (1) level, technically called "Break Signalling". That is why the Program Editor/Compiler "Refuses" to enable the internal Pullup on the RX pin (and we need to "trick" it by writing a "variable" in the command). Make sure you understand the "Hard Reset" procedure before using a DISCONNECT command!

Cheers, Alan.
 

inglewoodpete

Senior Member
The 22k series current-limiting resistor is not always required.

In the early days of the PICAXE, the most common method of connecting it to the computer for programming was via the computer's RS232 asynchronous serial port. My original kit (in 2005) included Rev-Ed's AXE026 cable, which fed the +/- 12v (or +/- 10v or +/- 5v) signal directly to the stereo plug. Voltages higher than +5v or less than 0v are likely to permanently damage the PICAXE input pin's silicon, so the 22k resistor is always included to limit the input current to a level that the pin's protection circuitry can tolerate (about 600uA).

The AXE027 cable outputs 5v logic levels (0v and 5v), which will not damage the PICAXE's internal input circuitry and the 22k resistor does not create a big enough restriction to interfere with programming . Other USB-to-serial cables are likely to output 5v logic-level data but you would need to confirm this if you use them.

Now, the big if: IF you are certain that you will never use a true RS232 cable or similar (High > 5v and/or Low < 0v), then you can dispense with the 22k resistor.
 

zorgloub

Member
The advantage of the discussions on this forum is that they often allow us to go further in our usual reflections and thus lead us to ask ourselves some additional questions!

And some of them have just popped up in my morning shower ;)

1_ It is well known that the serial input of the Picaxe (RX) must be at HIGH level for the integrated BootStrap to understand that there is a new program to download and that it then starts the internal communication/download procedure.
However, when the necessary download cable is connected, the usual R10K and R22K form a pull down which sets the RX input LOW via the R10K! Right?
Hence my astonishment and incipient incomprehension ...

2_ Regarding the procedure of "Hard Reset" to reprogram a Picaxe that would have been affected by a command DISCONNECT introduced in a previous program, here is how I proceed: I launch the loading of the program containing the instruction RECONNECT with the Editor and then I put the Picaxe under power. It seems to work every time. Is this the right way to do it?

3_ Side issue. During normal program execution, the Picaxe regularly "scans" the status of the RX pin to ensure that a new program should not be loaded.
As this pin is usually left "Up - No Connect", it is probably considered to be in the HIGH state but as there is no program to download, the Picaxe continues to process the current program.
Does this "check" take a long time in the processing loop?

Have a nice day everyone.
Thanks to all of you.
 

AllyCat

Senior Member
Hi,

Pete is technically correct and he does emphasise the IF and never , but I'm still not convinced that it's a "good" recommendation, particularly for novice users.

Firstly, it's often recommended to use a resistor in series with any pin that connects a PICaxe to "The Outside World". The "electrostatic protection" diodes inside the PICaxe can only work fully if there is some resistance in series with the pin. Of course it's not appropriate to connect a value as high as 22k in series with pins that are used as Outputs (or even for accurate ADC Inputs), but for example the "Enhanced Serial Download Circuit" (page 45 in Section 1 of the User Manual) shows 180 ohms.

Secondly, there is the possible issue of "Phantom Powering", which is quite relevant to this thread because the "Hard Reset" procedure is being discussed. If just a few volts is applied to almost any PICaxe pin without a series resistor, then there is a risk that the voltage can pass through the "protection" diode to the supply rail and keep the PICaxe running, even if the power supply is disconnected. This could defeat the Hard Reset procedure unless the supply rail is linked briefly to ground (not just "disconnected"), to discharge the decoupling capacitor(s).

Finally, I don't think that the OP's latest assumptions are entirely correct:
1. IF the Download cable (USB adapter) IS connected, then the 10k pull-down is NOT really needed (at that time) because the adapter itself provides the pull-down!
2. No, you don't need a RECONNECT command if a "new" program is being download, unless the new program itself also contains a DISCONNECT (or SERRXD) command. The advantage of the RECONNECT is that it can permit a program that does use a DISCONNECT to be "overwritten" without the need for a Hard Reset. For example putting the RECONNECT at the "end" of a program (if it doesn't contain an "infinite" Loop), or after detecting a "Reset" request within the program or on a suitable pin.
3. No, the program normally scans the pin to detect when a new Download should be started (i.e. whenever a High is detected), but the DISCONNECT instructs the program to "ignore" the High level. AFAIK, the pin is tested after every PICaxe Basic instruction (perhaps every few milliseconds), but takes only a few microseconds, or maybe less at high clock frequencies. It's just part of the general "housekeeping" for background tasks such as incrementing the "time" variable and polling for an interrupt, etc.

Cheers, Alan.
 

zorgloub

Member
Thank you for the additional information.
However you say:
"1. If the download cable (USB adapter) is connected, then the 10k pull-down is NOT really needed (at that time) because the adapter itself provides the pull-down! "

This pull-down does not set the RX input to the HIGH level which is necessary to enable the new download. OK?
However, it is a High level that is needed to download a new program.
So I don't see what causes the HIGH level when the download cable is connected?
 

AllyCat

Senior Member
Hi,

The "High" comes from the USB-Serial adapter when the Editor wants to start the "Programming" function (it generates a "Break" signal). If the adapter is not connected then there can be no program to download !
3_ ......
As this pin is usually left "Up - No Connect", it is probably considered to be in the HIGH state
No, the whole point of that design is that when power is applied to the PICaxe (IF the adapter is not connected) then the Serial Input pin MUST be low (provided that a pull-down resistor is fitted). There can be no voltage from the (disconnected) Serial Interface and even if AUX-In is "High", the voltage cannot pass (backwards) through the diode.

So, only after the Program has booted up can the Programming Input be DISCONNECTED and then the PULLUP command enables the pull-up resistor on that pin. Only then can the pin go high (if the AUX Input is High). That is why the Editor/Compiler refuses to enable the pullup resistor on that pin (with a command of the form PULLUP %xx1xxxxx), because without a DISCONNECT an incorrect program might "Shoot itself in the Foot". ;)

Cheers, Alan.
 

zorgloub

Member
Great Alan!
Everything is clear!
Thank you for your usual great availability and your patience!
Good day to all.
Best regards.
 

zorgloub

Member
Hi,
Regarding the first schematic I published in Post #3, inglewoodpete felt in his reply (in Post#4) that the R_100k in series with the programming pin is "likely to cause problems when programming the PICAXE".
In fact, I find such a scheme, Alan's scheme, with an R_Serial of 100K in Post #14 on page https://picaxeforum.co.uk/threads/using-pin-serial-in-like-normal-input-without-response-serial-output.29922/#post-335906

So, What is the best scheme to use?
The one in my Post#3 (in line with Alan's above) or the correction made in my Post#6?

Regards.
 

Attachments

lbenson

Senior Member
So, What is the best scheme to use?
I would say that the "best" scheme to use, for general utility, is as Alan has recommended--the full 10K to 0V and 22K to the programming pin. This allows you to program the PICAXE and to use it for debugging and doesn't run the risk that your program is never going to run because it's always looking for the download to begin.

The cost, on all my PCBs and breadboards, is a 3-pin header and the two resistors--in place of the single resistor (value 10K to 100K) to 0V which you must have to prevent the PICAXE firmware from continually looking for a download.
 

AllyCat

Senior Member
Hi,
100k in series with the programming pin is likely to cause problems when programming the PICAXE
IWP wrote "in series with" the Programming input, but we are discussing the Pull-Down resistance. IMHO, in practice it probably would program successfully through 100k (if that is all that's connected to the PICaxe programming input) but nobody (except in post #3) has suggested using that. And I'm not the only person to suggest a 100k pull-down for typical use, for example Westaust55 in post #5 HERE. Remember that the "normal" pull-down (with the programming cable removed) is not 10k it's 32k !

But the main point here is that my design referenced above has a special feature that the PICaxe can boot up even if the AUX In pin is HIGH (because the diode isolates it from the pin), although I don't know if the OP needs that feature. (Actually, in the form shown, a Low on the AUX input will probably prevent programming, but that can be worked around if necessary.) Then to allow the PICaxe to read a "1" (when appropriate), the PICaxe's internal Weak Pullup resistor must be able to lift the pin to higher than the Logic threshold level (i.e. around 1.5 v). That is rather "marginal" with 22k pulled down to ground by the programming adapter, because the WPU resistor is about 35k. And in the "worst case" it might be higher (maybe much higher according to the Microchip data sheet), therefore 100k is the minimum recommended value for that particular application.

Cheers, Alan.
 

neiltechspec

Senior Member
I only ever program using TTL levels, NOT rs232, so don't use any kind of potential divider.
I tend to use anything between 10k & 47k for pull down, depends on what I have to hand.

90% of my projects have included header pins for RX,TX & Gnd for programing in circuit.
 

lbenson

Senior Member
In fact, Alan stated in his Post#4 on https://picaxeforum.co.uk/threads/using-pin-serial-in-like-normal-input-without-response-serial-output.29922/#post-335906

"Firstly, the programming signal (which must remain low at all times except when actually programming) needs to be connected to the programming input by a much higher resistance than the usual 22k (say 100k or more). "

That was the reason for my first diagram.

So I'm still in doubt...
You omitted what Alan said (in post #7) immediately before the sentence you quoted: "I do have a method to allow the PICaxe to gate a logic signal onto the serial input pin, without the need for another pin, but it's quite an "advanced" method". (I looked it up because standing alone, what you quoted didn't make much sense for the typical case--and Alan always makes sense.)

It's unclear that this is what you intend to do--if not, what you quoted wouldn't apply. In fact, it's unclear that you wish to do anything at all which cannot be done with the usual 10K and 22K programming/debugging interface. What exactly is it that you intend to do that requires you not to use this?
 

zorgloub

Member
Hi Ibenson,
All my reflections go indeed further than simply programming and using "normally" a Picaxe 08M2 with the classic interface including the two famous resistors of 10K and 22K well known by all.
My reflections are in fact in line with the Post initiated, and brilliantly fed by Alan, at the address indicated in my previous Posts and which allows to use the Serin-RX input as an Auxiliary input in order to increase the capacities of this marvellous little 08M2.
It is indeed a pity to "lose" this available input after the programming has been done.
My initial question was therefore to have a practical ICSP connector on a board that would allow the programming input to be used as a normal digital input afterwards.
 

rq3

Senior Member
Hi Ibenson,
All my reflections go indeed further than simply programming and using "normally" a Picaxe 08M2 with the classic interface including the two famous resistors of 10K and 22K well known by all.
My reflections are in fact in line with the Post initiated, and brilliantly fed by Alan, at the address indicated in my previous Posts and which allows to use the Serin-RX input as an Auxiliary input in order to increase the capacities of this marvellous little 08M2.
It is indeed a pity to "lose" this available input after the programming has been done.
My initial question was therefore to have a practical ICSP connector on a board that would allow the programming input to be used as a normal digital input afterwards.
I went through this exercise a number of years ago. The 10k/22k input circuit was based upon the original RS-232 spec of +/-25 volts and the capabilities of the Microchip silicon (in particular the input protection diodes) at the time. The current Picaxe inputs are all CMOS with a very high impedance (in most cases). As Alan has repetitively indicated, almost any pulldown on the Serin pin will serve the function it needs to. The higher the resistance, the greater the sensitivity to noise, etc.

Only the designer of the circuit can determine when protection from the outside world is "good enough". If you need the Serin pin as a general purpose digital input, you will need to determine the maximum fanout of the driver (CMOS, TTL, ECL, Schmitt), and decide on what the value of the required pulldown on the Serin pin will be. I can't think of any logic family that can't drive one 10K load, except for ECL in extreme analog circumstances.

Of course, the value of the pulldown influences the response speed of the driving and driven gates (rise and fall times). In ECL, those values were typically 600 or 50 ohms for impedance matching at radio frequency transmission rates (Gigahertz), but I suspect you won't run in to those issues on a Picaxe.
 
Last edited:

lbenson

Senior Member
All my reflections go indeed further than simply programming and using "normally" a Picaxe 08M2 with the classic interface including the two famous resistors of 10K and 22K well known by all.
Still don't know what the specific circumstances of your input to C.5 are which would make the 10K & 22K programming interface unsuitable.

For instance, with a switch from 3V3 to 1K to pinC.5, this works:
Code:
#picaxe 08M2

pause 2000
disconnect
do
  if pinC.5=1 then: high C.0: else: low C.0: endif
loop
disconnect.jpg
 

zorgloub

Member
Hi Ibenson.

Your pertinent intervention has the merit of calming my agitated neurons and makes me think of the humorous adage: "Why make it simple when you can make it complicated".

In fact, I don't have any specific application, these are didactic elucidations that can always be used for a future project.

But indeed, once the Disconnect command has been introduced, this C.5 input does seem to be able to behave like a normal input without any other tricks. ( ? )

So Alan's solution of activating the internal pull-up resistor + input diode could simply be avoided?

I'll do some tests and why not, while we're at it, see if C.0 - pin7 couldn't also be configured as an input (initially pin 7 - RA0 of the PIC12F1840 used as a platform for the Picaxe 08M2, is I/O).

Fun ...
 

zorgloub

Member
Well, a quick test shows that pin7 SerialOut-TX can also work as INPUT!

Code:
#Picaxe 08M2
DO
if pinC.0=1 then
   High C.1
  Else
   Low C.1
  Endif
LOOP
 

Attachments

Last edited:

AllyCat

Senior Member
Hi,
... once the Disconnect command has been introduced, this C.5 input does seem to be able to behave like a normal input without any other tricks. ( ? ). ......So Alan's solution of activating the internal pull-up resistor + input diode could simply be avoided?
Yes, the whole point of my circuit is that IF your AUXIN pin holds the Serin pin HIGH when power is applied then the Program NEVER starts and so the DISCONNECT is NOT executed.

Of course the "sensible" solution is to ensure that AUXIN is NOT HIGH at power up, for example a pull-down resistor with "AUXIN" as a (normally open) push-button switch to the supply rail. That's why you should ALWAYS Start with a "Requirements Specification" for a project. There is no such thing as a "Universal" design.

Cheers, Alan.
 

zorgloub

Member
Hello Alan,
Thank you for the clarification.
This little 08M2 is really a cheap and fun little chip that allows a lot of fun and exciting reflections/experiments!
Thanks also to this great Forum and its contributors!
Have a nice day.
 

lbenson

Senior Member
"Why make it simple when you can make it complicated".
I thought you might be unnecessarily getting into the weeds. Glad you have it sorted. That's interesting about pinC.0 as an input--in 16 years on the forum, I don't think I've ever seen that. (But since every other pin can be an input, and you need at least one output to keep from being an input-only box, it would take special circumstances for it to be required.)
 
Top