Closed hippo5329 closed 1 year ago
Did you experience errors in the ESP32 interrupt in handling the detection of encoder pins switching?. I would suggest the use of RP2040 for a more robust and cost-effective solution for this.
Thanks
On Sun, May 21, 2023 at 10:01 AM hippo5329 @.***> wrote:
This is a port to ESP32.
- The i2cdev and mpu imu are synced to upstream i2cdevlib. The ESP32 needs the updates to work.
- The pwm and pcnt (pulse counter) modules of ESP32 are used for motors and encoders.
- The micro ros wifi transport support is added to config.
- The ArduinoOTA support is added to config.
- Build on Humble. Tested on an ESP32DEV kit with MPU6050 and BTS7960 like motor driver using both serial and wifi transport.
You can view, comment on, or merge this pull request online at:
https://github.com/linorobot/linorobot2_hardware/pull/29 Commit Summary
- 9845388 https://github.com/linorobot/linorobot2_hardware/pull/29/commits/984538808b04ff1b2d35ec76f824f89a31cd908f i2cdev sync with upstream i2cdevlib
- cf1abdf https://github.com/linorobot/linorobot2_hardware/pull/29/commits/cf1abdf3dfe62c2c5f013f75fccaf5112b62994c mpu6050 sync with upstream i2cdevlib
- c5d6d14 https://github.com/linorobot/linorobot2_hardware/pull/29/commits/c5d6d146e85fba878ac038684595693d985c9cff mpu9150 sync with upstream i2cdevlib
- 9d1eb74 https://github.com/linorobot/linorobot2_hardware/pull/29/commits/9d1eb74ccf808e72d10deb83ad1825bf3e6e36a6 mpu9250 sync with upstream i2cdevlib to be verified
- 1745af1 https://github.com/linorobot/linorobot2_hardware/pull/29/commits/1745af1e3db0bceb79f9a058a1d75cba7fc0d81b port to esp32
- 90a011b https://github.com/linorobot/linorobot2_hardware/pull/29/commits/90a011bc6c72e25dc4ddecea21aa8792f5cca06a use esp32 pcnt module for encoder
- 6cfd3c6 https://github.com/linorobot/linorobot2_hardware/pull/29/commits/6cfd3c6f8c3786a9246673e210fabc58abd584f3 add wifi transport support to config
- 01f1d23 https://github.com/linorobot/linorobot2_hardware/pull/29/commits/01f1d2329c8248787952ed6aaa085b70618add12 add ArduinoOTA support to config
File Changes
(15 files https://github.com/linorobot/linorobot2_hardware/pull/29/files )
- M config/lino_base_config.h https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-437a1842555c2425f74c872ea76fc77758f58e0ca4b9fb297a2f3040bc221095 (7)
- M firmware/lib/encoder/encoder.cpp https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-ca006e2d1e26ed515b8573cc4845453ae1ec6daf424bd7625c4fd82af242e2d9 (3)
- M firmware/lib/encoder/encoder.h https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-f95873e09029938e44f4e5e64fdbc6cb53d8176ecf44016488a877b588b305b9 (46)
- M firmware/lib/imu/I2Cdev.cpp https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-9c675aaff75f39fc71ef150ebe0033071e1f345955d5e065ddd204210fa4cf75 (294)
- M firmware/lib/imu/I2Cdev.h https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-32d3284c6d42fc508635f6e86e5dd52a5943224ced9f0e52fb8d906613914df0 (75)
- M firmware/lib/imu/MPU6050.cpp https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-1ca2a5939f3a2682b3e3b7390fd49b0fc96600e493b34e9c7b50cee8057f9438 (1282)
- M firmware/lib/imu/MPU6050.h https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-d1303f0da46ecf10ca0f3535ff94ca36641af86a898a3157fd5e868c981b172e (250)
- M firmware/lib/imu/MPU9150.cpp https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-b8b16af221d56c5aa078bb29201454a29e2873c79b44ca69c82303d5bb889603 (20)
- M firmware/lib/imu/MPU9150.h https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-dc450b8c0bf220f7d7490d6376e1584c81b47a81e2b5416689f5484442be64bf (4)
- M firmware/lib/imu/MPU9250.cpp https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-8e90025607fe7aa9d4c517c9f5a0d2409e81934b601aaef8fcd7e32c1aed7af2 (49)
- M firmware/lib/imu/MPU9250.h https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-d8f12345a56438ac7a6a0740c8dd20795e4fa3786acebd1c53eed23f4d610abc (33)
- A firmware/lib/imu/helper_3dmath.h https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-f114a621e1dfe7297ed9048bc30af0f02105756c9d5be6e48bc164a0be4ac919 (216)
- M firmware/lib/motor/default_motor.h https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-8ccc32cf91d05ad339ddcb4db366dd0d4e39a7fafb34cc1a0137bdc821770ce6 (10)
- M firmware/platformio.ini https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-f0ee0d0e7ec3cc340de0b44bb66ecab00ce9db7fa5830a5cdc3273fa5b429b61 (17)
- M firmware/src/firmware.ino https://github.com/linorobot/linorobot2_hardware/pull/29/files#diff-e8436140251e480237ca0a9abdae527025f81bde6a79dd979f9a5a17903c9020 (55)
Patch Links:
- https://github.com/linorobot/linorobot2_hardware/pull/29.patch
- https://github.com/linorobot/linorobot2_hardware/pull/29.diff
— Reply to this email directly, view it on GitHub https://github.com/linorobot/linorobot2_hardware/pull/29, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWGEKF3EVI44L52RCQBBRTXHFZPPANCNFSM6AAAAAAYJCRVR4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi Christ,
Yes. I experienced interrupt errors with encoder interrupts on ESP32 in my earlier robot projects. So I switched to the hardware PCNT 64 bits pulse counter of ESP32 with the ESP32Encoder library. It works well. No interrupt for encoder is required.
Withdraw WIFI related patches which are not essential for the ESP32 port. Only the i2cdev updates and key ESP32/encoder changes are required. I will put those auxiliary patches on my master branch.
Hi
This is a good initiative, but you may try RP2040 with the original chips. There is no problem with interrupts with the price and the new embedded wifi module makes more sense for a motor with encoder use.
Thanks
On Sun, May 21, 2023 at 9:38 PM hippo5329 @.***> wrote:
Hi Christ,
Yes. I experienced interrupt errors with encoder interrupts on ESP32 in my earlier robot projects. So I switched to the hardware PCNT 64 bits pulse counter of ESP32 with the ESP32Encoder library. It works well. No interrupt for encoder is required.
— Reply to this email directly, view it on GitHub https://github.com/linorobot/linorobot2_hardware/pull/29#issuecomment-1556183043, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWGEKHHRA36Y4LPXUOEXHDXHILGTANCNFSM6AAAAAAYJCRVR4 . You are receiving this because you commented.Message ID: @.***>
Thanks for the suggestion of RP2040. I will take a look. However, it might depend. With 700+ Hz encoder pulses per wheel with my current cheap motors, it will generate 2800+ interrupts per seconds for 4WD. With the factory lino_base_config 144000 count per rev, it will be 144000 140 / 60 4 = 1344000 interrupts per seconds for 4WD at full speed. That is a very heavy load for CPU. Maybe the Teensy40/41's dual 600MHz M7 can handle? I don't know. But with ESP32's 64 bits pulse counters hardware, it is just a piece of cake. NO interrupt!
There are two outstanding bug fixes from upstream, which are independent of platforms.
(1) The upstream fix of I2Cdev.cpp, "Remove extra begin/endTransmission calls during reads". commit 98a3b4e. https://github.com/jrowberg/i2cdevlib
(2) The upstream fix of the order to destroy executor and node in destroy_entities(), "Update reconnection example". commit commit 561c615. https://github.com/micro-ROS/micro_ros_arduino
Try Teensy 4.0, what I am referring to is the durability of the used microcontroller. Theoretical specs and reliability are something to consider relating to precision and accuracy albeit the fastest pulse counting.
Just a peso cent :)
Thanks
On Wed, May 24, 2023 at 2:36 AM Thomas Chou @.***> wrote:
Thanks for the suggestion of RP2040. I will take a look. However, it might depend. With 700+ Hz encoder pulses per wheel with my current cheap motors, it will generate 2800+ interrupts per seconds for 4WD. With the factory lino_base_config 144000 count per rev, it will be 144000 140 / 60 4 = 1344000 interrupts per seconds for 4WD at full speed. That is a very heavy load for CPU. Maybe the Teensy40/41's dual 600MHz M7 can handle? I don't know. But with ESP32's 64 bits pulse counters hardware, it is just a piece of cake. NO interrupt!
— Reply to this email directly, view it on GitHub https://github.com/linorobot/linorobot2_hardware/pull/29#issuecomment-1559952588, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWGEKHLWEHIEQSZ6F5BTQLXHT7TJANCNFSM6AAAAAAYJCRVR4 . You are receiving this because you commented.Message ID: @.***>
This is a port to ESP32.