1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Calling all programming heads

Discussion in 'Microcontrollers' started by Mr.K, Mar 7, 2009.

  1. Mr.K

    Mr.K New Member

    Joined:
    Feb 12, 2009
    Messages:
    47
    Likes:
    0
    -very true, but im not going to duplicate it I want to take out the ir stuff and have the keypad controll the dimming

    -Why is assembly better? I thought that was lower level? and if I should use assembly what is the best complier to use? Do you have a aim? I dont want to piss off the mods
     
  2. colin55

    colin55 Well-Known Member

    Joined:
    Feb 14, 2009
    Messages:
    3,534
    Likes:
    82
    Location:
    Melbourne Australia
    Assembly is the "lowest level". It comes aligned to "machine code" - the instructions that are instantly understood by the micro.

    The only reason I prefer machine code is for easy fault-finding.

    If you have a sub-routine that doesn't work, you know the fault lies in your code.
    Your project just requires 6 separate sub-routines plus some delays.

    These can all the created separately and tested separately and then combined.

    If you want to use a higher-level language, you will have to learn all the in’s and out’s of the language.

    With "machine code" you can “cut-and-paste” already written sub-routines.

    It’s up to you.
     
  3. Mr.K

    Mr.K New Member

    Joined:
    Feb 12, 2009
    Messages:
    47
    Likes:
    0
    I see your point where I find some already written sub-rountines or sample code to at least get started? Also when you say sub rountines is that like loops?
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. colin55

    colin55 Well-Known Member

    Joined:
    Feb 14, 2009
    Messages:
    3,534
    Likes:
    82
    Location:
    Melbourne Australia

    Each little thing you do is put into a sub-routine.
    One subroutine will be a delay another subroutine will scan the keyboard, another subroutine will detect the key-value and carry out the required operation.
    Another sub-routine will detect another key-value and carry out the appropriate operation.

    This is the way you build up the program.
    But first you will want to connect a LED to the chip and turn it on then turn it on an off. This will let you know how long the delay sub-routine has to be to get the effect.

    Don't forget the micro is carrying out instructions at 1,000,000 per second and it doesn’t stop, so you have to make sub-routines that can carry out a task and put the result somewhere where it can be located by another sub-routine.
    You have to learn about things like debounce, as the micro will detect the key-press very quickly and go away and do something else. When it comes back, it must know if the key is the same as previously or if your finger has been removed and replaced.
    You cannot expect to learn all these things in a week. It will take months. That’s why a large organisation knows the program is worth $5,000. They couldn’t get it for less.
     
  6. Mr.K

    Mr.K New Member

    Joined:
    Feb 12, 2009
    Messages:
    47
    Likes:
    0
    interesting Im going to do some reading in to programming in assembly this weekend and start something by monday hopefully i can have some code to show you and get your guidance

    thanks collin, oh btw you still haven't recommended me a assembly compiler
     
  7. colin55

    colin55 Well-Known Member

    Joined:
    Feb 14, 2009
    Messages:
    3,534
    Likes:
    82
    Location:
    Melbourne Australia
    3v0 wrote:


    The microchip PICkit3 is out and they are selling off the stock of PICkit2's for $30. Microchip makes sure the software is up to date, it works with MPLAB, and it is inexpensive.
     
  8. russ_hensel

    russ_hensel New Member

    Joined:
    Jan 28, 2009
    Messages:
    42
    Likes:
    0
    Location:
    South Dartmouth, Ma
    You want a Flash chip. It has an F in its part number. I like the 16F877A it has lots of pins and resources. It is out of date but still nice. I am told the 16F887 is a more modern version. Both should be under 10 bucks. The 18F series is more powerful and not much more expensive. Microchip has a free C compiler for the 18F series. If you use the 16F I would use the free version of BoostC, but it has a 2 k code limit. Plan to devote quite a few weeks to learning enough to do this project. You will need to start by flashing an LED. You will also need a breadboard...... Read some of the tutorials.
     
  9. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,227
    Likes:
    641
    Location:
    Derbyshire, UK
    There's no such thing - it's called an assembler (a compiler is for a high level language), and comes free as part of MPLAB from MicroChip.
     
  10. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    Assembler isnt machine coding.

    Machine code was written and entered byte by byte in hex format by hand, way back in the 'good old days' before assemblers were available.

    Nostalgia time again Nigel.

    Assembler is effectively a low level language.

    Whatever language you write in,
     
  11. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,019
    Likes:
    317
    Location:
    Brisbane Australia
    I'll add my 2c worth,

    Forget the 12c509, use something like the 12F675 or 12F683.
    Look at assembly and boostC, if you don't know either then the learning curve is probably the same in both cases.
    Just have a go and when you get stuck, just ask.

    Mike.
     
  12. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,807
    Likes:
    135
    Location:
    morristown,tn
    Mr.K I's not that hard to make you a dimmer but you wouldn't have any fun doing it. There all kind of code on the net for just about any thing you want to make. If you started your code people would help you. Here is some good site's to read.
    1. Gooligum Electronics
    2. Nigel's PIC Tutorial Hardware
    3. mikroElektronika : books : PIC microcontrollers
    4. Spency's PICBasic Home - PIC micro Tutorials and examples by Spency
    5. Easy PIC'n,Beginner Microchip, Getting started PIC, PIC Microcontroller
    Hope this helps I like the first two the best.
     
    Last edited: Mar 8, 2009
  13. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,807
    Likes:
    135
    Location:
    morristown,tn
    Mr.K If you would post what your trying to do here and stop Pm me. I'll do my best to help
    you with it. Now
    1. If you want to make a dimmer post the circuit or a link to it
    2. If your dimmer is to use something like a sony remote you can use the 12F675
    3. If it is to have a key pad then you need a bigger chip because of the key pad now you can use a 16f628a lot's of code that you can look at a learn by. Me my self I would use a 18f1230 I like basic and Assembly don't do much in C the 18F you can use swordfish basic
    4. If you want help the form is where it at now I -know you think people are not willing to help that's not so they wouldn't be on here.

    Post your code or a link to it here something like this
    Code (text):

     LIST p=16F628  
     include "P16F628.inc"
     ERRORLEVEL 0, -302 ;suppress bank selection messages
     __config 0x3D18
     
      cblock 0x20   ;start of general purpose registers
       count   ;used in looping routines
       count1   ;used in delay routine
       counta   ;used in delay routine
       countb   ;used in delay routine
       tmp1   ;temporary storage
       tmp2
       key   ;which key was pressed
       rows   ;counter for number of rows
       code1   ;registers for secret code
       code2
       code3
       code4
       key1   ;registers for keyed attempts
       key2
       key3
       key4
      endc
     
    Now down load the circuit for the keypad add your pic and dimmer control to it and let's get started pick'n
     

    Attached Files:

    Last edited: Mar 10, 2009
  14. Triode

    Triode Member

    Joined:
    Feb 11, 2009
    Messages:
    925
    Likes:
    22
    Location:
    Bay Area
    I think I saw a post somewhere on this site about a key pad input lock controller, like what you are talking about except it switches a pin on for a few seconds to operate the lock motor. Taking a look at that would be a good start.
     
  15. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,807
    Likes:
    135
    Location:
    morristown,tn
    Ok Mr.K take a look at this and lets see if we can make it work
     

    Attached Files:

    Last edited: Mar 11, 2009
  16. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    168
    Location:
    Toronto, Canada
    Put some pullups on a keyboard row. Keeps you from shorting outputs when you're scanning and someone presses more than one button at a time.
     
  17. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,807
    Likes:
    135
    Location:
    morristown,tn
    I wasn't done I was just trying to help him out I was going to put 3 10k on it and when I get time I'll add the part value.
     
    Last edited: Mar 10, 2009
  18. Mr.K

    Mr.K New Member

    Joined:
    Feb 12, 2009
    Messages:
    47
    Likes:
    0
    Sure :D like I mentioned in the pm, I want to make a modification to this hobby project

    http://img152.imageshack.us/img152/3954/irlightdimmer12f629.gif

    -My plan is to take out the IR stuff because it's controlled by IR and modify it. My Goal is to have the light dimmer be controlled by a 3x4 keypad. I have already order the parts from the schematic above minus the chip and the IR stuff. Here is how I want the chip to tell the keypad how to operate

    When power is first turned on press “*” and enter a four digit default code; such as, “0000”.

    -The light will begin to function.

    - To change the code press “#” input the old code followed with a new four digit code sequence.

    - New code sequence is accepted and must be used to allow the light to
    function.
    - Increasing brightness of the light will be controlled by pressing “2”.

    -Decreasing brightness of the light will be controlled by pressing “8”

    - After 30 seconds the user can not change the brightness with the “2” or “8” key. The selected code sequence must be re-entered.

    -When the power goes off the default code will be set back to 0000
     
    Last edited: Mar 10, 2009
  19. Mr.K

    Mr.K New Member

    Joined:
    Feb 12, 2009
    Messages:
    47
    Likes:
    0
    I like the schematic B! However I don't know which circuit better suites what im trying to do. Take a look at the circuit Im making the modification too and tell me what you think
     
    Last edited: Mar 10, 2009
  20. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,807
    Likes:
    135
    Location:
    morristown,tn
    It's more or less the same I just added A keypad
     
    Last edited: Mar 10, 2009
  21. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,807
    Likes:
    135
    Location:
    morristown,tn
    Are you going to use the 16f628a
     

Share This Page