Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with i2c #18

Open
laterrps opened this issue Aug 23, 2017 · 13 comments
Open

Problems with i2c #18

laterrps opened this issue Aug 23, 2017 · 13 comments

Comments

@laterrps
Copy link

I have problem using i2c comunication
i am using mpu6050 i dont know why but the program is freezing and interrupts still working

@laterrps
Copy link
Author

this was happening with max30102 sensor too this has been happening at randomly way.

@kriswiner
Copy link

kriswiner commented Aug 23, 2017 via email

@laterrps
Copy link
Author

image

i am using 2.2k resistors

@kriswiner
Copy link

kriswiner commented Aug 23, 2017 via email

@laterrps
Copy link
Author

I initialize like this:
Wire.setClock(reloj);
Wire.begin();

void movimiento() {
static bool calculaFC;

if (movread == true) {
	//Serial.println("acc1");
	flagMovimiento=Acel.getIntMotionStatus();
	movimientoActualizado = false;
	movread == false;
	if (flagMovimiento == true && movimientoActualizado == false) {
		/*Serial.println("update1");*/
		tiempoUltimoMovimiento = millis();
		movimientoActualizado = true;
		/*Serial.println("update2");*/

	}
	armv7m_timer_create(&timerMuestreoMovimiento, (armv7m_timer_callback_t)muestraMovimiento);

	armv7m_timer_start(&timerMuestreoMovimiento,200);
	//armv7m_timer_start(&timerMuestreoMovimiento, 100);
	movread = false;
	//Serial.println(flagMovimiento);
}
int tiempoActual = millis();
if (((tiempoActual - tiempoUltimoMovimiento) > 5000) && calculaFC==false) {
	calculaFC = true;
	correct = 0;
	configurarAfe4400();
	//Serial.println("timer");
	armv7m_timer_create(&timerPersistenciaFrecuenciaCardiaca, (armv7m_timer_callback_t)cancelarLecturaFrecuenciaCardiaca);

	armv7m_timer_start(&timerPersistenciaFrecuenciaCardiaca, 40000);
	stopedByTimer = false;
}
if (calculaFC) {
	tiempoUltimoMovimiento = millis();
	//Serial.println("dsp");
	DSP(false);
	if (correct == 6) {
		char ppm[10];
		calculaFC = false;
		float fc = auxFrec / 5;
		powerDownAfe4400();
		correct = 0;
		Oled.setDrawColor(0);
		Oled.drawBox(0, 16, 131, 16);
		Oled.setDrawColor(1);
		Oled.drawStr(0,16,"PPM");
		sprintf(ppm, "%.0f", fc);
		Oled.drawStr(50, 16, ppm);
		
	}
	else {
		if (stopedByTimer == true) {
			Serial.println("Error en lectura");
			///////////////AQUI PUEDE IR SINTETIZADOR DE VOZ//////////////////
			////////////////O REINTENTAR CALCULO DE FRECUENCIA CARDIACA///////////
			calculaFC = false;
			powerDownAfe4400();
			Oled.setDrawColor(0);
			Oled.drawBox(0, 16, 131, 16);
			Oled.setDrawColor(1);
			Oled.drawStr(0, 16, "Err.");
			Oled.sendBuffer();
			
			correct = 0;
			stopedByTimer = false;
		}

	}

}

}

@laterrps
Copy link
Author

I am using mpu library (Jeff Rowberg)

@kriswiner
Copy link

kriswiner commented Aug 23, 2017 via email

@laterrps
Copy link
Author

JAJAJAJ
Ok ok!

you recomendme make my own algorithm?
or does exist some other library?

@laterrps
Copy link
Author

or do you have any example?

@kriswiner
Copy link

kriswiner commented Aug 23, 2017 via email

@laterrps
Copy link
Author

I implemented a motion detect algorithm and it looks like it's working correctly thank you for your help i'll be carefull and instead of copy work from internet i will implement my own code.

@kriswiner
Copy link

kriswiner commented Aug 24, 2017 via email

@laterrps
Copy link
Author

I'm still having problems i did implement this:

Serial.print("status ");Serial.print(Wire.status());Serial.println();
		Serial.print("vector interrupciones  ");Serial.print(interrupcones,BIN);Serial.println();

and this shows in terminal.
image
and communication get down! but program still running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants