LCD issues
p_t
Posts: 15
I am currently working on a project with the education board. I am using a photo-transistor servo standard motor, LCD and a few LEDs. Basically I am replicating project 1 from Chapter 7 in Whats a Microcontroller book, except I am using the LCD instead of the debug terminal. My issues are, when I flash my light on the photo-transistor the servo goes to the designated position and vice versa when the light is off. During this, my LCD is rapidly blinking in between the light off and on, and it is also randomly beeping. I am not sure why it is doing it. Any help would be appreciated.
here is my code for the project. (Servo is connected to the servo header 12 pin and the lcd is connected to servo header 14 pin.)
here is my code for the project. (Servo is connected to the servo header 12 pin and the lcd is connected to servo header 14 pin.)
SEROUT 14, 84, [22,12,17]
HIGH 11
HIGH 10
HIGH 9
valMax CON 4000
valMin CON 100
time VAR Word
PAUSE 1000
DO
HIGH 2
PAUSE 1 ' PAUSE 100 -> PAUSE 1
RCTIME 2, 1, time
'DEBUG HOME, "time = ", DEC5 time
'SEROUT 14, 84, [128,17,"time = ", DEC5 time]
time = time MAX valMax MIN valMin
IF time > (valMax - valMin) / 2 THEN
'DEBUG CR, "Open blinds "
SEROUT 14, 84, [150,17, "Open blinds"] ' Modify
PULSOUT 12, 500 ' Add
ELSE
'DEBUG CR, "Close blinds"
SEROUT 14, 84, [150,17, "Close blinds"] ' Modify
PULSOUT 12, 1000 ' Add
ENDIF
LOOP
Comments
Mike,
I am using 2 rows x 16 characters Backlit with Piezospeaker (#27977)
150, is the position of the text on the LCD
17 was only added because the light kept turning off however it was still blinking on and off when light was shined on the transistor
I am initiating 22,12,17 because I want the LCD to turn on, clear previous program, and to turn on the back light.
I am also a new user to parallax and to the forum, please forgive me if I missed any other information. Thank you for your response. I tried two different batteries. However, they are new fresh ones. I will try this solution as soon as I hit the store.
SEROUT 14,84,[22,12]
PAUSE 5
SEROUT 14,84,[17]
instead of
SEROUT 14,84,[22,12,17]
Make sure the switches on the LCD are set for 9600 Baud.
Mike, thanks again for your input, unfortunately I am still facing the problem when the light is shined on the phototransistor the lcd still blinks. I tried the new code and a fresh new battery.
The debug doesn't give any issues. Another classmate is having the same issue as me as well. Is the photo transistor affecting it?
As Mike pointed out, whenever using the clear screen command you must follow it with a PAUSE 5.
Another thing that could be happening is that you're not allowing for any hysteresis in your program, so what could be happening is that when the time threshold is reached the servo engages and perhaps on the next loop the RCTIME is affected by the voltage drop and causes it to oscillate briefly between states.
Speaking of which, there should be a minimum delay of 15mS between refreshes of the servo, however your loop doesn't allow that. In a sense, you're overdriving the servo.