On advice from Gus I’ve started a new thread since the my previous post was on an old thread. My problem is that I don’t get a meaningful PWM signal on my Hydra with a time period much more than 2ms. Here’s the simple code:
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using Gadgeteer.Interfaces;
namespace GadgeteerApp4
{
public partial class Program
{
void ProgramStarted()
{
GT.Socket socket7 = GT.Socket.GetSocket(7, true, null, null);
PWMOutput myPWM = new PWMOutput(socket7, GT.Socket.Pin.Seven, false, null);
myPWM.Active = true;
uint l = 2000000; // this works
// l = 3000000 does not work
uint h = 1000000;
myPWM.SetPulse( l, h);
}
}
}
Exactly 2ms is fine, I get a nice square wave on my scope. 3ms is not, all I get is a signal pegged high. When I try 20ms ( what I need for a servo) I get signal which is about 1.7ms in length with the high length of 1ms ! Anyone have an idea what’s going on?
Here’s the firmware/SDK
TinyBooter Version: 4.2.3.1
Firmware Version: 4.2.3.1
SDK Version v0.0.8 , October 24, 2012
Does anyone know if this means that a Hydra can’t control a servo from a PWM pin but, a Spider can. Or is there’s something wrong with my Hydra or my setup? Just want to be sure before I go down the path of buying an I2C servo conroller or I suppose I could do PWM from a GPIO pin.
As PWM stands on Hydra, the current smallest frequency that can be achieved is 381.4755474 Hz which translates to 2.6214 ms. This is also based on a 25 MHz frequency. It may be possible to change the frequency range which we will try to implement in a future release. You may be able to use the register class to directly manipulate the PWM control registers to get the desired frequency or perhaps control the PWM from RLPLite where again you can control the PWM registers.
An alternative for Hydra right now to control a servo is our Pulse InOut Module, where you can control up to 8 servos on one module; plus, because it can be daisy-chained (via DaisyLink), it can control even more than 8. Here is the link to the module: http://www.ghielectronics.com/catalog/product/392