PDA

View Full Version : Beginners question



Cenlasoft
07-16-2009, 09:30 AM
Hello,
I have written the following for my demo prop board:
CON
_clkmode = xtal1 + pll16xииииииииииииииииииии ' Crystal and PLL settings
_xinfreq = 5_000_000иииииииииииииииииииииииии ' 5 MHz crystal
OBJ
sqwииии : "ECASquareWave"ииииииииииииииииииииииии ' Square wave object
VAR
pub go
sqw.Freq(5, 0, 353_000)ииииииииииииииииии ' Send 353 KHz
repeat

The code sends out a square wave on pin 5. It works. The square wave excites an LC circuit and produces 3 volts DC at resonance after rectifying. I have routed the output (3 VDC) to pin 1 of the prop. When I put a metal object near the coil, It lowers the voltage to about 1.3 VDC or lower. I want to read pin 1 and display if its high or low. If its high, an led should be lit, if low, the led should go off. How can I modify this code to do this?
Thanks,
Cenlasoft

Mike Green
07-16-2009, 09:43 AM
After the "pub go" put "dira[ 0 ] := 1". This enables pin 0 for output (for the LED).

Instead of the "repeat" use:


repeat
outa[ 0 ] := ina[ 1 ] ' Copy state of pin 1 to pin 0 (LED)


The LED should have its anode connected to pin 0 through an appropriate series resistor and its cathode to ground.

Cenlasoft
07-16-2009, 09:51 AM
Thanks,

I'll try it now.

Cenlasoft

Cenlasoft
07-16-2009, 10:00 AM
Thanks Mike,

I used the demo's board pin 23 and it works beautifully. Thanks. Now I will try to figure out how the measure this voltage. I have viewport and I want to use the digital scope in the software. Is there another way to measure the voltage? I tried an ADC, but it loads the circuit.

Cenlasoft