ZUNO_SERVOS can control only 1 servo?

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
vangoober
Posts: 8
Joined: 26 Feb 2019 06:59

ZUNO_SERVOS can control only 1 servo?

Post by vangoober »

I'm working with the SimpleServo example and I've discovered that if I try to declare a single ServoController on pin13, for example

ServoController Window0(13);

... then Window0.begin(), Window0.setValue(x), and Window0.end() will work properly. Now, if I try to declare more than one, for example:

ServoController Window0(13);
ServoController Window1(14);

then Window0.begin(), Window0.setValue(x), and Window0.end() will NOT work. If I swap the order of the declarations, for example:

ServoController Window1(14);
ServoController Window0(13);

... then Window0.begin(), Window0.setValue(x), and Window0.end() WILL work properly again. So, only the LAST ServoController declaration will function.


Is the ZUNO_SERVOS code intended to support more than 1 servo?

Thanks
-G
vangoober
Posts: 8
Joined: 26 Feb 2019 06:59

Re: ZUNO_SERVOS can control only 1 servo?

Post by vangoober »

Is the ZUNO_SERVO routine written such that the servo can be the only device that uses the general purpose timer? Is this why I can't create more than one of instance of ServoController? ... because each subsequent one effectively clobbers the previous one's use of the general purpose timer?
User avatar
PoltoS
Posts: 7571
Joined: 26 Jan 2011 19:36

Re: ZUNO_SERVOS can control only 1 servo?

Post by PoltoS »

There is only one GPT in the Z-Wave chip. It is quite hard to run few tasks on one GPT. It is possible to do it by specially changing the Servo code. By default only one is possible
vangoober
Posts: 8
Joined: 26 Feb 2019 06:59

Re: ZUNO_SERVOS can control only 1 servo?

Post by vangoober »

Ok... that's what I thought. I *was* wondering if it had capability similar to the standard Arduino servos library that supports multiple servos per timer, but as I dug into the ZUNO_SERVO source file, I could see this was not the case.
I've been working on changing the ZUNO_SERVO code to accommodate 4 servos, on pins 13, 14, 15 and 16, with each one being controlled within a window of 5ms, rather than the full 20ms -- so the GPT handler has 8 states rather than the original 3 (pin 13 on/off, pin 14 on/off, pin 15 on/off, pin 16 on/off). (I appreciate what you're saying that running multiple tasks on one timer would be difficult; I think I've made the problem at least a little bit more manageable by hard-coding the timer handler function for 4 servos!) I've dumped the output to a small data acquisition system to confirm the pulses are correctly sized before driving my servos. I'm turning servos off when they're not being used, though right now, I'm still working on making it stable -- or even predictable. I think I'm getting there, though it doesn't appear to behave exactly the same way when I have my servos connected as it does when I'm outputting to the data acquisition.
What sorts of functions should I be concerned might interfere with the GPT? Is there any reason I should choose a different set of pins than 13-14-15-16?

Thanks for replying.
-G
Post Reply