Using LCD from Mechatronics Demo Board


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Apr 2007
    Location
    Copenhagen
    Posts
    7

    Default Using LCD from Mechatronics Demo Board

    Hi,
    I have a Microchip's Mechatronics Demo Board and I am trying to use on board LCD with PBP. In the PBP manual it says that: "If a 4-bit bus is used the top 4 LCD data bits must be connected to either the bottom 4 or top 4 bits of one port."
    Now the problem is that LCD is already pre-connected to the PIC and as it says in the data sheet fist 4 ports are COM0-COM3. So I took the board and it looks that COM0 is on pin RB4, COM1 is RB5, COM2 RA2, COM3 RD0. Is it possible to run this LCD in PBP with such connections? How should I set DEFINEs?
    Attached Images Attached Images  

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Michlis View Post
    Hi,
    I have a Microchip's Mechatronics Demo Board and I am trying to use on board LCD with PBP. In the PBP manual it says that: "If a 4-bit bus is used the top 4 LCD data bits must be connected to either the bottom 4 or top 4 bits of one port."
    Now the problem is that LCD is already pre-connected to the PIC and as it says in the data sheet fist 4 ports are COM0-COM3. So I took the board and it looks that COM0 is on pin RB4, COM1 is RB5, COM2 RA2, COM3 RD0. Is it possible to run this LCD in PBP with such connections? How should I set DEFINEs?
    It's possible to run that LCD with a PIC, just not with the LCDOUT commands.
    The LCDOUT commands used in PBP with the PICs are for LCDs with built-in Hitachi 44780 style controllers with a parallel interface.
    Judging from the connector, what you've got is probably a 'dumb' LCD. You'll most likely have to dig up the spec's for the LCD, write a program to handle the multiplexing, etc.etc.etc.
    If you want an LCD, it's a heck of a lot easier to get on eBay or wherever and just buy a 16x2 LCD from somewhere for $10.

  3. #3
    Join Date
    Apr 2007
    Location
    Copenhagen
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Judging from the connector, what you've got is probably a 'dumb' LCD. You'll most likely have to dig up the spec's for the LCD, write a program to handle the multiplexing, etc.etc.etc.
    I have found the datasheet here:
    http://www.varitronix.com/Product/LC...332-DP(R0).pdf
    but I don't understand the table at the end of it. I guess it's the most important part.

    Quote Originally Posted by skimask View Post
    If you want an LCD, it's a heck of a lot easier to get on eBay or wherever and just buy a 16x2 LCD from somewhere for $10.
    Ok, now I know that, but unfortunately I have to stick to this LCD.

    How should I write a PBP code to handle this LCD, what do I need to take care of, in which order?
    I'd be grateful for any hints.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Michlis View Post
    I have found the datasheet here:
    http://www.varitronix.com/Product/LC...332-DP(R0).pdf
    but I don't understand the table at the end of it. I guess it's the most important part.
    Basically, that table says that if you put power (whatever that power may be according to the datasheet) on pin #5 and a ground on COM1, then the 'RC' will show on the LCD.

    PBP will NOT drive this LCD thru it's built in commands. As I said before, this is a 'dumb' LCD.

    You're going to need 14 pins from a PIC to provide power to a segment, and 4 MOSFETs/transistors to apply a ground to a COMmon.
    Then you're going to have to write software to drive the LCD, multiplexing various signals to get it to display what you want to display. Then you're going to have to get it to do this roughly 20+ times per second so your eyes don't see any flickering.

    You HAVE to stick with this LCD... This LCD is going to 'cost' at least 18 pins from a PIC and a LOAD of code and headaches... I'd talk to whoever is making you do this...and slap them up a bit...
    But if you must, do some searching here, there's a few projects around here that deal with multiplexing a display,etc.

  5. #5
    Join Date
    Apr 2007
    Location
    Copenhagen
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    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?

  6. #6
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    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

  7. #7
    Join Date
    Apr 2007
    Location
    Copenhagen
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    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.

  8. #8
    Join Date
    Apr 2007
    Location
    Copenhagen
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    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?

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Michlis View Post
    IF (down=0) AND (duty>0) THEN
    duty=duty-50 : PAUSE 200
    ENDIF
    If duty is 10 and you subtract 50 from it, you'll end up with a negative number, which PBP doesn't handle. I think you want the lines to be:
    IF (down = 0) AND (duty => 50) THEN blah blah blah...

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Nah, PBP handle it. if 0-50 in a byte variable will return 205 or 206.
    But 'duty' is a word and, if it does end up being a 'negative number', it'll be above the 1000 limit set in the IF/THEN above and nothing will happen to 'duty' and the program will appear to go stupid.

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Talking

    <table><td></td><td>hum hum... pfff i knew... it was a test to know if you follow... HUM HUM</td><td></td></table>
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    hum... pfff i knew... it was a test to know if you follow... HUM HUM
    Do I get anything as a prize?

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Wink

    My respect for few days... or some of those...

    Last edited by mister_e; - 10th May 2007 at 04:47.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  15. #15
    Join Date
    Apr 2007
    Location
    Copenhagen
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Ups, you're right. I will correct it today, but I don't think that this is the main problem, because I don't use the buttons to change the speed and the motor just stops.
    However, that gave me smth to think about. Maybe somehow now the pin connected to the "decrease" button is by default low, so in each loop program reduces the speed by one step, even though I didn't press anything?
    Maybe I should somehow configure the pins connected to buttons to detect button press correctly?

  16. #16
    Join Date
    Apr 2007
    Location
    Copenhagen
    Posts
    7


    Did you find this post helpful? Yes | No

    Smile Conclusions

    Quote Originally Posted by skimask View Post
    If duty is 10 and you subtract 50 from it, you'll end up with a negative number
    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.

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. 16f887 44 pin demo board code problem?
    By jessey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th December 2008, 14:17
  3. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. Replies: 8
    Last Post: - 7th December 2006, 15:42

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts