Automation project need help


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2010
    Posts
    20

    Default Automation project need help

    I'm having trouble with math in picbasic pro. I'll give you an over view of what I'm trying to do. I've been automating a few machines that feed out cardboard and cut it off. The feeding is done by a stepper motor directly connected to a roller. I've been using CNC control software to handle this up till now. I'd like to reduce my cost and have a smaller control.

    The roller that the stepper motor is connected to is 1.987” in diameter. So to figure out how much stock is fed out each turn I need the circumference. Which is 1.987 * PI = 6.2423. So with every turn of the stepper motor it feeds out 6.2423 inches of stock.

    I have a 2000 step per revolution stepper motor. So then we take the circumference 6.2423 / 2000 which gives us .003121”. This is how much stock is fed out with every step.

    This is easy in normal computer programming. But working with pic's is totally new to me.

    So far in this project I have a 4X4 keypad working it will store “123A 567B 789C *0#D” in a variable. I also have LCD out put working.

    So basically what I need working is for the user to be able to enter the amount of stock they want. Lets say they enter 60.25” inches. With the “*” as the decimal point on the keypad.

    So with the above equations all I really need to have in my program is a variable is the (steps per inch = .003121) and then you just take 60.25/.003121 = 19304 Then I would just send out 19304 pulses to a pin on the pic to step the drive.

    So my question is how do I work with decimals in 16bit math?

    My other question that goes with this is how do I store multiple keys typed in on the keypad so that if the user types in 60.25 I can work with it?

    I've attached a picture of the stepper motor (bottom left) attached to the machine with the rollers and cardboard feeding though so you can have a better idea of what I'm doing. Thanks.
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    I like it !
    Typically you would multiply everything by 1000 for .001 resolution .
    Oh, and you're cutting cardboard, forget measuring to .0001 or even .001 especially when you break it into dia/2000 the temp/humidity will kill those resolutions anyway, and seriously just how close does a cardboard piece have to fit? I make parts, mostly for the space/aircraft test industry and I see engineers throw out useless impossible tolerances which serve zero purpose other than make everyone's job harder and swell their ego's. Did a job recently where the engineer told me to bore some holes at the intersection of 2 parts and then take them apart and mill off .002 from 1 surface. Yea right, shimmed it with paper and bored it, on top of that the part it clamped was just a piece of PEX tubing which varied all over the place in diameter.
    I guess what I am trying to say is, make Your own job easy.
    Or turn that feed roller down to 1.9099 and it will roll out 6.000 .
    Last edited by Archangel; - 1st January 2010 at 18:23.
    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.

  3. #3
    Join Date
    Jan 2010
    Posts
    20


    Did you find this post helpful? Yes | No

    Default thanks

    That's funny. I'm a pattern maker in the arrow space industry. I got laid off early 2009 and started doing side jobs. I started my own company about two months ago and started automating some machines for an air filter company. Your suggestion to turn the roll down to 1.9099 is what I came up with also to make it easier. The problem I had was that they hired me to retro fit the design they already made for that project. In the future they will consult me first then I can make the hardware to fit the software better. thank you for your reply.

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    I am thinking it will boil down to just this much

    Steps = Length / 0.003121
    OR
    Steps = (Length * 1602) / 5

    About the question of your numbers with decimal point, PBP has no native floating point support. So, you have to coax your values into a fixed decimal base or maybe use the FP support addon with all its bells and whistles.

    The method above is suitable for plain integer math and can be used with PBP below PBPLong version too.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by microcnc05 View Post
    That's funny. I'm a pattern maker in the arrow space industry. I got laid off early 2009 and started doing side jobs. I started my own company about two months ago and started automating some machines for an air filter company. Your suggestion to turn the roll down to 1.9099 is what I came up with also to make it easier. The problem I had was that they hired me to retro fit the design they already made for that project. In the future they will consult me first then I can make the hardware to fit the software better. thank you for your reply.
    So what kind of tolerance do you have to play with? I am thinking, run down some round numbers and periodically add in a correction, to stay in tolerance. If you keep the numbers less than 65535 then it's pretty easy, if more then you will need to store some in another variable or an array . . . another, (better ?) way is to use an encoder instead of relying on the stepper not to drop steps.
    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.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    As always ... +1 with Jerson !!!

    7369/23 also could be considered ( 3.5 ppm error ... ROFL )

    may be we could tell µCNC to have a closer look to the DIV32 function ... that will allow 2^15 as a max. value to be divided ...


    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #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 : 1

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