Measuring Voltage
Hi Guys
Im trying to measure voltage using analogin on an SX48 protoboard.
Now I have the 2 10k resistors a 0.01uf cap (ceramic disc type) and have wired it as the example in the help file.
I have changed the pin to TLL as the max voltage I want to read on the test is 2v, now I am using the below code, and then runing debug and if I click run, stuff just goes red and the "a" variable in the watch list stays at 0.
Any ideas?
Here is the code:
' Example program using ANALOGIN command
DEVICE SX48, OSC4MHZ
FREQ 4_000_000
InPin PIN RA.0 INPUT TTL
OutPin PIN RA.1 OUTPUT
a VAR Byte
voltage var byte
PROGRAM Start NOSTARTUP
Start:
voltage = a
ANALOGIN InPin, OutPin, a, 1
WATCH a
watch voltage
BREAK
GOTO Start
END
DJH (not part of code :P)
Im trying to measure voltage using analogin on an SX48 protoboard.
Now I have the 2 10k resistors a 0.01uf cap (ceramic disc type) and have wired it as the example in the help file.
I have changed the pin to TLL as the max voltage I want to read on the test is 2v, now I am using the below code, and then runing debug and if I click run, stuff just goes red and the "a" variable in the watch list stays at 0.
Any ideas?
Here is the code:
' Example program using ANALOGIN command
DEVICE SX48, OSC4MHZ
FREQ 4_000_000
InPin PIN RA.0 INPUT TTL
OutPin PIN RA.1 OUTPUT
a VAR Byte
voltage var byte
PROGRAM Start NOSTARTUP
Start:
voltage = a
ANALOGIN InPin, OutPin, a, 1
WATCH a
watch voltage
BREAK
GOTO Start
END
DJH (not part of code :P)
Comments
Make sure you have everything connected correctly.
Do you get anything besides zero using CMOS on the input pin ?
Using TTL cause some side effect. Mainly that zero volts results in a positive value. And it requires a negative voltage being measured to get a zero result.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
double checked the coonnections, all seems ok, but RA1 does not seem to be putting out any voltage at all.
Im using a 9v supply to run the protoboard, and a regtualted psu to simulate voltage between 1-5V on cmos setting
DJH
What is the voltage that you are trying measure coming from ?
What values to you get if you connect to ground and Vdd ?
Try different SX Pins and see if you get the same problem.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
I will try other pins
DJH
or is it just part of that code?
Im beginning to think the latter, as otherwise when RA1 puts out voltage, it has no ground to work with so is useless
Please confirm, I feel really stupid now, this is what happens when i take a break from stuff for too long. [noparse]:([/noparse]
DJH
· Yes to need to connect the grounds together.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
here is my code, led is red (else statement led1)
DEVICE SX48, OSC4MHZ
FREQ 4_000_000
InPin PIN RA.0 INPUT CMOS
OutPin PIN RA.1 OUTPUT
Led1 PIN RA.2 Output
Led2 PIN RA.3 Output
Led3 PIN RA.4 Output
a VAR Byte
voltage var byte
PROGRAM Start NOSTARTUP
Start:
led2=0
voltage = a
ANALOGIN InPin, OutPin, a, 1
'WATCH a
'watch voltage
if a > 102 then
led3=1
else
led1=1
endif
'BREAK
GOTO Start
END
just cannot figure it out
If I put a multimetere prob at RA.0 it is always a ground, so how can it ever pick anything up?
I have RA.0 connect straight to inbetween the two resistors, which is also where one of the cap legs is connected (other cap leg goes to both grounds.
That sounds wrong but matches the diagram?
I presume that the + symbols on the diagram do not mean anything other than to show the lines are connected, and not that possitive voltage should be connected to it?
Im more and more sure that this is a physical problem with my circuit, just cannot figure out where
DJH
???
pic attached
ANALOGIN (??)
http://forums.parallax.com/forums/attach.aspx?a=12087
DJH
Thanks
DJH
I have SX/B 1.50 / SXKey v3.2 and I cannot find an ANALOGIN listed.· Is that a part of a new Rev.?
"1.50" has an 8-Bit ADC (ADC8.SXB) in·its Example Projects.· The circuit is like yours, except that the input comes in on a third pin.
Post Edit -- Looks like there IS a SX/B 1.51 and I didn't get the memo.· And there are some bugs (one which you found) and I'm reluctant to install it.· But, anyway -- isn't the circuit used the same except that·the ANALOGIN approach is just a "macro"-ized 'ADC8.SXB'?
Bean?
Post Edited (PJ Allen) : 1/23/2008 2:45:40 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
http://forums.parallax.com/showthread.php?p=597707
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
However, is the circuitry used to implement ANALOGIN the same as 1.50's Example Project (using 3 pins), or is it really just done with two pins?
If it is down to two pins, then perhaps my rendering (analogin.jpg) will shed some light on the subject (really don't like those ASCII-y things.)
djh82uk -- Does this help any?· Please advise same.
Post Edited (PJ Allen) : 1/23/2008 3:45:52 PM GMT
The 8-bit ADC example in the help file uses the comparitor to compare the input voltage to the voltage generated from the PWM output.
The analogin is a different method. It does not use the comparitor, and can use any two pins.
It looks to me like both schematics you post are correct for the method being used.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
Yes that is how I have it connected, RA.0 going in between the 2 resistors, and also the one leg of the cap, my cap says it's a 104 or 103, and my resistors are 10k, but this is where I see a problem, 4.8V say through a 100k resistor, shows as 0v at the other end, so regardless whether the voltage is coming from the power source or from RA.1, RA.0 never sees above 0v it seems.
Any Ideas? Im sure it's something stupid on my part.
DJH
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
[noparse][[/noparse]The "capacitor code" is the value in picofarads.· So, a 103 is 10 followed by 3 0's pF: 10,000pF /·10nF /·0.01uF]
10K.· So, they're both brown-black-orange?
If the circuit is disconnected·from the SX pins·you should measure the source voltage between the junction (R1, R2, C) and Ground or something is wrong (a bad contact in your breadboard, a bad cap.)
will check when i can get back in the workshop
DJH
with power disconnected to the sx, i get 5v before the resistor, and 0v after it.
Has got to be my problem would you agree?
DJH
Would you actually get any voltage at the end tho? As a 470ohm resistor reduces 12v enough to run an led, so would'nt 10k completley wipe it out? or is it current related?
There is defiantley no voltage getting past that 10k resistor anyway
DJH
[noparse][[/noparse]Is it you with the submarine meter or something? [noparse]:)[/noparse] ]
The troubleshooting·"experiment" requires that the circuit should be disconnected from the SX (note the Red Xs.)
Are you using a breadboard or are you soldering to the ProtoBoard?
If you are soldering to the ProtoBoard, then make sure it is to the "uncommitted" pads.
If you simply solder these presumed resistors in series and place that across your voltage source, totally independent of the SX, does it "divide": 1/2 across one R and the same across the other?
Post Edit -- picture added
Post Edited (PJ Allen) : 1/23/2008 10:10:29 PM GMT
Ha ha, did not think i mentioned that, but yes I have an ex-MOD multimeter with nixie tubes etc, has pressure relase valves and warm up circuit, very accurate, tho in this case I am using a normal digital multimeter, although I have a 5kv HT meter here too, tho never used it and prb never will (a good thing)
Right, i changed resitors, I found some that were 10k, (brown, black, red, gold) and also showed as 9.98k on multimeter,
Wired them as the diagrame (the one with the red x's) on a breadboard completley away from the sx, gave it 5v, and I get 5, 4.8v and 4.9v at the 3 possible test points on the resistors, so I then used these resistors on the sx board to replace the others, the sx is giving out 5v at the pin into one end of the resistors in series, and im giving it 5v at the other end, shows as 0v in the middle tho, and so RA.0 is also getting 0v, hence the lack of a reading. Perhaps i should describe the circuit, fresh eyes and all that.
RA.1 is connected to a resistor, connected to the other end of that is another resistor, on the end of that is the possitive connection of the voltage i wish to measure.
RA.0 is connected to the junction between the 2 resistors, , as is one leg of the cap, the other end of the cap is connected to the ground of the voltage I was to measure, as well as the ground of the sx protoboard (VSS).
I am soldering to the protoboard and not using any pads that are connected to anything else.
Thanks for your patience, sorry if I sound stupid, I am useless with electronics theory, something I really need to brush up on when I have time. Yet I can troubleshoot problems on games consoles, psu's etc, down to component level, im self taught which is prob not a good thing.
DJH
DJH
I'm thinking about installing the 1.51 SX-Key/SXB to find out what's what here.· But at this rate I've·> 1/2-a-mind to·just whump up a board for you to plug into.
If anybody wants to jump in, it's OK by me.
Post Edit -- Can you send post a screenshot of the page from the manual that you're working from (all about ANALOGIN or what ever it is)?