FEZmini Robot problem with PWM

I’ve updated the firmware using tera term, tested the motors, and the reflective sensors with the sample codes from the GHI website… they all work fine… I got a problem with the Servo Port… I load the code from the GHI page and it moves my DC motors instead… ??? … I load this code (see below), load the proper “References” that are needed; (I’ve even loaded all the References), but still only the DC motors in port A and B move… :think: I’ve even tested the other servo codes from GHI (for the sake of space I’ll not post all the code just name it… public static partial class FEZ_Components with the Main method code that calls the “Components” class. ) I still I get nothing or an error from these codes. On this code I have tried changing Di5 pin to the ones available like Di9, Di6, etc and still only the DC motors run :wall: …Im not a prof C# user, but not a newbie… the servos are fully rotational from a Boe Bot. Im just interested to get the Servo Port working…

Thanks :slight_smile:

using System;
using System.Threading;
using Microsoft.SPOT;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.FEZ;
 
namespace FEZ_Mini_Application1
{
    class Program
    {
        public static void Main()
        {
            PWM servo = new PWM((PWM.Pin)FEZ_Pin.PWM.Di5);
            while (true)
            {
                // 0 degrees. 20ms period and 1.25ms high pulse
                servo.SetPulse(20 * 1000 * 1000, 1250 * 1000);
                Thread.Sleep(1000);//wait for a second
 
                // 90 degrees. 20ms period and 1.50ms high pulse
                servo.SetPulse(20 * 1000 * 1000, 1500 * 1000);
                Thread.Sleep(1000);//wait for a second
 
                // 180 degrees. 20ms period and 1.75ms high pulse
                servo.SetPulse(20 * 1000 * 1000, 1750 * 1000);
                Thread.Sleep(1000);//wait for a second
            }            
        }
    }
}

Dude, code button above… :wink:

PWM servo = new PWM((PWM.Pin)FEZ_Pin.PWM.Di5);

means it’s using PWM on pin Di5. I don’t have the FezBot to know what port it’s meant to be connected to, but changing that to the correct pin should deal with your issue. According to the image on Page 5 of the robot manual, Di7 and Di8 are the Servo pins.

Or you can use OutputCompare on any pin.

Hi,
Fez Mini Bot used pin Di3, Di5, Di6 and Di 9 to control the motors
and used Di7 and Di8 for Servo. (See User Manual page 5)
[url]http://www.ghielectronics.com/downloads/FEZ/Mini/FEZ_Mini_RobotKit.pdf[/url]

and you can used available Servo Driver here
[url]http://www.ghielectronics.com/downloads/FEZ/Component/FEZ_Components_ServoMotor.cs[/url]

hope this help.

Hi Sam, Architect and Brett… I’ve tried to change the pin # to Di8 or Di7 but the compiler will give me an error messege…( “GHIElectronics.NETMF.FEZ.FEZ_Pin.PWM does not contain a defenition” this applies to Di8 or Di7)… when I backspace the “.Di5” so I can let “Intelisence” tell me whats available I only get these options; Di10, Di3, Di5, Di6, Di9, and LED… ??? … The firmware, .Net C# 2010, .NetMF4.1 are all up to date… Im using a laptop; I think this could be the problem, I know this from exp. when I hack a game or something it will give me a bug when its not… I try my desktop; never get a problem with it… I’ll start reading on the “output compare” method/ class to see if I can work around the problem…or make a “main” method to use the “public static partial class FEZ_Components” class. ???

Use output compare

Hi “Alex”,

Di7 and Di8 are not PWM capable!
That’s why got the error.

Like I mentioned from my last post, you can use this servo driver which used Output Compare to do the job, as Gus and Architect suggested!

and you can used available Servo Driver here
http://www.ghielectronics.com/downloads/FEZ/Component/FEZ_Components_ServoMotor.cs

Hurray :slight_smile: the PWM works… the way the code was originally coded… on my Boe Bot :wink: … Di6 = Pin 12, Di9 = Pin 15, On BS2 … now I need to learn Output Compare. :dance: