08M2 - No reset pin???

OLDmarty

Senior Member
Hi All,

I was playing with an 08M2 recently, then it dawned on me that there's no external reset pin.

I intend to use the serial pins (C.0 & C.5) for a project (using up all 6 I/O lines)

If i program the chip with some code running on all 6 pins, *will* i still be able to program it later on?
I'm assuming the chip will need a power-cycle during the programming phase, and "sneak in" before my program begins. Correct????

Do i need to set a small delay at the beginning of my program to allow a wider window for the programmer to handshake and program my chip?

with thanx
Marty.
 

hippy

Senior Member
Yes, all 6 pins of the 08M2 can be used for user I/O.

It is not necessary to add a delay at the start of the program but this can make it easier to apply the Hard Reset procedure, widens the window during which time a new download can be accepted.
 

AllyCat

Senior Member
Hi,

The "Programming" input pin (C.5) is effectively a "Reset" pin, so that is the most appropriate to use if a Reset facility is required. But if you disable it with a software DISCONNECT command (to use the pin for another purpose) then as hippy says, you must use the "Hard Reset" procedure when reprogramming the chip.

Cheers, Alan.
 

hippy

Senior Member
I intend to use the serial pins (C.0 & C.5) for a project (using up all 6 I/O lines)
One thing to bear in mind is that the Serial In pin (C.5) needs to be pulled low at power-up for the PICAXE to begin executing its program and, when used as an extra I/O line, it is intended to be used with a normally-open push button which connects to V+ ...

http://www.picaxe.com/FAQs/Interfacing/#q9

If wanting to drive C.5 from a digital high-low signal or active-low push button you will need to ensure the signal is kept low until PICAXE program execution has started.
 

erco

Senior Member
Interesting, I have wondered if it's possible to use a 38 kHz IR receiver on the Serin pin. It's a normally high device though, so that would probably cause problems if Serin must be held low on powerup. Maybe there's a workable combo of high-value pulldown resistor on the pin and an RC filter to the IR receiver Vin that would keep it low enough long enough on powerup.
 

hippy

Senior Member
Interesting, I have wondered if it's possible to use a 38 kHz IR receiver on the Serin pin.
Possibly, though on the understanding neither I nor Rev-Ed can take any responsibility for any hardware damage which might arise during experimentation.

IR receivers are open collector so it doesn't matter if the signal is pulled low at start-up. You may be able to rely on a 'set low by default' output to hold the Serial In low at power-on ...

Code:
                ___
       .-------|___|-------.
  _    |                   |
 | |   |    |          |   |
(| |---^--->| SI   C.0 |---'
 |_|        |          |
Code:
PowerOnReset:
  Disconnect
  High C.0
MainLoop:
  IrIn C.5, b0
Some IR receivers actually include a weak pull-up so it might not be that simple.
 

Buzby

Senior Member
... You may be able to rely on a 'set low by default' output to hold the Serial In low at power-on ...
I thought all the PICAXE pins were set to 'input' by default, and could only be changed to 'output' after the chip had started to run the user code, i.e. after the first 'look for programming' phase.

Or have I misunderstood something ?

Cheers,

Buzby
 

pxgator

Senior Member
I think that the sertxd pin or C.0 for a 08M2 automagically
defaults to an output..?? Anyway just using the 'high' command
will set the pin to output.

Cheers to All
 

erco

Senior Member
Some IR receivers actually include a weak pull-up so it might not be that simple.
Yes, 100% do from my experience. I've never needed to add a pullup resistor to any of the 38 khz receivers I've used.
 

AllyCat

Senior Member
Hi,

I thought all the PICAXE pins were set to 'input' by default,
I think there's one exception, C.0 which must be an output during programming and I suspect remains a Low Output afterwards. ;)

The way I would implement erco's idea is to increase the "22k" programming resistor to about 100k and connect the IR receiver directly to the C.5 pin (or via a diode so that it can only "pull-down" if it does have an internal pullup). Of course you will need to ensure that it doesn't detect any IR during programming.

To "enable" the IR input detection, issue a DISCONNECT and then a POKESFR WPUA,32 to enable the internal weak pullup (the PICaxe Editor won't allow you to use PULLUP 32). Now the input can go High and the IR receiver pull it Low when appropraite. Exactly the same code should work also with a 14M2 or 20M2.

Cheers, Alan.

PS: symbol WPUA = $8C ; for M2s
 

erco

Senior Member
Nice, Alan. Will add this to my to-do list after I finish my massive current project.
 

oracacle

Senior Member
I did a project not long back the involved send simple pulses at start up. The pulses were sent from other 08m2s along a chain of 08m2s and a fairly sizeable pause was needed to ensure that all of them had passed the start up period before the pulses were sent.
As it turns out each one had a slightly different start up time which had to be taken into account and something that you may need to bare in mind when setting the pause at the start of your programme
 
Hi,



I think there's one exception, C.0 which must be an output during programming and I suspect remains a Low Output afterwards. ;)

The way I would implement erco's idea is to increase the "22k" programming resistor to about 100k and connect the IR receiver directly to the C.5 pin (or via a diode so that it can only "pull-down" if it does have an internal pullup). Of course you will need to ensure that it doesn't detect any IR during programming.

To "enable" the IR input detection, issue a DISCONNECT and then a POKESFR WPUA,32 to enable the internal weak pullup (the PICaxe Editor won't allow you to use PULLUP 32). Now the input can go High and the IR receiver pull it Low when appropraite. Exactly the same code should work also with a 14M2 or 20M2.

Cheers, Alan.

PS: symbol WPUA = $8C ; for M2s
Hello,

I wonder how to cancel this command:
symbol WPUA = $8C ; for M2s

to put the chip into its default setting. Thank you for reply.
 

hippy

Senior Member
I wonder how to cancel this command:
symbol WPUA = $8C ; for M2s

to put the chip into its default setting.
That is not a command as such but the value used with one. Just don't include any "POKESFR WPUA" commands and the pull-ups won't be enabled or altered, and the chip will remain its default state.
 
Thank you for explaining it to me. I thought that this value is permanently written into the register and has to be cleared somehow. Now it is clear.
 
Because I want to use serial-in c.5 at PICAXE 08M2 as an input for IR, I experimented and it worked. The IR circuit is the same as here:
http://www.picaxe.com/Circuit-Creator/Sensors/Infra-red-Sensor/

The test code is here:
Code:
#no_data
disconnect
symbol WPUA = $8C
POKESFR WPUA,32
 
do

 irin [100], C.5, b4
  debug
  pause 500
loop
There still was a problem with download. I left the two resistors 10k + 22k that are connected to c.5 pin as they were and add another 100k resistor between pin c.5 and ground. The download still did not work. So I put one more resistor 4k7 betwen output of IR circuit and pin c.5 as described here:
http://www.picaxeforum.co.uk/showthread.php?29108-Picaxe-08m2-input-pin-c-5-issue
post #4, and everything worked without problem. Now the small robot can use even pin c.5. Maybe it comes handy for others as well.

Here is a quick circuit diagram
infra_New.jpg
 
Last edited:
I am at a loss. I tried simple program see below.
Code:
#no_data

disconnect
symbol WPUA = $8C
POKESFR WPUA,32

low c.1
low c.0
low c.2
low c.4
do

 irin [100], C.5, b4
  ;debug
  ;pause 500
  
  select b4
    case 16
      gosub led_on
    case 20
      gosub led_off    
  endselect
loop

led_on:
high c.2
return

led_off:
low c.2
return
It works only with the programming cable connected. When I disconnet the programming cable and switch power off and then on, it does not work. When I connect the programming cable again, it works. Now I really do not know what to do. Can anyone advice?
 

hippy

Senior Member
The problem is that are using an IR TSOP which has a normally high output ( no IR present ). This will hold the PICAXE in a 'waiting for download' state and prevent the PICAXE from running and downloading.

You are then trying to fudge things so that doesn't happen, so the download cable can override the IR TSOP, but the IR TSOP can still work. That is incredibly tricky and unreliable, relies on just the right component values which may vary enough to have things work some times but not others.

You may be better off with some other arrangement such as below. But the recommendation would be to not connect IR to the download serial in as any IR could corrupt a download, or to replace the diode with a link so that can be removed while downloading -

Code:
               _ _
           _    |
          | |---'              |
      IR (| |--------|<|---.-->| Serial In
          |_|---.          |   |
               _|_         |
                     ___   |
Download )------.---|___|--'
               .|.
               |_|
               _|_
 
Thank you very much Hippy. The diode did the trick. Now it works even with the programming cable disconnected. I attached a new circuit diagram, hoping the final one. I removed added resistor 100k and 4k7. The downloading circuit is now exact as in the manual (default wiring). But it will be safer to add jumper between the diode and the IR sensor.infra_New_final.jpg
 

AllyCat

Senior Member
Hi,

Reading through the whole thread, it appears that the IR detector does have an internal pullup, so hippy's diagram above is correct and my instructions from above become:

"The way I would implement erco's idea is to increase the "22k" programming resistor to about 100k [NOT add an additional resistor] and connect the IR receiver directly to the C.5 pin via a diode so that it can only "pull-down" (i.e. anode to C.5). Of course you will need to ensure that it doesn't detect any IR during programming.

To enable the IR input detection, issue a DISCONNECT command and then a POKESFR WPUA,32 to enable the internal weak pullup.
"

Additionally, if you wish to disable the IR detector again (to allow for re-programming without the need to use a Hard Reset), then the program can include a POKESFR WPUA,0 followed by a RECONNECT command (as many times as you wish).

Cheers, Alan.
 
Hi,

I use IR sensor TSOP34836 as can be seen in my circuit diagram. This TSOP34836 has output active low according to the datasheet. I did not use 100k resistor instead of 22k and program download works. I had to include one more line : symbol WPUA = $8C, see my test program before. Otherwise there is a syntax error. So far so good. Everything works and I am happy.
 

AllyCat

Senior Member
Hi,

I did not use 100k resistor instead of 22k and program download works...... Everything works and I am happy.
Maybe, but will it still work on another day (when the battery voltage or temperature might be different) or with a different PICaxe chip?

The issue is that the PIC internal pullup resistors can have an enormously large variation of resistance (more than a factor of 10 : 1 according to the data sheet), so it's quite possible that the resistance in another chip (or on another day) may be insufficient to overcome the current through the 22k pulldown resistor. Actually, even a value as high as 100k could be slightly "marginal", but some aspects of the Microchip data sheets are known to be overly "pessimistic" in practice.

Cheers, Alan.
 

hippy

Senior Member
The issue is that the PIC internal pullup resistors can have an enormously large variation of resistance (more than a factor of 10 : 1 according to the data sheet)
For the 08M2 the effective weak pull-up resistance is notionally about 34K but could go all the way up to 200K. Increasing the download 22K as suggested will give more guaranteed reliability against greater divergence from the notional value.

The 10K download pull-down is just to keep the input from floating when the cable is disconnected so it might be best to adjust that rather then the 22K, or adjust both. Maybe 56K for both ?
 
Hello,
I am trying this code:
Code:
#no_data

disconnect
symbol WPUA = $8C
POKESFR WPUA,32

do
irin C.5, b4
sertxd ("code = ",#b4,13,10)
pause 500
loop
I have IR sensor at c.5 pin with a diode as in the post #21 and both resistors 56k. But when I run this code and open the terminal window, it shows nothing. When I try to run motors, it works. But sertxd shows nothing. Can somebody advice where the problem is?
 
Last edited:

hippy

Senior Member
I have IR sensor at c.5 pin with a diode as in the post #21 and both resistors 56k. But when I run this code and open the terminal window, it shows nothing. When I try to run motors, it works. But sertxd shows nothing. Can somebody advice where the problem is?
It's not clear which circuit you are using or what you mean about running motors. I'm not sure the circuit in post 21 will work with the pull-up.
 
IR sensor is wired like this:
infra_New_final.jpg

When I connect motors to c.1 and c.2, I can control them with this IR sensor. It works fine. But when I use the above mentioned code (motors are not connected), the sertxd ("code = ",#b4,13,10) shows nothing in the terminal window.
 

hippy

Senior Member
When I connect motors to c.1 and c.2, I can control them with this IR sensor. It works fine. But when I use the above mentioned code (motors are not connected), the sertxd ("code = ",#b4,13,10) shows nothing in the terminal window.
And you have your IR in sensor connected as shown when controlling motors ?

If that works, I am guessing the code in Post #23 is effectively the same code but with 'doing something', driving the motors, once the IR is received has been taken out, replaced with SERTXD.

Plugging an AXE027 or other serial cable in will pull the Download Serial In down towards 0V so it may be that which is preventing the PICAXE from seeing the IR sensor output. You might have to build an adapter so the cable passes Serial Out but doesn't pass Serial In.
 
Thank you for help. I can use a jumper to disconnect and reconnect pin 2 in the programming cable or a small adapter, with wires at pin 1 and pin 3 only, between the programming socket and the programming cable
 
Top