Shop Learn
FlexBASIC Create robot comms — Parallax Forums

FlexBASIC Create robot comms

I am trying to create a program in FlexBASIC to communicate with the Create robot. I have tried different versions of 'print ', but did not get anything to work.

I have a SimpleIDE program that works with the Create robot, so I know the connections are correct. I am using the following:
include "fdserial.h"
include "simpletext.h"
cr=fdserial_open(0, 1, 0, 57600); //Connect to robot
fdserial_txChar(cr,128); //Put robot in Start mode.
I am not sure what the conversion of fdserial_txChar(cr,128); should look like in FlexBASIC.

Also, what would the conversion of this, look like in FlexBASIC:
void crFore()



  • Looks like the speed values are 16 bit number so they are breaking them down.

    print#1, chr$(145);
    print#1, chr$(speed_right >> 8); //send high byte
    print#1,chr$(speed_right & 0xff); //send low byte
    print#1,chr$(speed_left >> 8);
    print#1,chr$(speed_left & 0xff);

    Sorry I have not done basic programing in 40 years.


  • ersmithersmith Posts: 4,729

    @Rsadeika : if you're just sending one character at a time you might as well use the methods in the Spin serial object that you're using, e.g. something like:

    dim ser as class using "spin/SmartSerial.spin"
    ser.start(0, 1, 0, 57600)
    ser.tx( (speed_right>>8) and 0xff )
    ser.tx( speed_right and 0xff )

    and so on (in BASIC bitwise and uses the and operator instead of &).

  • I'm looking at some of my old Roomba code I never saw a way of controlling the wheel speed directly. I always had to send a speed and turning radius when controlling the robot. Was I doing it wrong of did the protocol change since 2011 when I was experimenting with a Roomba?

    Maybe I just missed the part where you could control the motors directly.

  • RsadeikaRsadeika Posts: 3,516

    I am aware that you can use 'ser.tx(xxx)' method, what I was trying to find out is if there was a way to use the 'print #x,' method. Not sure what the gain would be, at this point.

    I noticed the use of "spin/SmartSerial.spin", since this is a P1 project, I think that will not work, unless it has been changed so both Pi and P2 can use it.

    I am also using the original Activity Board, which has access to the uSD reader. Using FlexBASIC, what is some sample code to read and write to it, and what would be the pin usage, for the Activity board. I also noticed there is a new command, 'chain', can this work with a P1 setup, or is this strictly a P2 effort.

    The 'speed_right' and 'speed_left' are predefined, so you have to manually change that number. In my case I use 35 for turns, and 75 for straight runs. I need an easy way to speed up and slow down on the straight runs.


  • ersmithersmith Posts: 4,729

    There's no point in using print to send single bytes when you can use ser.tx directly -- the print would just end up calling ser.tx, so all you're doing is adding overhead.

    CHAIN will only work on P2. Actually all of the file system stuff only works on P2 right now. It might be possible to (just) squeeze the FAT file system and SD card code into P1, but there wouldn't be much memory left over for your program.

  • RsadeikaRsadeika Posts: 3,516

    Ah, yes, I keep forgetting that FlexBASIC is LMM and not CMM. I am in a tight spot, I just tried SimpleIDE for the Raspberry Pi, and that does not work. I think something changed when they created Raspberry Pi OS, which is not allowing SimpleIDE to run.

    I will have to to re-think how I will be using FlexBASIC to work with the Create robot. I guess I will have the Activity Board as a go between for the robot and the RPi, robot <-> Activity Board <-> Rpi. In this configuration, the RPi will do the heavy lifting while the Activity Board will just be a way to control the robot. There has to be an easier way to accomplish this, starting to add to many different systems, and the complexity is maybe getting in the way.


  • dgatelydgately Posts: 1,412

    When you say SimpleIDE for the Raspberry Pi does not work, do you mean this?:

    /opt/simpleide/bin/SimpleIDE: error while loading shared libraries: cannot open sh$

    If so, you can remedy the problem with:

    sudo apt install libpng12-0
    sudo apt install libpng12-dev
  • RsadeikaRsadeika Posts: 3,516

    Yep, that was it, Thanks dgately. I tried a search for libpng, never saw any those items. I guess my search techniques need a lot of improvement.


Sign In or Register to comment.