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.

Comparators & 16F628 help

Status
Not open for further replies.

jpr

New Member
Hi.

Ive created an op amp circuit connected to force sensor and the output voltage varies from 0V to 3V(aprox).

Does any one have any example asm code/ tips for being able to use the comparators in the pic 16F628 to detect 3 or 4 different voltages.

for example it will detect if the voltage is between;
0-1V, it will turn on Led1
1-2V it will flash Led1
2V+, it will turn Led2

Any help would be much appreciated, particualrily in coding.(asm)

Thanks
 
Hi, using the AD Module would make more sense. Comparators can only be used for single voltage references. Use the AD module to convert the input voltage and according to the calculated value, turn or flash your corresponding LED. Nigels tutorial will get you started.
 
Wond3rboy
Hi, using the AD Module would make more sense

Unfortunately the 628/A does not have a AD module - so you might be better upgrading to the 16F88 which does have AD.

Nigels tutorial is excellent though for many applications you can feed your 0 - 5v signal straight into the AD input of the pic, a voltage reference diode and op amp are not always needed.

For a simple experiment simply use a 10k trimmer connected to +5v and 0v with the slider to the pic AD input.
 
The '628 has a Voltage Reference Module that can be connected to the comparator. By selecting different reference voltages you can detect the output of a comparator and work out the voltage you are detecting.
 
Hi. Thanks for correcting me Wp100.

@ Colin, he wants to detect the voltages simultaneously and there is only one vref pin(which can output different voltages as you pointed out). Also since he has put up 3 voltage levels to be detected, he wont be able to do it with a 16F628A which has two comparators.
 
Hi.

Ive created an op amp circuit connected to force sensor and the output voltage varies from 0V to 3V(aprox).

Does any one have any example asm code/ tips for being able to use the comparators in the pic 16F628 to detect 3 or 4 different voltages.

for example it will detect if the voltage is between;
0-1V, it will turn on Led1
1-2V it will flash Led1
2V+, it will turn Led2

Any help would be much appreciated, particualrily in coding.(asm)

Thanks

hi,
When you say "to detect 3 or 4 different voltages." do you mean 3 or 4 different voltage levels.??

The levels detect is possible.
 
You perform the detection so quickly that 3 voltage levles can detected within a few microseconds.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top