Count, Servo and Interrupt interactions

RBruceM

New Member
In a project using the 40x1, I have a "background" interrupt routine which recieves serial data packets periodically via the hw serial port.

The main program occasionally uses rc servos for brief on-off controls. The program needs to wait 2 seconds for the mechanical servo to move to new position before turning off pulses and power to the servo

The new x2 doze command would be ideal but isn't on the x1.

Pause can't be used due to the interrupt discontinuing any pause.

I wrote an alt_pause routine using the settimer function, but forgot about my servo functions. The manual clearly says servo and timer functions are mutually exclusive.

So, I wondered about using the count command as a time delay. Is there a problem with this and interrupts or servo commands? There's no mention in the manual but I wonder what interaction there will be between count, interrupts, and servo commands. I also wonder how my "real" use of the count command as a tachometer will be affected by interrupts. The "counted" pulses are no faster than 110 ms and are at least 5 ms wide.

Bruce M
Snowflake, AZ
 
Last edited:

hippy

Technical Support
Staff member
I expect Count would not only inhibit interrupts but may also stop the servo pulses during its execution. Much of the PICAXE is by necessity bit-banged so it has to stop doing background tasks to be able to do what it needs to accurately and with correct timing. The only exception is probably PwmOut which, once configured, runs in its own hardware block.

There are microcontrollers which could do everything a PICAXE does ( same Basic command language and all ) without any intereference between any commands no matter what they were but not any PICmicro I know of and that is what introduces the limitations.
 

RBruceM

New Member
Thanks Hippy, I understand now how count must suspend the polled interrupts. It would take an advanced uC with multiple, sophisticated timers to do that sort of thing in the "background".

I'm guilty of getting carried away and not trying to keep my application as simple as possible.
I will change my program to get rid of polled interupts; I can send and process serial data packets from within my new pause subroutine.

Now I'm wondering about the "background" hw serial input on the X1 parts. Will this affect the count command or servo command functions?

Thanks again.
Bruce M
 

hippy

Technical Support
Staff member
Now I'm wondering about the "background" hw serial input on the X1 parts. Will this affect the count command or servo command functions?
It might, it all depends on how long the internal 'got a character' interrupt takes ... and of course if interrupts are entirely disabled the 'got a character' interrupt won't get handled until after the Count.

One advantage of the PICAXE is relatively low cost which means that the multiprocessor solution, each of which can work without interfering with the others, can often be implemented.
 

RBruceM

New Member
In this case it may be easier for me to just convert the tack input (a hall effect type gear tooth sensor looking a cast iron flywheel spokes) to an analog input and not use count.

Now that the x1 chips have I2C slave capability, adding a processor should be easier. I'll have to play with that soon.

But again, I wonder what conflicts might arise, command wise.

Thanks again for your thoughful help, Hippy.

Bruce M
 

BCJKiwi

Senior Member
Hall effect sensors are available with varying output voltage rather than pulses - this integration comes at a price but means you can just read that output with an ADC pin each loop around and you will get a read of current RPM each time you check.
 

RBruceM

New Member
Not very hard for me to convert the pulses to an analog level with a bit of linear circuitry, either, but thanks, BCJKiwi.
 
Top