######################################################################################### #This section works out the speeds and feeds for the motors based on the layup schedule.# ######################################################################################### import math # Define Variables mandrelStart = 0.0 # How far along the mandrel to start in mm mandrelLength = 300 #Mandrel Length in mm mandrelDiameter = 50 #Mandrel Diameter in mm layupSchedule = [45, 0, 90] # Define full coverage layers in laminate mandrelRPM = 10 #Revolutions of the mandrel per minute #Calculate required x speed to achieve angle called out in layupSchedule ply = 1 # ply number will need to change automatically later plyAngle = layupSchedule[ply-1] # angle specific to that ply print 'plyAngle = ', plyAngle mandrelLinearVelocity = mandrelDiameter/2 * mandrelRPM #mm/min print(mandrelLinearVelocity) zSpeedrev = (2 * mandrelDiameter ) / math.tan(math.radians(plyAngle)) # z speed in mm/rev zSpeedlin = zSpeedrev * mandrelRPM #xSpeed = math.cos(math.radians(plyAngle-45)) * mandrelLinearVelocity print'Speed/Rev:', zSpeedrev, 'mm/rev' print'Speed Linear', zSpeedlin, 'mm/min' ########################################################################################## #This section works out the coordinates for the center of each filament #It uses the filament width, start and finish locations and the amount of fill #required to generate the coordinates that the tapes should take. The first and #last coordinates can be used to give G-code start and stop locations. After the #first traverse the outer two numbers are eliminated filamentWidth = 5 # Width of filiament in mm zStartLoc = 100.0 #mm zFinsihLoc = 400.0 #mm windingLength = zFinsihLoc - zStartLoc layerFill = 25.0 #100% coverage fillLocations = windingLength/filamentWidth fillLocations = fillLocations * layerFill/100# Reducing the fill locations by the percentage fill. fillLocations = fillLocations / 2 #half the amount because we are tracking the locations on the top of the mandrel (see page 3 of notes) print 'Number of Fill Locations', fillLocations fillIncrement = windingLength / fillLocations #fillCoOrds=['holder']*fillLocations n=100 fillCoOrd=[0] #initialize the coordinate vector ii=0 #fillCoOrds = [None]*fillLocations while (ii< windingLength): ii=ii+fillIncrement fillCoOrd.extend([ii]) print 'First Traverse Filament Center Locations' , fillCoOrd filamentPitch = (2 * mandrelDiameter ) / math.tan(math.radians(plyAngle)) print 'Filament Pitch' , filamentPitch tapesToFill = filamentPitch / filamentWidth print 'Tapes to Fill Gap' , tapesToFill allFilamentLocations=[zStartLoc] #allFilamentLocations = windingLength/fiamentwidth ii=zStartLoc while (ii < windingLength): ii=ii+filamentWidth/(layerFill/100) allFilamentLocations.extend([ii]) print '% LayerFill Fill Filament Locations',allFilamentLocations ########################################################################################## #This section takes the list of locations from the fillCoOrd list and #puts them in order relating to the G-Code # Moves totalLocations = len(allFilamentLocations) moveList=['NONE'] #################################### jj=1 #Initialize the list of moves while (jj < totalLocations): moveList.extend([totalLocations]) jj = jj+1 ##################################### ii=0 #### Gcode syntax # Linear Motion G0,G1 zMove = 'Z ' print 'Z Move', zMove while ii<totalLocations: # print 'current' , current #scurrent =str(current) #print 'scurrent' , scurrent combineit = zMove + scurrent #print 'combined??' , combineit #Change current location into a string so it can be combined current = str(allFilamentLocations[ii]) moveList[ii] = zMove + current #movelist[ii] = zMove + str(allFilamentLocations[ii]) ii=ii+1 print moveList
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question