Pulsin, Pulsout, and count. Totally lost

shon242

New Member
Hi all,

I am trying to send and receive a pulse using two picaxe chips and I am totally lost.

I have no way of actually measuring the pulse, so I am wondering if there is a formula that I can use?

I tried using debug in the picaxe editor but nothing happens. Then again I have never used debug before so I am not sure on the exact operation.

My main question is how to figure out what number pulsout is?

Is the pulsout number the same as pulsin?



here is my code for the pulse out

Code:
high PulseOut
do
	
pulsout PulseOut, 150
pause 200

loop
and for my pulse in

Code:
do
		
		let w13 = 0
		Pulsin PulseIn,1,w13
	
		if w13 = 150 then
			goto PulseActivated
		else
			restart 2
	endif
	loop
I have read the manual and it is very vague and does not answer my questions?

Can anyone point me in the right direction?
 

erco

Senior Member
Yes, they have the same units (10 uS at 4 MHz). But there is some measurement variation from chip to chip. Your pulsout 150 may not be measured exactly at 150 by another Picaxe with pulsing. You're only looking for exactly 150, so suggest you measure and display the pulsing to see what the chip sees.

do
pulsin pin,1,w13
sertxd(#w13,13,10)
loop

You may need to specify a small range if it varies much. Are the Picaxes connected directly together? If you are using IR or some other roundabout circuit connection, that may introduce errors too.
 

AllyCat

Senior Member
Hi,

You have started with a High Pulsout so the pulse generated will be negative-going (from manual 2 : "Output a timed pulse by inverting a pin for some time"). However, your Pulsin is for a postive-going pulse (from Manual 2: "If state = 1 then a low to high transition starts the timing"). It's also dangerous to use a "reserved" word as a variable/constant.

Pulsin polls the pin once every 10 us, so even if the transmitted pulse were exactly 1500 us, then even the tinyest error can make pulsin return 149 or 151. In practice the clocks may not be perfectly accurate so your code should tolerate a range of at least 149 to 151 and preferably more.

As erco shows above, when debugging situations like this, the best method is to use sertxd to report what is actually being receiverd.

Cheers, Alan.
 

shon242

New Member
Yes, they have the same units (10 uS at 4 MHz). But there is some measurement variation from chip to chip. Your pulsout 150 may not be measured exactly at 150 by another Picaxe with pulsing. You're only looking for exactly 150, so suggest you measure and display the pulsing to see what the chip sees.

do
pulsin pin,1,w13
sertxd(#w13,13,10)
loop

You may need to specify a small range if it varies much. Are the Picaxes connected directly together? If you are using IR or some other roundabout circuit connection, that may introduce errors too.



Thank you many times. I can see the pulses with sertxd. It wont be a problem to calibrate it.

I using cat6 twisted pair cabling for my project. I do not have max length, but I have 1k ft of it so I will see how it preforms. Any ideas on distance limitation?
 

shon242

New Member
Hi,

You have started with a High Pulsout so the pulse generated will be negative-going (from manual 2 : "Output a timed pulse by inverting a pin for some time"). However, your Pulsin is for a postive-going pulse (from Manual 2: "If state = 1 then a low to high transition starts the timing"). It's also dangerous to use a "reserved" word as a variable/constant.

Pulsin polls the pin once every 10 us, so even if the transmitted pulse were exactly 1500 us, then even the tinyest error can make pulsin return 149 or 151. In practice the clocks may not be perfectly accurate so your code should tolerate a range of at least 149 to 151 and preferably more.

As erco shows above, when debugging situations like this, the best method is to use sertxd to report what is actually being receiverd.

Cheers, Alan.


Thank you for helping me. I have made the adjustments in my code. I am getting positive numbers now.

I am also going to change my var.

Thanks again.
 

erco

Senior Member
XLNT. Please test it and let us know what range you achieve. 1000 feet of cable might introduce some new variables. And 1000 straight feet versus 1000 feet coiled on a spool for testing might be very different.
 

AllyCat

Senior Member
Hi,

Yes, do tell us if it works. ;)

The "official" maximum run (for CAT5 cable) is 100 metres (330 feet) but that is for higher frequencies than you are using.

The characteristic impedance is about 100 ohms, so normally you should terminate with a series 100 ohm resistor at the transmit end and a parallel 100 ohms at the receive end (or use baluns at both ends). The dc (loop) resistance of 1000 feet is about 60 ohms, so this should work with the "TTL" threshold levels of a PICaxe input (series resistor on the "high" side).

However, the transit time is not much over 1 us for 1000 feet of cable, so even two (unterminated) reflections are unlikely to significantly affect the width of a pulse being timed to only 10 us resolution. But it may depend how you are connecting or using the other 6 conductors in the CAT5 cable.

Cheers, Alan.
 

srnet

Senior Member
The "official" maximum run (for CAT5 cable) is 100 metres (330 feet)
For a 'cable' to adhere to the CAT5 specification that is so, although strickly speaking the limit is 90M for the fixed premise cable (solid core normally) and allowing 5M for patch cables (multi stranded core normally) at either end.

100M is the limit for 100Mbs and 1Gbs Ethernet, over CAT5.

At lower frequncies, such as with 10Mbs Ethernet CAT5 is good to, and will pass the cable tests for, circa 170M.

A figure I always have in mind is that the propagation delay of most cables is 198M per microsecond.
 

shon242

New Member
XLNT. Please test it and let us know what range you achieve. 1000 feet of cable might introduce some new variables. And 1000 straight feet versus 1000 feet coiled on a spool for testing might be very different.
Will do.

Thought I had 1000 ft but it was only 424 ft :(.

I tested with jumpers and got a range of 3900 to 4100. Stripped one of the pairs from the cat6, coiled in box, 424ft and got the same range.

I need cable anyway so I will grab a box and try that.

I spend most of my hours in a 20 story building as telecom technician so I have access to the buildings telecom distribution wiring. I'll hook one end in the basement and see how far it goes. Distribution wiring is 100 pair cat3 though, old building, but we will see.

Have a good one.
 
Top