Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

7-segment with ECG

Status
Not open for further replies.
i really do not know what to tell you, you are really helping me a lot, thanx for anything.

what you said is correct it should calculate the number of the heart beat per mind, means that if the person had 60beat/sec(1beat/sec) the number in the seven segment should be 60.

i will go through the comments you post, and anything you think its better i will test and post the results here for all the ppl knowledge.


Regard's
 
Try this circuit.
 

Attachments

  • ECG_PIC..PNG
    ECG_PIC..PNG
    30.9 KB · Views: 362
I noticed an error with the first schematic in the way I connected the 7 segment displays. Here is the corrected schematic. Use this instead of my previous post.
 

Attachments

  • ECG_PIC..PNG
    ECG_PIC..PNG
    31.4 KB · Views: 262
Last edited:
ok thank you very much i will do my best to get the circuit work, but the section B in which circuit in post #16 or #19 ??

I'm not sure which one will work better. All you need to do is make sure that the LM339 comparator output goes high with each heart beat and then back to low afterwards. The signal going into RB0 of the PIC should be a square wave with momentary high times that coincide with the heart beats. You are going to have to decide which one is best either by simulating the circuit or building a test circuit.

A seperate question, do you already have the PIC, 7 segment displays, and the transistors? If not what hardware do you have already?
 
i have everything. but RB0 should get the ECG signal after amplification but u think it will measure the peak of the ONLY and calculate how many times this peak reach to the limits, so it shouldn't be a square wave if i am not mistaken so why u said have to get square wave ???
i will post the peaks of the ECG point (R-R) as far as i know this is the peaks .....
 

Attachments

  • ecg..png
    ecg..png
    19.6 KB · Views: 477
i have everything. but RB0 should get the ECG signal after amplification but u think it will measure the peak of the ONLY and calculate how many times this peak reach to the limits, so it shouldn't be a square wave if i am not mistaken so why u said have to get square wave ???
i will post the peaks of the ECG point (R-R) as far as i know this is the peaks .....

Both circuits shown in posts #16 and #19 will amplify the volatge measured from the sensors placed on the body. However, before going to the PIC, the amplified signal is fed into an LM339 comparator. The comparator output can only be either high or low. There is no intermediate state. The picture you attached to the previous post is the waveform before the LM339. The output after will be either 5V or 0V only. That is why I said it is a square wave. I attached a picture showing what the output of the LM339 should look like compared to the input.
 

Attachments

  • ecg_2..PNG
    ecg_2..PNG
    31.8 KB · Views: 256
ohhh, k that's will make my understanding better, means have to make sure the pulse 5v should goes to the PIC each 1sec, to get the correct heart beat, so i must set a delay each beat,which is shown in the post below, so is it what i am thinking of is correct ??
 

Attachments

  • ECG trace with gr&#.pdf
    16.3 KB · Views: 202
I'm not sure I understand what you are talking about with the delay but you don't need one. Just connect the output of the LM339 to pin RB0. RB0 on the 16F84A is an external intterupt input. The interrupt occurs when a rising edge is detected on RB0. This feature is enabled by setting the correct bits in both the INTCON and OPTION special function registers and is already part of the code in beat_rate.c. Once the interrupt occurs, the funtion void interrupt intrpt(void) will be called. The first if statement in the fuction will be true if the interrupt was a result of a rising edge on RB0 and not a result of a TMR0 overflow. If the first if statement is true, the number of beats counted in the last minute gets incremented, the interrupt flag is cleared, and the program goes about its business until the next interrupt.

At least that's how the program is supposed to work. To find out if the program is good, you will have to build the circuit and test it. If it doesn't work, we'll have to modify the program.
 
Thanx for all the help sir.

i want to know if we didnt press the button in RB0 so it will goes into delay for 125ms, why is this number ?? and why have to delay ??

summery: the whole program contain from 3 main parts

1- interrupt, while the time and the beat_rate will increase.
2-driving the 7-segment with the values of beat-rate which is a subroutine called show()
3-the main program where we will set the I/O ports and the button to proceed.

by the way the decimal equivalent for few of digits is not correct like

254-------8 its should be 255-----8
so do i have to check it out or to avoid this i writ it down using binary


thanx sir
 
i want to know if we didnt press the button in RB0 so it will goes into delay for 125ms, why is this number ?? and why have to delay ??

The button is connected to RA3, not RB0. The only thing connected to RB0 is the LM339 output. RB0 will only be '1' when there is a heart beat and will be '0' all other times.

In the main program, if while the number of beats counted is not 0, and you don't push the button connected to RA3, there will be a 250 ms delay (2 x 125ms). I don't know why the delay is there. I don't know what the program creator was trying to accomplish with it.

That is just one of the many things that makes me unsure if the program will work.

by the way the decimal equivalent for few of digits is not correct like

254-------8 its should be 255-----8
so do i have to check it out or to avoid this i writ it down using binary

254 is the correct decimal represntation for the number 8 based on the circuit schematic I supplied you with.

254 = 11111110

Pins a - g of the 7 segment are connected to pins 1 - 7 of Port B.

Pin 0 on Port B is the RB0 external interrupt input and it does not control the 7 segment.
 
One thought I just had was that since I'm not exactly sure what the original circuit looked like that was designed to work with beat_rate.c, I don't know if the button connected to RA3 was active high or active low. In other words, the button might have been wired so it made RA3 go to '0' when pushed, not '1'. If that was the case then:

if(RA3==0){ //If pushbutton is not pressed
__delay_ms(125); //Delays for 125 ms
__delay_ms(125); //Delays for 125 ms
TMR0=0; //Clears the TMR0 register
beat_rate=0;
goto start;
}

would only be executed when the button was pushed, not when it wasn't being pushed. That might actually make more sense than what I was thinking originally (that the pushbutton was active high). I'll have to think about it a little more.
 
Last edited:
correct, but i am willing to change it like this so is it can be work without pressing the button,and when press it will stop :

if(RA3==1){ //If pushbutton is pressed
__delay_ms(125); //Delays for 125 ms
__delay_ms(125); //Delays for 125 ms
TMR0=0; //Clears the TMR0 register
beat_rate=0;
goto start;
}

what are the values of R(1,2,3,4,5,6,7) that connected to the 7-SEGMENTS ???

thanx
 
correct, but i am willing to change it like this so is it can be work without pressing the button,and when press it will stop

Don't change it yet. If the program was in fact intenteded to receive input from an active low button, it would be better to change the button instead of the program. Just changing that one if statement in the program could have other unintended affects.

Do you know how to rewire the button connected to RA3 for active low?

what are the values of R(1,2,3,4,5,6,7) that connected to the 7-SEGMENTS ???

I never put values on R1-7 because thier values depend on the specific 7 segment displays you are using. Do you have a model number or datasheet for the 7 segment displays you are using?
 
i think i already post in i am not mistaken how to make it active high

i do not think i need a resistance coz all of the segments share the same source current ......what do you think ??
 
i think i already post in i am not mistaken how to make it active high

I'm sorry but I don't understand this. Do you know the differences between wiring a button for active high and active low or would you like me to show you?


ii do not think i need a resistance coz all of the segments share the same source current ......what do you think ??

This is not correct. You NEED resistors to limit the current through the LEDs or else they will burn out. You can also damage the PIC if you allow it to source more than its rated maximum. What color are the 7 segment displays you are using?
 
i do not know how so please cane you teach me how......??

Here is a picture showing the differences between an active high and an active low push button arrangement.

pb_configs-png.39341


The 100KΩ resistor and the 33nF capacitor are for debouncing. There are many different ways to debounce a switch. Using an RC filter is just one of them. If you don't know what debouncing is, you can read about it here.

the color is RED for all the three 7-segment.

A pretty standard forward voltage drop for a red LED is 2V. However, I don't know if the specific 7 segment displays you are using have 1 LED or 2 LEDs per segment. 2 LEDs would be a forward voltage drop of 4V.

There are two things you need to protect for when sizing the resistors.

  1. You have to ensure that you don't allow too much current to flow through the LED.
  2. You have to ensure that you don't source too much current from the PIC.

A fairly safe value to use for maximum current draw of most normal red LEDs is 20 mA. So, the maximum current draw you would ever want for the entire display would be:

7 x 20 mA = 140 mA.

However, in section 9.0 on page 49 of the data sheet for the PIC16F84A it shows that the maximum current sourced by PORTB should not exceed 100 mA. So, the PIC is our limiting factor in this case not the LEDs.

Therefore, the maximum current per segment should not exceed:

100 mA / 7 ≈ 14 mA

To size the resistors for 14 mA per segment use Ohm's Law.

Vs= Supply voltage (5V)
R = Resistor value
I = Current through each segment (14 mA or .014 A)
Vf = Forward voltage of each segment (either 2V or 4V)

V = IR

R = V/I

R = (Vs - Vf)/I

If you aren't sure whether or not your displays have a forward voltage of 2V or 4V assume 2V. That will give you the more conservative result. If the segments are too dim using 2V, gradually decrease the resistance value until the brightness is where you want it but DO NOT exceed 14 mA per segment.
 

Attachments

  • PB_configs..PNG
    PB_configs..PNG
    11.5 KB · Views: 2,565
thanx man for all the help, i will do my best to post all the results ....

but i need some other help hope you do not mind, its about a PIC infrared Tx and Rx so do u allow me to ask ???


thanx in advance
 
You are welcome for the help. I don't know if I'll be able to help with the infrared Tx and Rx project until I get more details. You should start a new thread to ask questions about the other project.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top