Beginners Project

Hi everyone.

I am new to this forum and I’ve just started to play around with a Cerbuino Bee. I have the main board, a display board and an expansion board connected to the Arduino connectors.

What I would like to do is read in 2 analogue values and display them on the LCD display, not particularly complicated! I’m sure most of you on this forum could knock something like this up in an hour or so!

I come from an analogue electronics background and my experience with systems like this is limited. Does anyone have any good pointers / resources where I could get started from.

I have found a book on .NET gadgeteer but it mainly deals with the FEZ starter kit.

Any advice would be greatly received.

Thanks,

Richard

Welcome to the community!

There are some good tutorials here:

https://www.ghielectronics.com/docs

We also have bunch of code examples on Codeshare.

Other than that do you have a more specific question?

Hi Architect.

Thanks for the link, looks like some pretty useful info in there.

I guess the main area of assistance I require revolve around the .NET programming framework. In the past I have only done a small amount of C but quite a bit of VHDL, something which I don’t think is going to be too useful here!

For my project I will require 2 analogue inputs and 1 digital input.

On this link:

https://www.ghielectronics.com/docs/45/fez-cerbuino-bee-developer

There are a list of all the I/Os on the Cerbuino Bee, do I need to list all of them in my project, or just the ones I am going to use, eg A0, A1 & D0.

Also where would I list that list, within the main .cs file or somewhere else?

Sorry these must be very basic questions but I am very keen to learn how to get this thing working.

Thanks again.

Richard

Ha, this thing is brilliant.

Excuse the excitement but I have just managed to display text on the display. For someone with limited programming knowledge that is a huge step!

No to make it display an analogue value…

1 Like

@ r.youden - Here is another helpful document to help you started:

https://www.ghielectronics.com/downloads/FEZ/Beginners%20guide%20to%20NETMF.pdf

Usually you create a higher primitive object that uses an IO.

for example in the following tutorial:

https://www.ghielectronics.com/docs/5/digital-inputs

There are two higher level object DigitalOutput on Pin 47 and DigitalInput on Pin 33 on the Spider board.

The output controls a LED. The input read the state of the button. Analog input constructed in a similar way. You will read an integer value in the range of 0 to 2 in power of n. where n is the resolution of the ADC. I think there is also a method that return real value in the range of 0…1. You can set up custom scale as well. ADC is 3V3 by the way.

Here https://www.ghielectronics.com/community/forum/topic?id=13710 is a thread about a free ebook.

Hi Reinhard, thanks for the link, it looks like a interesting book!

I have been playing around over the weekend and I can now display basic information onto my display.

I have tried to set the display so it will sho a variable as a counter increments using the following code:


namespace GadgeteerApp3
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            int MyVar;
            MyVar = 0;
            while(MyVar<10)
                {
                    MyVar++;
                    char_Display.Putc((byte)MyVar);
                    Thread.Sleep(2000);
                    char_Display.Clear();

            }
        }
    }
} 

However the display just shows random symbols every time the loop is executed.

Any suggestions?

Thanks,

Richard

Hi there Richard,

The PUTC command you have potentially just writes the ASCII characters between 0 and 10 to the display, none of which are actually display characters.

Try using something that adds decimal 48 to the value (which means your MyVar of 0 equals 48 which corresponds to ASCII ‘0’ character. Untested:

char_Display.Putc((byte)MyVar+‘0’);

Hi Brett,

Thanks for the feedback, I added 48 to my variable and set he count max to 58. It worked great until it got to 10 and displayed :

Is there anyway of making the display show a character string rather than a ASCII character. What I eventually want to do is display the voltage at one of the analogue inputs, I am just learning about the basic display controls at the moment.

Thanks.

Richard

I have managed to display string characters in the screen rather than jus ascii characters by using the following:

namespace GadgeteerApp3
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            int MyVar;
            MyVar = 48;
            while(MyVar<58)
                {
                    MyVar++;
                    char_Display.PrintString(MyVar.ToString());
                    Thread.Sleep(2000);
                    char_Display.Clear();

            }
        }
    }
}

I have looked through the book linked earlier (Begineers Guide to C# and the .NET Micro Framework and it covers digital input values but I can not find anything on handling analogue inputs. Does anyone know a good resource where I can find some info.

Thanks again.

Richard

Another thing I am now trying to do is toggle a digital output. I am using the following code:

namespace GadgeteerApp3
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            OutputPort LED;
            LED = new OutputPort((Cpu.Pin)??, true);
            while (true)
            {
                LED.Write(true);
                Thread.Sleep(200);

                LED.Write(false);
                Thread.Sleep(200);
            }
        }

    }
}

From my understanding the ‘??’ is the location of the pin on the CPU. Using the following document:

https://www.ghielectronics.com/docs/45/fez-cerbuino-bee-developer

If I wanted to toggle D0 then the pin assignment needs to be PB11.

Do I need to declare all of the pin allocations as in that link within my code? If so can someone please point me in the direction of further instructions.

Thanks,

Richard

Hi Richard,

I can understand the “10” value being printed as a colon “:” character. Check the ASCII table out, and you’ll see ! http://www.asciitable.com/ I was trying to assist your learning in one way but didn’t really focus on the end result (a generic string to the display) which is why I didn’t point you to that solution first. Here’s a couple of related tips:

Debug.Print("My value is = " + MyVar.ToString());
// will show the string in the debugging window of Visual Studio - one of the best features of netmf
String myString = "Value: " + MyVar.ToString();
// can then be used to output to display and to debug output if you like!
Debug.Print(myString);
char_Display.PrintString(myString);

To understand pins, there are usually pin mappings (enumerations) that GHI provide. And Visual Studio can help too. But for the best help, we’d need to know whether you created a Gadgeteer project or a regular netmf Console project - but assuming Gadgeteer (since that’s what the ProgramStarted() in your earlier code implies), here’s how I’d do it for a Cerb Bee Gadgeteer project.

By default, you get an inclusion of the “GHIElectronics.Gadgeteer.FEZCerbuinoBee” reference, and you need to add “GHI.Hardware.FEZCerb” manually. Then, make sure you add a “USING” statement to your program for the new reference (and Microsoft.Spot.Hardware) you can then start typing your command and have VS help along the way… I’ll list what I’d press as I type in <> brackets

outp myLED=n(()pi.

at that point you can see the enumerations of the pins from the generic Fez Cerb - pick what one you want, and you’re good to go !

Be warned, the OutputPort approach we just went through is NOT a Gadgeteer method nor is it Gadgeteer “safe” to share with modules if you wanted to use some of the pins that are not used by a module plugged into a socket. We’re just keeping you moving here, right, not teaching you everything at once? :slight_smile:

Analog input is pretty much the same as the OutputPort example. Let VS help you, so start

analomyAnalog=n(.
… and then you can see the AnalogIn channel enumerations. Here’s where it’s tricky. You need to match the Analog Channel to the individual pin you want. https://www.ghielectronics.com/docs/46/cerb-family describes the mapping for you that should help.

hope this all helps !

Hi Brett,

Thanks for your help.

I created a new project and this is the blank .cs file generated:

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;



namespace GadgeteerApp4
{
    public partial class Program
    {
        void ProgramStarted()
        {
        }
    }
}

I then modify it with the GHI.Hardware.FEZCerb line so it looks like this:

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using GHI.Hardware.FEZCerb;



namespace GadgeteerApp4
{
    public partial class Program
    {
        void ProgramStarted()
        {
        }
    }
}

Now when I try to run this program I get the following error:

Not sure where to go from here, thanks again.

Richard

Some namespaces/classes are in libraries which are not added in a new blank project.
Right-click on the references node in solution explorer, then Add Reference.
A window pops up where you can add a reference to additional libraries.

In your case you need GHI.Hardware.FEZCerb, select it and press Ok.
The library names does not always match the namespace names. They also often contain sub namespaces.
All GHI.Premium libraries are only useable with premium SoM’s (EMX, G120, G400)

Thanks Reinhard,

Unfortunately I do not have that option when I try to add reference. of the GHI.Hardware options all I have is EMX, G120 and G400. There is a GHIElectronics.Gadgeteer.FEZCerbuinoBee but that is the nearest to my board I can find.

Richard

I think you mix up Gadgeteer and plain NETMF.
In a Gadgeteer project the libraries should be added when you drag the board into the visual designer.
But then you usually don’t need the GHI.Hardware.FEZCerb namespace I think.
If you don’t want to create Gadgeteer project you should create a ‘Micro Framework/Console Application’

In the Gadgeteer libraries I also have Cerberus, and CerbuinoNet and Cerbot.

Hi Reinhard,

Please bare with me on this, as I am sure you can work out I’m very much new to all of this!

Going back to the very start…

I have selected .NET Gadgeteer Application from my New Project window.

I select my corresponding hardware from the list (FEZCerbuinoBee), I then get the program.gadgeteer tab and a program.cs tab. In the program.cs tab I have the usual introduction code with the following ‘using’ options:

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

I then look in the references tab in the solution explorer and try to add the GHI.Hardware.FEZCerb but I can’t find it.

Am I getting hopelessly lost here?

Thanks,

Richard

When you create a Gadgeteer project you should start in the visual designer.
1st you drag your board into the designer, then all modules you have, and then you drag the connectors of the modules onto the board.

hi there,

what version of Visual Studio do you have ? and can you confirm what SDKs you installed, and when you installed the SDKs?

Here’s what I have in my test app I set up to check this for you earlier… (I’m using Visual Studio 2012 with Netmf4.3 SDK and GHI’s 2013-R3 SDK)