Two Stepper Motors?
Author |
Message |
tamir
|
Posted: Wed Jan 16, 2008 4:36 pm Post subject: Two Stepper Motors? |
|
|
well i am doing a project with involves to rotating stepper motors and i do not understand how to active the second motor
if you guys can please check my program and see where i should put it and give me tips on how to do it
Turing: |
% The "GUI.CloseWindow" program.
import GUI
const screenWidth : int := Config.Display (cdScreenWidth )
const screenHeight : int := Config.Display (cdScreenHeight )
const titleBarHeight : int := 32
const windowEdgeSize : int := 13
const windowWidth : int := 330
const windowHeight : int := 390
var textBox, windowID, windowNumber, quitButton : int := 0
var input0, input1, tmpinput0, tmpinput1, tmpstate0, tmpstate1 : int := 0
PC.ParallelPut (1, 0)
procedure rotate
PC.ParallelPut (1, 0)
GUI.AddText (textBox, "Delaying for 1 seconds for spin-down..")
delay (1000)
GUI.AddLine (textBox, " done.")
tmpinput0 := input0
tmpinput1 := input1
input0 := tmpinput1
input1 := tmpinput0
% GUI.AddLine (textBox, "Rotate: " + intstr (input0) + " ; " + intstr (input1) + " ; " + intstr (tmpinput0) + " ; " + intstr (tmpinput1))
GUI.AddLine (textBox, "Alternating rotation.. ")
PC.ParallelPut (1, 2 ** input1 )
end rotate
procedure state
if input0 = 1 or input1 = 1 then
tmpstate0 := input0
tmpstate1 := input1
input0 := 0
input1 := 0
elsif input0 = 0 and input1 = 0 then
input0 := tmpstate0
input1 := tmpstate1
tmpstate0 := 0
tmpstate1 := 0
end if
GUI.AddLine (textBox, "Alternating power state.. ")
if (input0 + input1 >= 1) then
PC.ParallelPut (1, 2 ** 1)
else
PC.ParallelPut (1, 0)
end if
end state
/*
* ccw: i0 = 1; i1 = 0;
* cw: i0 = 0; i1 = 1;
*/
procedure rotateother
if input0 = 0 and input1 = 1 then
PC.ParallelPut (1, 0)
GUI.AddText (textBox, "Delaying for 1 seconds for spin-down..")
delay (1000)
GUI.AddLine (textBox, " done.")
elsif input0 = 1 and input1 = 0 then
return
end if
input0 := 1
input1 := 0
PC.ParallelPut (1, 2 ** input1 )
end rotateother
procedure rotatehome
if input0 = 1 and input1 = 0 then
if input0 = 0 and input1 = 0 then
return
end if
PC.ParallelPut (1, 0)
GUI.AddText (textBox, "Delaying for 1 seconds for spin-down..")
delay (1000)
GUI.AddLine (textBox, " done.")
elsif input0 = 1 and input1 = 1 then
return
end if
input0 := 0
input1 := 0
PC.ParallelPut (1, 2 ** input0 )
end rotatehome
procedure stateon
if tmpstate0 = 1 and tmpstate1 = 0 then
tmpstate0 := 1
tmpstate1 := 0
end if
GUI.AddText (textBox, "Restoring state data..")
input0 := tmpstate0
input1 := tmpstate1
GUI.AddLine (textBox, " done.")
GUI.AddText (textBox, "Initializing motor..")
tmpstate0 := 0
tmpstate1 := 0
PC.ParallelPut (1, 2 ** input1 )
GUI.AddLine (textBox, " done.")
end stateon
procedure stateoff
if input0 = 0 and input1 = 0 then
GUI.AddLine (textBox, "Motor is already off.")
return
end if
GUI.AddText (textBox, "Storing state data..")
tmpstate0 := input0
tmpstate1 := input1
GUI.AddLine (textBox, " done.")
GUI.AddText (textBox, "Shutting down motor..")
input0 := 0
input1 := 0
PC.ParallelPut (1, 0)
GUI.AddLine (textBox, " done.")
end stateoff
procedure makeWin
if windowID not= 0 then
GUI.CloseWindow (windowID )
end if
windowNumber + = 1
var xPos : int := Rand.Int (0, screenWidth - windowWidth - windowEdgeSize )
var yPos : int := Rand.Int (0, screenHeight - windowHeight - titleBarHeight )
windowID := Window.Open ("title:Window #" + intstr (windowNumber ) + ",graphics:" + intstr (windowWidth ) + ";" + intstr (windowHeight ) + ",position:" + intstr (xPos ) + ";" + intstr (yPos ))
textBox := GUI.CreateTextBoxFull (10, 110, 310, 265, GUI.INDENT, 0)
var tms := GUI.CreateButton (10, 70, 130, "Toggle Rotation", rotate )
var tmr := GUI.CreateButton (10, 40, 130, "Toggle State", state )
var quitButton := GUI.CreateButton (10, 10, 130, "Quit", GUI.Quit)
var tmsccw := GUI.CreateButton (150, 70, 170, "Spin Other Direction", rotateother )
var tmrcw := GUI.CreateButton (150, 40, 170, "Home", rotatehome )
var on := GUI.CreateButton (150, 10, 80, "Turn On", stateon )
var off := GUI.CreateButton (240, 10, 80, "Turn Off", stateoff )
end makeWin
makeWin
loop
exit when GUI.ProcessEvent
end loop
PC.ParallelPut (1, 0)
GUI.CloseWindow (windowID )
|
thank you in advance[/syntax] |
|
|
|
|
|
Sponsor Sponsor
|
|
|
OneOffDriveByPoster
|
Posted: Wed Jan 16, 2008 5:59 pm Post subject: Re: Two Stepper Motors? |
|
|
tamir @ Wed Jan 16, 2008 4:36 pm wrote: well i am doing a project with involves to rotating stepper motors and i do not understand how to active the second motor I didn't really look at your code, but how is the parallel port connected to the control circuits? |
|
|
|
|
|
tamir
|
Posted: Wed Jan 16, 2008 9:29 pm Post subject: Re: Two Stepper Motors? |
|
|
well i have a 74LS chip.. or something of that sort... (ill check) but i was told that i need to hook up da circuit from either pin 11-15 so i can use getkey.. !!
hope that helps.. if u want i can post up a schematic of my circuit.. |
|
|
|
|
|
OneOffDriveByPoster
|
Posted: Wed Jan 16, 2008 10:03 pm Post subject: Re: Two Stepper Motors? |
|
|
tamir @ Wed Jan 16, 2008 9:29 pm wrote: if u want i can post up a schematic of my circuit.. That would help. |
|
|
|
|
|
tamir
|
Posted: Thu Jan 17, 2008 5:38 pm Post subject: Re: Two Stepper Motors? |
|
|
alright.. i will take a picture of it tommorow... thanks for your help ... this is like 30% off my final mark..
but do u have any idea how this can work with a getkey... if u can show me i might be able to edit it and fix it to the circuit specificaitons.
Tamir |
|
|
|
|
|
tamir
|
Posted: Fri Jan 18, 2008 4:36 pm Post subject: Re: Two Stepper Motors? |
|
|
OneOffDriveByPoster my teacher took my PDA couldnt take a picture!
could you still help me tho? |
|
|
|
|
|
OneOffDriveByPoster
|
Posted: Fri Jan 18, 2008 6:13 pm Post subject: Re: Two Stepper Motors? |
|
|
tamir @ Fri Jan 18, 2008 4:36 pm wrote: OneOffDriveByPoster my teacher took my PDA couldnt take a picture!
could you still help me tho? I don't get what you are trying to do with getKey. Do you mean parallelget()? How is the program supposed to behave? I'm not sure if I can help you. |
|
|
|
|
|
tamir
|
Posted: Sat Jan 19, 2008 10:10 am Post subject: Re: Two Stepper Motors? |
|
|
yes parallel get...
i am supposed to use it to activate a second stepper motor..
the program is supposed to initiate with the help of the GUI two stepper motors, one moving clockwise and the other one counter clockwise. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
OneOffDriveByPoster
|
Posted: Sat Jan 19, 2008 3:55 pm Post subject: Re: Two Stepper Motors? |
|
|
I would imagine that the interface to both motors would be similar (except that the bits you need to set are different depending on which pins you connected the motors to). Why do you need parallelget? The circuit gives you feedback? |
|
|
|
|
|
tamir
|
Posted: Sat Jan 19, 2008 10:18 pm Post subject: Re: Two Stepper Motors? |
|
|
yes.. because i am also using IR devices.. and they are going to spin on the infared.. and when they meet.. they will beep..
i mean it doesnt have to be parallelget.. just a way to get it running.. |
|
|
|
|
|
OneOffDriveByPoster
|
Posted: Sun Jan 20, 2008 11:39 pm Post subject: Re: Two Stepper Motors? |
|
|
tamir @ Sat Jan 19, 2008 10:18 pm wrote: yes.. because i am also using IR devices.. and they are going to spin on the infared.. and when they meet.. they will beep..
i mean it doesnt have to be parallelget.. just a way to get it running.. I think the best idea is to experiment with what you get when you call parallelget after connecting the sensors to the port (yes, 11 and 15 will do). It may be easier for you to position the sensors manually (so that they meet or not) when you are testing that out. |
|
|
|
|
|
tamir
|
Posted: Mon Jan 21, 2008 5:01 pm Post subject: Re: Two Stepper Motors? |
|
|
thanks for the idea...
we tried the program today and it SUCKED!! haha and i have to redo it.. which is okay :p but yea i wanted to ask you if you knew any command for IR in turing? |
|
|
|
|
|
Dan
|
Posted: Mon Jan 21, 2008 10:06 pm Post subject: Re: Two Stepper Motors? |
|
|
tamir @ 21st January 2008, 5:01 pm wrote:
we tried the program today and it SUCKED!! haha and i have to redo it.. which is okay :p but yea i wanted to ask you if you knew any command for IR in turing?
As far as i know turing has no spefic IR commands, you will have to use the parallelget and parallelput commands and how you have to do this changes based on how you have your IR devices set up and the cirucitery of your robot thinggy. I do not think hooking IR sensors right in to the parrele port whould noramly work unless they are made for that, you whould have to make the cirutiery to support them correctly. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
|
|