1. OCAU Merchandise now available! Check out our 20th Anniversary Mugs, Classic Logo Shirts and much more! Discussion here.
    Dismiss Notice

Easiest beginner PLC/PIC programming

Discussion in 'Electronics & Electrics' started by bradrogers, Jul 16, 2006.

  1. OP
    OP
    bradrogers

    bradrogers Member

    Joined:
    Sep 19, 2003
    Messages:
    1,900
    Location:
    Canbizzle
    ok, I got all I need, to start programming pics.

    Anyone know any good simple examples, to program up a 16f88/16f628/18LF122???

    I'm using a JDM style programmer, MPLAB to program in ASM and compile to HEX, and using either ICProg or Winpic to upload (depending on the chip)
     
  2. dakiller

    dakiller (Oscillating & Impeding)

    Joined:
    Jun 27, 2001
    Messages:
    8,069
    Location:
    3844
    Start of by turning a LED on and off and go from there
     
  3. OP
    OP
    bradrogers

    bradrogers Member

    Joined:
    Sep 19, 2003
    Messages:
    1,900
    Location:
    Canbizzle
    Yeah I'm trying to find a simple code listing, and simple schematic though.

    Wouldn't mind finding an ASM command cheat sheet either.
     
  4. GooSE

    GooSE New Member

    Joined:
    Jun 26, 2001
    Messages:
    6,679
    Location:
    Sydney
    To connect an LED to some of your GPIO pins you'll probably want them to be active low, as logic devices are usually better at sinking current than sourcing current. This means that when you make the output pin logic 0, the LED will light up.

    (5V)---[Resistor]---|>|---(PIC)

    There are usually slightly different instruction sets between each series in the PIC microcontroller. Download the datasheet for your particular device from www.microchip.com and it will have all sorts of useful stuff in there. Stuff like instructions, register lists and roles, memory bank layout, etc.

    I started off on a 16F628A. Cheap, decent features, and easy to get your head around. :thumbup:
     
  5. nux

    nux Member

    Joined:
    Jan 20, 2002
    Messages:
    16,780
    Location:
    Melbourne
    Hey Brad, are you using the protoboard I sent you yet? Sorry I haven't gotten around to sending you the schematics and stuff. When you need them let me know.

    I'll try and find the sample code I used to flash the LED on the board too.
     
  6. OP
    OP
    bradrogers

    bradrogers Member

    Joined:
    Sep 19, 2003
    Messages:
    1,900
    Location:
    Canbizzle
    I've been mucking around with my breadboard / various components, using the pic for now. Just haven't had much time over the past couple of weeks to sit and get everything going.
     
  7. OP
    OP
    bradrogers

    bradrogers Member

    Joined:
    Sep 19, 2003
    Messages:
    1,900
    Location:
    Canbizzle
    BUMP:

    MODS: Can we have this moved to the Electronics section, now this forum has been split?

    Ok, making some good progress here, check out the Modding/Electronics Section of the wiki for the pic beginners page.

    After mucking around with an amp project I've had for tafe, I've finally found the time to write code for the PIC.

    Another great thing to learn which helped with PICs are Microprocessors. I have since learnt to program the motorola 6802 microprocessor at tafe. No BASIC, no ASM not even C. Just sitting there at the pcb, and tapping out hex codes on the keypad!

    http://www.zippyvideos.com/4849640236228366/video0025/
    ^^^Theres some work that I have done ^^^

    All in All, I'm getting there, I just need to find the time to sit down and explain it all in the beginners guide.
     
  8. OP
    OP
    bradrogers

    bradrogers Member

    Joined:
    Sep 19, 2003
    Messages:
    1,900
    Location:
    Canbizzle
    I should have posted the link! :p

    here it is: (not up to date as I've been extremely busy these days! I"m hoping to do a quick write up on Sunday, will see how I go!)
    http://www.overclockers.com.au/wiki/Brad_Pic
     
  9. nux

    nux Member

    Joined:
    Jan 20, 2002
    Messages:
    16,780
    Location:
    Melbourne
    That programmer looks familiar :p

    Have you tried wiring up my development board? What chip(s) are you playing around with?
     
  10. OP
    OP
    bradrogers

    bradrogers Member

    Joined:
    Sep 19, 2003
    Messages:
    1,900
    Location:
    Canbizzle
    I've mainly been working on the 16F88, using JAL programming language, and ICProg to upload the HEX files generated by JAL.

    nuxie1 I don't have the schematic for the protoboard. Is it possible you could send it somehow?
     
  11. nux

    nux Member

    Joined:
    Jan 20, 2002
    Messages:
    16,780
    Location:
    Melbourne
    Yeah, my schematic is somewhat messy though. Do you have Eagle? I can send you the files if so.

    I'll clean them up a bit now and try and post a shot.

    Basically the pins on the right side (8x3) are a row of 8 Ground, then a row of 8 Power, then all the PortB pins in a row.

    The four sets of 3 pins at the top are the same setup, ground-power-data with the port number listed at the top.
     
    Last edited: Nov 5, 2006
  12. OP
    OP
    bradrogers

    bradrogers Member

    Joined:
    Sep 19, 2003
    Messages:
    1,900
    Location:
    Canbizzle
    Haven't got eagle.

    Is that downloadable at all? (or commercial? :()
     
  13. GooSE

    GooSE New Member

    Joined:
    Jun 26, 2001
    Messages:
    6,679
    Location:
    Sydney
    There's a free version of Eagle that's limited to (I think) 150x150mm PCB size and 1 layer. It's fine unless you're going crazy with your design.
     
  14. OP
    OP
    bradrogers

    bradrogers Member

    Joined:
    Sep 19, 2003
    Messages:
    1,900
    Location:
    Canbizzle
    This PCB is pretty small, should be right :)
     
  15. nux

    nux Member

    Joined:
    Jan 20, 2002
    Messages:
    16,780
    Location:
    Melbourne
    Yep I just use the free version, it can do 2 layer boards too.

    I'll try to get them up in the next week when exams finish.
     
    Last edited: Nov 6, 2006
  16. OP
    OP
    bradrogers

    bradrogers Member

    Joined:
    Sep 19, 2003
    Messages:
    1,900
    Location:
    Canbizzle
    Ok no worries.
     
  17. Foliage

    Foliage Member

    Joined:
    Jan 22, 2002
    Messages:
    32,085
    Location:
    Sleepwithyourdadelaide
    This is a university project I did, I wont submit the whole thing, just the code and the procedure I went though. Basically we had to make the game pong in assembly (using the PIC18FXX2 instruction set) and it had to have an inbuilt scoring system, I also added difficulty so it gets faster as you play.

    Essentially how it worked was one of the ports was connected to two paddle switches and another port was connected to an 7 segment display. Its all heavily commented so you should be able to figure out whats going on and maybe learn something from it.

    http://www.hostmypiconline.com/images/f452tmpo.asm.txt.jpg
    http://www.hostmypiconline.com/images/procedure.txt.jpg

    ok I cant find anyway to host the txt files easily and im too lazy to sign up to hosting sites, just right click save as and rename to .txt to view these.
     
    Last edited: Nov 9, 2006
  18. zfind

    zfind Member

    Joined:
    Sep 5, 2006
    Messages:
    3,560
    Location:
    Helsinki
    OK, I'm gravedigging this thread up.

    I want to get started with microcontroller programming but even after reading everything in this thread (which is very helpful) I'm still a bit confused.

    From what I can gather, the two dominant types of controller for learning are the Microchip PICs and AVRs. To me, the PICs seem more widespread and more beginner friendly, with many starter kits and development kits while the AVRs seem more advanced and capable of more.

    How do I know which one to get? I'd like to buy a starter kit/development board that I can easily learn on. I don't want to learn ASM or C right now so would like to program in basic. I want to do things that a few have suggested here like starting off with simple LED projects and moving up to advanced things later on. I don't want to spend too much to start with either. I'd also like to have a largish amount of space for code so I have freedom to play :)

    So, which direction should I go in?

    zfind
     
  19. fref99

    fref99 Member

    Joined:
    Aug 11, 2002
    Messages:
    839
    Location:
    Switzerland
    Hi,

    have a look at the AVR range of CPU's. I've used Bascom AVR (A basic dialect) for quite afew projects now and although it's not perfect it's not bad.

    See if you can pick up a Mega8 or Mega32 development board (ebay maybe) and try out the demo version of Bascom (Full function but limited to 4Kb code).

    Here are a could of projects that I've done:
    1) A remote LCD display (remove as in anywhere on your network), it uses a mega8515 cpu, a HD44780 lcd display and an old NE2000 network card. Code size about 3.5Kb
    2) A remote control tilt/pan for a webcam, with a LED display, it uses a mega8515 cpu, RS232 LED display and an old NE2000 network card. Code size about 4.0Kb
    3) A fanbus controller (not finished) has LCD display, 6 temperature sensors, 2 controlled fan outputs (Driven by a PID controller), Water level sensors, water flow sensor. It uses a mega32 and the code is about 12Kb in size.

    Have a look at my site under projects and you'll see afew others including a simple servo tester (OCAU project).

    Regards
    FREF99
     
  20. zfind

    zfind Member

    Joined:
    Sep 5, 2006
    Messages:
    3,560
    Location:
    Helsinki
    Thanks FREF, that's some good info. You've highlighted for me one of the key difficulties I'm encountering - what size/capability MC I need. Would I really need something as big as the mega32 straight away? I can see the sense in getting it though as it would allow room later on for better programs.

    I've noticed the AVR Butterfly around a few places, is that actually a development board? It seems to be more of a flashy demo device than anything else, but I do remember it can be programmed by serial port and has some form of Mega on it.

    checking your site now.

    EDIT: wow, I like what you did with the webcam, nice! That was me looking at the cactus just now :) Can I ask, when using AVR's, do any development kits allow for USB programming of the MC? Reason being of the 4 computers in the house, not one has serial out so I'd have to use a serial to USB converter from my laptop.
     
    Last edited: Nov 27, 2007

Share This Page

Advertisement: