Propeller RCB and Roborealm setup?
Botdocter
Posts: 271
Can anyone tell me how to get the motor/servo/serial working with roborealm with the propeller robot control board?
I can make a connection but i think i need some code on the robot control board (prop) to get something moving. I haven't found anything on google that was helpful.
Thanx in advance!
I can make a connection but i think i need some code on the robot control board (prop) to get something moving. I haven't found anything on google that was helpful.
Thanx in advance!
Comments
http://forums.parallax.com/showthread.php?p=646454
http://forums.parallax.com/showthread.php?t=101570
Jeff T.
I think an "open" array would be best if possible. Because of many different variables in roborealm it would be the easyest to just receive everything and sort it out on the propeller.
So roborealm would send :
var1 var2 var3
Or
var1
var2
var3
How would i receive and handle this?
Here is a snippet that might be ok for what your wanting with a little modification.
repeat
temp:=ser.rxcheck
if temp=="!"
Var1:=ser.rxDec
Var2:=ser.rxDec
Jeff T.
I found this on the site of robotbasic. Allthough i cant understand how to do anything with the program without complex programming, i found this communication script.
http://www.google.nl/m/url?client=safari&ei=BQ7nTKjvHKTajQe7id2VAg&hl=nl&oe=UTF-8&q=http://www.robotbasic.org/resources/RobotBASIC_To_PropellerChip_Comms.pdf&ved=0CBAQFjAA&usg=AFQjCNEEtG5_VxyJBJZId-SRXvr-WUJq8Q
It does give me something back but it looks weird. I send 311, 2.2 and i get 255/198/..../255 or something like that.
Almost there! Just need the right values coming in the prop.
every third line is what i get back. the first and second line are beeing send by roborealm.
01393: FPS==20.0<cr>
01394: MOUSE_X==303
01395: \255\255\255\255
01396: FPS==19.9<cr>
01397: MOUSE_X==303
01398: \255\247\255\255
01399: FPS==19.7<cr>
01400: MOUSE_X==303
01401: \247\255\255\255\255\255\255
01402: FPS==20.2<cr>
01403: MOUSE_X==287
01404: \247\255\255
01405: FPS==20.0<cr>
01406: MOUSE_X==287
01407: \255\255\247
01408: FPS==20.6<cr>
01409: MOUSE_X==287
01410: \255\255\255\255
01411: FPS==20.4<cr>
01412: MOUSE_X==287
01413: \255\247\255\255
The spin code i used to receive and send the data back is this.
''
RB2Prop_IO_Binary.Spin
CON _clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
RxPin = 31 'can use a different pin...see note above
TxPin = 30 'can use a different pin...see note above
BaudRate = 9615200 'this is a good baud for 80MHz
OBJ
SerIO : "FullDuplexSerialPlus" 'object that implements serial I/O 'for the Propeller. It is part of 'the Propeller Education Kit library
Var
Long Vals[2]
byte buff_index
PUB RB_IO_Demo_Binary
SerIO.Start(RxPin, TxPin, %0000, BaudRate)
SerIO.Str(String("Ready")) 'send the Rdy to synchronize
repeat
GetBinaries 'get the binary 8 bytes
Vals[0] := Vals[0]+Vals[1] 'add the values
SendBinary 'send the binary 4 bytes
Pri GetBinaries 'reads in 8 bytes and puts them in the memory area starting 'at the Vals[] array....that effectively writes in the two 'numbers into the arrays
repeat buff_index from 0 to 7
byte[@Vals + buff_index] := SerIO.Rx
Pri SendBinary 'sends 4 bytes starting at the address of Vals[] 'that effectively sends the first element in the array.
repeat buff_index from 0 to 3
SerIO.Tx(byte[@Vals + buff_index])
What did i do wrong? i need to get exactly the same to the propeller as is beeing send.
here some code:
from PRCB receive datas:
*******************************************************************
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
rxpin = 0 ' Receive on I/O pin 1 <- black from master black txpin p1
txpin = 1 ' Transmit on I/O pin 0 -> red to master red rxpin p0
VAR
LONG myInput
LONG txVal_1, txVal_2 ' transmit
LONG rxVal_1, rxVal_2 ' receive from master and PST
{******************************************************************}
OBJ
serial : "Extended_FDSerial" '' "FullDuplexSerial"
f : "Float32Full"
{*****************************************************************}
PUB Main | DutyCycle ' new stuff DutyCycle
serial.start(rxpin,txpin,%0000, 9600) '- rxpin,txpin,mode,Baud
REPEAT
Receiver
IF rxVal_1 == 1011
{*****************************************************************}
PUB RECEIVE_FW_DATAS
' receive datas as integers
Deg := serial.rxDec
{**************************************************************}
PUB Receiver
rxVal_1 := serial.rxDec
{*******************************************************}
PUB forwardTransmitter
txVal_1 := 6
serial.dec(txVal_1)
serial.tx(13)
{******************************************************************}
PUB Transmitter
txVal_1 := 5
serial.dec(txVal_1)
serial.tx(13)
*******************************************************************
regards nomad
One thing though....
on line 32 it says:
PUB RECEIVE_FW_DATAS
' receive datas as integers
Deg := serial.rxDec
That "Deg" is not devined. Is it correct? i cannot compile the program now.
Value "500" is what is beeing send from roborealm to the prop. The rest is send back by the prop to roborealm.
00315: 500
00316: \242\242\242\242\6\0
00317: 500
00318: 500
00319: 500
00320: \242\242\242\242\6\0
00321: 500
00322: 500
00323: 500
00324: \242\242\242\242\6\0
00325: 500
00326: 500
00327: 500
00328: \242\242\242\242\6\0
00329: \242\242\242\242\6
00330: 500
00331: l\177bb*\0
00332: l\177bb*
00333: 500
00334: \27\27\27\27\6\0
00335: \27\27\27\27\6
00336: 500
00337: 500
00338: Zi\210I\249\6\0
in Parallax serial terminal i get the below results with the same spin script:
Send:2222222222222222222222 11111111111111111111111 00000000000000
Recei:dddd2dddd2RRR@ QQQQ1bbbb1bbbb1@@@@ ````0
Ok you seem to be a very fast programmer.
And it is the same experience as so many times before.
If it should go very fast it turns out to be very slow.
BaudRate = 9615200
is a really strange baudrate.
it's no standrad value like 9600 19200 38400 57600 115200
and the value is way above what FullDuplexSerial can do
(More than 9 Megabaud.)
If you are stumped by the not defined variable "deg"
define it. If you don't know how to to that my recommendation is
to learn it.
There are three ways to do this
1.) taking a WORKING example of code and modify ONE line
testing it again
2.) working through the tutorials how to program in SPIN
3.) taking a working example of code and change more than one line
before testing the code
The 3rd way will be the slowest. Even if it seems to be the fastest.
Knowing so less about programming in general and serial datatransmission
you will mess up the code and not recognizing it. Then gueesing through the fog what it might be change some more codelines messing up it even more.
I have been developing software now for 25 years and it is still true.
change one line of code and check again what has changed
everything right? OK change next line of code and check again
not everything right? analyse what is wrong and what is causing it
if you found the bug correct it it
repeat change next line of code and check the effects until everything works
best regards
Stefan
I have (ofcourse) done my fair share of trying and searching, but no solution came up. No-one seems to use roborealm with the propeller.
I'm not a coding wiz, but always know my code when implemented or written. I recoqnize code easily. It's just that i don't know enough to solve this.
Please if you know what to do, don't keep it from me trying me to teach a lesson. I'm not choosing the easy way....
There is even another errorsource: inverted logic levels on the serial interface you can exclude that by doing the following tests
I'm not sure about your setup. Did you try to receive roborealm-commands
with another PC or a second COM-Port and a serial terminal software that is well known as working correctly?
By testing this you can exclude that the fault is somewhere inside roborealm
or maybe the dataformat is different. What is it exactly 9600 baud 8N1 or something different. You will only receive garbage if only one parameter is different.
Next thing is to program a small propeller testprogram that sends some
characters like "test". And check receiving this by a terminal program.
Then you know that your assumptions about the roborealm-parameters are correct. And you know you can receive propeller sended data correctly.
After this pretests I would start testing roborealm sending a single character like "A" prop receives and echos back the character.
This way keeps a lot of things constant to make it easier to find the real problem.
best regards
Stefan
It sometimes cuts off the transmission and add's the rest to the next transmission (see below). i have the speed set to 14400 baud.
send
00419: 514<cr>
00420: 180<cr>
00421: 24.9<cr>
received
00422: .0<cr>
00423: 514<cr>
00424: 180<cr>
00425: 24.9
send
00426: 514<cr>
00427: 180<cr>
00428: 25.0<cr>
received
00429: <cr>
00430: 514<cr>
00431: 180<cr>
00432: 2
send
00433: 514<cr>
00434: 180<cr>
00435: 25.0<cr>
received
00436: 5.0<cr>
00437: 514<cr>
00438: 180<cr>
00439: 25.
send
00440: 514<cr>
00441: 180<cr>
00442: 25.4<cr>
received
00443: 0<cr>
00444: 514<cr>
00445: 180<cr>
00446: 25.4<cr>
send
00447: 514<cr>
00448: 180<cr>
00449: 25.5<cr>
received
00450: 514<cr>
00451: 180<cr>
00452: 25
send
00453: 514<cr>
00454: 180<cr>
00455: 25.7<cr>
received
00456: .5<cr>
00457: 514<cr>
00458: 180<cr>
00459: 25.7
send
00460: 514<cr>
00461: 180<cr>
00462: 25.7<cr>
received
00463: <cr>
00464: 514<cr>
00465: 180<cr>
00466: 2
send
00467: 514<cr>
00468: 180<cr>
00469: 25.9<cr>
received
00470: 5.7<cr>
00471: 514<cr>
00472: 180<cr>
00473: 25.
This is the code i use. I know it's designed for binary but seems to work and it's the best i could find. Any help on conversion is welcome too if this will solve the problem.
code:
''
RB2Prop_IO_Binary.Spin
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
RxPin = 31 'can use a different pin...see note above
TxPin = 30 'can use a different pin...see note above
BaudRate = 14400 'this is a good baud for 80MHz
OBJ
SerIO : "FullDuplexSerialPlus" 'object that implements serial I/O 'for the Propeller. It is part of 'the Propeller Education Kit library
Var
Long Vals[40]
byte buff_index[38]
PUB RB_IO_Demo_Binary
SerIO.Start(RxPin, TxPin, %0000, BaudRate)
SerIO.Str(String("Rdy")) 'send the Rdy to synchronize
repeat
GetBinaries 'get the binary 8 bytes
Vals[0] := Vals[0]+Vals[1] 'add the values
waitcnt(clkfreq/14 + cnt)
SendBinary 'send the binary 4 bytes
Pri GetBinaries 'reads in 8 bytes and puts them in the memory area starting 'at the Vals[] array....that effectively writes in the two 'numbers into the arrays
repeat buff_index from 5 to 8 'skip eerste 4 bits. uitbreiden= 8 verhogen
byte[@Vals + buff_index] := SerIO.Rx
Pri SendBinary 'sends 4 bytes starting at the address of Vals[] 'that effectively sends the first element in the array
repeat buff_index from 5 to 8
SerIO.Tx(byte[@Vals + buff_index])
I also have no idea how to call these values seperately to use them as a variable.
so if i have for example:
500
300
26.7
500 has to be variable MOUSE_X
300 MOUSE_Y
26.7 FPS
How do i split up this array or string?