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

Porting this code #6

Open
sreibs opened this issue Apr 23, 2018 · 3 comments
Open

Porting this code #6

sreibs opened this issue Apr 23, 2018 · 3 comments

Comments

@sreibs
Copy link

sreibs commented Apr 23, 2018

Hi guys,

I am trying to use this with a raspberry. I used this code and the BCM2835 for hardware management (GPIO etc....).

Most is working (communication, SPI, spo² value seems correct..) but the heartbeat is very unstable (78bpm then 150 then 90...).

Can you point at extra care to have to get this code working on another target? I have seen the "FS" constant that is supposed to be a sampling frequency, but I don't know how to adjust it for my target.

Thank you very much for your help.

@protocentralashwin
Copy link
Contributor

@sreibs It looks you might be missing samples, can you please recheck your readback routines (to read data from the AFE4490's SPI)?

@adelalfusail
Copy link

its not stable except when there is no light in the room

@sreibs
Copy link
Author

sreibs commented Oct 28, 2018

Hi all,
I am sorry for being so late, this topic has been putting aside for a (too) long time. Here is the routine:

bool processAFE44xxMeasure(void){
	bool result = false;
	
//	if (drdy_trigger == HIGH)
	if(bcm2835_gpio_lev(PIN_DRDY) == HIGH)
     {
//        detachInterrupt(0);
        afe44xxWrite(CONTROL0,0x000001);  
        IRtemp = afe44xxRead(LED1VAL);
        afe44xxWrite(CONTROL0,0x000001);  
        REDtemp = afe44xxRead(LED2VAL);   
        afe44xx_data_ready = true;
     }  
                    
	if(afe44xx_data_ready == true)
	{

		IRtemp = (unsigned long) (IRtemp<<10);
		seegtemp = (signed long) (IRtemp);
		seegtemp = (signed long) (seegtemp>>10);  

		REDtemp = (unsigned long) (REDtemp<<10);
		seegtemp2 = (signed long) (REDtemp);
		seegtemp2 = (signed long) (seegtemp2>>10);

		if(dec==20)
		{
		  aun_ir_buffer[n_buffer_count]=(uint16_t) (seegtemp>>4);
		  aun_red_buffer[n_buffer_count]=(uint16_t) (seegtemp2>>4);
		  n_buffer_count++;
		  dec=0;

		}
		dec++;

		if(n_buffer_count>99)
		{

		  estimate_spo2(aun_ir_buffer, 100, aun_red_buffer, &n_spo2, &ch_spo2_valid,&n_heart_rate, &ch_hr_valid); 
		  g_AFE44xxData.bpm = (float)n_heart_rate;
		  g_AFE44xxData.spo2 = (float)n_spo2;
		  printf("Estimate data : \tbpm:%.0f\tspo2:%0.1f\n", g_AFE44xxData.bpm, g_AFE44xxData.spo2);
		  fflush(stdout);
		  n_buffer_count=0;
		  if(g_AFE44xxData.bpm >= 0 && g_AFE44xxData.spo2 >= 0){
			  result = true;
			}
		}         

		afe44xx_data_ready = false;
		drdy_trigger = LOW;
//		attachInterrupt(0, afe44xx_drdy_event, RISING );  
		while(bcm2835_gpio_lev(PIN_DRDY) == HIGH);

	}        
	return result;
}

Do you think it is a matter of light in the room ?

Thank you for your feedback,

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

3 participants