Andreas Boerzel

Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • Author Image
    Andreas Boerzel
    Participant

    Hi,
    I have implemented the sensor class AbsoluteIMU_ACGSensor.cs, that works with the Mindensors AbsoluteIMU-ACG sensor and created a pull request at Github. I also added a the test sample AbsoluteIMU_ACGSensorExample.cs.

    Andreas

    Author Image
    Andreas Boerzel
    Participant

    Hi!
    Yes of course, I will add the code! But I still need few days to refactor the code before I publish it.

    Author Image
    Andreas Boerzel
    Participant

    Hi,
    I have good news!
    At the weekend I updated my sd-card to the latest image and got the latest version from the master-branch, and now the AbsoluteIMU-ACG sensor works with the implementation I added in the tread How to use AbsoluteIMU-ACG sensor?.

    Maybe the problem was only that I used an old sd.card image?!

    Author Image
    Andreas Boerzel
    Participant

    Unfortunately it does not work yet! The WriteAndRead-method of the I2CSensor class doesn’t work with the AbsoluteIMU sensor. It seems for me that the AbsoluteIMU sensor has a different command-structure. I also tried to port the LeJOS-implementation of the AbsoluteImuAgcMindSensor.java class to MonoBrick, but unfortunately the Libc lowlevel methods are not compatible with them of LeJOS. So I contacted the mindsensors support, but at the moment I’m helpless!

    in reply to: How to use AbsoluteIMU-ACG sensor? #4956
    Author Image
    Andreas Boerzel
    Participant

    Hi Max,
    I’ve tried both, but without success…

    Author Image
    Andreas Boerzel
    Participant

    Hi Anders,
    thank you for your tip and I would like to try this, but I can’t find a corresponding method for

    if (!writeI2C(link, MSANG_I2CRequest, MSANG_I2CReply, 4))
    return -1;  

    in the UnixDevice class. I don’t have much unix knowledge, is there a corresponding method for ‘writeI2C’ in the Libc library available?

    Thanks,
    Andreas

    in reply to: How to use AbsoluteIMU-ACG sensor? #4951
    Author Image
    Andreas Boerzel
    Participant

    Hi,
    I tried the sample code from Max, but it’s the same result byte[] ReadRegister(byte register, byte rxLength) returns only the first byte and all other bytes are zero, exactly as described by Filip. I really want to use this sensor with MonoBrick and I am willing to provide a sensor implementation, but my knowledge regarding I2C devices are not sufficient for this purpose. Can someone help me?

    Thanks!

    in reply to: How to use AbsoluteIMU-ACG sensor? #4944
    Author Image
    Andreas Boerzel
    Participant

    I also tried sensor mode LowSpeed9V, but with the same result.

    in reply to: How to use AbsoluteIMU-ACG sensor? #4942
    Author Image
    Andreas Boerzel
    Participant

    Thank you very much for your answer, I think it’s the right way. I tried to implement my own sensor-class, see code below. But my test program reads only invalid and constant values.

    Does anyone know what’s wrong with my sensor implementation?

    Thanks,
    Andreas

     public class AbsoluteIMU_ACGSensor : I2CSensor
        {
            private const byte ADDRESS = 0x22;
    
            private enum I2CRegisters : byte
            {
                Command = 0x41, 
                XGyroDataLSB = 0x53, 
                XGyroDataMSB = 0x54,
                YGyroDataLSB = 0x55,
                YGyroDataMSB = 0x56,
                ZGyroDataLSB = 0x57,
                ZGyroDataMSB = 0x58
            };
    
            private static int MLBToInteger(byte lsb, byte msb)
            {
                return (int)lsb + ((int)msb << 8);
            }
    
            public AbsoluteIMU_ACGSensor(SensorPort port)
                : base(port, ADDRESS, I2CMode.LowSpeed)
            {
                base.Initialise();
            }
    
            public GyroData ReadGyro()
            {
                LcdConsole.WriteLine("ReadGyro...");
                byte[] result = ReadRegister((byte)I2CRegisters.XGyroDataLSB, 6);
                LcdConsole.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", result[0], result[1], result[2], result[3], result[4], result[5]);
                return new GyroData(result);
            }
    
            public class GyroData
            {
                public GyroData(byte[] rawData)
                {
                    X = MLBToInteger(rawData[0], rawData[1]);
                    Y = MLBToInteger(rawData[2], rawData[3]);
                    Z = MLBToInteger(rawData[4], rawData[5]);
                }
    
                public int X { get; private set; }
                public int Y { get; private set; }
                public int Z { get; private set; }
            };

    Testprogram:

     class Program
        {
            static void Main(string[] args)
            {
                var buts = new ButtonEvents();
    
                LcdConsole.WriteLine("Starting...");
    
                var gyroSensor = new AbsoluteIMU_ACGSensor(SensorPort.In2);
                gyroSensor.SendCommand((byte)AbsoluteIMUCommands.ChangeAccelerometerSensitivityTo2G); 
    
                bool end = false;
    
                buts.EscapePressed += () =>
                {
                    end = true;
                    LcdConsole.WriteLine("Stopping...");
                };
    
                while (!end)
                {
                   // LcdConsole.Clear();
                    var result = gyroSensor.ReadGyro();
                    LcdConsole.WriteLine("GX: {0}", result.X);
                    LcdConsole.WriteLine("GY: {0}", result.Y);
                    LcdConsole.WriteLine("GZ: {0}", result.Z);
                    Thread.Sleep(250);
                }
            }

    The AbsoluteIMU-User-Guide describes the I2C-registers.

Viewing 9 posts - 1 through 9 (of 9 total)
Posted in

Make a donation