Wich software can compile this project

hello evry one i find this programe writt be GURU
and i read all his page about blood pressure and calculation and schematic
i need to build it for an competition
i need to edit this program for add more thing about hardware and software
but i test this program on atmel studio and not compile yet and in mickoc for avr and not compile yet
wich software can compile this project

#include <Mega32.h>  
#include <delay.h>

#asm
     .equ __lcd_port = 0x15
#endasm

#include <math.h>
#include <lcd.h>
#include <stdio.h>
#include <stdlib.h>

//define states for motor control
#define startState 0
#define inflate1State 1
#define inflate2State 2
#define deflateState 3
#define displayState 4
#define resetState 5


//define states for Measure control
#define Sys_Measure 6
#define Sys_Cal 7
#define Rate_Measure 8
#define dias_Measure 9 
#define dias_Cal 10

#define LCDwidth 16	


void initialize(void);

//declare functions for motor control            
void start_state(void);
void inflate1_state(void);
void inflate2_state(void);
void deflatestate(void);
void display_state(void);
void reset_state(void);

//declare all functions for measuring control
void pressuremeasure(void);
void sysmeasure(void);
void syscal(void);
void ratemeasure(void);
void diasmeasure(void); 
void diascal(void);

//declare variable for motor controls
unsigned char Maybe0,Maybe1,Maybe2,countlcd;
unsigned char currentState;
unsigned int timepress0, timepress1, timepress2, timelcd;      
char lcd_output[17];

//declare variable for measuring and calculating value
float DC_gain;
unsigned char meas_state;
unsigned int timing, timerate, timerun_dias, timecount, timedeflate, timedisplay; 
float  maxpressure, pressure,accum_data, press_data; 
unsigned char count, stop_count;

//ADC data variabls
float Vref;
unsigned char data;
float adc_data, former; 

//define counter
unsigned char sys_count,count_average, countpulse;

//declare rate measure variable
float time_pulse,pulse_period, total_pulse_period, pulse_per_min;

//declare systolic and diastolic variable
float systolic, diastolic;

//declare all the threshold values
float TH_sys, TH_rate, TH_dias;

       
//***********************************************
//timer 0 compare ISR
interrupt [TIM0_COMP] void timer0_compare(void)
{
   if(~PINB & 0x01) timepress0++;
   if(~PINB & 0x02) timepress1++;  
   if(~PINB & 0x04) timepress2++;  
   timecount++;                      
   timedeflate++;
    //Decrement each time tast if they are not already zero
    
    //timing for sampling data at every 40 msec
 	if(timing>0) --timing; 
 	//-----------------------------------------------------
	 //run time for different tasks

 	//run timerate for measuring heart rate
	 if(timerate<6000) ++timerate;
 
	 //run timerun_dias
	 if(timerun_dias<2000) ++timerun_dias;
 
   //if(countlcd) timelcd++; 
   
    //run time for the display
    if(timedisplay<2000) ++timedisplay;   
}

//***********************************************
// ADC Interrupt
//**********************************************************

interrupt [ADC_INT] void adc_complete(void)
{ 
 data = ADCH;
 //then calculate adc_data into float;
    adc_data = (float)(((float)data)/256*Vref);
    
 
 //if signal is above threshold, go to calculate systolic pressure
 if(meas_state ==Sys_Measure)
 	{   
	   
 	   if(former<=TH_sys && adc_data>TH_sys)
 	    sys_count++;        
 	    
 	   former = adc_data;            
	    
 	   
 	   
    }
 //-----------------------------------------------------------
 else if(meas_state==Sys_Cal)
 	{ 
 	
 	  if(count<4)
 	  {
 	   accum_data=accum_data+adc_data;
 	   count++;
 	  }
 	  if(count==4)
 	  {
 	  press_data=accum_data/4;
 	  systolic = (press_data/DC_gain)*9375;//calculate from adc_data
 	  meas_state = Rate_Measure; 
 	  countpulse=0;
 	  former = 2.4; //set the initial point for rate measuring
 	  count_average=0;
 	  }
 	}
 //----------------------------------------------------------
 	
 else if(meas_state==Rate_Measure)
 {
 	if(count_average<5)
 	{
 	
 	 if(former<TH_rate && adc_data>TH_rate && countpulse==0)
 	 	{
 	    timerate=0;
 	    countpulse=1;
 	    former=adc_data;
 	    }
 	    
 	 if(former<TH_rate && adc_data>TH_rate && countpulse==1)
 	    {	    
 	    total_pulse_period=total_pulse_period+timerate; 
 	    timerate=0;
 	    count_average++; //finish reading one period  
 	    }
 	  
 	 }//count_average 
 	 
 	 former=adc_data;
 	 
}// else if(meas_state=Rate_Measure)
//-------------------------------------------------------------
else if(meas_state==dias_Measure)
{
   	if(timerun_dias<2000)
   		{
    	if(adc_data>TH_dias)
    	{ timerun_dias=0; //reset time if the signal 
    	//is still greater than threshold (so it will never reach 1999)
    	//if it doesn't reset,the time will stuck at 1999
    	lcd_clear();
		lcd_gotoxy(0,0);
		lcd_putsf("Dias measure");   
		}
   		}
   	if(timerun_dias>=2000)
   		{  
   		meas_state = dias_Cal;//if done go back to Sys_Measure to be ready for next opt
   		} 
    
}
//------------------------------------------------------------- 
else if(meas_state==dias_Cal)
{     
      diastolic = (adc_data/DC_gain)*9375;//calculate from adc_data
 	  meas_state = Sys_Measure; 
 	  currentState = displayState;  
 	  //open valve
 	  PORTD=0;
 	
}

 timing = 40;//set time for another conversion
 
}// end of ADC interrupt
//***********************************************************


void main(void)
{
	initialize();
	while(1)
	{	
		switch(currentState)
		{	
			case startState:
				 start_state();
				 break;
			case inflate1State:
				 inflate1_state();
				 break;
			case inflate2State:
				 inflate2_state();
				 break;
			case deflateState:
				 deflatestate();
				 break;
			case displayState:
				 display_state();
				 break;
			case resetState:
				 reset_state();
				 break;
		
		}
	}
	
}
//***********************************************
void start_state(void)
{   sys_count=0;              
    pressure = 0;
    accum_data=0; 
	press_data=0; 
    count=0;
    stop_count=0; 
     
    maxpressure = 160; 
    meas_state = Sys_Measure; 
    former=TH_sys-0.01;

	timerun_dias=0;
	time_pulse=0;
	timerate=0;

	timing=40;

	total_pulse_period=0;
	systolic=0;
	diastolic=0;
	pulse_per_min=0;

	sys_count=0;
	count_average=0;
	countpulse=0;

	if((~PINB & 0x01) && (timepress0 > 30)) Maybe0 = 1;
	if(Maybe0 && (PINB == 0xff))
	{
			countlcd = 1;
			timelcd = 0;
			lcd_clear();
			lcd_gotoxy(0,0);
			lcd_putsf("Inflating");
			currentState = inflate1State;
			Maybe0 = 0;
			timepress0 = 0;  
			timecount=0;
			//turn on motor and close the valve
			PORTD=0x03;
			//activate ADC
	} 
}
//***********************************************

void inflate1_state(void)
{         
	if(timecount>=200)
	{
	timecount=0;                       
	sprintf(lcd_output,"%-i",(int)pressure);
	lcd_gotoxy(0,1);
	lcd_puts(lcd_output);
	}
	
	if((~PINB & 0x02) && (timepress1 > 30)) Maybe1 = 1;
	if(Maybe1 && (PINB == 0xff))
	{
		lcd_clear();
		lcd_gotoxy(0,0);
		lcd_putsf("Emergency Stop");             
		sprintf(lcd_output,"%-i",(int)pressure);
	    lcd_gotoxy(0,1);
	    lcd_puts(lcd_output);
		//turn off motor and open the valve
		PORTD=0;
		currentState = resetState;
		Maybe1 = 0;
		timepress1 = 0;
		countlcd = 0;
	}
	else
	{
		currentState = inflate2State;
	} 
		
}
//***********************************************
void inflate2_state(void)
{   
     ADMUX=0b00100001;//choose ADC1 for reading DC
		
    //enable ADC and set prescaler to 1/128*16MHz=125,000
    //and uncheck interupt enable
    //and start a conversion
    ADCSR = 0b11000111;  
    data= ADCH;
    adc_data = (float)(((float)data)/256*Vref);
    pressure= (adc_data/DC_gain)*9375;  
  
    if(pressure>=maxpressure) stop_count++;   
    else stop_count = 0;
    
    if(stop_count>=5)
	{
		lcd_clear();
		lcd_gotoxy(0,0);
		lcd_putsf("Deflating");        
		sprintf(lcd_output,"%-i",(int)pressure);
	    lcd_gotoxy(0,1);
	    lcd_puts(lcd_output);
		//turn off motor but keep the valve
		PORTD = 0x02;
		delay_ms(1000);
		currentState = deflateState;   
		timedeflate = 0;    
		sprintf(lcd_output,"%-i",(int)pressure);
	    lcd_gotoxy(0,1);
	    lcd_puts(lcd_output);
	}
	else
	{
		currentState = inflate1State; 	
	} 
	
}
//***********************************************
void deflatestate(void)
{                                         
    /*if(timedeflate >= 1900)
    {   
         PORTD = 0;
         if(timedeflate >= 2000)
         {
         	PORTD = 0x02;
         	timedeflate = 0;
         }
    }*/
	if((~PINB & 0x02) && (timepress1 > 30)) Maybe1 = 1;
	if(Maybe1 && (PINB == 0xff))
	{
		lcd_clear();
		lcd_gotoxy(0,0);
		lcd_putsf("Emergency Stop");                  
		sprintf(lcd_output,"%-i",(int)pressure);
	    lcd_gotoxy(0,1);
	    lcd_puts(lcd_output);
		//turn off motor and open the valve
		PORTD=0;
		currentState = resetState;
		Maybe1 = 0;
		timepress1 = 0;                            
    }
	//if(done) --> Display state
	if(currentState==deflateState) pressuremeasure(); //if still deflating, measure everything
}

//***********************************************
void display_state(void)
{   
     
if(timedisplay<=1000)
{
    if(timecount>=200)
	{
	lcd_clear();
    timecount=0;
	lcd_gotoxy(0,0);
	lcd_putsf("Sys"); 
	lcd_gotoxy(7,0);
	lcd_putsf("Dias");
	lcd_gotoxy(15,0);
	lcd_putsf("HR");                     
	sprintf(lcd_output,"%-i",(int)systolic);
	lcd_gotoxy(0,1);
	lcd_puts(lcd_output);  
	
	sprintf(lcd_output,"%-i",(int)diastolic);
	lcd_gotoxy(7,1);
	lcd_puts(lcd_output); 
	
	sprintf(lcd_output,"%-i",(int)pulse_per_min);
	lcd_gotoxy(14,1);
	lcd_puts(lcd_output);  
	} 
}

else if (timedisplay>1000&&timedisplay<2000)
{	
	if(timecount>=200)
	{	lcd_clear();
        timecount=0;
        
		lcd_gotoxy(0,0);
		lcd_putsf("Black: Resume"); 
	
	}  
}

else
{
    timedisplay=0;
}	
	if((~PINB & 0x04) && (timepress2 > 30)) Maybe2 = 1;
	if(Maybe2 && (PINB == 0xff))
	{
		lcd_clear();       
		lcd_gotoxy(0,0);
		lcd_putsf("White: Start");
		lcd_gotoxy(0,1);
		lcd_putsf("Grey: Stop");
		currentState = startState;
		timepress2 = 0;         
		Maybe2=0; 
		systolic=0;
		diastolic=0;
		pulse_per_min=0;
	
	} 
	   
}
//***********************************************
void reset_state(void)
{   
if(timedisplay<=1000)
{
    if(timecount>=200)
	{   timecount=0;
     	lcd_clear();
		lcd_gotoxy(0,0);
		lcd_putsf("Emergency Stop"); 
	} 
}

else if (timedisplay>1000&&timedisplay<2000)
{	
	if(timecount>=200)
	{	lcd_clear();
        timecount=0;
        
		lcd_gotoxy(0,0);
		lcd_putsf("Black: Resume"); 
	
	}  
}

else
{
    timedisplay=0;
}	          
	if((~PINB & 0x04) && (timepress2 > 30)) Maybe2 = 1;
	if(Maybe2 && (PINB == 0xff))
	{
		lcd_clear();       
		lcd_gotoxy(0,0);
		lcd_putsf("White: Start");
		lcd_gotoxy(0,1);
		lcd_putsf("Grey: Stop");
		currentState = startState;
		timepress2 = 0;
		Maybe2=0; 
	}
	
}
//***********************************************
// Function to measure everything
//------------------------------------------------
void pressuremeasure(void)
{
 switch (meas_state)
 	{	  
 	    case Sys_Measure:
 	    	 if(timing==0) sysmeasure(); //sampling signal at 40msec
 	    	 break;
 	    	 
 	    case Sys_Cal:
 	         if(timing==0) syscal();
 	         break;
 	         
 	    case Rate_Measure:
 	    	 if(timing==0) ratemeasure();
 	    	 break;
 	    
 	    case dias_Measure:
 	    	 diasmeasure();
 	    	 break;
 	    	 
 	    case dias_Cal:
 	    	 diascal();
 	    	 break;
 	    	
    } //switch
    
}//pressuremeasure
//*********************************************************
void sysmeasure(void)
{
	if(timing==0)
		{ADMUX = 0b00100000; //choose ADC0 for reading AC
		
        //enable ADC and set prescaler to 1/128*16MHz=125,000
        //and set interupt enable
        //and start a conversion
        ADCSR = 0b11001111;
        
        } 
         if(sys_count>=6)
         { 
         meas_state = Sys_Cal;
         timecount=0;
         }
        
        if(timecount>=200)
        {  
        lcd_clear();
		lcd_gotoxy(0,0);
		lcd_putsf("Measuring");
        timecount=0;
        } 
}

//***********************************************************
//this function is to calculate systolic pressure
void syscal(void)
{
	
		ADMUX=0b00100001;//choose ADC1 for reading DC
		
		//enable ADC and set prescaler to 1/128*16MHz=125,000
        //and set interupt enable
        //and start a conversion
        ADCSR = 0b11001111; 
        
        if(timecount>=200)
        {  
        lcd_clear();
		lcd_gotoxy(0,0);
		lcd_putsf("Sys Cal");
        timecount=0;
        } 
        
        
}//syscal

//************************************************************
void ratemeasure(void)
{
	
		ADMUX=0b00100000; //choose ADC0 for reading AC
		
		//enable ADC and set prescaler to 1/128*16MHz=125,000
        //and set interupt enable
        //and start a conversion
        ADCSR = 0b11001111;
        //calculate the mean of pulse rate
 	    if(count_average==5)
 	    {
 	     pulse_period = total_pulse_period/5000;
 	     pulse_per_min= 60/pulse_period;  
 	     
 	    lcd_clear();
		lcd_gotoxy(0,0);
		lcd_putsf("Pulse Rate");    
	    sprintf(lcd_output,"%-i",(int)pulse_per_min);
        lcd_gotoxy(0,1);
        lcd_puts(lcd_output); 
        
 	     meas_state = dias_Measure;
 	     //then set timerun_dias=0
 	     //also reset count_average for the next operation
 	     count_average=0;
 	     timerun_dias=0;
 	    }  
}
//************************************************************
void diasmeasure(void)
{
		ADMUX=0b00100000;//choose ADC1 for reading AC
		
		//enable ADC and set prescaler to 1/128*16MHz=125,000
        //and set interupt enable
        //and start a conversion
        ADCSR = 0b11001111; 
      
          
       
        
        
}//dias measure
//*************************************************************

void diascal(void)
{
		ADMUX=0b00100001;//choose ADC1 for reading DC
		
		//enable ADC and set prescaler to 1/128*16MHz=125,000
        //and set interupt enable
        //and start a conversion
        ADCSR = 0b11001111;  
        
        if(timecount>=200)
        {
        lcd_clear();
		lcd_gotoxy(0,0);
		lcd_putsf("Dias_Cal");    
        timecount=0;
        } 

}

void initialize(void)   
{                       
    
    
	//Initialize LCD
	timecount=0;    
	lcd_init(LCDwidth);      
	lcd_clear();       
	lcd_gotoxy(0,0);
	lcd_putsf("White: Start");
	lcd_gotoxy(0,1);
	lcd_putsf("Grey: Stop");
	
	//set up timer0
    TIMSK =2; //turn on timer 0 comp match
    OCR0 = 250; //set the compare register to 250
 
    //prescaler to 64 and turn on clear-on-match
    TCCR0 = 0b00001011;
    timepress0 = 0;
    timepress1 = 0;     
  
    
                        
    DDRB=0x00; //PORT B is an input(2 buttons)
    DDRD=0xff; //PORT D is an output(motor control); 
    PORTD=0x00; 
    PORTB=0xff;
    PORTA=0x00;       
    
    maxpressure = 160; 
    meas_state = Sys_Measure; 
    former=TH_sys-0.01;


	TH_sys=4.0;
	TH_rate = 2.5;
	TH_dias = 4.8;
	timerun_dias=0;
	time_pulse=0;
	timerate=0;

	timing=40;
	timedisplay=0;

	total_pulse_period=0;
	systolic=0;
	diastolic=0;
	pulse_per_min=0;
	Vref=5.0;          
	

	sys_count=0;
	count_average=0;
	countpulse=0;
	                   
	DC_gain=213;
	
	accum_data=0; 
	press_data=0; 
    count=0;


	#asm
	sei
	#endasm
}

With a little effort you could get that to compile on Arduino, or at least on an old version of AVR Studio, but unless you have the specific hardware required, there is no point in doing so.

Adapt the code to the hardware you intend to use and update calls like these to the new naming conventions (quite different for modern AVR processors).

interrupt [TIM0_COMP] void timer0_compare(void)

PS: the code is badly written, with lots of I/O in long interrupt routines, etc. It would be a waste of anyone's time to fix all that.

1 Like

Is that related to this old discussion?
https://www.avrfreaks.net/forum/help-problem-programming-atmega32

Seems source code is from
https://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2005/ww56_ws62/Final%20Project%20Web/code.c

Did you find more about their specifics?

From reading this The provided code is written in codevisionAVR

i try it on arduino im no have big knowledge on programming language for adapt it with arduino i try to do this project it 1 month day and night without success and i have only 3 days for build it and i don't find any one have the programming knowledge in main country for help me on this project 3 days not suffusing for build the complete project
and this project missing the time i need to add it look like dd/mm/yyyy and hh:mm
and other thing easy adding thermal printer for ticket

This is not a beginner project. If you want to pay someone to do this for you, post on the Jobs and Paid Consultancy forum section.

tinks you very much i will download it and try it now i never listen by codevisionC

i know but is a challenge on firsts place

its not an free compiler the free compiler of codevsionavr is for very small project about 4kb and i don't know how is the size of this project

if i have the money for paid someone for do that i don't search for it or consulting on the forum

The issues seem to be that

  • you don’t have the programming skills
  • you lost a month doing we don’t know what with some code you found we don’t know where nor why you picked that
  • seems the compiler is not free and even if you paid for it, you probably would not understand how to use it
  • you don’t have time anymore to learn programming

Building a pulse / blood monitoring thingy on arduino could have been done on arduino by investing efforts in the language and the various sub components you needed and possibly existing libraries… but now it is too late…

As a side note, This is for a competition and it would be unfair to present a solution you did not develop yourself…

Has been done, countless times. Two of the many mistakes made by the OP were to enter a competition, and to choose this particular project to copy.

The entire project is here: http://enggproj.blogspot.com/2012/12/portable-digital-blood-pressure-monitor.html
It looks quite interesting and is well presented but is effectively copying the functionality of a commercially available consumer electronics device.
Looking at the code you realise how much Arduino simplifies things with analogRead(), digitalWrite() etc.
Converting that code so it is compilable for Arduino would be simple enough for someone who knows what they are doing and there is no end of LCD libraries to choose from to replace the Codevision one. However, assembling and testing the hardware is going to take some time.
To buy, these are now very cheap:
https://m.banggood.com/de/Home-Automatic-Wrist-Blood-Pressure-Monitor-Blood-Pressure-Voice-Digital-Oxygen-Blood-Glucose-Blood-Pressure-Instrument-p-1744190.html?imageAb=1&utm_source=googleshopping&utm_source=googleshopping&utm_medium=cpc_organic&utm_medium=cpc_eu&gmcCountry=CH&utm_content=minha&utm_content=lynna&utm_campaign=minha-ch-en-pc&utm_campaign=aceng-ssc-ch-en-all-0420&currency=CHF&cur_warehouse=CN&createTmp=1&ad_id=515942612042&gclid=EAIaIQobChMIkam-nPeX-AIVhoXVCh2JMw2MEAYYASABEgLNUfD_BwE&akmClientCountry=CH

every time i try to do something with my self and learning about what i will do but on my self only is not helping to do every thing and understand every thing read it
and i don't find anny thing help and when i see multiple topic about sniffing on bus i2c i buy device for do my project and i try to do all instruction without success
i remove the transducers from the newer device because it unavailable in my country i try to do the project from scratch i find multiple error and problem of precision result
and when i read this programme i see it perfect and stable and very powerful
i try to developed my self but an pore like me out from his home to work and return to learn is hard for developed on the programmatic domain
we not see every thing like his true

i see this page i find this project on it
and i think his an open source not commercial
i will try to do this convert for adapt it to arduino if i can to adapt him in the specific time

i need some thing for dia and sys and hr and time for in result print all using thermal printer
not only pulse of heart

I meant could have been done by the OP . Yes there is proof it’s doable

I’m sorry but did not get what you said.

Then you have to choose and acquire suitable additional hardware if you have not already done so, that is a real time clock such a DS3231 and the thermal printer, Be aware that you also need suitable libraries to drive these devices and such libraries must be compatible with the development system you use (CodevisionAvr, Arduino etc.)

If your target MCU is a Uno/Nano etc., also understand that there may be subtle differences between the ATmega32 that the application has been written for and the ATmega328P of the Uno/Nano. For example, the port on which the ADC is available.

the printer don't need any library is working on UART and receive text and write it i test it and the main rtc is ds1307