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.
SendSerial ( D0, 19200, 128, 0, 127, (255 & 0x7F )
but it won't accept the "(255 & 0x7F)"
clear as mud eh!
Upgrade to ARC Pro
Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro
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...
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
127 = (255 & 0x7f) = 127 = (255 & 0x7f) = 127
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.
(255 & 0x7f) = 127
SendSerial ( D0, 19200, 128, 3, 89, (220 & 0x7F ))
1) Load Windows Calculator
2) select View and choose Programmer
3) To enter 220 (which is decimal) select DEC from the radio buttons
4) Enter 220
5) Press AND
6) To enter 0x7f (which is hex) select HEX from the radio buttons
7) Enter 7f
8) Press =
9) The answer will be displayed in HEX because that is the last format you used. Simply press DEC to view it in decimal
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.
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.
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