Home→Forums→MonoBrick EV3 Firmware→Mindsensors' GlideWheel sensor (and possibly other sensors from MS) doesn't work
- This topic has 13 replies, 4 voices, and was last updated 10 years ago by Anders Søborg.
-
AuthorPosts
-
November 2, 2014 at 10:01 #4948
Filip KirschnerParticipantI submitted this to github as a bug as well.
I implemented class for data collection from Mindsensors’ GlideWheel, datasheet is here.
However, the
ReadRegister(bool register, int length)
is returnsbyte[]
which consiststs of first byte containing register number equivalent to the first argument ofReadRegister()
and the rest of bytes contain zeroes.I suppose this is a monoev3 related bug since:
* The physical sensor works in EV3 graphical SDK as expected
* Other manufacturers’ sensors work on tested EV3 as expected (tested with Hi-Technic Gyro and Lego Color sensor)
* Other users are having this issue as well with other Mindsensors’ sensorsCode including Main() for testing purposes follows:
c# using System; using MonoBrickFirmware; using MonoBrickFirmware.Display.Dialogs; using MonoBrickFirmware.Display; using MonoBrickFirmware.Movement; using MonoBrickFirmware.Sensors; using System.Threading; using System.Collections; using MonoBrickFirmware.UserInput; namespace MonoBrickHelloWorld { class MainClass { public static void Main (string[] args) { EventWaitHandle stopped = new ManualResetEvent (false); MindsensorsAngleSensor NewSensor = new MindsensorsAngleSensor(SensorPort.In1); HiTecGyroSensor gyro = new HiTecGyroSensor(SensorPort.In2); NewSensor.ResetAngle(); ButtonEvents buts = new ButtonEvents (); buts.EscapePressed += () => { stopped.Set (); }; buts.EnterPressed += () => { LcdConsole.WriteLine(Convert.ToString(NewSensor.ReadAngle())); LcdConsole.WriteLine(Convert.ToString(gyro.ReadAngularAcceleration())); }; stopped.WaitOne (); } } public class MindsensorsAngleSensor : I2CSensor { internal enum GlideWheelRegister : byte { ResetCommand = (byte)'r', Command = 0x41, Angle = 0x42, RAW = 0x46, RevolutionsPerMinute = 0x4A }; public MindsensorsAngleSensor (SensorPort Port) : base (Port, (byte)0x30, I2CMode.LowSpeed9V) { base.Initialise(); } private static int byte4toInt(byte[] b){ return (int)b[0] + ((int)b[1] << 8) + ((int)b[2] << 16) + ((int)b[3] << 32); } public void ResetAngle() { byte[] BytesToWrite = {(byte)0}; BytesToWrite[0] = (byte)GlideWheelRegister.ResetCommand; WriteRegister((byte)GlideWheelRegister.Command, BytesToWrite); return; } public int ReadAngle () { return byte4toInt(ReadRegister((byte)GlideWheelRegister.Angle, 4)); } public int ReadRAW () { return byte4toInt(ReadRegister((byte)GlideWheelRegister.RAW, 4)); } public override string ReadAsString() { return("Angle: " + Convert.ToString(ReadAngle()) + " RAW: " + Convert.ToString(ReadRAW())); } public override string GetSensorName() { return "Mindsensors GlideWheel"; } public override int NumberOfModes() { return 1; } public override void SelectNextMode() { return; } public override void SelectPreviousMode() { return; } public override string SelectedMode() { return ("Mode 1"); } } }
November 2, 2014 at 11:48 #4949
Anders SøborgParticipantHi there
Try to read 8 bytes instead of four. I found that some sensors only supports read 8 bytes at a time. If this does not work try to read a single byte.
/Anders
November 2, 2014 at 11:51 #4950
Anders SøborgParticipantHi there
I just had a look at this code and it seems that he is using a readAndWrite. Have you tried this?
/Anders
November 2, 2014 at 17:23 #4952
Andreas BoerzelParticipantHi Anders,
thank you for your tip and I would like to try this, but I can’t find a corresponding method forif (!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- This reply was modified 10 years ago by Andreas Boerzel.
November 3, 2014 at 17:49 #4955
Anders SøborgKeymasterNo need to look in the UnixDevice class. In the I2c class there you will a WriteAndRead method.
/Anders
November 6, 2014 at 21:56 #4958
Anders SøborgParticipantHi
Did you get this working?
/Anders
November 7, 2014 at 11:24 #4960
Andreas BoerzelParticipantUnfortunately 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!
November 7, 2014 at 15:06 #4961
Anders SøborgKeymasterHi there
Could you please post the code you used for WriteAndRead method what is your input to this function?
/Anders
November 7, 2014 at 19:19 #4962
Anders SøborgParticipantHi there
The folks over at mindsensors.com are kind enough to send me a sample for me to work with…keep me posted if you make any progress and I will do the same.
/Anders
- This reply was modified 10 years ago by Anders Søborg.
November 10, 2014 at 11:28 #4967
Andreas BoerzelParticipantHi,
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?!
November 10, 2014 at 22:10 #4974
Anders SøborgKeymasterHi there
Great. Now remember to add your code to the Github using a pull request..
Anders
November 11, 2014 at 13:31 #4975
Andreas BoerzelParticipantHi!
Yes of course, I will add the code! But I still need few days to refactor the code before I publish it.November 19, 2014 at 21:21 #4988
Andreas BoerzelParticipantHi,
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
November 19, 2014 at 21:30 #4989
Anders SøborgKeymasterHi Andreas
Great I will have a look at it when I get the time…
Anders
-
AuthorPosts
You must be logged in to reply to this topic.
Follow