Pulsein

I am making a light gate to measure the time it takes a card to pass through it for physics experiments does anyone know how to over come the limitation of pulsin timing out every .6 seconds which will miss a proportion of readings.
 

hippy

Ex-Staff (retired)
Under-clocking would be the most obvious answer - Running at 2MHz would extend the maximum before timeout to 1.2 seconds, but resolution drops to 20uS, that probably isn't a problem for longer times.

The timeout can be extended further by running even slower.

The 18A, 18X and 08M are best for this as the operating speed can be changed programmatically ( drop down to desired speed before the PULSIN, then back to normal execution speed afterwards ). An 08M could be used as a pulse measuring front-end for PICAXE's with a crystal, capturing the pulse time, then sending it to the main PICAXE using SEROUT.
 

flyingnunrt

Senior Member
Need more info or some sample code please for underclocking an 18x to m2 or even m1
All I get is "unknown symbol" error
 

hippy

Ex-Staff (retired)
The trick is to POKE to the OSCCON register at SFR address $8F; the SETFREQ command doesn't support M2 or M1 as you've discovered.

The mechanism is described for the 08M here ...

http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=2262

and should be the same for the 18X.

Note the caveat from Technical, that this technique is not recommended for the 18A, and presumably not for the 18X or 08M either ...

http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=467
 

flyingnunrt

Senior Member
If I underclocked by poking the oscon register and then at some stage did powerdown during use etc., and locked the picaxe into m1 mode, could the picaxe still be programed by the program editor, acepting the fact that it will still be in m1 mode?
ie. still have a programmable 1Mhz 18x chip.
 

hippy

Ex-Staff (retired)
When the PICAXE is reset, its internals are initialised to default setting, and the first job of the Firmware is to to adjust internal settings to what they must be for normal operation. Therefore the PICAXE shouldn't get locked into any mode other than its default of 4MHz operation. In the worse case, it would be necessary to power off the PICAXE and turn it back on to force a hard power-on reset. On an 18-series, pulling the Reset/MCLR input low should do the same, but it is possible that the PICAXE handles this event differently to a power-cycling.

The caveat from Tehnical may be more precautionary than anything else, and I've had no such problem when I've experimented with under-clocking. Providing you are prepared to accept such a risk associated with underclocking ( a very minimal risk, IMHO ), you shouldn't have any problem.

Most manufacturers have to protect themselves from users doing things with their products which they aren't designed for and then complaining and demanding replacements if something consequently breaks, so such caveats are common place. I cite such caveats when I know of them, so I don't blamed either if it goes wrong :)
 
Top