How to learn pic programming.

Discussion in 'Programmer's Corner' started by lilunwl, Mar 29, 2009.

  1. lilunwl

    Thread Starter Member

    Mar 29, 2009
    17
    0
    Ok here is maybe a silly question for yall. I mod xbox 360 controllers to make rapid fire controllers. I use 12F683 I/P45U 0901 microcontrollers. I currently buy them from another guy and then install them into peoples controllers. It makes 3 modes of rapid fire. Basically when they pull the shoot button it makes it fully auto rather than semi auto. My question is how do I learn to program the chips myself? Is there a way to learn at home or basically something I need to go to school for? If its not something you would say would be easy to learn at home.Then what course's would teach this? I know they wont teach to mod controllers but to program microcontrollers. Thank you for your help in advance.
     
  2. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    I guess if you can make sense out of a PIC data sheet you are a good way down the road. The link below points to the micro family you are using.

    http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010115

    Have you any programming experience - say in BASIC, Assembly languages or higher level stuff like "C"? For instance does the chapter (13) on the "Instruction Set Summary" make any sense to you?

    If no programming experience, you can probably pick it up via private study. Assisted or formal course study is the quickest way for most people. Don't know about available useful courses in the US education system, so I can't help there unfortunately.

    You would also need to acquire some hardware and software development environment tools to actually try your hand at this work. It's a reasonable "learning curve" but probably well within your grasp. If you can see a commercial incentive then all the more motivation for success!

    Good luck with this. Other AAC members will (no doubt) have worthy and excellent advice to offer.:)
     
  3. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,699
    907
    I am assuming you do not have the program and the chips are read protected.

    Do you have a device for physically programming the chips? I use PicStart Plus from Microchip. There are several other possibilities. You will need something like that.

    Finally, while you probably do not have the program, do you have any idea how it works? I suspect it may take the trigger input, and if it exceeds a certain duration, it outputs a series of pulses, otherwise, it just outputs a single pulse. That would be quite easy to do in Assembly. As tnk suggests, if the instruction set makes sense to you, check out some tutorials on flashing LEDs, and try it. Once you are able to flash an LED, doing a program like I just suggested would be obvious to you.

    John
     
  4. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    If you get a PicKit2, you can read the IC's he programmed, although that is unethical, as he wrote the code, debugged it, goes through the mind numbing task of programming, and is selling his work.

    What are the rates of fire on different pins? Writing a program to do that is simple, as mentioned above. Just like blinking 6 LEDs at different rates on the different pins.

    Then order a batch of surface mount 12F675s, and a SOIC-DIP adapter ($40) to make a programmer. The PicKit2 ($30-$35) can store a program in memory, so you only need to plug in a new IC, hit the button, wait, repeat.

    A C or Basic license for commercial products is usually $249 to $5,000.
     
  5. lilunwl

    Thread Starter Member

    Mar 29, 2009
    17
    0
    t n k .... I have no experiance at all in the programming side of things. Im not dumb per say but I have looked at some sites that have to do with the programming side and got nothing out of it. I think I will have to start looking for some private classes or someone close that knows the programming part.
    jpanhalt...The program is available yes I am not sure if the chips are protected or not but it is an "open source code" I believe anyways. The code is posted online but I dont know if it is "truely" it or not or if anything is missing or whatever because it makes no sense to me. LoL
    I do not have a programmer yet. I was actually going to wait to find out if I can learn it without going to school or whatever. I have looked at many of them online but didnt want to just buy it and not know what to do with it.
    If you would like to see the wireing diagram and see what it does and all that you can look at my website. Im new at website making or whatever so its not the best but it does have the diagram. http://xbox.e-motz.net/ As far as the Leds. I wouldnt know where to start. LoL So when they make the trigger fully auto it is the same as the flashing led? That is where the pulse comes from? Is that what you are saying? LoL Thanks for all your help I do appreciate it!!
     
  6. lilunwl

    Thread Starter Member

    Mar 29, 2009
    17
    0
    thatoneguy...I do not want to "copy" per say his code directly from the chip. But I do have access to what I believe is the code.I would like to enter the available code if it is a working code.And make my own chips. I think if I were to copy his code directly that wouldnt be fair incase he has added his own touch or whatever.The rates of fire can only be upto 8 shots per second or it is caught and then slowed down per microsoft. If I were to buy the pic2 does it come with instructions for a noob? Like I said im not "dumb" but I dont want to buy it if it is more focused on the experianced programmer.

    So I would have to get a liscense to make and sell these chips? Do you have to have more than a vendors liscense? I do not plan on making a business per say. But I guess in alot of sense it would be the same as a business.How would I find out exactly what I need as far as liscense? Thanks for all the advise.
     
  7. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    If the source is GNU/Open Source, and known working: If you post the source code, and I happen to have the compiler for it, I'll make a hex file of it that can be downloded, which you can then program to ICs with a PicKit2.

    I can't guarantee it will work as I do not exactly know what signals the xbox uses, but if it only involves putting a high or low voltage on a pin for a certain period of time, and repeating that, it is pretty straightforward. Once I see the code I can guess better how it works.

    Unfortunately, a chip can't be downloaded, only the .hex file to program it. If it works, load it into the pickit2 loader, build a PC board with programming pins, and keep hitting the program button.

    MPLAB comes free with the PicKit2, and the hardware programming ('burning the chip') is the 'hard part' for people starting out, so once you are past that, learning BASIC or another programming language is pretty easy with all the examples around. You could then design a "Better" rapid fire program, at least, that would be my goal for helping with the first part. :)

    The easiest to use/learn is Oshonsoft PIC/AVR IDE Simulator which is programmed in Basic, and is affordable. It doesn't support your package, but the demonstation period is long enough to look at examples provided to get an idea of how stuff works with a PIC.
     
  8. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,699
    907
    If it is open source code, you can do whatever you want with it within the limits of the open source licensing.

    As for the chip, it is easy enough to tell if it is protected when you insert a pre-programmed chip in your programmer. But, you may not need to do that, if it is open source.

    The chips look like DIP, not SMD (SOIC). It is only a tiny compexity going from DIP to SOIC, but since you are already set up for the DIP version, I woud stick with it for the time being.

    Since you are new at it, I would recommend going with something like the PicStart or other well made commercial version instead of a sligtly less expensive homemade version. It limits the variables you have to deal with.

    I mentioned the LEDs as an example of a common beginner's program. Basically, it will teach you how to make one or more outputs vary depending on the input to one or more pins. That is what it sounds to me like you are doing. Most important, you will learn to set up the header file. It is possible that the open source code is for a different PIC MCU, so the code may be fine, but the header will need tweaking for whichever chip you decide to use. The 12F683 is one of the more capable and expensive of that series of chips. It is entirely possible that you could use a cheaper chip in the 12F5XX series or even 12F6XX series depending on the code.

    If you want a slightly cheaper SOIC to DIP adapter, I published a project in the Projects Collection (http://forum.allaboutcircuits.com/showthread.php?t=17798 ) here that shows how to build it.

    John
     
  9. lilunwl

    Thread Starter Member

    Mar 29, 2009
    17
    0
    These are the 2 codes i have that are said to be open source. They are both supposed to be the same concept but I dont know how to read them. All I know is one seems different from another.

    :1000000000308A000428000084011F30830571300D
    :1000100083168F0083121F1383161F109F101F114A
    :100020009F110730831299008316950181170108EB
    :10003000C73908388100831290010030A100920076
    :10004000003083169200073083129900831605084A
    :1000500006308312A000A00B2B28000019088C1179
    :100060008316990101308F008312A60183160512B1
    :10007000831205128316851283128516A608031DA6
    :100080004D283230A60083160512103083128506E3
    :1000900083168512203083128506A6033E2863004E
    :02400E00F43C80
    :00000001FF
    ;PIC12F683



    :020000040000FA
    :100000002828A301A200FF30A207031CA307031C9A
    :1000100023280330A100DF300F200328A101E83E90
    :10002000A000A109FC30031C1828A00703181528FC
    :10003000A0076400A10F152820181E28A01C222844
    :1000400000002228080083130313831264000800B1
    :1000500001309F0083169F018501831264000518FB
    :10006000322833202E280511051183160511323050
    :1000700083120120051583160511323083120120E9
    :04008000051508005A
    :02400E00FC3F75
    :00000001FF

    Ofcoarse my goal is to create a better program after I learn how to program it. But I need to learn first LoL
     
  10. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,699
    907
    Those are the HEX files, which one might be able to disassemble given the time and inclination. Unfortunately, my MPLAB is installed on another computer, the disk from which has to be transferred to my new computer. That won't be done in the next day or two.

    Do you have the program source code? It will be written in words you will recognize as having meaning. The language will likely be Assembly, C, or Basic.

    John
     
  11. lilunwl

    Thread Starter Member

    Mar 29, 2009
    17
    0
    This? I think this is it.

    Setfreq m8
    rapidoff:
    Low 1
    do
    if pin3 = 1 then pause1
    loop while pin3 = 0
    goto rapidoff
    pause1:
    pause 1000
    goto rapidon
    rapidon:
    Low 1
    Pause 300
    High 1
    Readadc 4,b0
    If b0 > 125 then Rapidfire1
    If pin3 = 1 then pause2
    goto rapidon
    Rapidfire1:
    Do
    High 1
    Low 4
    Pause 180
    High 4
    Low 1
    Pause 175
    b0=b0 and %00000000
    Let dirs=b0
    Readadc 4, b0
    Loop while b0 > 125
    goto rapidon
    pause2:
    pause 1000
    goto rapidon2
    rapidon2:
    Low 1
    Pause 200
    High 1
    Readadc 4,b0
    If b0 > 125 then Rapidfire2
    If pin3 = 1 then pause3
    goto rapidon2
    Rapidfire2:
    Do
    High 1
    Low 4
    Pause 150
    High 4
    Low 1
    Pause 145
    b0=b0 and %00000000
    Let dirs=b0
    Readadc 4, b0
    Loop while b0 > 125
    goto rapidon2
    pause3:
    pause 1000
    goto rapidon3
    rapidon3:
    Low 1
    Pause 100
    High 1
    Readadc 4,b0
    If b0 > 125 then Rapidfire3
    If pin3 = 1 then pause4
    goto rapidon3
    pause4:
    pause 1000
    goto rapidoff
    Rapidfire3:
    Do
    High 1
    Low 4
    Pause 100
    High 4
    Low 1
    Pause 95
    b0=b0 and %00000000
    Let dirs=b0
    Readadc 4, b0
    Loop while b0 > 125
    goto rapidon3
     
  12. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Source code is in BASIC. The first ones posted are the .hex files that the basic compiles to for writing to the IC.
     
  13. lilunwl

    Thread Starter Member

    Mar 29, 2009
    17
    0
    So then this is what i need to study to learn from? http://www.oshonsoft.com/pic.html ?? Or is there somethingelse? Now that you know what type it is what would you say start to finish what I need to do as far as learning to do this? Thank you for being so helpful!!!!
     
  14. maxpower097

    Well-Known Member

    Feb 20, 2009
    795
    388
    If your wanting to do XBOX 360 mods, 1st get a pickit 2. This will allow you to program chips and debug some. Then they sell the hex code on ebay for $10. Then you just load the hex file with the pickit 2 wired to the pic chip and done. Working xbox chips.
     
  15. lilunwl

    Thread Starter Member

    Mar 29, 2009
    17
    0
    Someone from on here sent me a message on my website and for some reason it sent me as unknownsender@unknowndomain.com You were asking about rapid fire and about lights. Email me through my site again or through my personal email. I will help you out. Thanks and I do apologize. George mybills2356@aol.com
     
  16. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    That'd be SPAM. Report the PM to admin

    As far as learning how.. Do you just want to make more chips with the existing hex file? You have the hex file posted above, all that is needed is a PicKit 2 and a breadboard.

    If you want to design new features for the controller, and are brand new to microcontrollers and electronics, I'd highly recommend the oshonshoft IDE Development Kit. That, combined with information online will get you up to speed on "How They Work" Very Quickly, with visual feedback. I'm unsure if that BASIC supports the 12F in demo mode, though.

    You can demo a different chip for 25 runs, it has example programs and is a free download. After looking at the examples and seeing how stuff works, it should help you decide if you want to fork out money for a PicKit 2 and learn more.

    Just a warning: If you like tinkering with electronics much at all, you will become addicted to microprocessors!
     
  17. lilunwl

    Thread Starter Member

    Mar 29, 2009
    17
    0
    Thanks!
    Yes I want to learn more about programming. Not just steal someones code and run. LoL I want to learn how to program microcontrollers for other reasons to but for now I want to be able to eventually make my own better rapid fire code. I have learned a lil bit and i will look into the kit you recomend!! Thanks alot!!! At any rate thanks alot for all the help and all the info you have given. Greatly appreciated!!!
     
Loading...