PDA

View Full Version : RealBasic to Propeller



T Chap
10-22-2006, 06:38 PM
I am working on a RealBasic app that will send data to a Propeller. I am really confused on how to do this, maybe someone could understand what is the snag and clarify this stuff.

The data to be sent from RB to the Prop in one string:

MotorNumber1 byte
MotorNumber2 byte
MotorNumber3 byte
MotorNumber4 byte
Distance A long(possible word)
Distance B long "
Distance C long "
Distance D long "
ControlA 1-15 possibilities of numbers byte
ControlB 1-15 possibilities of numbers byte
Control 1 byte
" "
" "
Control 15 byte


Here is the motorMove method I was trying to make work, a scaled down version that is.

motorNumber As Integer, distance as integer




Dim msg As New MemoryBlock(4)

msg.Byte(0) = motornumber 'works when looking for a number/text but not bin

msg.Byte(1) = distance

msg.Byte(2) =1000

msg.Byte(3) = &b11110000 ' test

serial1.Write msg




From what I can tell, the RB will send a binary byte like this, and the Stamp will receive it as a binary: &b00000000. However, I cannot find a way to set a variable to be a binary in RB, but I can just serial.write &b00000000 and it works. I get errors of mismatch when attempting to change the method to motormove as binarystream.

Now to the Propeller, it would really be helpful to find out how I am even going to deal with the data once I do get it in a format. In testing with the BS2p40, this seems to be a workable concept:




'read the byte(11)
if byte(0) = 0 then 'we are dealing with motor 1, therefore
byte(1) = the distance to move motor 1 by the Props motorMove method
byte(2) = the distance to move motor 1 by the Props motorMove method
etc etc for all motors, all controls




How to get a long value integer out of RB and reasembled in the Prop for use in the distance value? who knows

Right now the biggest question is to narrow down whether to use hex, bin, dec etc.

I am too tired to make a point.

Bill Henning
10-22-2006, 10:49 PM
msg.Byte(2) =1000 <--- 1000 will not fit into a byte

Best,

Bill

T Chap
10-23-2006, 02:18 AM
Yes that is the problem. I am realizing that there is no way to have a nice tidy array that holds everything. All data must be sent separately, as the values can range from 0 to longs on some parameters, and no way to package various values up in one fixed size array.

Post Edited (originator99) : 10/22/2006 7:14:14 PM GMT

Bill Henning
10-23-2006, 03:31 AM
sure there is. you can put smaller items into bigger ones - use an array of longs