2
$\begingroup$

I am using a Raspberry Pi 3, B+ pertinent libraries are WiringPi, with WiringSerial. Code is written in c.

EDIT: the Serial connection is handled through GPIO 14(Tx) & 15(Rx), 5v (Tx) is stepped down through 165 ohm resistor and, a 3.3v Zener Diode.

The following code is what I use to retrieve and and convert Raw Encoder Count to 16bit value.

int16_t sensors_left_encoder_init() {
int16_t left_encoder_start = 0;
char buffer_l[2];
int i = 0;

serialFlush(fd);
serialPutchar(fd, 142); // Request sensor packet
serialPutchar(fd, 43); // Left encoder request
do {
    buffer_l[i] = serialGetchar(fd);
    printf(" -> Left Serial Value: %d\n", buffer_l[i]);
    i++;
} while (serialDataAvail(fd));
left_encoder_start = (int16_t)(((buffer_l[0]) & 0xFF) << 8 | (buffer_l[1]) & 0xFF);
printf(" -> Left Encoder Start: %" PRId16 "\n", left_encoder_start);

return left_encoder_start;
}

int16_t sensors_right_encoder_init() {
int16_t right_encoder_start = 0;
unsigned char buffer_r[2];
int i = 0;

serialFlush(fd);
serialPutchar(fd, 142); // Request sensor packet
serialPutchar(fd, 44); // Left encoder request
do {
    buffer_r[i] = serialGetchar(fd);
    printf(" -> Right Serial Value: %d\n", buffer_r[i]);
    i++;
} while (serialDataAvail(fd));
right_encoder_start = (int16_t)(((buffer_r[0]) & 0xFF) << 8 | (buffer_r[1]) & 0xFF);
printf(" -> Right Encoder Start: %" PRId16 "\n", right_encoder_start);


return right_encoder_start;
}

I pulled the battery, ran the code and the first run produced:

-> Left Serial Value: 0 -> Left Serial Value: 1 -> Left Encoder Start: 1 -> Right Serial Value: 0 -> Right Serial Value: 2 -> Right Encoder Start: 2

However the second run through produced this:

-> Left Serial Value: 0 -> Left Serial Value: 3 -> Left Encoder Start: 3 -> Right Serial Value: 0 -> Right Serial Value: 4 -> Right Encoder Start: 4

I have a feeling its how serialGetchar() is receiving the serial output from the interface, but I am not 100%.

From reading the wheel encoder topics on here, and the OI Specs, I understand that the raw values should not change unless a drive command was issued to the interface.

$\endgroup$

1 Answer 1

1
$\begingroup$

I'm not familiar with the Rpi3 UART capabilities as I'm using a different controller with a hardware UART, but I can report that others have had difficulties using software-based UARTS with later generation of Roombas, i.e. Series 500 and later

https://www.ez-robot.com/Community/Forum/Thread?threadId=10953

I suggest adding a USB-based UART dongle and see if that solves the issue

I think you are indicating that you are using a Roomba 690, which I thought was Wi-Fi only. If that's the case, how are you connecting to it?

$\endgroup$
3
  • $\begingroup$ Thanks for the link! I was under the impression the PL011 which is the main UART on the PI was hardware, but I could be mistaken. I am using a Roomba 690, it does indeed have Wi-Fi, but it also has the same mini-DIN as the create 2. Only difference is that the create 2 is missing the vacuum components, and have an 7 Segment LED display (I think). $\endgroup$
    – Pete
    Commented Jun 19, 2018 at 19:00
  • $\begingroup$ Where is the mini din located on the 690? Under the faceplate like 650? $\endgroup$
    – Faengelm
    Commented Jun 20, 2018 at 19:26
  • $\begingroup$ It sure is; Located on the left front, under the outer face faceplate. $\endgroup$
    – Pete
    Commented Jun 22, 2018 at 3:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.