Will this program work???
krazyideas
Posts: 119
I am building a program that can turn 6 electro coils on and off at exact degrees of rotation.
(Called Ffire1 through Ffire6) I have the 6 fireing programs in 6 seperate cogs so that I know they will be fast enough, These·turn·the electro coils on and off.
(Called Windows) Then I have another cog that is controling the variables, at run time so I can tune or play with the timeing, that tell the coils at what degree and how many degrees to turn on and off. I did this because this program is really slow, but if it is in a cog seprate from the fireing cogs that is ok, cuz it works like I want it too.
(Called Reader) I'm still working on building this. but will mesure the leangth of time for one degree to rotate, all Fireing cogs will use this.
So I just wanted to know if I'm on a pretty good track, and that what I have written so far will work, Because this is my first propellor program.
I need to have at least one degree accuratce, half or quorter would be better.· Any thoughts or comments would be appreceated.
Thanks
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
term : "tv_terminal"
kb : "keyboard"
VAR
long fire1 {how·many degrees·to wait before turning #1 on}
long fire2 {how many degrees before turning #2 on}
long fire3 {how many degrees before turning #3 on}
long fire4 {how many degrees before turning #4 on}
long fire5 {how many degrees before turning #5 on}
long fire6 {how many degrees before turning #6 on}
long win1 {how many degrees #1 is on}
long win2 {how many degrees #2 is on}
long win3 {how many degrees #3 is on}
long win4 {how many degrees #4 is on}
long win5 {how many degrees #5 is on}
long win6 {how many degrees #6 is on}
long begin················· {Use to Delay Ffire programs for about 8 seconds then start all 6 fireing cogs at the same moment}
long degree··············· {The leagth of time for 1 degree to rotate}
long read [noparse][[/noparse]20] {Stack space for Reader}
long f1 [noparse][[/noparse]20]··· {Stack space for Ffire1}
long f2 [noparse][[/noparse]20]··· {Stack space for Ffire2}
long f3 [noparse][[/noparse]20]··· {Stack space for Ffire3}
long f4 [noparse][[/noparse]20]··· {Stack space for Ffire4}
long f5 [noparse][[/noparse]20]··· {Stack space for Ffire5}
long f6 [noparse][[/noparse]20]··· {Stack space for Ffire6}
PUB Windows {cog #0}
cognew(Reader, @read)·· {Staring all cogs}
cognew(Ffire1, @f1)
cognew(Ffire2, @f2)
cognew(Ffire3, @f3)
cognew(Ffire4, @f4)
cognew(Ffire5, @f5)
cognew(Ffire6, @f6)
fire1 := degree '* ?··· {Starting Positions of each cogs turn on degree}
fire2 := degree '* ?···· I don't know these yet so I put ? marks instead
fire3 := degree '* ?
fire4 := degree '* ?
fire5 := degree '* ?
fire6 := degree '* ?
win1 := degree * 5·· {Starting·# of degrees each cog will be on before turning off}
win2 := degree * 5
win3 := degree * 5
win4 := degree * 5
win5 := degree * 5
win6 := degree * 5
term.start(12)·················································· {Start TV and Keyboard}
term.str(string("START FIREING WINDOWS",13))
kb.start(26,27)
begin := cnt···························· 'Starting point for Ffire cogs sync up
····························· I did this so I could be sure to have all 6 of my fireing programs start at the same time with the same point of begining
repeat···························· {Keyboard Controls for adjusting while program is running}
if kb.newkey == "q"
fire1 := fire1 + degree
elseif kb.newkey == "Q"
fire1 := fire1 - degree
elseif kb.newkey == "w"
fire2 := fire2 + degree
elseif kb.newkey == "W"
fire2 := fire2 - degree
elseif kb.newkey == "e"
fire3 := fire3 + degree
elseif kb.newkey == "E"
fire3 := fire3 - degree
elseif kb.newkey == "r"
fire4 := fire4 + degree
elseif kb.newkey == "R"
fire4 := fire4 - degree
elseif kb.newkey == "t"
fire5 := fire5 + degree
elseif kb.newkey == "T"
fire5 := fire5 - degree
elseif kb.newkey == "y"
fire6 := fire6 + degree
elseif kb.newkey == "Y"
fire6 := fire6 - degree
if kb.newkey == "z"
win1 := win1 + degree
elseif kb.newkey == "Z"
win1 := win1 - degree
elseif kb.newkey == "x"
win2 := win2 + degree
elseif kb.newkey == "X"
win2 := win2 - degree
elseif kb.newkey == "c"
win3 := win3 + degree
elseif kb.newkey == "C"
win3 := win3 - degree
elseif kb.newkey == "v"
win4 := win4 + degree
elseif kb.newkey == "V"
win4 := win4 - degree
elseif kb.newkey == "b"
win5 := win5 + degree
elseif kb.newkey == "B"
win5 := win5 - degree
elseif kb.newkey == "n"
win6 := win6 + degree
elseif kb.newkey == "N"
win6 := win6 - degree
term.dec (fire1)······························ {Displying Results on TV for tracking·on·and off·positions}
term.str(string(" "))
term.dec (fire2)
term.str(string(" "))
term.dec (fire3)
term.str(string(" "))
term.dec (fire4)
term.str(string(" "))
term.dec (fire5)
term.str(string(" "))
term.dec (fire6)
term.str(string(" ",13))
term.str(string(" ",13))
term.dec (win1)
term.str(string(" "))
term.dec (win2)
term.str(string(" "))
term.dec (win3)
term.str(string(" "))
term.dec (win4)
term.str(string(" "))
term.dec (win5)
term.str(string(" "))
term.dec (win6)
term.str(string(" ",13))
term.str(string(" ",13))
term.str(string(" ",13))
term.str(string(" ",13))
term.str(string(" ",13))
PUB Reader··································· {Measureing of time for one Degree to Rotate, cog #1}
'degree :=··········································· This is what I am trying to build right now
Pub Ffire1 | time0············································ {Running motor #1, cog #2}
waitcnt (begin := begin + 384_000_000)··············· 'wait to sync with other cogs, 8 seconds
time0 := cnt
outa[noparse][[/noparse]0] := 0
repeat
waitcnt(time0 += (degree * fire1))
outa[noparse][[/noparse]0] := 1
waitcnt(time0 += (degree * win1))
outa[noparse][[/noparse]0] := 0
waitcnt(time0 += (degree * (360 - (fire1 + win1))))
Pub Ffire2 | time1···················································· {Running motor #2, cog #3}
waitcnt (begin := begin + 384_000_000)······················· 'wait to sync with other cogs, 8 seconds
time1 := cnt
outa := 0
repeat
waitcnt(time1 += (degree * fire2))
outa := 1
waitcnt(time1 += (degree * win2))
outa := 0
waitcnt(time1 += (degree * (360 - (fire2 + win2))))
Pub Ffire3 | time2······································································ {Running motor #3, cog #4}
waitcnt (begin := begin + 384_000_000)········································· 'wait to sync with other cogs, 8 seconds
time2 := cnt
outa := 0
repeat
waitcnt(time2 += (degree * fire3))
outa := 1
waitcnt(time2 += (degree * win3))
outa := 0
waitcnt(time2 += (degree * (360 - (fire3 + win3))))
Pub Ffire4 | time3······································································· {Running motor #4, cog #5}
waitcnt (begin := begin + 384_000_000)········································ 'wait to sync with other cogs, 8 seconds
time3 := cnt
outa := 0
repeat
waitcnt(time3 += (degree * fire4))
outa := 1
waitcnt(time3 += (degree * win4))
outa := 0
waitcnt(time3 += (degree * (360 - (fire4 + win4))))
Pub Ffire5 | time4························································· {Running motor #5, cog #6}
waitcnt (begin := begin + 384_000_000)···························· 'wait to sync with other cogs, 8 seconds
time4 := cnt
outa := 0
repeat
waitcnt(time4 += (degree * fire5))
outa := 1
waitcnt(time4 += (degree * win5))
outa := 0
waitcnt(time4 += (degree * (360 - (fire5 + win5))))
Pub Ffire6 | time5·························································· {Running motor #6, cog #7}
waitcnt (begin := begin + 384_000_000)····························· 'wait to sync with other cogs, 8 seconds
time5 := cnt
outa := 0
repeat
waitcnt(time5 += (degree * fire6))
outa := 1
waitcnt(time5 += (degree * win6))
outa := 0
waitcnt(time5 += (degree * (360 - (fire6 + win6))))
(Called Ffire1 through Ffire6) I have the 6 fireing programs in 6 seperate cogs so that I know they will be fast enough, These·turn·the electro coils on and off.
(Called Windows) Then I have another cog that is controling the variables, at run time so I can tune or play with the timeing, that tell the coils at what degree and how many degrees to turn on and off. I did this because this program is really slow, but if it is in a cog seprate from the fireing cogs that is ok, cuz it works like I want it too.
(Called Reader) I'm still working on building this. but will mesure the leangth of time for one degree to rotate, all Fireing cogs will use this.
So I just wanted to know if I'm on a pretty good track, and that what I have written so far will work, Because this is my first propellor program.
I need to have at least one degree accuratce, half or quorter would be better.· Any thoughts or comments would be appreceated.
Thanks
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
term : "tv_terminal"
kb : "keyboard"
VAR
long fire1 {how·many degrees·to wait before turning #1 on}
long fire2 {how many degrees before turning #2 on}
long fire3 {how many degrees before turning #3 on}
long fire4 {how many degrees before turning #4 on}
long fire5 {how many degrees before turning #5 on}
long fire6 {how many degrees before turning #6 on}
long win1 {how many degrees #1 is on}
long win2 {how many degrees #2 is on}
long win3 {how many degrees #3 is on}
long win4 {how many degrees #4 is on}
long win5 {how many degrees #5 is on}
long win6 {how many degrees #6 is on}
long begin················· {Use to Delay Ffire programs for about 8 seconds then start all 6 fireing cogs at the same moment}
long degree··············· {The leagth of time for 1 degree to rotate}
long read [noparse][[/noparse]20] {Stack space for Reader}
long f1 [noparse][[/noparse]20]··· {Stack space for Ffire1}
long f2 [noparse][[/noparse]20]··· {Stack space for Ffire2}
long f3 [noparse][[/noparse]20]··· {Stack space for Ffire3}
long f4 [noparse][[/noparse]20]··· {Stack space for Ffire4}
long f5 [noparse][[/noparse]20]··· {Stack space for Ffire5}
long f6 [noparse][[/noparse]20]··· {Stack space for Ffire6}
PUB Windows {cog #0}
cognew(Reader, @read)·· {Staring all cogs}
cognew(Ffire1, @f1)
cognew(Ffire2, @f2)
cognew(Ffire3, @f3)
cognew(Ffire4, @f4)
cognew(Ffire5, @f5)
cognew(Ffire6, @f6)
fire1 := degree '* ?··· {Starting Positions of each cogs turn on degree}
fire2 := degree '* ?···· I don't know these yet so I put ? marks instead
fire3 := degree '* ?
fire4 := degree '* ?
fire5 := degree '* ?
fire6 := degree '* ?
win1 := degree * 5·· {Starting·# of degrees each cog will be on before turning off}
win2 := degree * 5
win3 := degree * 5
win4 := degree * 5
win5 := degree * 5
win6 := degree * 5
term.start(12)·················································· {Start TV and Keyboard}
term.str(string("START FIREING WINDOWS",13))
kb.start(26,27)
begin := cnt···························· 'Starting point for Ffire cogs sync up
····························· I did this so I could be sure to have all 6 of my fireing programs start at the same time with the same point of begining
repeat···························· {Keyboard Controls for adjusting while program is running}
if kb.newkey == "q"
fire1 := fire1 + degree
elseif kb.newkey == "Q"
fire1 := fire1 - degree
elseif kb.newkey == "w"
fire2 := fire2 + degree
elseif kb.newkey == "W"
fire2 := fire2 - degree
elseif kb.newkey == "e"
fire3 := fire3 + degree
elseif kb.newkey == "E"
fire3 := fire3 - degree
elseif kb.newkey == "r"
fire4 := fire4 + degree
elseif kb.newkey == "R"
fire4 := fire4 - degree
elseif kb.newkey == "t"
fire5 := fire5 + degree
elseif kb.newkey == "T"
fire5 := fire5 - degree
elseif kb.newkey == "y"
fire6 := fire6 + degree
elseif kb.newkey == "Y"
fire6 := fire6 - degree
if kb.newkey == "z"
win1 := win1 + degree
elseif kb.newkey == "Z"
win1 := win1 - degree
elseif kb.newkey == "x"
win2 := win2 + degree
elseif kb.newkey == "X"
win2 := win2 - degree
elseif kb.newkey == "c"
win3 := win3 + degree
elseif kb.newkey == "C"
win3 := win3 - degree
elseif kb.newkey == "v"
win4 := win4 + degree
elseif kb.newkey == "V"
win4 := win4 - degree
elseif kb.newkey == "b"
win5 := win5 + degree
elseif kb.newkey == "B"
win5 := win5 - degree
elseif kb.newkey == "n"
win6 := win6 + degree
elseif kb.newkey == "N"
win6 := win6 - degree
term.dec (fire1)······························ {Displying Results on TV for tracking·on·and off·positions}
term.str(string(" "))
term.dec (fire2)
term.str(string(" "))
term.dec (fire3)
term.str(string(" "))
term.dec (fire4)
term.str(string(" "))
term.dec (fire5)
term.str(string(" "))
term.dec (fire6)
term.str(string(" ",13))
term.str(string(" ",13))
term.dec (win1)
term.str(string(" "))
term.dec (win2)
term.str(string(" "))
term.dec (win3)
term.str(string(" "))
term.dec (win4)
term.str(string(" "))
term.dec (win5)
term.str(string(" "))
term.dec (win6)
term.str(string(" ",13))
term.str(string(" ",13))
term.str(string(" ",13))
term.str(string(" ",13))
term.str(string(" ",13))
PUB Reader··································· {Measureing of time for one Degree to Rotate, cog #1}
'degree :=··········································· This is what I am trying to build right now
Pub Ffire1 | time0············································ {Running motor #1, cog #2}
waitcnt (begin := begin + 384_000_000)··············· 'wait to sync with other cogs, 8 seconds
time0 := cnt
outa[noparse][[/noparse]0] := 0
repeat
waitcnt(time0 += (degree * fire1))
outa[noparse][[/noparse]0] := 1
waitcnt(time0 += (degree * win1))
outa[noparse][[/noparse]0] := 0
waitcnt(time0 += (degree * (360 - (fire1 + win1))))
Pub Ffire2 | time1···················································· {Running motor #2, cog #3}
waitcnt (begin := begin + 384_000_000)······················· 'wait to sync with other cogs, 8 seconds
time1 := cnt
outa := 0
repeat
waitcnt(time1 += (degree * fire2))
outa := 1
waitcnt(time1 += (degree * win2))
outa := 0
waitcnt(time1 += (degree * (360 - (fire2 + win2))))
Pub Ffire3 | time2······································································ {Running motor #3, cog #4}
waitcnt (begin := begin + 384_000_000)········································· 'wait to sync with other cogs, 8 seconds
time2 := cnt
outa := 0
repeat
waitcnt(time2 += (degree * fire3))
outa := 1
waitcnt(time2 += (degree * win3))
outa := 0
waitcnt(time2 += (degree * (360 - (fire3 + win3))))
Pub Ffire4 | time3······································································· {Running motor #4, cog #5}
waitcnt (begin := begin + 384_000_000)········································ 'wait to sync with other cogs, 8 seconds
time3 := cnt
outa := 0
repeat
waitcnt(time3 += (degree * fire4))
outa := 1
waitcnt(time3 += (degree * win4))
outa := 0
waitcnt(time3 += (degree * (360 - (fire4 + win4))))
Pub Ffire5 | time4························································· {Running motor #5, cog #6}
waitcnt (begin := begin + 384_000_000)···························· 'wait to sync with other cogs, 8 seconds
time4 := cnt
outa := 0
repeat
waitcnt(time4 += (degree * fire5))
outa := 1
waitcnt(time4 += (degree * win5))
outa := 0
waitcnt(time4 += (degree * (360 - (fire5 + win5))))
Pub Ffire6 | time5·························································· {Running motor #6, cog #7}
waitcnt (begin := begin + 384_000_000)····························· 'wait to sync with other cogs, 8 seconds
time5 := cnt
outa := 0
repeat
waitcnt(time5 += (degree * fire6))
outa := 1
waitcnt(time5 += (degree * win6))
outa := 0
waitcnt(time5 += (degree * (360 - (fire6 + win6))))
Comments
if this can works depends highly on the rpm that have to be controlled by this.
To make your code more readable use this little manual
attached to this posting
Its a pdf named .pdf.zip that this forumsoftware can handle it
@Parallax: From this forumsoftware I get more and more the impression is limited and NOT up to date
searchfunction: miserable
attachment-manager: rejects a lot of file types
go searching for a better software or make the company hurry up to improve it SUBSTANTIAL
best regards
Stefan
Post Edited (StefanL38) : 10/22/2008 8:28:47 PM GMT