Thread: Heart Rate Monitor store data into array and print it out later.

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    5

    Heart Rate Monitor store data into array and print it out later.

    Hey all, now I'm making a heart rate monitor program into a 68HC11 that input's the frequency generated by a function generator to get output.

    Now i know this is embedded system program but what I'm asking is just about c I'm quite bad at it, I'll do the embedded part.

    The function generator will sent out a signal to that will calculate the variable "bpm" along with the real time timer, How do I log it into an array and print it out with another function?


    This is what needs to be done.

    • Heart rate (in beats/minute) averaged over previous 5s.
    • Alarm to be sounded if rate is above or below preset limits.
    • Alarm conditions to be logged with time data.
    • Rate to be logged every 5s for later download.


    All variables are global.
    In main, this is how I store it, It's wrong so I want to know how to fix it.

    Code:
    int i;
    log[2][100];
    
    main()
    
    {
     */bpm= some equation from func gen*/
    
    
    
    If (bpm>=400)
    
    
    {
    printf("ALARM!Rate is too high") ;
    log[i+1][secs,mins,hours]=[bpm][secs,mins,hours] ;                          //[i+1] for alarm status. [i] for normal log
    
    
    }
    
    
    If (bpm<=100)
    
    
    {
        printf("ALARM!Rate is too low");
    log[i+1][secs,mins,hours]=[bpm][secs,mins,hours] ;
    
    
    }
    
    }
    So far here is my array part program


    Code:
    datalog()
    
    for (=0;i<
    
    
        printf("[%d][%d:%d:%d]",log[bpm],log[sec,mins,hours] );
    When I get to the function datalog(), how do I print out all the log that is currently stored? I know using some loop but I'm not sure where to go.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Can you show a small example of the input you will be receiving, and how you want it to be stored and output?

    Two lines only in the log[] seems to suggest you want multiple "records" on log[0], and possibly multiple alarms on log[1].

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    5
    Okay BPM might output numbers like

    133
    234
    323
    451
    531
    32

    depending on what frequency is currently input, the bpm will be calculated every second and (hopefully) stored into log[i+1].

    Now here's another catch. I also wanna log the time when the bpm is stored everytime. Now I currently set the real time interrupt for the timer program so that it will print every second. Here's the timer interrupt function code

    Code:
    @interrupt void timer(void)
    {
    
    
    ticks++;
    rollovers++;
    if (ticks==30)
    {
        ticks=0;
        secs++;
        printf("%70Time: %2i:%2i:%2i\n",hours,mins,secs);
        calcnow=1;    
        
    }
    
    
    
    
    
    
    if (secs==60)
    {
        secs=0;
        mins++;
    }
    if (mins==60)
    {
        mins=0;
        hours++;
    }
    if (hours==24)
    {
        hours=0;
    }
    
    
    *tflg2=0x40;                                                        
    }
    So how do I log the bpm WITH the timer's secs,mins,hours.

    I tried:

    log[bpm][timer]=[bpm][secs,mins,hours];

    If I can do that I might be able to figure out how to store when BPM is over 400 or below 100.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Can you have more rows in log[][]? Right now you only have 2 (index 0 and 1), so log[bpm][] is WAY off the reservation.

    Will another program be reading the log, or is it going to be read by humans, directly?

  5. #5
    Registered User
    Join Date
    Dec 2011
    Posts
    5
    Yes, there can be more rows. Haha I just realized it's impossible to store any more bpm if you only have 2 array.

    hmm. if it's log[100][100] it would be able to store 10000 data...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 11-04-2011, 01:16 PM
  2. Heart Rate R-to R value
    By biomedC in forum C Programming
    Replies: 12
    Last Post: 11-16-2010, 03:23 PM
  3. Pick data from file store in array
    By swgh in forum C Programming
    Replies: 1
    Last Post: 07-10-2009, 09:57 AM
  4. Monitor Refresh Rate
    By golfinguy4 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 02-10-2003, 05:51 AM
  5. finding monitor refresh rate
    By eats only heads in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 04:12 PM