Shop OBEX P1 Docs P2 Docs Learn Events
FullDuplexSerial sending variable through dec method — Parallax Forums

FullDuplexSerial sending variable through dec method

OwenOwen Posts: 100
edited 2007-01-22 18:43 in Propeller 1
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

Comments

  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-21 15:19
    Re: Heading

    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
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-21 15:21
    or should have said -
    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
  • Luis DigitalLuis Digital Posts: 371
    edited 2007-01-21 15:22
    QuattroRS4 said...
    Re: Heading

    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)


    and it worked out fine Using Demo Board (5Mhz Crystal)

    value:=123450
    serial.dec(12345) <-That is trap. tongue.gif
    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
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-21 15:26
    Var
    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
  • OwenOwen Posts: 100
    edited 2007-01-21 16:56
    thank you for the responses,
    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
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-21 17:03
    did you try
    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
  • OwenOwen Posts: 100
    edited 2007-01-21 17:12
    sorry that's just a typo on the post i've changed code too much trying to get it to work. I'm posting the whole program in an attachment so it's easy to look at.

    thanks,
    Owen
  • inserviinservi Posts: 113
    edited 2007-01-22 18:43
    Hello,

    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
Sign In or Register to comment.