Detecting voltage

TTOP

New Member
I have a analog comparator voltage detecting circuit that I want to convert to a Picaxe equalvalent. Need to detect a voltage of 70 millivolts and above.
1. Can the 08M2 be used ?
2. Would a internal V ref be used or a external one ?
3. What commands would be used to set this up ?
 

eggdweather

Senior Member
Use an ADC input and READADC10 and using the internal reference and a 5v supply, you will be able to measure to a resolution of 5/1014 or 4mV, so expect a reading of 70/4 or about 14 for your 70mV threshold, that should be enough to detect below 70mV up to your threshold value.
e.g.
readadc10 1,w1 ; read value into w1
IF w1 > 14 THEN
trigger code here
ENDIF
 

TTOP

New Member
Want to detect a voltage of 70 mv or above on pinc.1 and then turn c.0 high.
Would this be the code to use ?

readadc10 1, w1
if w1 > 14 then high c.0 endif
 

TTOP

New Member
start:
readadc10 1, w1
if w1 > 14 then high c.0 endif
if w1 < 14 then low c.0 endif
goto start

When the code is running on PE6 w1 has a value of 256 and c.0 goes high and when I make pinc.1 high nothing happens. Does this code and others that use analog commands need to be run in a actual circuit to test it ?
 

TTOP

New Member
^ Why does w1 load with the value of 256 when the code is runnig. Will it be 256 in the actual physical circuit ?
 

eggdweather

Senior Member
Code is OK, must be a simulator issue, or tell the simulator (if you can) what the value of input is to the ADC, e.g. 0.07v to get near the threshold and then 0.071 to trigger.
 

The bear

Senior Member
Hi TTOP,
Just so you don't have nightmares.

Try pin c.4
Put your number(s) in the Values chart, its bottom left.
put it in under WORD in line with c.4

Regards, Bear.
.
Code:
 start:

 low c.0

 readadc10 4, w1
 if w1 > 14 then
 high c.0
 endif
 if w1 < 14 then
 low c.0
 endif
 goto start
 

rq3

Senior Member
^ Why does w1 load with the value of 256 when the code is runnig. Will it be 256 in the actual physical circuit ?
You're running in the simulator, right? You have to click on the appropriate simulator box to "force" the value of 14 that you expect from your code. You can toggle up and down from there to see the pin response in the simulator. The physical circuit will only "see" whatever the measured value really is.

Rip
 

TTOP

New Member
UPDATE- I searched older posts on READADC10 and came across a term called generic thingy. I did not know that you can set the values in PE6. Did all of the above and it now works in simulation. Thanks All.
 
Top