Timeline for Arduino Mega 2560 + DRV8871: Motor Not Moving with PWM Control
Current License: CC BY-SA 4.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 2 at 7:38 | vote | accept | Luigi | ||
| Jan 31 at 15:32 | comment | added | InBedded16 | If you mean replacing the while loop with a delay() function, than no it is not exactly the same. You should look into the consequences of delay() to understand better, but it basically pauses your program for that time period which has implications for interrupts and other processes. Probably not a big deal for your program specifically, but best practice is definitely timer based delays. | |
| Jan 31 at 11:09 | comment | added | Luigi |
Thanks. I've tried a simple script and it's working, so the issues are related to my code. I'm improving thanks to your hints. Regarding the while loop when LS hit, is it the same if I write delay(disengage_ls) instead?
|
|
| Jan 30 at 17:25 | comment | added | InBedded16 | @Luigi and all this stuff is normal to iterate through, its why I recommend a simple script to get movement working first - otherwise how do you know if its the PWM thats the problem or the logic in your code? Start from your basic functionality, then build everything else in step by step and make sure it works before you move to the next thing. | |
| Jan 30 at 17:20 | comment | added | InBedded16 | @Luigi two more quick notes: in the while loop for waiting the 500ms after a LS hit, you're continuously calling limSwHit() and then HeadCoast(). This will just continously stop and start the motor. You want to move those two function calls outside the while loop so it runs once, ends in the COAST state, and then enters the while loop to wait those 500ms. Second thing is that you have HeadCoast() inside an else statement, so everytime the accel_interval has not been reached, you switch to the COAST state. Move that to an else if statement that triggers when none of the buttons are pressed. | |
| Jan 30 at 17:12 | history | edited | InBedded16 | CC BY-SA 4.0 |
Removed a critique that was based on a misunderstanding
|
| Jan 30 at 17:12 | comment | added | InBedded16 | @Luigi ah okay I missed where you set zero to millis() in those loops. Yes, that's fine, although something like zeroRef may be a less confusing variable name. | |
| Jan 30 at 16:56 | comment | added | Luigi | Thanks for the in depth analysis. I'm going to make the trials with PWM, in the meanwhile I've updated the code trying to follow your suggestions., please let me know if I understood correctly. I have some doubts on the comment on zero subtraction: I'm setting the time to zero after each time I increase the speed, in order to reset the counter for the next speed increase (where accel_interval is the time between 2 different speed set. I don't understand why you suggest to remove it | |
| Jan 29 at 20:21 | history | edited | InBedded16 | CC BY-SA 4.0 |
added 434 characters in body
|
| Jan 29 at 20:13 | history | edited | InBedded16 | CC BY-SA 4.0 |
added 596 characters in body
|
| Jan 29 at 20:03 | history | answered | InBedded16 | CC BY-SA 4.0 |