Adjusting PW in Repeat loop
lardom
Posts: 1,659
I'm working on a way to adjust current for my electrolysis experiments. I'm using a parent object to pass values at the moment. I'll use a pot for my next set of tests. The code works. I want Hi and Lo to update. Is there an expression that simplifies the process?
(I switched set/Post set assignment operators but that's minor)
(I switched set/Post set assignment operators but that's minor)
VAR
long stack[10], Incr, Hi, Lo
word cog
'Low frequency current control for electrolysis
'child object
PUB Start
cog := cognew(TestArea, @stack) + 1
PUB Stop
If cog
cogstop(cog~ - 1)
PUB Main(a, b) 'Parent passes values to this method
Hi := a
Lo := b
PUB TestArea 'Hz * PW = increments
Incr := (clkfreq/10_000) '1Khz
dira[1]~~
repeat
Hi:= Hi 'Is there a better way to update
outa[1]~
waitcnt(Incr*Hi+cnt)
Lo:= Lo 'Is there a better way to update
outa[1]~~
waitcnt(Incr*Lo+cnt)

Comments
The various cogs all use the same hub RAM for variables. There aren't multiple instances of "Hi" and "Lo".
Cog RAM is being used to run the Spin interpreter. Your variables are not stored in cog RAM.