propb ?: need help adding a cog to make four lines run at same time..totally lost..?
cazman128
Posts: 25
Hello...my code for my senior project is almost perfect, which a due date looming i need some help..
My code is for two motors to run off a r/c transmitter. The pulses are perfect..the only problem now is the two motors will not run at same time...i need helping writing code for this portion.. : "question at bottom"
CODE:
PULSIN CHa, 1, X
PULSIN CHb, 1, Y
PAUSE 18
IF X < 1400 THEN M1R
IF X > 1600 THEN M1F
IF Y > 1625 THEN M2F
IF Y < 1375 THEN M2R
PAUSE 18
GOTO START
PAUSE 18
M1F:
LOW MA
HIGH MB
PAUSE 18
GOTO START
M1R:
LOW MB
HIGH MA
PAUSE 18
GOTO START
M2F:
LOW MC
HIGH MD
PAUSE 18
GOTO START
M2R:
LOW MD
HIGH MC
PAUSE 18
GOTO START
Question :
I need to be able to run the X and Y pulsins at same time as well the IF statements (2 for x, 2 for y) at sime time...and also need to run two of the four labels at same time.. ik you need to use cogs and such to make it work, this is where im totally lost with a due date looming, any help is appreciated....... i also attached the rest of the code to make it easier to read... THANKS :frown:
Thank you,,,,
CAZ
My code is for two motors to run off a r/c transmitter. The pulses are perfect..the only problem now is the two motors will not run at same time...i need helping writing code for this portion.. : "question at bottom"
CODE:
PULSIN CHa, 1, X
PULSIN CHb, 1, Y
PAUSE 18
IF X < 1400 THEN M1R
IF X > 1600 THEN M1F
IF Y > 1625 THEN M2F
IF Y < 1375 THEN M2R
PAUSE 18
GOTO START
PAUSE 18
M1F:
LOW MA
HIGH MB
PAUSE 18
GOTO START
M1R:
LOW MB
HIGH MA
PAUSE 18
GOTO START
M2F:
LOW MC
HIGH MD
PAUSE 18
GOTO START
M2R:
LOW MD
HIGH MC
PAUSE 18
GOTO START
Question :
I need to be able to run the X and Y pulsins at same time as well the IF statements (2 for x, 2 for y) at sime time...and also need to run two of the four labels at same time.. ik you need to use cogs and such to make it work, this is where im totally lost with a due date looming, any help is appreciated....... i also attached the rest of the code to make it easier to read... THANKS :frown:
Thank you,,,,
CAZ
doc
26K
Comments
Sorry about the looming due date, but this is a senior project. You're supposed to have come up with a test version early enough to figure out that it didn't work as expected. You'll have to come up with the new version yourself. It's a simple enough program and PropBasic takes care of a lot of the work for you.
Wow, deja vu, my teacher pretty much said same thing today, haha.. thankss for the start!
thanks....
CAZ
Why the PAUSE 18 between the GOTO START and the M1F:?
Why the GOTO MOTOR2CODE just before the ENDTASK?
The BIG question:
Why the COGSTART MOTOR2? That's executed every time your main loop executes. What effect would that have? What about the AUTO option?
Hmmm. "Just plop this on", eh?
Hmmm. "Deja vu", eh?
good question, i kind of just used pauses in case it got bogged down, i was using a pdf file on syntax and on propbasic to write the code for cogs and it said to use AUTO if you want it to run at start of program, it also said COGSTART task to start the cog, its all confusing to me
Thanks everyone
i read in the pdf to add COGSTART task to make it run, and my task is called MOTOR2, so what you mean is when i define my task in begining of program it runs?? so i dont need to have COGSTART??
Get used to attaching your current version of your program to your messages.
The motor2 is the code, i only need two cogs, one for the first part and another for motor2 task, i got like two hours left....
What does AUTO do?
The motor2 task is for the second motor while anything before task motor2 is the first motor that works perfect, also the m2c label is so the goto mc2 in the other labels go to the start of the task.
Thanks.... running out of time
i read that cogs share outputs and inputs...
Yes they do share the inputs and outputs, BUT each one has its own definition register (DIRA) for the input/output use of the pins (the DIRection on port A).
OK i attached my code...now what..i need help badly....
See if this works:
This goes back to just using 2 cogs and restores your original structure, this should work if your original got one motor to work (why have a cog do nothing):
Might I recommend having a Propeller board at home and the components that you are working with, so that you are not limited to the time in class?
I usually do do that but i just didnt have time today to pack upp and take it homee
When i use that code the motors do not move at all.....