Quick coginit question
mikediv
Posts: 825
I was using one of the sample code examples in methods and cogs it goes somehting like this
VAR
··· long stack[noparse][[/noparse]30]
PUB LaunchBlinkCogs
··· coginit( 1, Blink(4, clkfreq/3, 9), @stack[noparse][[/noparse]0])··· ' Ijust initialized a cog number1
··· coginit(22, Blink(5, clkfreq/7, 21), @stack[noparse][[/noparse]10])· ' I turned on cog 22 how can that be!!!!
··· coginit(3, Blink(6, clkfreq/11, 39), @stack[noparse][[/noparse]20])
PUB Blink( pin, rate, reps)
··· dira[noparse][[/noparse]pin]~~
··· outa[noparse][[/noparse]pin]~
···
··· repeat reps * 2
······ waitcnt(rate/2 + cnt)
······ !outa[noparse][[/noparse]pin]
it blinks some leds I am sure you guys can figure that out by reading code. My question is
when typing I accidently put this in coginit(22, Blink(5, clkfreq/7, 21), @stack[noparse][[/noparse]10])· '·I compiled it
and the program ran just fine I then on purpose when I saw this program seemed to work added 3 more lines with
coginit(12, Blink(5, clkfreq/7, 21), @stack[noparse][[/noparse]10])· '· downloaded it and ran the program the Leds all blinked and the program appears to run just fine
but if there are only 8 cogs how can this be?? is spin just defaulting to a know cog state,, and since my program appears to work
is there anyway to actualy see the cogs running in real time? how can I tell which cogs were actualy started if any?
VAR
··· long stack[noparse][[/noparse]30]
PUB LaunchBlinkCogs
··· coginit( 1, Blink(4, clkfreq/3, 9), @stack[noparse][[/noparse]0])··· ' Ijust initialized a cog number1
··· coginit(22, Blink(5, clkfreq/7, 21), @stack[noparse][[/noparse]10])· ' I turned on cog 22 how can that be!!!!
··· coginit(3, Blink(6, clkfreq/11, 39), @stack[noparse][[/noparse]20])
PUB Blink( pin, rate, reps)
··· dira[noparse][[/noparse]pin]~~
··· outa[noparse][[/noparse]pin]~
···
··· repeat reps * 2
······ waitcnt(rate/2 + cnt)
······ !outa[noparse][[/noparse]pin]
it blinks some leds I am sure you guys can figure that out by reading code. My question is
when typing I accidently put this in coginit(22, Blink(5, clkfreq/7, 21), @stack[noparse][[/noparse]10])· '·I compiled it
and the program ran just fine I then on purpose when I saw this program seemed to work added 3 more lines with
coginit(12, Blink(5, clkfreq/7, 21), @stack[noparse][[/noparse]10])· '· downloaded it and ran the program the Leds all blinked and the program appears to run just fine
but if there are only 8 cogs how can this be?? is spin just defaulting to a know cog state,, and since my program appears to work
is there anyway to actualy see the cogs running in real time? how can I tell which cogs were actualy started if any?
Comments
-Phil
Oh thanks that makes sense about the 22 being ANDed
-Phil
and the moderator insisted the proper way was coginit and at the time it kind of made sense to me, but I just got the manual "didnt realize the whole manual was online I thought Parallax charged for the book its very nice of them to make it available I guess thats why I keep ordering stuff from them everyday LOL this is a worse addiction than crack. wife is going to freak when she sees my credit card bill. my office looks like a mad scientist I have wire wrapped circuit boards everwhere I now own at least one of everything Parallax sells ,really! and Boe-Bot keeps pissing off her dog ... Anyway Phil if you see this and get around to it. another problem I could use some help with
I am trying to add my own objects to code I am writing while I can seem to use others from the object files my sample code is not working here is somehting very simple I tried to do can you see wher eI am going wrong.
Thank you in advance ..
Top File: CogObjectExample.spin
Blinks an LED circuit for 20 repetitions.· The LED
blink period is determined by how long the P23 pushbutton
is pressed and held.
OBJ
··· Blinker : "Blinker"
··· Button· : "Button"
··· mike : "myobject"
PUB ButtonBlinkTime | time
··· repeat
······ time := Button.Time(23)
······ Blinker.Start(4, time, 20)
······ Mike.start
The object myobject is just another blinker program here """"""""""""""""""""""""""""""""""""""""""""
PUB Blink | pin, rate, reps
··· pin := 6
··· rate := clkfreq/3
··· reps := 9
··· dira[noparse][[/noparse]pin]~~
··· outa[noparse][[/noparse]pin]~
···
··· repeat reps * 2
······ waitcnt(rate/2 + cnt)
······ !outa[noparse][[/noparse]pin]
it just blinks pin 6 no big deal but I wanted to call it into the main program just trying to learn to bring in objects/methods but every time I try to compile it I get the error expected a subroutine name? I also tried
mike.start or object.start., nothing seems to work right I just want to be able to properly incorporate drivers and other program bits into my main program .