ANALOGIN Problems
MacGeek117
Posts: 747
I just started·to work with the ANALOGIN command, and it works fine for Vdd and Vss(255, 0, respectively), but it doesn't work for any value in between(I have a voltage divider composed of two 10k resistors connected to Vdd and Vss). Could I please have some help?
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·

Comments
What value to you get ? What cap value are you using ?
Details man, we need details...
P.S. Are you setting the input pin to CMOS trigger level ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Don't mistake experience for intelligence. And vis-vera.
·
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
Does the voltage measure 2.5V on a meter ?
Try a larger prime value.
Double check your connections.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Don't mistake experience for intelligence. And vis-vera.
·
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·
Try using RB.0 & RB.1 like the example.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Don't mistake experience for intelligence. And vis-vera.
·
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"
Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·
Persistance pays...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Don't mistake experience for intelligence. And vis-vera.
·
Just for information,
Where (apart on this forum's trhead) there are informations on the new command ANALOGIN?
I searched in the help window and there's no mention of such a command,
I searched also the What's new section of the SX basic and there's only
This is all i could find about.
Please more informations needed
Regards
Stefano
Post Edited (ellizard) : 10/17/2006 10:51:03 AM GMT
ANALOGIN InPin, OutPin, Value[noparse][[/noparse], Prime] Reads an analog input voltage using the continuous calibration method All you need is 2 10K resistors and a 0.01uF capacitor(for 4MHz) or 0.001(for 50MHz) You can experiment with different resistor and/or capacitor values. Don't use resistor values below 220 ohms to protect the SX output pin. The variable Value will get set to the analog voltage at the input with 255 = Supply voltage. So if you get a reading of 127 and the supply voltage is 5 volts, then the input voltage is about 2.5 volts. Note that the input pin needs to be set to CMOS input threshold. By default the sx sets all pins to TTL threshold. The TTL theshold is 1.4Volts. That will make the full scale reading of 255 = 2.8 volts regardless of the supply voltage. The method needs to "prime" the capacitor to get a stable reading. By default the prime value is 1. If you get unstable readings either use a smaller cap value or increase the prime value. Prime must be a constant from 0 to 255. However larger prime values will increase the time it takes to get a reading. The time required to get a reading is 3825*(1+Prime)/Frequency. So with the default prime value of 1, if the clock is 4MHz it will take 3825*2/4000000 seconds or about 1.91 milliseconds to get a reading. For faster clocks either use a smaller cap value or a larger prime value. Note that this circuit has a fairly low input impedence. If you use a pot or resistor divider to create the analog voltage the ANALOGIN command may not reach the limits (0 or 255). A simple test using the 10K pots on the PDB yielded values from 0 to 241. The following is an example program: '------------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 InPin PIN RA.0 INPUT CMOS OutPin PIN RA.1 OUTPUT ' Analog Voltage >---/\/\/\-------+----+------------ SX Read Pin (RA.0) ' 10K | | ' ----- +--/\/\/\---- SX Write Pin (RA.1) ' ----- 10K ' 0.01uF / \ ' | ' | ' GND a VAR Byte PROGRAM Start NOSTARTUP Start: ANALOGIN InPin, OutPin, a, 2 WATCH a BREAK GOTO Start ENDYou can also try looking in the help for the Javelin. It has a similar command. I thinks it's called "ADC" on the javelin.
I hope this helps,
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Don't mistake experience for intelligence. And vis-vera.
·
hope it will be in SX-Basic help window too.......
it helped somehow
Stefano