# ***20M PICAXE Ohmmeter***

Status
Not open for further replies.

Joined Apr 5, 2018
2
I've built a circuit that is supposed to shine certain number LEDs depending on the resistance of a resistor in the circuit (R1). I did this by setting up a voltage divider and measuring the output voltage (Vout) using readadc.

The LED's aren't lighting up properly (some of them light up for some resistors, but there is no clear pattern). When I simulate on PICAXE editor, for both low and high ADC values the LEDs light up, which doesn't make any sense. When ADC is low, there should be more LEDs lit up than when it is high.

- My equation for R1 using a voltage divider is R1 = (Vin*R2 - Vout*R2)/(Vout)

- R2 = 10,000 ohms

- Vin = 4.8 (24/5)

- I divide at the end of statements to minimize data lost from the integer rounding down PICAXE does. Wherever you see multiplying and dividing by 100 in the code I am trying to minimize data loss as well (ex. .90 rounds down to zero, while 90 is untouched). The multiplying by 100 should cancel in the statement w3/w0.

Circuit:

My code is below:

w1=24*10000/5 ;first term numerator, see R1 equation below
w2=10000*w0/100 ;second term numerator, divided to rid of 100 in w0
w3=w1-w2*100 ;numerator total * 100
w4=w3/w0 ;total (the 100s cancel)

if w4>0 then
high B.3
endif
if w4>500 then
high B.4
endif
if w4>1000 then
high B.5
endif
if w4>1500 then
high B.6
endif
if w4>2000 then
high B.7
endif

#### Raymond Genovese

Joined Mar 5, 2016
1,658
Welcome to AAC. You only need one thread for one issue.

Can you you use debug to look at the value of your variables - that can help. Also, you can programmatically/systematically change the value of b1 (rather than reading it in) and see if the program behaves the way you think it does.

Status
Not open for further replies.