Total Newbie...


Closed Thread
Results 1 to 18 of 18

Thread: Total Newbie...

  1. #1
    Join Date
    Aug 2008
    Posts
    39

    Default Total Newbie...

    Hi all I am totally new to programing Pics, and I am looking for some good tutorials.

    I currently am using Microchips PIC18 explored board, along with PICBasic Pro. The Pic is an 18F8722.

    Right now I have gott two pieces of code to work, I can blink an LED, and I can turn an LED on and off when I press a button... sounds simple, but like I said I am totally new.

    What I want to do next is to have the 8 on board leds display the status of 8 bits, but I am totally lost on how to do this...

    Any help would be great!

    Thanks,

    Lou

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Welcome to the forum.

    This example might do the trick
    http://www.microengineeringlabs.com/...pbc/countx.bas
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Thanks...

    I actually got it working before I read this... Had to set the Port as Outputs...

    Now my next question:

    The PIC18 explored poard has an LCD display on it. It is connected through an SPI I/O expander, MCP23S17. How do in therface it??? Microchips Manual is totally useless for me since I have no programming background...

    The user guide states this:

    An LCD display with two lines, 16 characters each, is connected to the SPI I/O
    expander, MCP23S17. The two control lines and eight data lines are connected to the
    I/O expander.
    The I/O expander has an SPI interface that connects it to the microcontroller.The I/O
    expander is disabled or enabled from the SPI by jumper JP3.
    Last edited by Frozen001; - 8th August 2008 at 16:06.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Not familiar with that board. Do you have a link to the docs?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Not familiar with that board. Do you have a link to the docs?
    http://www.microchip.com/stellent/id...cName=en535770

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Well, hate to give you a bit of bad news, but you can't drive that LCD directly using PicBasicPro (maybe you already knew that, maybe not...)
    It's set up such that the I/O from the expander drive the LCD pins. The LCD is a standard parallel, Hitachi 44780 compatible type from the looks of it.
    If you do a Google search on that term, you should be able to find some documentation on how to drive it. I don't have anything with me at the moment or I'd attach it here.
    Once you get your head wrapped around driving that LCD thru the I/O expander, it should be a piece of cake.
    Since the board is from Microchip, I can't imagine somebody NOT having already written some 'libraries' to handle that.

  7. #7
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Well, hate to give you a bit of bad news, but you can't drive that LCD directly using PicBasicPro (maybe you already knew that, maybe not...)
    It's set up such that the I/O from the expander drive the LCD pins. The LCD is a standard parallel, Hitachi 44780 compatible type from the looks of it.
    If you do a Google search on that term, you should be able to find some documentation on how to drive it. I don't have anything with me at the moment or I'd attach it here.
    Once you get your head wrapped around driving that LCD thru the I/O expander, it should be a piece of cake.
    Since the board is from Microchip, I can't imagine somebody NOT having already written some 'libraries' to handle that.
    SO I guess that mean I must send the data out serially?? Like I said I hvae no programming experience, so everythign is new...

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Frozen001 View Post
    SO I guess that mean I must send the data out serially?? Like I said I hvae no programming experience, so everythign is new...
    Not so much serially, but yes, serially.

    You'll have to set each pin individually, for each operation, every time, because you are accessing each pin, one at a time, thru the I/O expander.

    For instance, to send any character (assuming the LCD is initialized), you'll have to set each data bit, one at a time, set the R/W line (which can most likely be set once to WRITE when the prorgam starts, then leave it alone), then strobe the E line high then back low.

    Initialization is another thing... It's a long-ish sequence of setting various bits and/or bytes in the LCD itself, specifying modes, cursors, and so on. Nice thing is, once it's done, you don't have to do it again.

    Call me crazy, but it's not really that hard once you get a set of 'core' subroutines built-up. Not to mention, you'll really get a feel for how PBP works once you're done writing the mess...

    I suppose the other option is to disconnect that LCD and wire it up as shown in the PBP manual or something close to it...which isn't an unreasonable option. Might require a bit of trace cutting and/or rewiring. Not sure, haven't look at the datasheet for that board too closely.

    (just looked at the datasheet for the board)
    For that matter, you could probably disconnect the LCD from the mount it sits in right now, plug it into that expansion slot off to the side and set up each pin to do what you need.
    If you can blink an LED, you can build up to running an LCD.
    Last edited by skimask; - 8th August 2008 at 17:49.

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Frozen001 View Post
    SO I guess that mean I must send the data out serially?? Like I said I hvae no programming experience, so everythign is new...
    Maybe, but I doubt it. Like skimask said. Can not use it with standard PBP commands.

    Get a cheap LCD and hook it up like the example in the manual if you need to play with an LCD now.

    Or wait and do some research like skimask said. Or maybe Darrel will have a trick up his sleeve.
    Dave
    Always wear safety glasses while programming.

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Or wait and do some research like skimask said. Or maybe Darrel will have a trick up his sleeve.
    Probably a bit over his head at the moment, but....
    http://www.picbasic.co.uk/forum/showthread.php?t=7038

  11. #11
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Probably a bit over his head at the moment, but....
    http://www.picbasic.co.uk/forum/showthread.php?t=7038
    I thought about that, but after looking at the data sheet for the MCP23S17 I am not so sure he wants to go there yet either. The MCP23S17 appears to be programmable or at least configurable. Looks like a fun chip.
    From the data sheet:
    The MCP23017/MCP23S17 (MCP23X17) device
    family provides 16-bit, general purpose parallel I/O
    expansion for I2C bus or SPI applications. The two
    devices differ only in the serial interface.
    • MCP23017 – I2C interface
    • MCP23S17 – SPI interface
    The MCP23X17 consists of multiple 8-bit configuration
    registers for input, output and polarity selection. The
    system master can enable the I/Os as either inputs or
    outputs by writing the I/O configuration bits (IODIRA/B).
    The data for each input or output is kept in the corre-
    sponding input or output register. The polarity of the
    Input Port register can be inverted with the Polarity
    Inversion register. All registers can be read by the
    system master.
    The 16-bit I/O port functionally consists of two 8-bit
    ports (PORTA and PORTB). The MCP23X17 can be
    configured to operate in the 8-bit or 16-bit modes via
    IOCON.BANK.
    There are two interrupt pins, INTA and INTB, that can
    be associated with their respective ports, or can be
    logically OR’ed together so that both pins will activate if
    either port causes an interrupt.
    Dave
    Always wear safety glasses while programming.

  12. #12
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I thought about that, but after looking at the data sheet for the MCP23S17 I am not so sure he wants to go there yet either. The MCP23S17 appears to be programmable or at least configurable. Looks like a fun chip.
    From the data sheet:
    It is a handy chip to have around, especially (in my case) just to use to trip MOSFETs around. Keeps anything crazy away from my PICs. A bit spendy compared to buying a large-ish I/O count PIC around, but so EEAASSYY to hook up...

  13. #13
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    I would rather not hack the board up at this point....

    If I could get this all striaght in my haed I know I can get the LDC display working...

    Lookint at the expander datasheet and the demo board schematic it looks like LCD Data Lines (DB0B7) are connected to the GPIO lines (GPB0:GPB7). LCD RD is on GPA7 and LCD E is on GPA6.

    The Pic is connected to the expander like this:
    PIC Expander
    RC3 --> SCK
    RC5 --> SI
    RF6 --> Reset

    Knowing that How do I cammand the expander to do what I want it to do?

    Thanks for all you help so far... it has been GREAT!!
    Last edited by Frozen001; - 8th August 2008 at 19:43.

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Frozen001 View Post
    I would rather not hack the board up at this point....

    If I could get this all striaght in my haed I know I can get the LDC display working...
    Re-check post #8 and you might get a couple of good ideas there. It might be possible to do what is suggested there. Again, not 100% sure. Maybe when I get home, I'll pour over the schematics, see if the LCD connections and that port can be made to provide all the power/ground/control/data lines to run an LCD.

    Does that LCD on the Microchip board unplug or is it hard soldered?

  15. #15
    Join Date
    Aug 2008
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Re-check post #8 and you might get a couple of good ideas there. It might be possible to do what is suggested there. Again, not 100% sure. Maybe when I get home, I'll pour over the schematics, see if the LCD connections and that port can be made to provide all the power/ground/control/data lines to run an LCD.

    Does that LCD on the Microchip board unplug or is it hard soldered?
    It is hard soldered....

  16. #16
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Frozen001 View Post
    It is hard soldered....
    Well, then I guess I'd check around the microchip forums a bit and see if you can find any 'libraries' to handle the LCD for you on that board, that is if you don't want to write the code yourself.
    Using the LCD as it sits on that board can be done...it's not impossible by any stretch. It's just that you'll have to do all the leg work.

    The Pic is connected to the expander like this:
    PIC Expander
    RC3 --> SCK
    RC5 --> SI
    RF6 --> Reset

    Knowing that How do I cammand the expander to do what I want it to do?
    First thing you've got to do is get your hands on the datasheets for the I/O expander and the LCD itself, which as I said before is most likely a Hitachi 44780 parallel input compatible LCD, almost any datasheet for an LCD with 14 or 16 pins on the inputs will most likely work just fine. Because without knowing how to run the I/O expander or the LCD, you'll be stuck.
    But for now, maybe hang some LEDs off the I/O outputs of the expander. Once you can command that thing to do whatever you want, the LCD will be close behind...
    Last edited by skimask; - 8th August 2008 at 20:08.

  17. #17
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Frozen001 View Post
    I would rather not hack the board up at this point....

    If I could get this all striaght in my haed I know I can get the LDC display working...

    Lookint at the expander datasheet and the demo board schematic it looks like LCD Data Lines (DB0B7) are connected to the GPIO lines (GPB0:GPB7). LCD RD is on GPA7 and LCD E is on GPA6.

    The Pic is connected to the expander like this:
    PIC Expander
    RC3 --> SCK
    RC5 --> SI
    RF6 --> Reset

    Knowing that How do I cammand the expander to do what I want it to do?

    Thanks for all you help so far... it has been GREAT!!
    I wouldn't hack it up, I would set it aside until you catch up to it, You will have a much easier time learning if you use an PIC with a simpler architecture like 16F648A. I like that one because it is simple but not useless, nothing tough to get going and has 4k space. You can get an LCD for about $10 from this vendor. http://cgi.ebay.com/20x4-LCD-Module-...QQcmdZViewItem
    I buy from him pretty regularly.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  18. #18


    Did you find this post helpful? Yes | No

    Default

    I would forget about the on-board LCD for the time being and get some experience using one wired in parallel (which is well documented). When you have that knowledge under your belt then think about tackling the on-board one.

    PICs offer so many functions and possibilities It is tempting to try to take on to much at once. If you do, you are likely to be frustrated and spend a lot of time getting nowhere. However, take everything one step at a time and you will progress rapidly.

    Best of luck,
    Pat. Pending

Similar Threads

  1. Newbie making an ignition timer
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 5th August 2012, 17:45
  2. Controlsystem for compact sporting (clay shooting)
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th July 2009, 16:48
  3. Total Motor Currents
    By Darrel Taylor in forum Off Topic
    Replies: 29
    Last Post: - 13th October 2008, 00:50
  4. Newbie: Temperature measurements
    By Budda in forum General
    Replies: 10
    Last Post: - 30th March 2007, 09:56
  5. request for a newbie forum
    By nimonia in forum Forum Requests
    Replies: 1
    Last Post: - 20th May 2006, 09:01

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