Page 1 of 1

iRobot Create Interface - Help with Dec to Bin conversion

Posted: Sat Nov 27, 2010 5:53 am
by jvincent
I'm attempting to build a control interface for the iRobot Create using Flowstone. I'm doing this using the Open Interface Protocols from iRobot and need to be jumping back and forth between binary, hex, and decimal with the control instructions. There is an Int to Hex component, but I'm having trouble figuring out how to convert to binary (easily). Am I overlooking a component or is there an easy way to do this? Thanks for any help anyone can give me.

PS - Flowstone is a great development and educational platform . I teach high school courses in computer science, robotics, and pre-engineering. My robotics class uses iRobot Creates quite heavily and my plan is to get my interface running so that I can use Flowstone in some of my second semester classes. Thanks to the developers!

Re: iRobot Create Interface - Help with Dec to Bin conversio

Posted: Sun Nov 28, 2010 11:22 am
by DSP
If I need binary I just make a simple module that uses boolean algebra to decode the individual bits. There is no hex or dec to binary module. Usually it's not actually binary you need but the discrete bits out for say a digital output board (8 outs etc).
If you are still struggling, I can send you an example

Re: iRobot Create Interface - Help with Dec to Bin conversio

Posted: Sun Nov 28, 2010 4:41 pm
by jvincent
The Create Open Interface consists of a set of opcodes (for specific instructions) followed by data bytes. Unfortunately, many of the data bytes are defined as integer values that need to be converted into binary and broken into two seperate 8 bit bytes to send to the Create. For example, to move the Create forward at 500 mm/s, 500 must be converted to binary (111110100), padded to 16 bits (0000000111110100), broken into a "high byte" and "low byte" (high byte = 00000001, low byte = 11110100), and then the opcode byte and the two data bytes are sent to the Create. I'm converting data to Hex to make it easier to view the data set.

Because of the way the Open Interface is set up, I'm not sure if your suggestion would work DSP. But I appreciate your reply and I could be wrong, so I'll play around with your idea see if I get anywhere. Any other ideas?

Re: iRobot Create Interface - Help with Dec to Bin conversio

Posted: Mon Nov 29, 2010 1:07 am
by jvincent
I figured out how to get my Decimal to Binary conversions to work using some comparisons and an int loop. If anyone is interested in the modules, let me know.

Re: iRobot Create Interface - Help with Dec to Bin conversio

Posted: Mon Nov 29, 2010 4:19 pm
by DSP
Another option is to use Selectors to select the binary value. This way it's always padded.

Have a look at this example:

This converts an Int - Hex then to 8 bit Binary

Re: iRobot Create Interface - Help with Dec to Bin conversio

Posted: Tue Nov 30, 2010 3:15 am
by jvincent
That is very similar to the way I did it. Although I overcomplicated the index value for the selector, you have it set up in a much more clever way (I used a loop and a comparison). Thanks for your help!