Counter Modules blues.
Iguanaman
Posts: 32
in Propeller 1
Hello. I took the software from the binder of the Propeller Education Kit Labs: Fundamentals By Andy Lindsay. On page 131 I used the code on my propeller and it worked very well. I want to put this output not on the " Parallax Serial Terminal ". I want to put the output on my NEW LCD 2X16 #27977 display. After much trial and error this is what I came up with. It works but it is very primitive. Any input on making it look less amateurish? Here be code.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
tx_pin = 0
Brud = 19_200
OBJ
LCD: "FullDuplexSerial.spin"
PUB Init
ctra[30..26]:= %01000
ctra[5..0]:= 17
frqa:= 1
main
PUB Main | time
repeat
' Repeatedly takes and displays P17 RC decay measurments.
dira[17]:= outa[17]:= 1
waitcnt(clkfreq/100_000 + cnt)
dira[0]:= %1
waitcnt(500_000 + cnt)
LCD.tx(17)
waitcnt(500_000 + cnt)
' Start RC decay measurement. It's automatic after this...
phsa~
dira[17]~
' Optional - do other things during the measurement.
LCD.Start(tx_pin, tx_pin, %1000, 19_200)
waitcnt(500_000 + cnt)
time := (phsa - 624) #> 0
' Display results
LCD.str(string("time = "))
LCD.Dec(time)
waitcnt(clkfreq/2 + cnt)
LCD.tx(12)
waitcnt(50_000 + cnt)
LCD.str(string("time = "))
I know I have LCD.str(string("time= ")) down two times. But it was the only way that I could get the Time = to stay on the LCD. With out it the LCD numbers will circle back around and wright over the Time =. Changing this program and having it work with only two weeks of me using trial and error to make head way is a big steep forward for me. I know. I have a long way to go. I also changed out the 10K pot to a Phototransistor and now I have a portable light meter. (Kind of??). Thank you for any help that you might give me because you feel sorry for me and my poorly written code. 20 mar 2019(wen).
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
tx_pin = 0
Brud = 19_200
OBJ
LCD: "FullDuplexSerial.spin"
PUB Init
ctra[30..26]:= %01000
ctra[5..0]:= 17
frqa:= 1
main
PUB Main | time
repeat
' Repeatedly takes and displays P17 RC decay measurments.
dira[17]:= outa[17]:= 1
waitcnt(clkfreq/100_000 + cnt)
dira[0]:= %1
waitcnt(500_000 + cnt)
LCD.tx(17)
waitcnt(500_000 + cnt)
' Start RC decay measurement. It's automatic after this...
phsa~
dira[17]~
' Optional - do other things during the measurement.
LCD.Start(tx_pin, tx_pin, %1000, 19_200)
waitcnt(500_000 + cnt)
time := (phsa - 624) #> 0
' Display results
LCD.str(string("time = "))
LCD.Dec(time)
waitcnt(clkfreq/2 + cnt)
LCD.tx(12)
waitcnt(50_000 + cnt)
LCD.str(string("time = "))
I know I have LCD.str(string("time= ")) down two times. But it was the only way that I could get the Time = to stay on the LCD. With out it the LCD numbers will circle back around and wright over the Time =. Changing this program and having it work with only two weeks of me using trial and error to make head way is a big steep forward for me. I know. I have a long way to go. I also changed out the 10K pot to a Phototransistor and now I have a portable light meter. (Kind of??). Thank you for any help that you might give me because you feel sorry for me and my poorly written code. 20 mar 2019(wen).
Comments
Your LCD probably has commands to set cursor so instead of using LCD.str... twice, you can just put the cursor on the screen where you want stuff to appear.
Cheers,
Jesse