raspibotics / MABEL

MABEL is a feature-packed, open-source, legged balancing robot based off of the Boston Dynamics Handle robot.
https://raspibotics.github.io/MABEL/
GNU General Public License v3.0
155 stars 35 forks source link

Can't get YABR code running on Arduino Uno + CNC Shield #3

Closed ghost closed 1 year ago

ghost commented 3 years ago

Hey there, I'm having some issues getting the YABR code working. I've got the same hardware as mentioned in your project. An Arduino Uno (SMD version, should not differ, as far as I researched) and CNC Shield. It seems the code fails on following line: TIMSK2 |= (1 << OCIE2A); The result of running the YABR code are two non functional stepper motors. One of them can be moved by hand, the other one being blocked at a position. Both are producing some noise. I checked the current limit on the driver and used other motor drivers. Unfortunately without success.

I tried to increase OCR2A = 39; to 3999999 which should result in a timer interrupt every 2 seconds instead the 20 µs, but looking into serial output the timer would still spam the code, way faster than 2 seconds. I replaced the Arduino with another one (different brand, same processor, not SMD). Same behavior there. I replaced the writing to PORTD with digitalWrite() but had no luck either.

Could it be possible that I'm missing out on some point not mentioned in the guide?

Greetings, Niko

raspibotics commented 3 years ago

Hi Niko,

I had issues at first with getting my steppers to cooperate. I would suggest testing some seperate example code to see if you can get any sort of movement out. Are you absolutely sure that you've wired the correct stepper coils to the stepper drivers? I know when I did the guide I was following had some inaccuracies so I had to use trial and error as well as measuring the resistance to determine which order the coils should be connected. If they are connected wrong the stepper will move unexpectedly or lock up but when working correctly should activate when the accelerometer reads the critical value.

There shouldn't be too many differences with board pinnout and I'm afraid I can't help diagnose too many software issues with the original YABR code as I left it mostly unchanged and did most of the software on the raspberry pi. Although the original author goes through the code in great detail in these two videos if you rule out hardware.

https://youtu.be/VxpMWncBKZc

https://youtu.be/mG4OtAiY_wU

Hope this helps,

Harry

On Fri, 19 Mar 2021, 16:39 niko-kl, @.***> wrote:

Hey there, I'm having some issues getting the YABR code working. I've got the same hardware as mentioned in your project. An Arduino Uno (SMD version, should not differ, as far as I researched) and CNC Shield. It seems the code fails on following line: TIMSK2 |= (1 << OCIE2A); The result of running the YABR code are two non functional stepper motors. One of them can be moved by hand, the other one being blocked at a position. Both are producing some noise. I checked the current limit on the driver and used other motor drivers. Unfortunately without success.

I tried to increase OCR2A = 39; to 3999999 which should result in a timer interrupt every 2 seconds instead the 20 µs, but looking into serial output the timer would still spam the code, way faster than 2 seconds. I replaced the Arduino with another one (different brand, same processor, not SMD). Same behavior there. I replaced the writing to PORTD with digitalWrite() but had no luck either.

Could it be possible that I'm missing out on some point not mentioned in the guide?

Greetings, Niko

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/raspibotics/MABEL/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALPUOY5GA74MTQY2DK5XW2DTEN42NANCNFSM4ZPEA6QA .

ghost commented 3 years ago

Hi Harry,

thanks for your fast response. I forgot to mention that I succeeded in controlling the stepper motor with some separate test code, before I asked my first question. After watching the two videos you linked I noticed that my driver was set to full instead of 1/4 step mode. Setting the jumper my robot started balancing or at least trying it. So the wheels are spinning now, but way to fast.. resulting in the robot falling over. When tilting the robot I can confirm that the wheels are changing their direction, but they are still spinning, even if I balance the robot manually by hand. Did you experience something similar? Did also correct my MPU position to being equal to the balancing robot in the video. So I can exclude this being a part of the problem.

Current connections on the CNC board are:

Am I missing some jumpers?

Greetings, Niko

raspibotics commented 3 years ago

Hi!

When oriented like the original the MPU calibration value should be around 1000, once I had sorted out hardware issues the thing balanced pretty well with no modifications to the PID values. My microstepping jumper is in the second slot to create a 1/4 step but where you place the jumper will differ depending on the truth table for your particular driver. Are you using A4988 drivers?

Could you send a video, it may help to see what's going on? The wheels do spin very fast in mid air but when angled slowly into position it should just take over and begin balancing.

Harry

On Sun, 21 Mar 2021, 17:28 niko-kl, @.***> wrote:

Hi Harry,

thanks for your fast response. I forgot to mention that I succeeded in controlling the stepper motor with some separate test code, before I asked my first question. After watching the two videos you linked I noticed that my driver was set to full instead of 1/4 step mode. Setting the jumper my robot started balancing or at least trying it. So the wheels are spinning now, but way to fast.. resulting in the robot falling over. When tilting the robot I can confirm that the wheels are changing their direction, but they are still spinning, even if I balance the robot manually by hand. Did you experience something similar? Did also correct my MPU position to being equal to the balancing robot in the video. So I can exclude this being a part of the problem.

Current connections on the CNC board are:

  • drivers, stepper motor, 1/4 step jumpers
  • EN/GND jumper to enable the board
  • power input for stepper motor
  • MPU connection with SDA/SCL

Am I missing some jumpers?

Greetings, Niko

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/raspibotics/MABEL/issues/3#issuecomment-803628130, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALPUOY47OR5PPTDDAKQSCSDTEYUEBANCNFSM4ZPEA6QA .

ghost commented 3 years ago

Hey,

yes I'm using the A4988 driver, so my microstepping jumper is also set on the second slot. Meanwhile I was able to find my problem. The stepper coils were indeed wired wrong. Fixing that the balancing part finally works.

I made still a video for the (new) sound my stepper motors are producing when I'm lifting the robot. My best guess would be that the current limitation is set wrong. By looking into the datasheet, I read a motor needs 1.7A. So Vref on the driver should be half of that. But neither 0.85V nor less than tha (down to 0.5V) would fix this. Other than that I'd need to get another power adapter, since mine has 12V and only 2.5A, so I can exclude that as an issue.

Niko

raspibotics commented 3 years ago

Hi!

Wow that's awesome, the Motors have a tendency to do that when they've stalled, if you increase the motor current allowed this should solve that although it will still stall in extreme cases, only thing you can do is to tip the robot on its side which will reset the motors. By the way us mentioned setting the VREF to 0.85v for 1.7A, this would be correct for DRV8825 drivers but for A4988 the formula used is slightly different and is based on one of the SMD resistors. This guide should help you set the correct Vref but it may still stall in extreme cases.

https://e3d-online.dozuki.com/Guide/VREF+adjustment+A4988/92

Harry

On Sun, 21 Mar 2021, 19:35 niko-kl, @.***> wrote:

Hey,

yes I'm using the A4988 driver, so my microstepping jumper is also set on the second slot. Meanwhile I was able to find my problem. The stepper coils were indeed wired wrong. Fixing that the balancing part finally works.

I made still a video https://drive.google.com/file/d/13ucOEg1BF7VQoPmIf4q2sNA6-ISzJRO4/view?usp=sharing for the (new) sound my stepper motors are producing when I'm lifting the robot. My best guess would be that the current limitation is set wrong. By looking into the datasheet, I read a motor needs 1.7A. So Vref on the driver should be half of that. But neither 0.85V nor less than tha (down to 0.5V) would fix this. Other than that I'd need to get another power adapter, since mine has 12V and only 2.5A, so I can exclude that as an issue.

Niko

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/raspibotics/MABEL/issues/3#issuecomment-803646988, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALPUOY6FARBX2XB5TCF2LTTTEZDBRANCNFSM4ZPEA6QA .

ghost commented 3 years ago

Hey there,

I guess I have the Stepstick or a clone driver since it's red colored. There is not datasheet available where I bought it. Taking the information for Rs = 0,2 out of here and input there 1.7A as rated current I get 2.18V for Vref.. which is probably way to high and wrong. I tried to adjust the driver current to 1V and the motor began to get small pulses in idle, so I stopped there. Adjusted the current just by trial and error and the best value for me seems to be around 0.4 to 0.5 for Vref. Then the motor doesn't even make any sounds in idle. I guess I stick to that solution for the beginning.

raspibotics commented 3 years ago

Hi,

Yeah it's not a major issue, 1.7A does seem quite high however. I got confused with stepper powering early on, the current drawn is dependent on the voltage supplied to the motors, the motor datasheets tend to give a high rated current but it will usually be at a low supply voltage maybe around 3V. Since you're powering off I'm assuming around 12V the actual current should be much lower and the driver current rating should match that. So looking at rated power may be a more useful metric. Trial and error will probably work though and you can always increase it later.

On Wed, 24 Mar 2021, 09:23 niko-kl, @.***> wrote:

Hey there,

I guess I have the Stepstick or a clone driver since it's red colored. There is not datasheet available where I bought it. Taking the information for Rs = 0,2 out of here https://v6zmvq5nk5.codesandbox.io/ and input there 1.7A as rated current I get 2.18V for Vref.. which is probably way to high and wrong. I tried to adjust the driver current to 1V and the motor began to get small pulses in idle, so I stopped there. Adjusted the current just by trial and error and the best value for me seems to be around 0.4 to 0.5 for Vref. Then the motor doesn't even make any sounds in idle. I guess I stick to that solution for the beginning.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/raspibotics/MABEL/issues/3#issuecomment-805638416, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALPUOY7OBTJJ3HU4FTXYMEDTFGVP3ANCNFSM4ZPEA6QA .