Castle Serial Link Communication

16 views Asked by At

I am successfully able to write throttle, read Throttle and RPM. However the RPM values I read are random.

clear_command_buffer(ser)

            read_command = [0x80, 5, 0, 0]  # Example read command based on document structure
            read_checksum = calculate_checksum(read_command)
            read_command.append(read_checksum)
            ser.write(read_command)
            print(f"Sent RPM read command: {read_command}")

            response = ser.read(3)
            print(f"Read RPM Response:{response}")
            
            if len(response) == 3 and verify_response_checksum(response):
                    rpm_response = (response[1] << 8) + response[2]
                    rpm = (rpm_response / 2042) * 20416.66
                    print(f"RPM read value: {rpm}")

            else:
                print("Sorry didn't read RPM this time")

            time.sleep(5)

This is the code I use to read RPM. I have also used the scaling factor as mentioned in the documents. I am still reading random values at various throttles.

I have a feeling that this could also be related to how the ESC responds to the input throttle depending on vehicle type. But how it reacts is still unclear. For my setup i am running a 4 pole BLDC using a Castle Phoniex Edge HV40 ESC, Castle Serial Link and a FTDI which are all connected in series to a PC that uses python code to control the settings.

The Random values I read are more like at 8000 throttle input I read a RPM of 614439.48 while it is just at 4300 RPM when checkedd with the Tachometer. At 9000 it is around 435958.68 and 10000 around 374758.692 while tachometer reading is 5848.

How could fix this issue to get the right RPM?

I have set the Right motor details in the ESC too. Are there any other settings that might affect my reading output?

0

There are 0 answers