Freeze with NXT-EV3 Mindsensors adapter

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

fredsiva
New User
Posts: 13
Joined: Thu Nov 09, 2017 7:24 am

Freeze with NXT-EV3 Mindsensors adapter

Postby fredsiva » Thu Nov 30, 2017 2:59 pm

Hello,
I am using the mindsensors NXT-EV3 adapter which allows the EV3-UART sensors to be plugged in the NXT.
Using lejos 0.9.1 , java8 and Eclipse Neon.

I am using it on an EV3 to view the ev3 sensors as I2C devices, to learn this I2C technology, and hopefully multiplex several EV3 sensors (since I2C allows that).

It is working most of the time fine. But, from time to time, the EV3 totally freeze (even the Linux layer).

Are some of you using this adapter successfuly on an EV3?

thanks guys.

User avatar
gloomyandy
leJOS Team Member
Posts: 5969
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Freeze with NXT-EV3 Mindsensors adapter

Postby gloomyandy » Thu Nov 30, 2017 3:26 pm

I've never seen the EV3 lock up when talking to an i2c device. What class are you using to talk to the adaptor? How often does it happen? Can you reproduce the problem with a short test program?
leJOS news https://lejosnews.wordpress.com/

fredsiva
New User
Posts: 13
Joined: Thu Nov 09, 2017 7:24 am

Re: Freeze with NXT-EV3 Mindsensors adapter

Postby fredsiva » Thu Nov 30, 2017 4:16 pm

I will try to reproduce through simple test program.

I also got a freeze at boot time, even before my program started, just with the adapter plugged in.

Mindsensors.com support is telling me there is no known bug with this adapter.

User avatar
gloomyandy
leJOS Team Member
Posts: 5969
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Freeze with NXT-EV3 Mindsensors adapter

Postby gloomyandy » Thu Nov 30, 2017 4:28 pm

That sounds very odd, the EV3 doesn't really do anything with i2c at boot time, so I don't really see how just having it attached would cause a problem. Again I've never seen the EV3 freeze at boot time unless the SD card is corrupt. I assume you are not really using Java 8 on the EV3 (unless you really know what you are doing this is not a good idea). The standard JRE we recommend for use is the Java 7 one.

You didn't say how you are talking to the device?
leJOS news https://lejosnews.wordpress.com/

fredsiva
New User
Posts: 13
Joined: Thu Nov 09, 2017 7:24 am

Re: Freeze with NXT-EV3 Mindsensors adapter

Postby fredsiva » Fri Dec 08, 2017 2:47 pm

Finally got to reproduce this pretty consistently.

Refreshed fully my EV3 with 0.9.1 Lejos and JRE 1.7.
I am compiling using Eclipse.

Here is my Java version on EV3:
root@EV3:~/lejos/ejre1.7.0_60/bin# ./java -version
java version "1.7.0_60"
Java(TM) SE Embedded Runtime Environment (build 1.7.0_60-b19, headless)
Java HotSpot(TM) Embedded Client VM (build 24.60-b09, mixed mode, sharing)



-------------------------------------------------------------------------------------------------
Here is a copy of my program

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.text.DateFormat;
import lejos.hardware.port.*;
import lejos.hardware.sensor.I2CSensor;
import lejos.hardware.Button;
import lejos.hardware.lcd.LCD;
import lejos.hardware.port.SensorPort;

class WaterTempSensor {
private TestAdap theController;
int I2CSlaveAddress = 0,
I2C_readRegister = 0,
I2C_activationRegister = 0;
byte[] bufReadResponseLH = new byte[2];
ByteBuffer wrapped;
I2CSensor i2cSensor;

public WaterTempSensor(TestAdap aController, Port port, int I2C_adr, int I2C_activation_registry, int I2C_readReg) {
I2CSlaveAddress = I2C_adr;
I2C_readRegister = I2C_readReg;
I2C_activationRegister = I2C_activation_registry;

try {
i2cSensor = new I2CSensor(port, I2C_adr);
i2cSensor.sendData(I2C_activation_registry, (byte) 0x01);

theController.log("I2C Sensor Activate. Vers=" + i2cSensor.getVersion() +
", Vdr=" + i2cSensor.getVendorID() + ", Prd=" + i2cSensor.getProductID() +
", Adr=" + i2cSensor.getAddress() + " Activation Reg=" + I2C_activationRegister +
" Read Reg=" + I2C_readRegister, 0);
} catch (Exception e) {
System.err.println("Error init I2C sensor on Port (" + port.getName() + ") with adr (" + I2C_adr + ") : " + e);
}
}

public int getValue() {
i2cSensor.getData(0x54, bufReadResponseLH, bufReadResponseLH.length);

wrapped = ByteBuffer.wrap(bufReadResponseLH);
wrapped.order(ByteOrder.LITTLE_ENDIAN);
return (wrapped.getShort());
}
}

public class TestAdap {
static BufferedWriter bwriter = null;
static FileWriter fwriter = null;
static Runtime rt;
WaterTempSensor sen;

public static void main(String[] args) {
TestAdap obj = new TestAdap();
try {
obj.run();
} catch (Exception e) {
System.out.println("Run Failed" + e);
}
}

public void run() throws Exception {
long count = 0;
fwriter = new FileWriter("TestAdap.txt");
bwriter = new BufferedWriter(fwriter);
bwriter.write("New log File");
rt = Runtime.getRuntime();

sen = new WaterTempSensor(this, SensorPort.S1, 0x32, 0x52, 0x54); //EV3 Color on Mindsensor Adap (NXT port on EV3 brick)

while (Button.getButtons() !=Button.ID_ESCAPE) {
LCD.drawString("S1 Val=" + sen.getValue() + " (" + count + ") ", 0, 0);

if (count % 100 == 0) // Log every 100 samples
log("S1 Val=" + sen.getValue() + " (" + count + " samples)", 0);
count++;
}
}

public static void log(String msg, int prio) {
try {
bwriter.write(""+ DateFormat.getTimeInstance().format(System.currentTimeMillis()) + ": " + msg +
"[" + rt.totalMemory()/1024 + " Mb Tot /" + rt.freeMemory()/1024 + " Mb Free]");
bwriter.newLine();
bwriter.flush();
} catch (Exception e) {
System.err.println("Error Logging Text (" + msg + ") " + e);
}
}
}



it freezes after between 100.000 to 1 million samples.

here is extract of the trace:
New log File1:33:30 PM: I2C Sensor Activate. Vers=V1.17, Vdr=mndsnsrs, Prd=EvSadpt, Adr=50 Activation Reg=82 Read Reg=84[4992 Mb Tot /3426 Mb Free]
1:33:30 PM: S1 Val=39 (0 samples)[4992 Mb Tot /3339 Mb Free]
1:33:31 PM: S1 Val=39 (100 samples)[4992 Mb Tot /3315 Mb Free]
<... a lot more lines ...>
1:54:08 PM: S1 Val=37 (141100 samples)[4992 Mb Tot /3105 Mb Free]
1:54:09 PM: S1 Val=37 (141200 samples)[4992 Mb Tot /3076 Mb Free]


Any clue about what can be happening?

User avatar
gloomyandy
leJOS Team Member
Posts: 5969
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Freeze with NXT-EV3 Mindsensors adapter

Postby gloomyandy » Fri Dec 08, 2017 6:33 pm

Not idea to be honest and that is a lot of operations, what happens if you use...

Code: Select all

i2cSensor = new I2CSensor(port, I2C_adr), SensorConstants.TYPE_HIGHSPEED);


rather than

Code: Select all

i2cSensor = new I2CSensor(port, I2C_adr);


To create the port? You may need to import lejos.hardware.sensors.SensorConstants to get TYPE_HIGHSPEED This will use a high speed i2c interface (100KHz instead of 10KHz), which may or may not work with this hardware, the high speed implementation is totally different to that used for the default mode, so it may work better for you.


Oh and when posting code it really helps if you use the code tags.
leJOS news https://lejosnews.wordpress.com/

fredsiva
New User
Posts: 13
Joined: Thu Nov 09, 2017 7:24 am

Re: Freeze with NXT-EV3 Mindsensors adapter

Postby fredsiva » Sat Dec 09, 2017 11:00 pm

Thanks for the hint, it now works (More than 2 million samples)

BTW, still scary to have the EV3 freeze totally when something wrong is going on in the Java VW

User avatar
gloomyandy
leJOS Team Member
Posts: 5969
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Freeze with NXT-EV3 Mindsensors adapter

Postby gloomyandy » Sun Dec 10, 2017 8:33 am

There is a lot more going on in the EV3 than just running a Java VM. When using the slow i2c interface the EV3 is using a special real time interrupt system to actually generate the required i2c waveforms using standard I/O ports. This code runs at a higher priority than the Linux kernel and could possibly be the source of the lockup. If you want to know more take a look for "ARMFIQ" Having said that I've never seen an EV3 lockup with any other i2c hardware device so something odd is going on here!
leJOS news https://lejosnews.wordpress.com/


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 6 guests