Ok, that sounds quite tricky
PIC16F917 has some LCD module. Maybe it's possible to use it, so that it will be easier and simpler to drive this 'dumb' LCD? What kind of functionality does this LCD module provide?
Ok, that sounds quite tricky
PIC16F917 has some LCD module. Maybe it's possible to use it, so that it will be easier and simpler to drive this 'dumb' LCD? What kind of functionality does this LCD module provide?
Hi Michlis,
The LCD on your demo board is similar to driving a 7 segment display. Your program will need to output the data to the first display digit, then to the second, then to the third, etc. There are many types of LCD displays out there. The ones that are used with PBP are quite different from the one on your demo board. The PBP LCDOUT routines will not work with the type of LCD display that you have. I just took aglance at microchip's website and there seems to be alot of reading material in relation to their LCD PICs. The 16F917 is a specialty chip with a built in LCD driver so you need to learn how to address that driver to get information displayed. The built-in driver probably explains why the chip has a large program memory, 14K!
Didn't your demo board come with sample applications? If so, why don't you use the information there to create an assembly routine to operate the display within a PBP program.
I personally use the regular LCD displays in either a serial or parallel manner whereby I can use LCDOUT or Serout2 commands to display data quick and simple!
HTH,
BobK
After all, the LCD works. Here is the code that I use to display "1234":
PAUSE 1000 'wait for LCD start up
LCDPS = %00110001 'Selecting the frame prescale
LCDSE0.0 = 1 'Segment pins
LCDSE0.1 = 1
LCDSE0.2 = 1
LCDSE0.3 = 1
LCDSE0.6 = 1
LCDSE1.3 = 1
LCDSE2.0 = 1
LCDSE2.5 = 1
LCDSE2.6 = 1
LCDSE2.7 = 1
LCDCON = %01000011 'Multiplex,bias,timing, sleep
LCDDATA0 = %01001000 'initial LCD values "1234"
LCDDATA1 = %00001000
LCDDATA2 = %10100000
LCDDATA3 = %00000000
LCDDATA4 = %00001000
LCDDATA5 = %11100000
LCDDATA6 = %00001100
LCDDATA7 = %00000000
LCDDATA8 = %10100000
LCDDATA9 = %01001000
LCDDATA10 = %00000000
LCDDATA11 = %00000000
PIR2.4 = 0 'clearing LCD interrupt flag
LCDCON = %01010011 'enabling bias voltage pins
LCDCON = %11010011 'enabling the LCD module
however, I have problems when trying to run PWM module while using LCD. I will post about it soon.
As mentioned above, I have problems when trying to use LCD (code above) and HPWM at the same time.
This is my HPWM program:
'Connections:
'SW2->RD1 increase switch
'SW3->RA4 decrease switch
'P1->Vdd motor turned on constantly
'RC5/CCP1->N2 CCP1 is pwm output pin
'DC motor is connected to DRIVE 1 and DRIVE 2
'HPWM initialization
duty VAR WORD ' Duty cycle value )
TRISC.5 = 0 ' Set PORTC.5 (CCP1) to output
CCP1CON = %00001100 ' Set CCP1 to PWM
T2CON = %00000101 ' Turn on Timer2, Prescale=4
PR2 = 249 ' Set PR2 to get 1KHz out
duty = 500 ' Set duty cycle to 50%
up var PORTD.1 'user-friendly names for ports
down var PORTA.4
'Main program loop
loop:
CCP1CON.4 = duty.0 ' Store duty to registers as
CCP1CON.5 = duty.1 ' a 10-bit word
CCPR1L = DUTY >> 2
'check if button "up" is pressed and duty is not maximum
IF (up=0) AND (duty<1000) THEN
duty=duty+50
PAUSE 200
ENDIF
'similar as before but for reducing the speed
IF (down=0) AND (duty>0) THEN
duty=duty-50
PAUSE 200
ENDIF
GoTo loop ' Do it forever
End
When I combine these two programs (first LCD then HPWM) it starts to work that is I get "1234" on the LCD and then motor starts to turn but only for 2-3sec. Later is just stops. It looks like PWM signal just dies...?!
I have no idea why these two modules (LCD and HPWM) cannot work togather? I have checked the pins and timing sources but don't see any possible conflicts?
Nah, PBP handle it. if 0-50 in a byte variable will return 205 or 206.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
You are of course right, but I start the program with duty=500 and use only +/-50 steps, so this IF statement is correct in my case.
After some time I found the bug. At first I set all LCDSEn registers and it was a mistake since the LCD uses only few pins, so my button input pins were in segment functionality instead of I/O. Now I only set the segment pins that are actually used by LCD.
Bookmarks