Automation project need help


Results 1 to 7 of 7

Threaded View

  1. #7
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default Stepper drive automation

    You might consider:

    1. Scaling - as others have said so that you work in some basic unit that is acceptable - probably relates to the maximum error you can tollerate in the stock length.

    2. consider using a 'maths co-processor' to handle complex calculations and numbers outside the range of your MCU - Ive had a preliminary play about with the MicroMega chip and it's amazingly powerful.

    3. Keypad input. This is what I do:

    define OSC 20 ' Define Xtal as 20 MHz, use "HS" for programming

    X var byte ' Reusable variable
    Y var byte ' Reusable variable
    Key_Press var byte ' Keypad Read condition of keypad port
    Key var byte ' Keypad Key pressed
    Accumulate var word ' Keypad Accumulated input number

    TRISD = %01110000 ' D0-D3 driven outputs, D4-D6 read inputs

    Main:
    gosub Keypad
    ' Use the returned 4 digit number here
    goto Main
    '----------------------------------------------------------------------------------------------------
    Keypad:
    for Y = 1 to 4 ' Accumulate four keyboard numbers
    Get_Number:
    PORTD = %00000001 ' Apply +5 to first row
    for x = 0 to 3 ' Read the columns in turn
    Key_press = PORTD & %01110000 ' Isolate the three columns
    select case key_press
    case %00000000 ' No key pressed
    Key = 0
    case %01000000 ' Righthand column
    Key = 3 + 3*x
    case %00100000 ' Centre column
    Key = 2 + 3*x
    case %00010000 ' Lefthand column
    Key = 1 + 3*x
    end select
    if Key <>0 then Key_Done ' got a result so quit
    PORTD = PORTD << 1 ' Moves +5 to rows 2,3 and 4
    next X
    Key_Done:
    if Key = 0 then Get_Number ' No key pressed so do it again
    IF Key > 9 then Key = 0 ' Treat the * and # keys as zero

    Accumulate=Accumulate*10+Key ' Shift the accumulated result up and add last key press
    high Heartbeat : pause 150 : Low Heartbeat
    pause 300 ' If key is held down then repeat number
    next Y
    return
    '----------------------------------------------------------------------------------------------------
    end

    And the circuit diagram of the keypad:
    Attached Images Attached Images  

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. A Temperature & Humidity Data Recorder Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 9th July 2008, 18:47
  3. Help with final project
    By OvERKiLL in forum General
    Replies: 4
    Last Post: - 15th December 2006, 20:35
  4. Help on coding/ selecting PIC chip for project
    By lovemeok in forum General
    Replies: 0
    Last Post: - 27th July 2006, 19:21
  5. A category for Project Ideas
    By Pic_User in forum Forum Requests
    Replies: 2
    Last Post: - 23rd June 2006, 07:29

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