Passing an Array
SailerMan
Posts: 337
I have a COG 1 Running a Spin program that is collecting 12 Pulse and putting them in An Array continually. How can I pass that array to a program in another Cog?
Can someone point me in the right direction.
Thanks,
Eric
·
Can someone point me in the right direction.
Thanks,
Eric
·
Comments
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
SelmaWare Solutions - StampPlot GUI for controllers, XBee and Propeller Application Boards
Southern Illinois University Carbondale, Electronic Systems Technologies
(* - So long as you don't care that whilst reading with one COG the other COG might change the contents of the array half way through. If you do care about that, you need to look at the topic of LOCKS in the manual.)
If you try something and have trouble getting it to work, then you can post a snippet here for further suggestions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
Play Defender - Propeller version of the classic game
Prop Room Robotics - my web store for Roomba spare parts in the UK
Post Edited (CardboardGuru) : 12/8/2007 10:27:09 AM GMT
'pilot.spin
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
cs =4 'pin 4 on adc cs ADC0830 pin assignments cs,clk,di,do.
clk =5 'pin 7 on adc clk adc pins via 1K resitors to Prop (tempory solutions but works)
dao =6 'pin 6 on adc do
dai =7 'pin 5 on adc di
dec = 10 'pin 10 decrement... simple push button
as = 9 'pin 9 auto/standby.... simple push button ... for cal long hold down
inc = 8 'pin 8 increment....simple push button
mux_v =%011 'select channel 1 mux data .....monitor vane
mux_ =%111 'select channel 2 mux data......monitor rudder position
var
long stack_1[noparse][[/noparse]10]
long stack_3[noparse][[/noparse]10]
long stack_2[noparse][[/noparse]20]
long stack_4[noparse][[/noparse]40]
long stack_5[noparse][[/noparse]40]
byte mux_id 'channel select passed to PUB ADC returns "v"
byte ib 'incoming data bit from ADC
byte mode 'cal, standby, apparent wind steer of steer waypoint supplied by NMEA sentence from NAV center
byte dir 'steer direction....port startboard
byte c_r 'rudder setup in cal mode, one time set up
byte c_v 'vane setup in cal mode, one time setup
byte v 'normalized wind vane position
byte r 'normalized ruder position
byte p_len 'auto rudder gain
byte ra 'rudder angle
byte vd 'vane damping
byte db 'dead band detect repetative course changes, ignor but keep checking pattern
byte ss 'sea state
byte cte 'cross track error
byte rl 'rudder limit setup in cal mode
byte k
pub main
'cognew(panel, @stack_1)
'cognew(steer, @stack_3)
cognew(adc(@v), @stack_2)
'cognew(nmea(@wp),@stack_3)
'cognew(control,@stack_5)
mode:=0
dira[noparse][[/noparse]4..7]:=%1101
repeat
v:=adc(mux_v)
'*********************************************adc cog*******************************************
pri adc (x)| y
mux_id:=x
y:=0
outa[noparse][[/noparse]4..5]:=%10
!outa[noparse][[/noparse]cs]
repeat 3
clkpulse
outa[noparse][[/noparse]dai]:=mux_id
mux_id:=mux_id>>1
ib:=0
repeat 9
clkpulse
ib:=ina[noparse][[/noparse]dao]
y:= (y << 1) + ib
return y
pri clkpulse
pse
!outa[noparse][[/noparse]clk]
pse
!outa[noparse][[/noparse]clk]
pri pse
waitcnt(clkfreq/1000+cnt)
Extract from auto.pilot
Assuming the both cogs are spin
ron