Fez Panda II with battery problem

Hello,

I have created a car with 4 motors, 2 motor controllers and 7,5v battery pack and Fez Panda II. All pieces are connected and when I run my project with visual studio USB connected (side by side with battery), everything works ok. When I remove the USB and run the project onchip with battery, behavior is not the same. The wheels just run on one direction. I’m noob with electronics (not with programming) but I can’t figure out the problem. I thought that this might be ground problem because it seems that the “high” digital IO does nothing. But still the same bahavior. I have also erased the board with MFDeploy to be sure that there is latest program on chip but still same results. I’m confused ::). Any ideas? Remember that I’m a noob so this might be really simple :wink:


 public static void Main()
        {
            while (true)
            {
                MotorController.Forward();
                Thread.Sleep(1000);

                MotorController.Reverse();
                Thread.Sleep(1000);

                MotorController.TurnLeftForward();
                Thread.Sleep(1000);
            }
        }

MotorController.cs


public class MotorController
    {
        static byte speed = 100;
        static PWM pwmRight = new PWM((PWM.Pin)FEZ_Pin.PWM.Di8);
        static OutputPort directionRight = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di20, false);

        static PWM pwmLeft = new PWM((PWM.Pin)FEZ_Pin.PWM.Di6);
        static OutputPort directionLeft = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di24, false);

        public static void Stop()
        {
            pwmRight.Set(19200 * 1000, 0);
            pwmLeft.Set(19200 * 1000, 0);
            Thread.Sleep(3000);
        }
        public static void Forward()
        {
            Stop();
            directionRight.Write(true);
            directionLeft.Write(false);
            pwmRight.Set(19200 * 1000, speed);
            pwmLeft.Set(19200 * 1000, speed);
        }
        public static void TurnLeftForward()
        {
            Stop();
            directionRight.Write(false);
            directionLeft.Write(false);
            pwmRight.Set(19200 * 1000, speed);
            pwmLeft.Set(19200 * 1000, speed);
            Thread.Sleep(2000);
            Stop();
        }
        public static void TurnRightForward()
        {
            Stop();
            directionLeft.Write(true);
            directionRight.Write(true);
            pwmRight.Set(19200 * 1000, speed);
            pwmLeft.Set(19200 * 1000, speed);
            Thread.Sleep(2000);
            Stop();
        }
        public static void Reverse()
        {
            Stop();
            directionRight.Write(false);
            directionLeft.Write(true);
            pwmRight.Set(19200 * 1000, speed);
            pwmLeft.Set(19200 * 1000, speed);
        }
    }

I believe the general guideline is to run the Fez on a different battery from the motor controller. it minimizes noise.

How do you supply the Panda did you connect the battery through the connector ?

Try a simple led blinking example running from battery.

I added extra 9v battery to run the Panda and now everything works great. So it must have been the noise thing. Thanks for the help.