Detecting voltage

TTOP

New Member
I have a analog comparator voltage detecting circuit that I want to convert to a Picaxe equalvalant. 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 ?
 

hippy

Ex-Staff (retired)
The M2's do not support the COMPSETUP command but comparators can be used by poking appropriate SFR's where the chip has the hardware.

Unfortunately, on the 08M2 only one of the comparator inputs is accessible on an ADC pin so you would need to compare with an internal voltage reference, DAC or FVR, most likely DAC because 70mV is well below the FVR voltage.

1/32nd of 1.024V is 32mV so it may be possible using FVR and DAC. The following project may give you a start on how to do that -

http://www.picaxeforum.co.uk/showthread.php?19289-Composite-video-signal-detector
 

BeanieBots

Moderator
I think you could do it quite easily with just a ReadADC10 line. (depends how accurate you want it to be)
With a 5v supply, the 10-bit ADC has a resolution of 4.88mV.
Therefore, a reading of 14 would be close to 68mV. A reading of 15 would be 73mV.
You could test the value and then set an output pin high or low depending on your needs.
 

TTOP

New Member
Beano, ReadADC10 works good, at least on the PE6 simulation. Going to download the program in the 08M2 and test it and see what happens. I dont know what hippie is saying with poking, SFR, DAC and FVR.
 

hippy

Ex-Staff (retired)
I dont know what hippie is saying with poking, SFR, DAC and FVR.
Sorry; I thought you were wanting to duplicate your analogue comparator using the on-chip hardware of the PICAXE rather than just measuring the voltage to detect its presence -- Just use READADC10 as suggested.
 

TTOP

New Member
hippy, yes I want to use the 08M2 to detect voltages of 70 millivolts and above. In the command manual it says "Note that the 1.024 V reference may not be accurate if used as the Vref+ of the ADC (only 2.048 or 4.096 should be used for this purpose)". I used the code-
START:
READADC10 1,W1
if W1>=14 THEN HIGH C.0 ENDIF
IF W1<14 THEN LOW C.0 ENDIF
GOTO START
It works in simulation but have not tried it in an actual 08M2 yet. What is the default fixed voltage referece for the 08M2 and should it be changed for the above code and should FVRSETUP FVR1024 or FVRSETUP FVR2048 or FVRSETUP FVR4096 be used? What about Poking, SFR and DAC ?
 
Last edited:

TTOP

New Member
I just read the ADCCONFIG command and saw the default Vref+ signal for the ADC is the power supply (V+). However the Vref signals can be altered to external pins instead by using the ADCCONFIG command. Why would a external Vref be used and not the internal Vref ?
 

hippy

Ex-Staff (retired)
An external Vref input would be used where a reference voltage was desired which the FVR could not provide, or where the accuarce of the reference needed to be more than the FVR offered. It also offers the option of an adjustable reference voltage to be used.
 

TTOP

New Member
Okay on that info. What about the 3rd post above ^? I originally left out one line of code (READADC10 1,W1) but have edited it in.
 
Top