FullDuplexSerial sending variable through dec method
Owen
Posts: 100
I'm trying to send a long var out with FullDuplexSerial using the method PUB Dec(value). Although it compiles fine it will only sends 00
Var
Long value
OBJ
serial : "Extended_FDSerial"
value:=12345
serial.dec(value)
Any reason value wouldn't be sent? As a test i put 54321 in place of value and it worked... just not when I use a variable.
Thanks,
Owen
Var
Long value
OBJ
serial : "Extended_FDSerial"
value:=12345
serial.dec(value)
Any reason value wouldn't be sent? As a test i put 54321 in place of value and it worked... just not when I use a variable.
Thanks,
Owen
Comments
You stated FullDuplexSerial
but under obj
you have "Extended_FDSerial" ?
I did the following .................. using FullDuplexSerial
Var
Long value
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
serial : "FullDuplexSerial"
Pub Dec
serial.start(8, 7, 2, 9600)
value:=123450
serial.dec(12345)
Serial.dec(value) '
and it worked out fine Using Demo Board (5Mhz Crystal)
Post Edited (QuattroRS4) : 1/21/2007 4:16:09 PM GMT
Var
Long value
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
serial : "FullDuplexSerial"
Pub Dec
serial.start(8, 7, 2, 9600)
value:=123450
serial.dec(Value)
but it was fine .....
Obviously your serial.start has to match rxpin,txpin,mode,baud for your chosen pins
value:=123450
serial.dec(12345) <-That is trap.
It corrected. You can also edit its comment and only to put one new when necessary.
Post Edited (Luis Digital) : 1/21/2007 3:58:06 PM GMT
Long value
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
ExtSerial : "FullDuplexSerial"
Pub Dec
extserial.start(8, 7, 2, 9600)
value:=123450
extserial.dec(Value)
does just fine for extended ......
luis thanks for typo correction but got there b4 u !!
Post Edited (QuattroRS4) : 1/21/2007 4:19:20 PM GMT
my serial code wasn't the problem in the end but I seem to be having diffuculty passing variables in one of my objects to the variable i wanted to send of serial. Can anyone help me understand why I cant give the variable "coordinateNew" a new value from the ManualSteping method? ultimatly i'm trying to return the value of coordinateNew to my toplevel object.
var
long stack[noparse][[/noparse]50]
byte Cog
long coordinateNew
pub Start(stepPin, enablePin, dirPin, manualmove, dir, speed, coordinate): coordinateReturn
stop
Cog := cognew(ManualSteping(stepPin, dirPin, enablePin, manualmove, dir, speed, coordinate), @stack)+1
coordinateReturn:= coordinateNew
PUB Stop
{{Stop toggling process, if any.}}
if Cog
cogstop(Cog~ - 1)
PUB ManualSteping(stepPin, dirPin, enablePin, Move, dir, speed, coordinate) | pc, pcRamp, Rs, R, Rt
pcRamp :=0
pc := 0 ' pc = pulses counter
Rs :=400
Rt :=2000
dira[noparse][[/noparse]enablePin]~~
outa[noparse][[/noparse]enablePin]~~
dira[noparse][[/noparse]stepPin]~~
outa[noparse][[/noparse]stepPin]~
dira[noparse][[/noparse]dirPin]~~
outa[noparse][[/noparse]dirPin] := dir
repeat until Move == 1
outa[noparse][[/noparse]enablePin]~
repeat until Move == 0
if pc =< Rs
R:=Rt*(Rs-pc)*(Rs-pc)/Rs
if Move==0
pcRamp:=pcRamp+1
R:=Rt*(Rs-(Rs - pcRamp))*(Rs-(Rs-pcRamp))/Rs
if Move==1
R:=1
pc := pc + 1
outa[noparse][[/noparse]stepPin] := 1
waitcnt(speed+ R + 1000 + cnt )
outa[noparse][[/noparse]stepPin] := 0
waitcnt(speed + R + cnt)
outa[noparse][[/noparse]enablePin]~~
coordinateNew:= coordinate + pc
Stop
coordinateNew := coordinateReturn
instead ?
is your code indented like that ?
perhaps try the following
repeat until Move == 1
·· outa[noparse][[/noparse]enablePin]~
repeat until Move == 0
· if pc =< Rs
· R:=Rt*(Rs-pc)*(Rs-pc)/Rs
if Move==0
··pcRamp:=pcRamp+1
· R:=Rt*(Rs-(Rs - pcRamp))*(Rs-(Rs-pcRamp))/Rs
if Move==1
· R:=1
· pc := pc + 1
Post Edited (QuattroRS4) : 1/21/2007 5:13:08 PM GMT
thanks,
Owen
If i understand the problem, you need to transfering the variable adresse with @coordinateNew to the ManualSteping methode.
like :
...
long coordinateNew
...
Cog := cognew(ManualSteping(stepPin, dirPin, enablePin, manualmove, dir, speed, coordinate, @coordinateNew ), @stack)+1
...
PUB ManualSteping(stepPin, dirPin, enablePin, Move, dir, speed, coordinate, inCoordinateNew ) | pc, pcRamp, Rs, R, Rt
...
long[noparse][[/noparse]inCoordinateNew]:= coordinate + pc
...
Best regards,
dro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus
Post Edited (inservi) : 1/22/2007 6:50:09 PM GMT