Shop OBEX P1 Docs P2 Docs Learn Events
News! RoboRealm finally get's support for the Propeller chip! — Parallax Forums

News! RoboRealm finally get's support for the Propeller chip!

BotdocterBotdocter Posts: 271
edited 2011-03-28 10:18 in Propeller 1
Since 2 weeks or so RoboRealm has a new plugin for easy exchange of variables through serial/usb. It's called the 'MCU Comunicator'.

I took the initiative to contact RoboRealm and asked them to make a .spin program that receives and sends the variables between the Prop. and PC.
this what they replied:
Hi,

We will be adding this within the next 2 weeks if not earlier. I'll let you know if we run into any delays.

I can't wait!!! Finally RoboRealm can be used with the Propeller!


Wil keep you posted on where to find the downloads.

Comments

  • BotdocterBotdocter Posts: 271
    edited 2011-03-02 05:56
    They finally released the spin communication protocol.

    <code>CON*
    **_clkmode = xtal1 + pll16x*
    **_xinfreq = 5_000_000*
    **
    **rxpin = 31 ' Receive on I/O pin 1 <- black from master black txpin p1*
    **txpin = 30 ' Transmit on I/O pin 0 -> red to master red rxpin p0*
    **ServoCh1 = 0 *'Steering servo * * * * * * * * * * * * * *
    **ServoCh2 = 4*

    **MCU_GET_ID *= 1
    **MCU_END_FRAME = 2
    **MCU_SET_NUMBER_MAILBOX = 3
    **MCU_SET_TEXT_MAILBOX = 4
    **MCU_SET_LOGIC_MAILBOX = 5
    **MCU_GET_NUMBER_MAILBOX = 6
    **MCU_GET_TEXT_MAILBOX = 7
    **MCU_GET_LOGIC_MAILBOX = 8

    VAR*

    **BYTE mailboxToSend[20]
    **BYTE mailboxSendFlag[20]

    **LONG intValue[20]
    **BYTE logicValue[20]
    **LONG textValue[20]
    **BYTE textStore[1024]
    **LONG textStoreTop
    **BYTE buffer[8]
    **BYTE command
    **BYTE crc
    **BYTE mailbox
    **LONG hold

    **LONG i,j
    **LONG lvalue
    **LONG tvalue
    **
    OBJ*

    **serial : "FullDuplexSerial" * ' "Extended_FDSerial" ''*
    **f : "Float32Full"
    **SERVO : "Servo32v5.spin"*

    PUB Main | DutyCycle ' new stuff DutyCycle*

    **dira[16]~~
    **
    **serial.start(rxpin,txpin,%0000, 115200) * * * * * * * * *'- rxpin,txpin,mode,Baud*

    **textStoreTop := 0
    **
    **repeat
    ** *repeat
    ** * *command := serial.rx
    ** *while command & 128 == 0

    ** *crc := command
    ** *
    ** *command := command ^ 128
    ***
    ** *case command
    ** * *MCU_GET_ID:
    ** * * *serial.Str(String("MCUC"))
    ** * *MCU_SET_NUMBER_MAILBOX:
    ** * * *if ((buffer[0] := serial.rx)&128)
    ** * * * *next
    ** * * *crc ^= buffer[0]
    ** * * *if ((buffer[1] := serial.rx)&128)
    ** * * * *next
    ** * * *crc ^= buffer[1]
    ** * * *if ((buffer[2] := serial.rx)&128)
    ** * * * *next
    ** * * *crc ^= buffer[2]
    ** * * *if ((buffer[3] := serial.rx)&128)
    ** * * * *next
    ** * * *crc ^= buffer[3]
    ** * * *if ((buffer[4] := serial.rx)&128)
    ** * * * *next
    ** * * *crc ^= buffer[4]
    ** * * *if ((buffer[5] := serial.rx)&128)
    ** * * * *next
    ** * * *crc ^= buffer[5]
    ** * * *if ((buffer[6] := serial.rx)&128)
    ** * * * *next
    ** * * *if ((crc&127)<>buffer[6])
    ** * * * *next
    ** * * *intValue[buffer[0]] := buffer[1]|(buffer[2]<<7)|(buffer[3]<<14)|(buffer[4]<<21)|(buffer[5]<<28)
    ** * * *mailboxToSend[buffer[0]] := 0
    ** * *MCU_SET_LOGIC_MAILBOX:
    ** * * *if ((buffer[0] := serial.rx)&128)
    ** * * * *next
    ** * * *crc ^= buffer[0]
    ** * * *if ((buffer[1] := serial.rx)&128)
    ** * * * *next
    ** * * *crc ^= buffer[1]
    ** * * *if ((buffer[2] := serial.rx)&128)
    ** * * * *next
    ** * * *if ((crc&127) <> buffer[2])
    ** * * * *next
    ** * * *logicValue[buffer[0]] := buffer[1]
    ** * * *mailboxToSend[buffer[0]] := 0
    ** * *MCU_SET_TEXT_MAILBOX:
    ** * * *if ((mailbox := serial.rx)&128)
    ** * * * *next
    ** * * *crc ^= mailbox
    ** * * *hold := textStoreTop
    ** * * *textStoreTop--
    ** * * *repeat
    ** * * * *textStoreTop++
    ** * * * *textStore[textStoreTop] := serial.rx
    ** * * * *crc^=textStore[textStoreTop]
    ** * * *while (textStoreTop<1024)&(textStore[textStoreTop]<>0)
    ** * * *textStoreTop++
    ** * * *if ((crc&127)<>serial.rx)
    ** * * * *textStoreTop := hold
    ** * * * *next
    ** * * *textValue[mailbox] := @textStore[hold]
    ** * * *mailboxToSend[mailbox] := 0 **
    ** * *{ stream values to mailbox }
    ** * *MCU_GET_NUMBER_MAILBOX:
    ** * * *mailbox := serial.rx
    ** * * *if (((crc^mailbox)&127)<>serial.rx)
    ** * * * *next
    ** * * *mailboxToSend[mailbox] := MCU_GET_NUMBER_MAILBOX
    ** * *MCU_GET_LOGIC_MAILBOX:
    ** * * *mailbox := serial.rx
    ** * * *if (((crc^mailbox)&127) <> serial.rx)
    ** * * * *next
    ** * * *mailboxToSend[mailbox] := MCU_GET_LOGIC_MAILBOX
    ** * *MCU_GET_TEXT_MAILBOX:
    ** * * *mailbox := serial.rx
    ** * * *if (((crc^mailbox)&127) <> serial.rx)
    ** * * * *next
    ** * * *mailboxToSend[mailbox] := MCU_GET_TEXT_MAILBOX
    ** * *MCU_END_FRAME:
    ** * * *processMailboxes
    ** * * *{ note that Text values are lost after being processed as we }
    ** * * *{ will reuse the buffer for the next frame * * * * * * * * * }
    ** * * *textStoreTop:=0

    ** *repeat i from 0 to 19 * *
    ** * *if (mailboxToSend<>0)&(mailboxSendFlag<>0)
    ** * * *case (mailboxToSend)
    ** * * * *MCU_GET_NUMBER_MAILBOX:
    ** * * * * *lvalue := intValue
    ** * * * * *serial.tx(buffer[0]:=MCU_GET_NUMBER_MAILBOX|128)
    ** * * * * *serial.tx(buffer[1]:=i)
    ** * * * * *serial.tx(buffer[2]:=lvalue&127)
    ** * * * * *serial.tx(buffer[3]:=(lvalue>>7)&127)
    ** * * * * *serial.tx(buffer[4]:=(lvalue>>14)&127)
    ** * * * * *serial.tx(buffer[5]:=(lvalue>>21)&127)
    ** * * * * *serial.tx(buffer[6]:=(lvalue>>28)&127)
    ** * * * * *serial.tx((buffer[0]^buffer[1]^buffer[2]^buffer[3]^buffer[4]^buffer[5]^buffer[6])&127)
    ** * * * *MCU_GET_LOGIC_MAILBOX:
    ** * * * * *serial.tx(buffer[0]:=MCU_GET_LOGIC_MAILBOX|128)
    ** * * * * *serial.tx(buffer[1]:=i)
    ** * * * * *serial.tx(buffer[2]:=logicValue&127)
    ** * * * * *serial.tx((buffer[0]^buffer[1]^buffer[2])&127)
    ** * * * *MCU_GET_TEXT_MAILBOX:
    ** * * * * *tvalue := textValue

    ** * * * * *serial.tx(buffer[0]:=MCU_GET_TEXT_MAILBOX|128)
    ** * * * * *serial.tx(buffer[1]:=i)
    ** * * * * *crc := buffer[0]^buffer[1]
    ** * * * * *j := 0
    ** * * * * *repeat while (byte[tvalue[j]] <> 0)&(j<254)
    ** * * * * * *byte[tvalue[j]] &= 127
    ** * * * * * *crc ^= byte[tvalue[j]]
    ** * * * * * *j++
    ** * * * * *j++
    ** * * * *
    ** * * * * buffer[2] := crc&127

    ** * * * * serial.tx(buffer[0])
    ** * * * * serial.tx(buffer[1])
    ** * * * * serial.str(tvalue) * * * * **
    ** * * * * serial.tx(buffer[2])
    ** * * * **
    ** * * *mailboxSendFlag := 0

    PUB processMailboxes

    **{ Assumes values for servos are in mailbox 0 and 1 }
    **SERVO.Set(ServoCh1,intValue[0])*
    **SERVO.Set(ServoCh2,intValue[1])

    **if (intValue[2]<>0)
    ** *outa[16]~~
    **else
    ** *outa[16]~

    **intValue[3] := ina[17]
    **mailboxSendFlag[3] := 1
    ** * * **</code>

    It is also downloadable from the RoboRealm website.
  • charleyshfcharleyshf Posts: 165
    edited 2011-03-02 06:09
    Nice!!

    I've been waiting for this, can't wait to start using it!
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-03-02 10:50
    What you can see from the code is

    they have climbed up the learning curve and have experience with programming in general and about serial data send and receive.

    climbing up the learning curve is the thing you have to do too. If you do not you will stay down as a - sorry for this word - thumb user
    doing some clicks always staying inside the fence that the other rised up with their tools.

    best regards

    Stefan
  • BotdocterBotdocter Posts: 271
    edited 2011-03-28 10:18
    You obviously never used RoboRealm...

    The serial sending /receiving is fast and only possible in one way. It is quite a fragile connection too. Any hickup screws everything up!
    This plugin is available for almost all platform mcu's.
    That isn't without a reason.

    Anyway. Most people using roborealm do programming in vbscript.
Sign In or Register to comment.