count and servo and debug in the same loop

Wrenow

Senior Member
Thinking about a servo test rig (to test speed of CR servos. However, my piccaxe stuff is out of pocket (in another vehicle) for a couple of days, or UI woulkd just be sussing this out with a hardware test.

What is giving me pause - I was wanting to use the Servo, Count, and debug commands all in a loop. I am thinking the Debug might kill the Servo command due to using the serial interface, right?

How about the count command - is it compatible with the servo command running in the backgro9und or will they trip each other up?

Cheers,

Wreno
 

lbenson

Senior Member
DEBUG seems to me like a sledgehammer--in fact I've never used it. What can it do that sertxd can't do more efficiently and with finer control?
 

nbw

Senior Member
DEBUG is great for when you want to keep an eye on multiple variables changing reasonably quickly, without code, code, code to pump stuff out to sertxd, scrolling etc.

Sertxd is great for a step-by-step record of what's happened on the other hand. Mind you, it doesn't take long before the little buffer fills up and it starts flushing out earlier readings.
 

Wrenow

Senior Member
Sometimes a big honkin' hammer is just what you need. In this case, for a one-time use test rig, it seems to be a bit of a kludge but should be effective.

The big question being whether count and servo can coexist (i.e. can you do a 30 second count with servo doing its background thing)?

I am trying to count actual revolutions at a specific servo pulse commanded speed (so I can plot the speed versus pulse width on several different setups).

Dialing in the pulse width with a pot manually and then hand counting the revs over 30 sec for each pulse width from 0.7ms to 2.3ms is a bit of a pain.......

Cheers,

Wreno
 

Technical

Technical Support
Staff member
Count does not disable the servo pulses, so could in theory be used at the same time as servo. However if the count transition edge occurs during the time that the background servo interrupt happens to be occuring the accuracy of the count will be affected.
 

Wrenow

Senior Member
Count does not disable the servo pulses, so could in theory be used at the same time as servo. However if the count transition edge occurs during the time that the background servo interrupt happens to be occuring the accuracy of the count will be affected.
Sounds good (well, likely), then. Since I am talking from 50-70 RPM maximum, and am thinking on an optical interrupter with the servo horn swinging through it, it will trigger twice per revolution, measured for 30 seconds. At 60 RPM, close to the maximum, I should be getting about 2 pulses per second, each pulse being in the neighborhood, I am thinking, of about 1/6 or 1/3 second in duration (depending on whether the optointerrupter is measuring the light or the dark), so I am guessing I will not miss a lot of pulses.

I will, of course, compare to the manual count for verification and quality control to see if it becomes an issue, but thanks for the heads-up. I do, of course, have a plan b - use my servo tester for the servo signal and use the Picaxe fust for counting.

Yeah, I could just count by hand (done a lot of that already, which is why I am wanting to automate a bit.

Cheers,

Wreno
 

Wrenow

Senior Member
Well,I picked up some opto-interrupters for a couple of bucks (got 2 each of 2 different types). If I can get them up and running without frying anything, I will see if I can use the count or need to do a custom count routine. Might could do the same thing with a pulsin, though that would require some calibration, of course. I like the elegance of using count, if'n it'l work.:)

Of course, if I fry the opto-interrupters, :eek: there is always the old LDR or photo transistor and LED I was originally planning on pulling out of the box and using anyway before I spotted the opto-interrupters on sale at the local surplus house for under $0.50.

Got the laptop with the IDE back last night, too, and should have my picaxe stuff back today or tomorrow. Sounds like a fun weekend coming up! :D

Cheers,

Wreno
 
Top