PULSIN on the 18M2 causing servo glitch.

AndyGadget

Senior Member
My circuit is using an 18M2 with f/w vB running at 16MHz. Programming Editor 5.5.1.

I've got a situation where I've got 2 continuous rotation servos running and a pulsein command is called every 250ms or so. The signal being monitored by PULSIN will usually produce a pulse of up to 20ms, but occasionally will not, so PULSEIN times out and returns zero. (The occasional missing pulse is expected.) Stripping the code down to minimum, when there is no pulse detected and the 164ms timeout occurs, there is a brief pause of the servos.

The firmware.txt release notes show that an issue with COUNT stops the servo timer was corrected with release D. - CORRECTED ISSUE WITH USE OF THE COUNT COMMAND STOPS BACKGROUND SERVO AND TIME OPERATING. What I'm wondering is if there's a similar issue with PULSIN on the earlier firmware as I believe PULSIN uses the same timer as COUNT. I assume if this is the case the much shorter PULSIN delay of <20ms in normal operation does not upset the servo.

Could someone (Technical?) advise on this please.

(I could easily verify this, but my 'scope throws a hissy-fit (literally - EHT breakdown) on anything but the driest days. With the weather recently . . . No chance #;¬)
 
Last edited:

inglewoodpete

Senior Member
Manual 2, Appendix 4 "Possible Conflicting Commands" says: "Note that other timing commands (e.g. count, pulsin, pulsout etc.) do not disable the interrupts, but, if active, the hardware interrupt processing time may affect the accuracy of these commands when they are processed."

While it doesn't exactly describe your situation, I would expect some potential conflict between ServoPos and PulsIn commands.
 

Goeytex

Senior Member
From experience I can tell you that pulsin will cause servo glitches. If the pulsin command happens to start & stop during the ~18ms period between servo pulses, and the input pulse is short, you may not see any problems. Sometimes a strategically placed "pause" will stop periodic glitching. However with pulsin reading long pulses or with a pulsin timeout there will be servo problems. Servo is greedy and requires exclusive use of the timer in order not to glitch / pause.

Now if the Picaxe had an extra timer available ...
 
Top