Shop OBEX P1 Docs P2 Docs Learn Events
Beginners question — Parallax Forums

Beginners question

CenlasoftCenlasoft Posts: 265
edited 2009-07-16 03:00 in Propeller 1
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

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-16 02:43
    After the "pub go" put "dira[noparse][[/noparse] 0 ] := 1". This enables pin 0 for output (for the LED).

    Instead of the "repeat" use:
    repeat
        outa[noparse][[/noparse] 0 ] := ina[noparse][[/noparse] 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.
  • CenlasoftCenlasoft Posts: 265
    edited 2009-07-16 02:51
    Thanks,

    I'll try it now.

    Cenlasoft
  • CenlasoftCenlasoft Posts: 265
    edited 2009-07-16 03:00
    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
Sign In or Register to comment.