Use "count" with "servo"??

jims

Senior Member
I'm looking for a way to count pulses while continuous servos are running. Is there any way to count pulses when using the "servo" command since the "count" command stops the servos? Thank you, JimS
 

hippy

Technical Support
Staff member
It may be possible with a count period less than the 20ms servo refresh rate or perhaps using the SETTIMER command for counting when available. One way might be a separate PICAXE doing the COUNT which the master can poll to get the count result. Or have a separate PICAXE driving the servo being positioned by the master.
 

AllyCat

Senior Member
Hi,

What is the frequency (or period) and duty cycle (or pulse width) of the "pulses"? If they are not too "fast" then you could use a software polling loop, or an interrupt. For narrow pulses there is additional on-chip hardware available (at least with M2 PICaxes) such as the SR-Latch and Timer1 Gate modules.

Cheers, Alan.
 

Goeytex

Senior Member
The Servo command wants exclusive use of both timer1 and timer2. As you have found out "Count" interferes with "Servo". Attempting to use any method that requires the use of Timer1 or Timer2 will likely be complex & timing sensitive or will not work at all.

I think your best option is to use a Master Picaxe for glue logic, counting, and other stuff and to use a separate Picaxe such as 08M2 or 14M2 as a dedicated Servo Controller. The master Picaxe could possibly communicate with the servo Picaxe via serial commands assuming that that the serial comms does not kill the servos on the servo controller.

Anything that uses interrupts such as HI2C/HSER/HSPI will likely cause problems with servo operations in the form of intermittent glitches or even temporary stoppage.

If attempting to do stuff during the servo "off time", how many servos are operating will determine how much time is available between servo pulses. With 2 servos this is about 15 ms which should be enough for the servo Picaxe to receive serial commands to control the servos.

One Byte of serial data can be sent in about 1 ms with a baud rate of 9600. If using M2 parts I would use a 16Mhz Clock to reduce processor overhead.

Even better would be to Use X2 parts @ 32Mhz and serial coms at 38400 between the Picaxe Chips.
 
Last edited:

erco

Senior Member
If I didn't know better Jims, I'd suspect you might be counting wheel encoder ticks on a robot using CR servos for motors. :)
 

jims

Senior Member
It's time to explain what I want to do....Want to build several IR beacons. Frequency of each beacon will be different and controlled with a simple 555 chip. My robot runs with CR servos and will search for the beacon that I assign to it "on the fly" using an IR clicker. I'm using a 20M2 chip (seems that servo and irin don't work on a 20x2). I was hoping to use pulsin or count to identify the assigned beacon. Just have to bang away at it. Thanks for the input. JimS
 

hippy

Technical Support
Staff member
Rather than use SERVO commands, a COUNT for 20ms and PULSOUT commands to control the motors should work just as well.
 

jims

Senior Member
erco...in your demo you mention "hooded IR sensors". Iim guessing that they are two TSOP-4038 modules. Do you have details of these and the IR beacons. I hate to "reinvent the wheel" so to speak. Thsnk you, JimS
 

erco

Senior Member
jims: Sorry, been busy. As you surmised, I did use TSOP4038 sensors, which are continuous signal compatible. Those are discontinued now, but the replacement TSSP4038 (Mouser, Digikey, etc) works as well or better. The sensors were in light-tight baffles/blinders, I used posterboard sprayed with ultra flat black paint.

The attached 556 beacon circuit will actually work with many non-continuous signal sensors (TSOP3828/38238) over the 8K-15K range shown. An 08M2-based beacon would work as well and require no analog calibration.

My code is attached, and you can find more info at http://www.botmag.com/picaxe-part-4/

Hope that helps!

IRbeacon.jpg
 

Attachments

jims

Senior Member
erco... Thank you for all the good info. Now I'm working on what I call "Smart Beacons". Beacons have some intelligence (Picaxe 08m2) and each is programmed with it's own ID code which it continuously transmits using "IROUT" in the form of a clicker key code (1,2,3,4,etc.). The robot searches for and goes to the Beacon with ID#1 first. After finding ID# 1 it searches for ID#2 & travels to ID#2. This continues until all Beacons are covered. Pattern is varied by changing the placement of the Beacons.
 
Top