gcormier / megadesk

Open-source IKEA Bekant controller board
GNU General Public License v3.0
719 stars 53 forks source link

Exit linBurst() early if either motor doesn't respond #79

Closed philwmcdonald closed 3 years ago

philwmcdonald commented 3 years ago

If SERIALERRORS is enabled report problems with motor responses or with one motor position differing by more than 20 compared to the other. Format of these diagnostic messages can be seen below...

In the event of a bad motor read, exit early and avoid further commands. Don't update currentHeight. If feedback is enabled and SERIALERRORS make a subtle error beep too.

Removed DEBUG_ENCODER #def as SERIALERRORS covers this now.

Changes here were in response to observed behavior while sitting idle:

8E2303,0 # misread from pid8. *zero* bytes read.
!E4512,5 # late
DE2303,143 # mismatch between pid8 (2303) and pid9 (2160)
currentHeight is set by pid9 so no apparent motion.

9E2303,0  # misread from pid9.*zero* bytes read
!E4496,5 # late
DE2157,146 # mismatch between pid8 (2157) and pid9 (2303)
>+143,0 # apparent phantom movement 
>=2303,146
>-143,0 # resume normal reads
>=2160,3

RAM: [======== ] 77.5% (used 397 bytes from 512 bytes) Flash: [========= ] 91.9% (used 7528 bytes from 8192 bytes)

gcormier commented 3 years ago

Looks like if I have FEEDBACK enabled, I will hear a tiny blip when an error happens during linBurst()? If so I will keep feedback enabled to see how often it occurs on my desk.