08M2 used to monitor data on an input pin ???

OLDmarty

Senior Member
Hi All,

I want to monitor the presence (or lack of) the Serial IN data when a pic is being programmed in my test jig.

I plan to use an 08M2 to monitor what the SER IN pin on the "MAIN" picaxe chip is doing and then have the 08M2 flash a LED to indicate the main device is currently being programmed.
It's more of a visual indicator to remind me not to pull the chip out of the ZIF socket, or turn off the power etc etc.

In the past (long ago) i used to use 74123 or 4528 monostables to detect serial com port data to trigger the monostable to flash a LED, (a type of pulse stretching arrangement) which simply acted as a "data present" indicator.

Now i'm trying to replicate the same thing with a picaxe as the 08m2 is smaller than the older chips and needs no R's or C's etc. ;-)


Looking at my VERY simple code below, would this actually work? or do i need to re-arrange the way i monitor the input pin?

I know i shouldn't use pauses, so i think i need to gosub to a procedure that's probably a "for..next" counter to act as the delay for the LED
( The delay time isn't too critical, as long as it's long enough to flash a LED to be easily seen ).

I'm hoping there's a fast & reliable way to do this without missing too many captures of the incoming data pulses, hence me setting the FREQ to it's highest speed?



Code:
#Picaxe 08M2

; set FREQ to highest speed?
; obviously ports/bits configured as INs and OUTs as needed.


Do

	IF pinC.1 <> 0 THEN	'If pin is NOT 0, then there must be activity (data/voltage present) 
        High PinC.2		'Turn a LED ON, on pinC.2
	pause 100		'Keep LED ON at least 100mSecs so it's visible.
	Else			'otherwise.....
	Low PinC.2		'Turn a LED OFF, on pinC.2
	Pause 100		'Keep LED OFF at least 100mSecs so it's visible.
	End if
      
Loop				'Keep monitoring for activity on PinA.0 and repeat.
 

hippy

Technical Support
Staff member
You might find that just putting a LED+R on Serial In is good enough.

Otherwise your code looks fine to me, and will give a 'more solid' LED indication than just a LED as above. You might want to tweak the PAUSE periods to get it how you like it and SETFREQ 'as fast as possible' will help.

By using SFR tricks you can monitor and latch rising edges of the serial stream so you don't miss things or end up always sampling when the stream happens to be low but that is probably not necessary in this application.
 

OLDmarty

Senior Member
Thanx Hippy, and yes, the LED+R on the serial line flickers too much or almost on/faintly (just like when i used to monitor RS232 comms, hence the mosostable time-stretching to pulse a LED continously during data received).

Additionally, i didn't want the run a LED+R direct on the SER pin, juts in case the LED was robbing current and interfering the serial data arriving.
I figured hanging a separate pic direct on the serial line would not have an affect on corrupting the data.

I definately don't need the LED to track every single toggle of Data on the SER pin, but the LED can flash at it's own rate when a series of pulses starts arriving on the SER pin, simply to show activity.
Yes, my pauses might reduce to 50mS or even 10mS, something i'll tinker with when it's up & running.

Thanx again.
 

wapo54001

Senior Member
In my programmer, I use the serial in data stream to both turn on an LED to show programming is active AND apply power to the chip being programmed followed by turning power off within two seconds of when programming is complete. Works a charm. Cannot upload schematic, picture, or diagram because the website times out whenever I try to upload anything. I use three 08M2 pins to provide the power for programming.
 

Flenser

Senior Member
the website times out whenever I try to upload anything
I had the same problem trying to upload the picture of a circuit that was a 72.8kB jpg.
Shrinking the size of the picture to produce a smaller 29.1 kB jpg file worked for me.
 
Top