Known issues with Cerberus and analog sockets?

Just getting around to using my Cerberus now that I have 4.2 on it and it no longer hangs/blue screens and am running into strange analog input issues. I tried looking on the wiki and searching through the forums but did not find anything. It would seem like the definition for the Cerberus board has the analog pins misplaced for the sockets but since the code is not on Codeplex yet I cannot verify that assumption. Per http://wiki.tinyclr.com/index.php?title=FEZ_Cerberus_Developer#Technical_Documentation it seems like there are 3 distinct analog ports and they are all different sets of pins. On the same page it says that analog input is completed in firmware as well.

I have 2 joystick modules connected to my Cerberus. Joystick1 is connected to socket 4 and Joystick2 is connected to socket 3. First off, if I try to read Joystick2’s position I get an InvalidOperationException in Microsoft.SPOT.Hardware.dll. If I continue to play around and I just read Joystick1’s position then when I move along the Y axis then the X position changes!? If I move along the X axis there is no change. To add to the weirdness, if I move Joystick2 along the X axis then Joystick1’s Y position changes?! No change if I move Joystick2 along the Y axis.

I have not tested using socket 2 as a different analog port becuase I need it for serial (U) and would not be able to change it anyways.

Can someone verify what I am seeing? Thanks.

Anyone?

We will verify once we are back at office. Today is holiday in USA.

Thanks Gus. I am enjoying Memorial Day myself, but was hoping to get some coding in at the same time. :slight_smile: I was hoping that someone could tell me I did something wrong or could tell me it is a known issue. I will wait to see what you can find out tomorrow. Thanks.

Hi JREndean,

How are you trying to use the analog, with Gadgeteer or non Gadgeteer? What firmware version are you using? Can you post some code so we can see where the error may be coming from?

Hi Aron. I am using Cerberus as a Gadeteer board with a 4.2 project with 4.2 firmware. From MFDeploy → Device Capabilities:

ClrInfo.targetFrameworkVersion: 4.2.0.0
SolutionReleaseInfo.solutionVersion: 4.2.0.1

I have two of the Gadgeteer Joystick Modules (http://www.ghielectronics.com/catalog/product/299) plugged in to sockets 3 and 4 and the code just prints the position of the joysticks in the debug output during a GT.Timer tick.


            GT.Timer timer = new GT.Timer(100);
            timer.Tick +=
                (t) =>
                {
                    var j1 = joystick1.GetJoystickPostion();
                    int j1x = (int)(j1.X * 100);
                    int j1y = (int)(j1.Y * 100);
                    // throws exception
                    //var j2 = joystick2.GetJoystickPostion();
                    //int j2x = (int)(j2.X * 100);
                    //int j2y = (int)(j2.Y * 100);
                    int j2x = 0;
                    int j2y = 0;

                    Debug.Print("j1: " + j1x + "," + j1y + " j2: " + j2x + "," + j2y);
                };
            timer.Start();

Hello JREndean,

I tried to connect two Joystick Modules to my Cerberus, as you described. If I use sockets 3 and 4 I get same exception. Any other combination (socket 2&4, 2&3) works.
My Cerberus have latest firmware and I used Gadgeteer 4.2 project in VS 2010 Premium.

I hope you get the reason for that soon.

Thanks jernejk for verifying that I am not crazy and for getting additional data with the socket combinations. I am unsure if I can switch to socket 6 from socket 2 for the U socket. I think I saw on the wiki that there is only one COM port working on Cerberus. I will try the other one tonight and see if I can free up socket 2 to use 2&3 or 2&4 for the joystick modules.

JREndean,
There are two COM ports available on Cerberus with the latest firmware release. On the Cerberus there are two U sockets. As you are using socket 2, which happens to be COM 2, the other one is in fact COM 3.

As for the issue to which both of you are describing, we are looking into it.

Some more information to help your investigation.

If I have Joystick1 in Socket 4 and Joystick2 in Socket 2:
Joystick1 has one axis that always reads a position of 82 (sometimes changes +/- 2 or 3 with holding that axis full) the other axis works fine
Joystick2 works perfectly

If I have Joystick1 in Socket 3 and Joystick2 in Socket 2:
Joystick1 works perfectly
Joystick2 works perfectly

If I plug the serial device, XBee Adapter (http://www.ghielectronics.com/catalog/product/314) with a RN-XV WiFly module (http://www.sparkfun.com/products/11047) into
socket 6 (which is the other U socket and COM3) it does not seem to power up the module. The LEDs on the XBee and WiFly do not turn on. If I instead plug it back into socket 2 all the LEDs come on.

We have discovered the problem. One of the analog pins on socket 4 were mislabeled, causing this behavior. This will be fixed and released with the next SDK.

Awesome!

I still have to figure out why socket 6 does not power up my XBee adapter but socket 2 does. If I can clear that hurdle that I am good to go on Cerberus otherwise I will have to wait for the next SDK to fix the analog ports so I free up socket 2 again for XBee. I will take my meter to it tonight and check out that socket. Any other thoughts on what the problem could be?

Does any A socket on the Cerberus support analog input? I’ve tried all those labled A with an extender module. I’ve tried several pins on sockets 2,3, and 4. Finally I tried my code on the spider and it just worked.
This seems to apply to both analog in and analog out.

They all should work. Example code?

This works as expected on Spider mainboard but not on Cerberus:


using Microsoft.SPOT;

using GT = Gadgeteer;
using Gadgeteer.Modules.GHIElectronics;

namespace CerberusAnalogIn
{
    public partial class Program
    {
        GT.Timer timer;
        Gadgeteer.Interfaces.AnalogInput analogIn;
        Gadgeteer.Socket socket;
  
        void ProgramStarted()
        {
            socket = Gadgeteer.Socket.GetSocket(4, true, null, "A");
            analogIn = new GT.Interfaces.AnalogInput(socket, GT.Socket.Pin.Five, null);
            
            timer = new GT.Timer(1000);
            timer.Behavior = GT.Timer.BehaviorType.RunOnce;

            timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
            Debug.Print("Program Started");
        }

         void timer_Tick(GT.Timer timer)
        {
            
            Debug.Print(analogIn.ReadVoltage().ToString());
        }

         void button_ButtonPressed(Button sender, Button.ButtonState state)
         {
             double voltage = analogIn.ReadVoltage();
             Debug.Print(voltage.ToString());

             //if (!button.IsLedOn)
             //{
             //    timer.Start();
             //    button.TurnLEDOn();
             //}
             //else
             //{
             //    timer.Stop();
             //    button.TurnLEDOff();
             //}
         }
    }
}

What is the firmware version?

Re-flashed with Cerberus_4_2_0_0.dfu

The most current firmware would be TinyBooter_4_2_0_1.dfu. This is part of the latest SDK download. The new firmware will require you to reflash the board with the TinyBooter.dfu file and then deploy TinyCLR as you would any other upgrade. Analog was corrected in the new firmware.

What is the date on the download that includes TinyBooter_4_2_0_1.dfu ?

Hi Mike,

Here is the link to the latest 4.2 SDK that includes TinyBooter_4_2_0_1.dfu: http://www.tinyclr.com/forum/topic?id=6927
If you do not have TinyBooter_4_2_0_1.dfu in your current Cerberus directory then you probably do not have the latest SDK.