How to access the Cerbuino shield pins?

Hi All,

I already missed the 80 pins I got so used to on my Panda 2, so I bought the IO60P16 for my Cerbuino Bee in order to have a lot of IO again, but that module is giving me some issues at the moment.

So I thought, lets use the Cerbuino pins instead (the arduino shield header pins). However, I can’t seem to get that to work as well. If I want to use a digitalinput, pwm or analog port, it will always ask for a socket number (GT.Interfaces.DigitalInput di =new GT.Interfaces.DigitalInput, first parameter is GT.Socket, no overloads).

I just want to use PWM on A0 for instance, directly on the board without any module plugged into any socket. I searched the forum and this thread:
http://www.tinyclr.com/forum/topic?id=7530

Kind of indicates the same problem. It states that a new DLL will be available soon, but I still can’t find it. Should I add another reference or download a new SDK? Or is the new SDK not available yet? That thread is already half a year old, so knowing GHI I’m almost sure that this will be possible by now and I’m just not finding it.

Thanks for your time reading this again and helping me out :slight_smile:

PB1 would be pin

Microsoft.SPOT.Hardware.Cpu.Pin pb1Pin = (Microsoft.SPOT.Hardware.Cpu.Pin)0x11;

A little further explanation for you: on the Cerb it appears pins are grouped in banks of 10. So you add 10 to the number for each bank after A.

Example
A0-9 = 0-9
B0-9 = 10-19
C0-9 = 20-29
etc.

:slight_smile:

@ mammaplank -

Keep in mind that Skewworks is talking in hexadecimal now. So make sure you prepend 0x :wink:

Yes, good point! I’m sorry I didn’t make that clear. :slight_smile:

Aaaaaah… thanks for the quick responses!

I wanted to use GT.Interfaces.PWMOutput for instance, but there was no way I could create an object of any of those with only the Microsoft.SPOT.Hardware.Cpu.Pin value. So I guess you should not use GT.Interfaces.“Anything” if you want to use the shield pins and you should simply use the Microsoft.SPOT.Hardware classes instead?

This starts to make sense to me now! Thanks a lot!

That pin is not a PWM pin. Look at the design here: http://www.ghielectronics.com/downloads/Gadgeteer/Mainboard/Cerberus/FEZ_Cerbuino_Bee_Sch.pdf

Now pick a PWM pin.

Here’s how to create a Gadgeteer PWMOutput on you own. You need to do a little extra coding on your own, but this is basically extracted from the Gadgeteer core, so you can make your own class that accepts a CPU.Pin

       private Cpu.PWMChannel pwmChannel = Cpu.PWMChannel.PWM_NONE;
        private PWM pwm = null;
        private Socket.Pin pin;
        private bool invert = false;
        private bool started = false;
pwmChannel = socket.PWM7; // Swap PWM as appropriate

 /// <summary>
        /// Sets the frequency and duty cycle of the <see cref="PWMOutput"/> interface and starts the PWM signal.
        /// </summary>
        /// <param name="frequency">Required frequency in Hertz.</param>
        /// <param name="dutyCycle">Duty cycle from 0-1.</param>
        public void Set(int frequency, double dutyCycle)
        {
            if (frequency < 0) throw new ArgumentException("frequency");
            if (dutyCycle < 0 || dutyCycle > 1) throw new ArgumentException("dutyCycle");
            if (pwm == null)
            {
                pwm = new PWM(pwmChannel, frequency, dutyCycle, invert);
                pwm.Start();
                started = true;
            }
            else
            {
                if (started) pwm.Stop();
                pwm.Frequency = frequency;
                pwm.DutyCycle = dutyCycle;
                pwm.Start();
                started = true;
            }
        }

        /// <summary>
        /// Sets the period and high time of the <see cref="PWMOutput"/> interface and starts the PWM signal.
        /// </summary>
        /// <param name="period_ns">Period of the signal in nanoseconds.</param>
        /// <param name="highTime_ns">High time of the signal in nanoseconds.</param>
        public void SetPulse(uint period_ns, uint highTime_ns)
        {
            if(pwm == null) 
            {
                pwm = new PWM(pwmChannel,period_ns, highTime_ns, PWM.ScaleFactor.Nanoseconds, invert);
                pwm.Start();
                started = true;
            }
            else
            {
                if(started) pwm.Stop();
                pwm.Scale = PWM.ScaleFactor.Nanoseconds;
                pwm.Period = period_ns;
                pwm.Duration = highTime_ns;
                pwm.Start();
                started = true;
            }
        }

        /// <summary>
        /// Gets or sets a Boolean value that indicates whether the PWM interface is active, <b>true</b> if active
        /// otherwise <b>false</b>.
        /// </summary>
        public bool Active
        {
            get
            {
                return pwm != null;
            }
            set
            {
                if (Active == value) return;
                if (value)
                {
                    pwm = new PWM(pwmChannel, 1, 0.5, invert);
                    started = false;
                }
                else 
                {
                    if (started) pwm.Stop();
                    pwm.Dispose();
                    pwm = null;
                }
            }
        }
1 Like

This is great Skewworks, thanks a lot for helping me out on this one!

Unless i am not reading the question right…which is highly likely :smiley: … it’s alot simpler than the above solutions to get to the pins.

           
GHI.OSHW.Hardware.FEZCerbuino.Pin.AnalogIn.A0; //Analog
GHI.OSHW.Hardware.FEZCerbuino.Pin.Digital.D0; // Digital
GHI.OSHW.Hardware.FEZCerbuino.Pin.Gadgeteer.Socket1.Pin3; //Gadgeteer Sockets
GHI.OSHW.Hardware.FEZCerbuino.Pin.PWM.D10; // PWM