Machine Automation Program - need peer feedback...


Results 1 to 8 of 8

Threaded View

  1. #1
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    76

    Default Machine Automation Program - need peer feedback...

    I am a using PicBasic Pro to program machines at work. I have no peers around me that I can lean on for support or ideas. I know I'm not very good at this stuff and I learn best when there are others to tell me when there's a better way.

    I have attached a snippet of code as an example of how I am controlling a two-sided machine. The machine shares two stepper motors in movement and actuation. Otherwise it is mostly pneumatic controls and electric motors.

    The machine works and is producing parts but I have some bugs to work out and still think it could be done a lot better by someone that knows what they are doing. :-)

    The example below is for your critique. Beat it up please! I need feedback. I have not bothered to put in all of the up front stuff like naming of variables and such, it is merely to show a flow of machine operation.

    Thank you!

    Ross



    Code:
    '****************************************************************
    '*  Name    : Machine Operation Example.BAS                                                      *
    '*  Author  : Ross Freeman                                                                               *
    '*  Date    : 4/18/2013                                                                                    *
    '*  Version : 1.0                                                                                             *
    '****************************************************************
    
    'I just finished the mechanical design of a fairly complex machine that
    'automates a tedius process in the assembly of components in production.
    
    'I do not have any peers in the area of programming and do this as a hobby only
    'and seldom even as that. I have an electronics guru that helps me in that 
    'department. My expertise is in mechanical design but I cross into all areas.
    
    'I need critical feedback on my programming. What am I doing right and what am
    'I doing wrong. Specifically, I am operating multiple stepper motors at the 
    'same time in different areas of the machine. 
    
    'Currently, the program loops continuously at high speed through MAIN. The 
    'step operations go through branch instructions and back to MAIN. To send fifty
    'pulses to a stepper motor I loop through Main 50 times. Only one pulse is sent
    'during that step per loop. This means loops through MAIN must be fast and 
    'timing is critical. But if I do it carefully, I can control several motors
    'on each loop. Speed control for each stepper is done through loops within its
    'individual branch operation. (I hope that made sense)
    
    'To put it another way, I can accelerate or decelerate for each individual
    'stepper without slowing down loops through MAIN.
    
    'In this example, the machine is assembling components on two sides of the
    'machine and sharing stepper motors between them.
    
    'My Question: Is this how it is done??? Or am I out in left field? 
    
    'I have been sucessful on this project and wrote 35 pages of code in the
    'process. That's the longest program I've ever written and it has some bugs I'm
    'still working out... but we're making product and the operators love the 
    'machine.
    
    'Please critique my programming. This is a simple example of how I control the
    'machine below... I've not bothered to name variables and such... this is just
    'for discussion. THANK YOU!!! 
    
    Main:
            
            gosub left_side_operation
            Gosub right_side_operation
            gosub get_inputs
            gosub update_outputs
            gosub status
            goto main
            end
            
    Left_Side_Operation:
            
            while left_side_step <> 0
            branch left_side_step, [lstep_0,lstep_1,lstep_2,lstep_3]
            wend
            if start_button_pushed = yes and op_side = 0 then
            left_side_step = 1
            return
            
    LStep_0:
            
            Return
            
    LStep_1:
    
            'do these things
            left_side_step = 2
            return
            
    LStep_2:
    
            'do these things
            left_side_step = 3
            Return
            
    LStep_3:
    
            'do these things
            left_side_step = 0
            return
            
    Right_Side_Operation:
    
            while right_side_step <> 0
            branch right_side_step, [rstep_0,rstep_1,rstep_2,rstep_3]
            wend
            if start_button_pushed = yes and op_side = 1 then
            right_side_step = 1
            return
            
            
    RStep_0:
            
            Return
            
    RStep_1:
    
            'do these things
            left_side_step = 2
            return
            
    RStep_2:
    
            'do these things
            left_side_step = 3
            Return
            
    RStep_3:
    
            'do these things
            left_side_step = 0
            return
            
    Get_Inputs:
    
            'This is where I watch for sensors, switches, push_buttons, interlocks
            Inputs = portb
            return
            
    Update_Outputs:
    
            'This is where I turn on relays or solenoids, send pulses to steppers, 
            'alert the operator with lights or buzzers, or send info to the LCD
            Return
            
    Status:
    
            'This is where I determine what to do with changing input signals 
            'such as an operator pushing the start button or the pressure switch
            'sensing low or no pressure...


    Attachment 6975
    Last edited by rossfree; - 18th April 2013 at 19:55.
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

Similar Threads

  1. Insteon Home Automation Software Development Kit
    By Stuartk in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 23rd November 2013, 17:52
  2. Replies: 3
    Last Post: - 26th November 2012, 11:20
  3. Automation project need help
    By microcnc05 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th January 2010, 03:17
  4. pic to pic to pic as peer to peer to peer
    By Geezer in forum General
    Replies: 1
    Last Post: - 5th September 2008, 06:53
  5. Replies: 8
    Last Post: - 8th May 2007, 11:15

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