Shop OBEX P1 Docs P2 Docs Learn Events
Cognew Compiles but the program wont run — Parallax Forums

Cognew Compiles but the program wont run

SnyggisSnyggis Posts: 14
edited 2013-06-20 20:25 in Propeller 1
I am still very new to the propeller, and this is probably a basic question. I am trying to launch 4 cogs to perform multiple tasks. I have the code working just fine with three cognew commands, but when I add a 4th everything stops working. If anyone had an idea where to look I would really appreciate it!

Code Below:

[CON

_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000


OBJ

Debug: "FullDuplexSerialPlus"


Var long stack[50], RPM

PUB Main
Debug.start(31, 30, 0, 57600)

Dira[16]:=0
Dira[11]~~

cognew(PulseOut(21, 50, 148), @stack[10])
cognew(LEdge(16), @stack[20])
cognew(Output(15), @stack[30])
cognew(Pulsetest(11), @stack[40])

repeat
waitcnt(clkfreq + cnt)
debug.str(String("RPM = "))
debug.dec(RPM)
debug.str(string(13))

Pub PulseOut(pin, hz, ms)
repeat
Outa[Pin]:=1
waitcnt(clkfreq/100000*ms + cnt)
outa[21] := 0
waitcnt(clkfreq/hz + cnt)


Pub LEdge(inpin)| Edge
ctra[30..26]:= %01010
ctra[5..0]:= 16
frqa:=1
Edge~

Repeat
phsa~
waitcnt(clkfreq/1000+cnt)
if phsa> 1
edge++
RPM := edge

Pub Output(LEDPin)

Dira[ledpin]~~
repeat
outa[ledpin] := ina[16]

Pub Pulsetest(pin)
Repeat
outa[pin]:=0
waitcnt(clkfreq/2+cnt)
outa[pin]:=1
waitcnt(clkfreq/2+cnt)]

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-06-20 18:49
    You didn't post your full program!

    Also, please use [ code ] tags in the future to maintain the formatting of your code.

    My guess is that your indentation is off somewhere, but I can't tell from what you posted.

    You also start Debug twice, which may be (depending on your driver) an extra cog.
  • SnyggisSnyggis Posts: 14
    edited 2013-06-20 19:21
    I updated the entire program as requested. I also removed the second debug, that didnt seem to help. Would you help me understand the [code] tags? I would be happy to change that to.

    Thanks for looking at this!
  • kuronekokuroneko Posts: 3,623
    edited 2013-06-20 19:31
    Why do you think the program doesn't work? IOW, what do you expect to happen and what doesn't?

    re: tags, you put [noparse]
    [/noparse] before the code block and [noparse]
    
    [/noparse] at the end.
  • SnyggisSnyggis Posts: 14
    edited 2013-06-20 19:55
    Pulseout - This is a method to run a RC motor controller, This works fine when I only have 3 cogs
    LEDedge - This is to debounce a optical switch and output a single edge - Works fine with only 3 cogs
    Output - All this does is turn on a a LED whenever the optical switch comes on - Also works fine

    Everything seems to function okay until I try to add another cog with Pulsetest - This is just pulsing a pin on and off. As soon as I add this method none of the other three methods function at all (RC pulses stop, LED edge stops, and the LED ouput also stops. The funny thing is if I delete one of the other cogs and method then the remaining ones work. It seems like it only wants to have 3 functioning at once.
  • kuronekokuroneko Posts: 3,623
    edited 2013-06-20 20:25
    Snyggis wrote: »
    Pulseout - This is a method to run a RC motor controller, This works fine when I only have 3 cogs
    This method doesn't do anything. While you modify outa, no pin in this cog is set as an output (dira[n] := 1). Unless the code you posted is still incomplete. Can you please re-check?
    Snyggis wrote: »
    Everything seems to function okay until I try to add another cog with Pulsetest - This is just pulsing a pin on and off.
    Again, no pin is set as an output so no pulsing takes place.

    FWIW, I generated fake input for pin 16 and relocated some pin locations to indicator LEDs (demoboard). With those changes all 4 cogs work just fine.
Sign In or Register to comment.