microsoft / jacdac

Device and service catalogs for Jacdac.
https://aka.ms/jacdac
Creative Commons Attribution 4.0 International
66 stars 24 forks source link

jacdac-servo servo2 can't work fine in first time #1293

Open smfox10 opened 1 year ago

smfox10 commented 1 year ago

https://makecode.microbit.org/_J583d5P8XeYL

1、They all work fine in the dashboard.I set their angle to 90 2、I download this program 3、I press button A ,In fact, both servos should be turned to 0 degrees,but Servo2 don't work.(first time) 4、I press button A again,Servo2 works fine

https://github.com/microsoft/jacdac/assets/3880290/3b9c5324-9496-437f-b6a3-2e8b58f76b7b

pelikhan commented 1 year ago

Migth have been fixed, please test again.

smfox10 commented 1 year ago

This problem still exists image

https://github.com/microsoft/jacdac/assets/3880290/244b71ef-d035-4b28-b71c-3896a388454b

tballmsft commented 9 months ago

@smfox10, we have a fix: https://github.com/microsoft/pxt-jacdac/pull/101

Please test.

pelikhan commented 8 months ago

@smfox10 reopen in the problem is still there

smfox10 commented 8 months ago

version image

code: https://makecode.microbit.org/_b2tLX20DCgcC

https://github.com/microsoft/jacdac/assets/3880290/dd52e3d6-4deb-410e-9e4a-cb0656f4f1d7

https://github.com/microsoft/jacdac/assets/3880290/29fd7ba1-4d67-4685-903c-16442f8c900d

@xmeow

xmeow commented 8 months ago

I just managed to setup a local pxt-microbit and jacdac environment. It looks like the servo module only response to one of the enable packets sent to the servo. trace.jd.txt

xmeow commented 8 months ago

The problem is possibly caused by the firmware missed the timing to receive some of the jacdac packets. This will only happen when both servos are powered off, and the dedicated position is different from the current position.

And this can be reproduced in the dashboard by following steps:

  1. download following code to microbit
    
    console.log("Servo test")

basic.showIcon(IconNames.Heart) // basic.pause(100) // modules.servo1.setEnabled(true) // modules.servo2.setEnabled(true) // basic.showIcon(IconNames.SmallHeart)

input.onButtonPressed(Button.A, function () { modules.servo1.setAngle(0) modules.servo2.setAngle(0) })

input.onButtonPressed(Button.B, function () { modules.servo1.setAngle(90) modules.servo2.setAngle(90) })

2. Reset the servo module from dashboard. Make sure both servo module is powered off. **This is important**
3. click button B, both servo service will try to power on the servo, then move to 90.

Only one of the servo may got powered on or moved, and there is massive RX t/o error in the log.

Here is some codalLogStore dump:

0x20000010 : "\201\002" 0x20000013 <codalLogStore+3>: "" 0x20000014 <codalLogStore+4>: "ADC calib: 0x48\nrtc: 1s=32180 ticks; presc=1005\nfree:5716\nstk:68\nstk:272\n[#0 0 6 0]\nstk:408\n[#0 0 7 0]\nstk:448\ncmd: 0x2001 1\n[#1 0 6 0x2001 1]\n[#3 0 init 6]\n[#2 pulse 0 6 500]\n! RX t/o\n! RX t/o\n! RX t"... 0x200000dc <codalLogStore+204>: "/o\n! RX t/o\n! RX t/o\n! RX t/o\n! RX t/o\n! RX t/o\n! RX t/o\n! RX t/o\n! RX t/o\ncmd: 0x2001 1\n[#1 1 6 0x2001 1]\n[#2 pulse 1 6 500]\ncmd: 0x2002 1\n[#1 2 6 0x2002 1]\n[#2 pulse 2 6 1500]\ncmd: 0x2001 2\n[#1 3 7 "... 0x200001a4 <codalLogStore+404>: "0x2001 1]\n[#3 3 init 7]\n[#2 pulse 3 7 500]\ncmd: 0x2002 2\n[#1 4 7 0x2002 1]\n[#2 pulse 4 7 1500]\ncmd: 0x2001 1\n[#1 5 6 0x2001 0]\ncmd: 0x2001 2\n[#1 6 7 0x2001 0]\ncmd: 0x2001 1\n[#1 7 6 0x2001 1]\n[#2 pulse"... 0x2000026c <codalLogStore+604>: " 7 6 1500]\n! RX t/o\n! short frm\n! RX t/o\n" --Type for more, q to quit, c to continue without paging--c 0x20000296 <codalLogStore+646>: "" 0x20000297 <codalLogStore+647>: "" 0x20000298 <codalLogStore+648>: ""