Boe-Bot and Fez-Mini

I am still trying to get the Mini to control the Boe-Bot. using code from your e-book (which is excellent by the way) I need to send PWM to pin 12 on the bot. Trouble is, the enumeration for PWR pins does not include pin 12. Here is the code.


public static void Main()
        {
            try
            {

                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
                }
                //Thread.Sleep(-1);

            }
            catch (Exception ex)
            { 
            
                Debug.Print("An error occurred " + ex.Message.ToString());
            
            }
        }

    }

Is there a way to “map” a Fez pin to a different output pin for the boe-bot? The servos on the Boe-Bot are on Pins 12 & 13.
I am sooooo close to making this work!

Any ideas?

Ron

PWM is (unfortunately for you) enabled only on a set number of defined pins. The only way to achieve what you want is to connect a PWM capable pin to the expected connection on the Bot. So your “re-map” is really going to be a “rewire”.
(PS: using CODE tag helps :wink: )

Please use code tags so your code is readable.

I have used the same robot and I remember I was able to use PWM pins. But you can get PWM on any pin using OutputCompare as well.

Maybe when you complete this you can make a wiki page on how you made the robot dance using FEZ :slight_smile:

on my boe bot i moved 13 to 15 its a hardware pwm port.

Where is the wiki page bstag? Points hint hint :slight_smile:

Or even on fezzer

I guess i can wiki my boe bot conversion soon. I had it almost complete with all the book samples converted to .net. Will have to be after the up and coming robot meet i am preparing for.

I will re-wire this week-end…too stuborn to give up!!! Thanks for all the advice/ideas.

OK, I did it. The RtServo can stay connected but you just have to feed the signal for the Lft Servo to P11 on the Board of Education.

 
  try
            {
               
              
                PWM rtServo = new PWM((PWM.Pin)FEZ_Pin.PWM.Di6); //pin 12 (do not change on BOE)
                PWM lftServo = new PWM((PWM.Pin)FEZ_Pin.PWM.Di5);//white signal wire to P11 on BOE
                for (int x=1; x <200; x++)
                {
                   
                    rtServo.SetPulse(20 * 1000 * 1000, 1300 * 1000);    //full speed clockwise
                    lftServo.SetPulse(20 * 1000 * 1000, 1700 * 1000);  //counterclockwise
                }

                                              
            }
                

rt Servo: 1.3ms = full speed clockwise
lft Servo: 1.7ms = full speed counterclockwise
In Setpulse, the first argument means 20ms (20*1000 * 1000ns)

To go in reverse, just reverse my setpulse commands. To spin, you set them to the same values, etc. I hope this will help someone else.