Putt Putt
Canada
Asked
— Edited
Hi all and DJ,
I'm trying to figure out the syntax to mask the 8th bit of a packet serial command from EZ-B to RobotClaw Motor Controller, any help would be appreciated if it's possible on the EZ-B.
On other MCU's that I have I use this format...
Serout P15, i19200, [128, 0, 127 (255 & 0x7F) ]
Serout - well that's the command for output from the serial port,
in EZ-b that would be SendSerial.
P15 - is the port ...EZ-B D0
i19200 - is the baud rate...EZ-B just 19200 or whatever baud i use..
The 128, 0, 127, (255 & 0x7F) is "address, command, address, (checksum & 0x7F)
the 0x7F is the Hex code to mask the 8th bit.
Sooooo...
EZ-B code...
SendSerial ( D0, 19200, 128, 0, 127, (255 & 0x7F )
but it won't accept the "(255 & 0x7F)"
clear as mud eh!
:)
255 & 0x7f = 127
So you'd use
Check the datasheet for the motor controller, as that doesn't look correct. The datasheet i gave a quick look at is here. And the syntax for Simple Serial is...
Thanks for the reply DJ but....
Sorry the device i'm using is the RobotClaw dual 30 amp
The simple serial is ok, it's the packet serial code that I need to use for my bot.
The problem is that the 255 & 0x7F comes up as an error in EZ-B,
the 255 is the checksum for the "128, 0 127, " and the & 0x7F is mask for the 8th bit
255 & 0x7f is decimal 127
127 = (255 & 0x7f) = 127 = (255 & 0x7f) = 127
I agree the 0x7F = 127 but the line of code is
SendSerial ( D0, 19200, 128, 0, 127, (255 & 0x7F ))
It still wouldn't work if I sent it like this
SendSerial ( D0, 19200, 128, 0, 127, (255 & 127 ))
because EZ-B doesn't like the & symbol
when I try to save in the script config I get the error...
Syntax Error: (255 & 127 is not in a valid format.
Am I driving you nuts?
(255 & 0x7f) = 127
ok so what would the code look like for
SendSerial ( D0, 19200, 128, 3, 89, (220 & 0x7F ))
Windows calculator is actually quite powerful - I use it often
Who ever documented that protocol did a terrible job. I can see performing a bitwise AND operation on a variable, but not a constant. By performing (220 & 0x7f) would use many unneeded cycles of operations within the processor; where simply entering the value would suffice.
:)
The code is for an Atom Pro 28 to RobotClaw , there must be a reason why it's done that way.
@DJ
I've setup the RobotClaw and EZ-B and all seems well so far THANKS, and thanks for putting up with my thick brain, I've been using Basic Atom pro for so long that I couldn't see how just the decimal number would work, it's never used that way for programing the Pro.
And now for another question...
This has probably been asked, can all the D ports be used for serial in and out?
And is there a command like "ReceiveSerial" or "GetSerial" etc.
There is no GetSerial. There are not enough free clock cycles to receive serial input during PID execution. Our new hardware guy is working on an EZ-Bit for that
Ok,
Why doesn't this line work with the variables
SendSerial (D0, 38400, 128, 6, "$L" , "$CS6" )
The variables work when using the print command but not in the line of code
Won't work.....error: not a valid format confused
Ah, fixed for the next release
ok, thanks again