Skip to content

Control GUI - Error during read servo position #2

@jan-kacina

Description

@jan-kacina

Hi guys,
I am experiencing the following error when read_ServoPos method is called (located within controlGUI.py file):

INFO: Connecting to PiArm on Port /dev/ttyS0 & baudrate 115200..
INFO: PiArm is Initialized
DEBUG: write: b'UU\x01\x04\x1f\x01\xda'
DEBUG: notification: Serial Device Connected
DEBUG: write: b'UU\x01\x03\x1c\xdf'
DEBUG: response: [b'U', b'U', b'\x7f', b'~', b'\\', b'\x00']
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.7/tkinter/__init__.py", line 1705, in __call__
    return self.func(*args)
  File "/home/pi/PiArm/controlGUI.py", line 279, in read_ServoPos
    pos = int.from_bytes(response[5]+response[6], byteorder='little')
IndexError: list index out of range

The code is in accordance with Servo Communication Protocol.pdf specification. Based on DEBUG logs, received array has only 6 items, so with zero-indexed array, there is no response[6] element.

When I "workaround" the error with pos = int.from_bytes(response[4], byteorder='little') on line 279, the console output is as follows:

INFO: Connecting to PiArm on Port /dev/ttyS0 & baudrate 115200..
INFO: PiArm is Initialized
DEBUG: write: b'UU\x01\x03\x1c\xdf'
DEBUG: response: [b'U', b'U', b'\x7f', b'~', b'\\', b'\x00']
DEBUG: write: b'UU\x02\x03\x1c\xde'
DEBUG: response: [b'U', b'U', b'\xbf', b'\xc7', b'C']
DEBUG: write: b'UU\x03\x03\x1c\xdd'
DEBUG: response: [b'U', b'U', b'~', b'~', b'\\', b'\x04']
DEBUG: write: b'UU\x04\x03\x1c\xdc'
DEBUG: response: [b'U', b'U', b'_', b'\xc7', b'G']
DEBUG: write: b'UU\x05\x03\x1c\xdb'
DEBUG: response: [b'U', b'U', b'}', b'~', b'\\', b'\x02']
DEBUG: write: b'UU\x06\x03\x1c\xda'
DEBUG: response: [b'U', b'U', b'\xbe', b'\xc7', b'K']

Please note that responses from servos 1,3,5 have 6 items while responses from servos 2,4,6 have 5 items only.
When I move with arm manually and read the values again, they remain the same.
Moreover, writes to servos return no error, but no servo is moved.

My setup is as follows:

  • Raspberry Pi 4 8GB, Raspberry Pi OS (32-bit) with desktop and recommended software
  • PiArm Basic Kit (purchased recently)
  • Servo Shield connected via GPIO
  • Arm connected via JST connector type 1 (number 14 in your lesson 1); number 7 has the same behavior
  • LED on servos are blinking a 7 color sequence + turned off (does it mean something?)
  • powered by included AC adapter
  • servos are daisy-chained - wire from servo below going into left socket, then wire from right socket to next servo up; as described in MagPi review; wiring based on you tutorial where motors 3 and 2 are wired differently makes no change in behavior

Where else should I look for the error reason? Is it something wrong with the shield? Is it Raspberry Pi 4?

Please help.

Regards,
Jan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions