A question about cogs
SailerMan
Posts: 337
I want a cog to do nothing but take Sonar Readings.
I read the sonar with a Pulsin command from the BS2 Library.
Anyhow... In my Object I have a "Start" method that just starts the cog with a user defined pin number. Then I have a public "Read" method that is a loop that does nothing but take readings.
The "Read" method doesn't return anything because it is in a loop constantly taking readings.
What simple thing am I missing here
Here is the Code for the Sonar Object.
·
My question is how to get·the "Result" from The Pub Read back to the·main program?
Hope this makes sense.
Eric
·
I read the sonar with a Pulsin command from the BS2 Library.
Anyhow... In my Object I have a "Start" method that just starts the cog with a user defined pin number. Then I have a public "Read" method that is a loop that does nothing but take readings.
The "Read" method doesn't return anything because it is in a loop constantly taking readings.
What simple thing am I missing here
Here is the Code for the Sonar Object.
·
Con _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 Var Long Stack[noparse][[/noparse]25] Long Cog Pub Start(Pin) Cog:=Cognew(Read(Pin),@Stack) Pub Read(Pin):R Ctra := 0 Ctra := (%11010 << 26 ) | (%001 << 23) | (0 << 9) | (PIN) Repeat DirA[noparse][[/noparse]PIN]~ frqa := 1 waitpne(1 << pin, |< Pin, 0) phsa:=0 waitpeq(1 << pin, |< Pin, 0) waitpne(1 << pin, |< Pin, 0) R:=(PHSA/ (clkfreq / 1_000_000) + 1)/147 ' Calculate Inches from the Pulse Width
My question is how to get·the "Result" from The Pub Read back to the·main program?
Hope this makes sense.
Eric
·
Comments