ConfigurableFirmata icon indicating copy to clipboard operation
ConfigurableFirmata copied to clipboard

Q: Report position and smooth stop in the middle of process

Open LinuksGuru opened this issue 5 years ago • 1 comments

Hi! I'm having some problems with library. Right now I can init, start, stop motors, with smooth acceleration/deceleration (with Python on Raspberry Pi). Unfortunately, there are 2 things which don't work yet for me.

  1. Report position. Code snippets attached. Returned position is always "0". Looks like coded something wrong. If you have samples how to properly use "report position" it would be great.

  2. Smooth stop command when move is still NOT complete. I have no idea if its possible to reset (re-init) number of steps while motor still spinning. If this is technically possible, report position feature is required (p 1).

Thanks in advance for any help.

PS. Unfortunately googling "firmata accelstepper example" yields nothing useful.

def accStepFmt_Step(brd, dev_no, num_steps):
    cmd = bytearray([acc.ACCELSTEPPER_STEP, dev_no])
    cmd.extend(ecn.encodeIntTo7bitSysex(num_steps))
    brd.send_sysex(acc.ACCELSTEPPER_DATA, cmd)

def accStepFmt_ReportPosRequest(brd, dev_no):
    cmd = bytearray([acc.ACCELSTEPPER_REPORT_POSITION, dev_no])
    return brd.send_sysex(acc.ACCELSTEPPER_DATA, cmd)
  
def accStepFmt_ReportPosReply(brd, dev_no):
    sb = bytearray([0] * 5)
    cmd = bytearray([acc.ACCELSTEPPER_REPORT_POSITION, dev_no, sb[0], sb[1], sb[2], sb[3], sb[4]])
    brd.send_sysex(acc.ACCELSTEPPER_DATA, cmd)
    return ecn.bytesToInt(sb)

LinuksGuru avatar Sep 30 '20 10:09 LinuksGuru

This is actually follow-up of this bug report https://github.com/firmata/ConfigurableFirmata/issues/99

Anyway, if someone can provide sample how to properly implement ACCELSTEPPER_REPORT_POSITION in Python on RapPi it would be very nice. Main doesn't work and vice versa.

LinuksGuru avatar Oct 01 '20 09:10 LinuksGuru