Shop OBEX P1 Docs P2 Docs Learn Events
display flash help and analog signal question — Parallax Forums

display flash help and analog signal question

science_geekscience_geek Posts: 247
edited 2008-10-04 22:08 in Propeller 1
im packing to questions in one here, so bare with me

i have been messing around a lot today and converted some of my old bs2 code to spin and seeing just how much i can get a single cog to do at "once", i was wondering how to get a pin to read an analog voltage,

and my next question deals with my oled display, i have it showing the reading off a pot and the distance produced with a ping sensor, it is working just fine, but the screen flashes really fast, not really a problem but is rather annoying, below is the code for the pot and ping read, i know its not my diplay object cause it works just fine when alone, but when i do more with the prop it flashes. please pay no attention to the comments i have hacked up code from several object from obex and copied and pasted random stuff from here and there.

CON
··
· _clkmode = xtal1 + pll16x················· ' System clock → 80 MHz
· _xinfreq = 5_000_000
··
OBJ
··
· Debug: "display test"············· ' Use with HyperTerminal to display values
· ping : "ping"
··
PUB Init
· 'Start serial communication, and wait 2 s for user to connect to HyperTerminal.
· Debug.INIT
· waitcnt(clkfreq * 2 + cnt)
· ' Configure counter module.
· ctra[noparse][[/noparse]30..26] := %01000···················· ' Set mode to "POS detector"
· ctra[noparse][[/noparse]5..0] := 17·························· ' Set APIN to 17 (P17)
· frqa := 1································· ' Increment phsa by 1 for each clock tick
· main······································ ' Call the Main method
PUB Main | time, RANGE············································································································
'' Repeatedly takes and displays P17 RC decay measurements.
· repeat
···· ' Charge RC circuit.
···· dira[noparse][[/noparse]17] := outa[noparse][[/noparse]17] := 1·············· ' Set pin to output-high
···· waitcnt(clkfreq/100_000 + cnt)········· ' Wait for circuit to charge
·····
···· ' Start RC decay measurement.· It's automatic after this...
···· phsa~·································· ' Clear the phsa register
···· dira[noparse][[/noparse]17]~······························ ' Pin to input stops charging circuit
···· ' Optional - do other things during the measurement.
···· DEBUG.FTEXT(7,7, $F0, $00, 2, string("WORK IN PROGRESS "),0)
···· DEBUG.FTEXT(0,11, 0, $FF, 2, STRING("POT READING = "),··· 0)
···· DEBUG.FTEXT(0,12, 0, $FF, 2, STRING("PING READING = "),·· 0)
·························································
························
···· ' Measurement has been ready for a while.· Adjust ticks between phsa~ & dira[noparse][[/noparse]17]~.

···· time := (phsa - 624) #> 0
···· range := ping.Millimeters(15)··············
····
···· ' Display Result·································
··
···· DEBUG.FTEXT(14, 11, $0F, $F1, 2, TIME,···· 1)
···· DEBUG.FTEXT(16, 12, $0F, $F1, 2, RANGE, 1)
···· waitcnt(clkfreq/100_000 + cnt)········· ' Wait for circuit to charge
····
···· DEBUG.ERASE

Comments

  • LeonLeon Posts: 7,620
    edited 2008-10-04 22:08
    Have a look at the RCTIME demos. I haven't tried them, though.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
Sign In or Register to comment.