Post by Max on May 23, 2016 0:31:39 GMT -7
This is an "archived" copy of the topic from previous hosting.
Posted by nad » Sun Apr 17, 2016 1:00 pm
Hi Everyone,
I did dobot myself, so i don't have dobot boards. I have Arduino mega,ramps 1.4 and a4988 drivers. Can i use open-dobot? Sorry for my amateur.
I tried to control but i couldn't. Firstly i used this code (github.com/erwincoumans/7433a9ea7951932b9d79) but i couldn't send position commands on the terminal. After i tried this way (github.com/paulmorrishill/armour) but when i started "ConsoleArmControl" on visualbasic, console window is empty. How can i control this dobot?
Thanks...
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sun Apr 17, 2016 5:24 pm
The first link you posted is broken. This is the correct one https://gist.github.com/erwincoumans/74... 51932b9d79
So, erwin's gist is just a proof of concept that just moves all three steppers for 1000 steps each with acceleration/deceleration and cannot be controlled from computer.
Paul made use of repetier firmware. That can be controlled with G-codes (like a 3D-printer). You can use Repetier host for that.
As for open-dobot, 0.1 is the only version that supports ramps github.com/maxosprojects/open-dobot/tree/0.1
You can get it into Arduino and control with corresponding python driver (python/ramps/Dobot.py). There is an example how to do that (python/ramps/example.py).
I plan no future releases for ramps version as there are certain limitations to what Arduino is capable to do without additional hardware and the protocol dobot's fpga board understands is now well known. So no point to not use fpga board. That said and the fact that I don't have time to support both versions and no one else has expressed any interest in doing so, right now prospect for ramps version doesn't look promising.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Mon Apr 18, 2016 8:49 am
Thanks for your helping reply.
I tried paul's way, when i started "ConsoleArmControl" in visual studio
this window is empty. but i can control on repetier firmware.
Image
How can i install open-dobot? Must i change files with original dobot software's files? Sorry, I would not be plagued you with this. I don't have enough information, I'm trying to learn.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Mon Apr 18, 2016 11:53 am
To get open-dobot 0.1 running on ramps open the Arduino project github.com/maxosprojects/open-d ... rmware.ino in Arduino IDE and click the upload button. I hope you've used Arduino IDE? If not, then there are plenty of resources and tutorials on the internet how to use Arduino IDE.
After you've flashed the firmware to your Arduino Mega, use the the example github.com/maxosprojects/open-d ... example.py
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Tue Apr 19, 2016 1:49 am
Thanks, its worked. İts only for test i guess, how can i control?
like with this codes? accel(254, 1, False)
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Tue Apr 19, 2016 9:21 am
nad wrote:
Thanks, its worked. İts only for test i guess, how can i control?
like with this codes? accel(254, 1, False)
accel() is a function in that example. It issues a sequence of Steps() commands with different number of steps and scalers for each joint to make a smooth and accelerated/decelerated move. See Dobot.py in the same folder for details.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Sat May 07, 2016 12:15 pm
Thanksvery much! Can i adjust new versions for ramps 1.4? Is there anyway?
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sat May 07, 2016 12:56 pm
nad wrote:
Thanksvery much! Can i adjust new versions for ramps 1.4? Is there anyway?
The fpga firmware version relies on the fpga board to handle stepping and execute commands at exactly 50Hz. If fpga firmware version was adapted to ramps these two functions would have to be implemented in Arduino, which would make the firmware more complex as interrupts will be required for both functions, which brings concurrency.
However, if there are at least couple of people wanting ramps and don't mind adding second Arduino I think it would be possible to emulate fpga on it and offload these functions to it. So the main firmware will remain without changes, but the second one, for the Arduino that will be actually connected to ramps hat, will have its own firmware, still quite simple: there will be no queueing there, no crc, no confirmations and it will set the 50Hz pace - no concurrency.
Adapting the Driver and SDK to the ramps firmware could be another option, but then ramps firmware would have to be extended to support all functions that fpga firmware version does. As I said before, you are free to do that. I can only provide guidance if someone needs, but I won't support ramps version myself - I simply don't have time to support two firmware branches.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Sun May 08, 2016 9:18 am
Max wrote:
nad wrote:
Thanksvery much! Can i adjust new versions for ramps 1.4? Is there anyway?
The fpga firmware version relies on the fpga board to handle stepping and execute commands at exactly 50Hz. If fpga firmware version was adapted to ramps these two functions would have to be implemented in Arduino, which would make the firmware more complex as interrupts will be required for both functions, which brings concurrency.
However, if there are at least couple of people wanting ramps and don't mind adding second Arduino I think it would be possible to emulate fpga on it and offload these functions to it. So the main firmware will remain without changes, but the second one, for the Arduino that will be actually connected to ramps hat, will have its own firmware, still quite simple: there will be no queueing there, no crc, no confirmations and it will set the 50Hz pace - no concurrency.
Adapting the Driver and SDK to the ramps firmware could be another option, but then ramps firmware would have to be extended to support all functions that fpga firmware version does. As I said before, you are free to do that. I can only provide guidance if someone needs, but I won't support ramps version myself - I simply don't have time to support two firmware branches.
oh,this sounds quite difficult for me. Sorry, i don't have enough technical knowledge to make them. I need to have its own control board for follow your works. Do you have any documents about dobot's control board(like pcb files..)?
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sun May 08, 2016 12:09 pm
nad wrote:
...I need to have its own control board for follow your works. Do you have any documents about dobot's control board(like pcb files..)?
Can you maybe rephrase? I didn't get that.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Mon May 09, 2016 9:40 am
Max wrote:
nad wrote:
...I need to have its own control board for follow your works. Do you have any documents about dobot's control board(like pcb files..)?
Can you maybe rephrase? I didn't get that.
open-dobot works with Dobot's original control board, right? I don't have Dobot's original control board because i made it, i didn't buy. Sorry for my bad english.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Mon May 09, 2016 12:05 pm
nad wrote:
Max wrote:
nad wrote:
...I need to have its own control board for follow your works. Do you have any documents about dobot's control board(like pcb files..)?
Can you maybe rephrase? I didn't get that.
open-dobot works with Dobot's original control board, right? I don't have Dobot's original control board because i made it, i didn't buy. Sorry for my bad english.
Oh, I see what you mean.
As I said:
if there are at least couple of people wanting ramps and don't mind adding second Arduino I think it would be possible to emulate fpga on it and offload these functions to it. So the main firmware will remain without changes, but the second one, for the Arduino that will be actually connected to ramps hat, will have its own firmware, still quite simple: there will be no queueing there, no crc, no confirmations and it will set the 50Hz pace - no concurrency.
That means that for people not having the FPGA board (who built the arm themselves, or fpga board got broken for any reason, or just don't want to use it for any reason) it would be possible to emulate it on a separate Arduino. So, instead of original set of "Arduino + FPGA board" you get "Arduino + Arduino". The second Arduino gets its own firmware to emulate the FPGA board. That way the stepping and PWM functions and fine resolution are still easily maintained, both firmwares are still simple (including being simple to extend functionality) and we still support both variations easily.
As this is an open-source project, anyone is free to implement the firmware for the second Arduino. I will provide guidance, but I will not participate in implementation other than that unless there are at least couple of people committed to this approach.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Thu May 12, 2016 10:46 am
That means that for people not having the FPGA board (who built the arm themselves, or fpga board got broken for any reason, or just don't want to use it for any reason) it would be possible to emulate it on a separate Arduino. So, instead of original set of "Arduino + FPGA board" you get "Arduino + Arduino". The second Arduino gets its own firmware to emulate the FPGA board. That way the stepping and PWM functions and fine resolution are still easily maintained, both firmwares are still simple (including being simple to extend functionality) and we still support both variations easily.
As this is an open-source project, anyone is free to implement the firmware for the second Arduino. I will provide guidance, but I will not participate in implementation other than that unless there are at least couple of people committed to this approach.
if emulated second arduino works with dobot tools and open-dobot, it would be great. I would love to try, but I do not have enough technical knowledge to do it. :roll:
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Fri May 13, 2016 11:21 pm
Can you help me?, I want to try to emulate.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sat May 14, 2016 11:50 am
nad wrote:
Can you help me?, I want to try to emulate.
You are so far the only person interested in this. I can only provide guidance in this case.
Here is an outline of what and how to do:
Don't use Arduino IDE or its libraries and program to AVR libraries instead. This is how open-dobot is built (the FPGA version). This way you avoid unnecessary interrupts (for millis() and such) and have perfect timing in your firmware. You can leverage the build script github.com/maxosprojects/open-d ... /upload.sh to build and upload the firmware. You can use a simple text editor with syntax highlighting. I use Sublime.
Program one of the simple timers to call ISR every 20ms (50Hz). This ISR will request next command from the main Arduino via SPI and program five other timers to do stepping for three steppers and PWM for two servos according to the previous command (there is one-command-latency in FPGA, which makes sense).
Rewire RAMPS to connect stepping pins to corresponding pins on Arduino so that stepping is driven directly by the timers avoiding software interrupts. This is required because while the two boards talk to each other the previous command has to still be executed at the same time (you don't want the arm to be stopped while receiving next command which would make it jerky). Timing is critical to maintain head-to-tail SPI flow. You can't afford stack operations in between. Besides, driving steppers with timers directly makes hardware take care of that which makes timing perfect and stepping independent to what firmware does at the same time.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Wed May 18, 2016 10:35 pm
Max wrote:
nad wrote:
Can you help me?, I want to try to emulate.
You are so far the only person interested in this. I can only provide guidance in this case.
Here is an outline of what and how to do:
Don't use Arduino IDE or its libraries and program to AVR libraries instead. This is how open-dobot is built (the FPGA version). This way you avoid unnecessary interrupts (for millis() and such) and have perfect timing in your firmware. You can leverage the build script github.com/maxosprojects/open-d ... /upload.sh to build and upload the firmware. You can use a simple text editor with syntax highlighting. I use Sublime.
Program one of the simple timers to call ISR every 20ms (50Hz). This ISR will request next command from the main Arduino via SPI and program five other timers to do stepping for three steppers and PWM for two servos according to the previous command (there is one-command-latency in FPGA, which makes sense).
Rewire RAMPS to connect stepping pins to corresponding pins on Arduino so that stepping is driven directly by the timers avoiding software interrupts. This is required because while the two boards talk to each other the previous command has to still be executed at the same time (you don't want the arm to be stopped while receiving next command which would make it jerky). Timing is critical to maintain head-to-tail SPI flow. You can't afford stack operations in between. Besides, driving steppers with timers directly makes hardware take care of that which makes timing perfect and stepping independent to what firmware does at the same time.
I guess There are few peoples who make itself dobot so hard to find another for who want emulate fpga.
Thank you Max, You've been very helpful. I regret to say, I couldn't.
I want to deal with dobot as a hobby project, I did mechanics. Software knowledge lack. I think fpga schematics to be shared as open source, but I was wrong.
And I agree wrote on reddit. The term open source used for advertising purposes.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Wed May 18, 2016 11:49 pm
Dude, you are killing me. I can't stand you feeling so upset. It made me think about that again, from the value perspective too.
So, given dobot team's dishonesty and obvious greed we can expect them releasing new versions of hardware to make it harder and harder to reverse engineer, so a backup plan may be of great value. This already happened with v1.1 where they replaced accelerometers and because I don't have one of used there and no one volunteered to send me one to reverse engineer there is currently no support for those new accelerometers in open-dobot.
What I can't promise right now is that we would get something working from the following.
What I do promise is that I will give it a good thought over the next couple of days and perhaps try to get RAMPS working with current open-dobot SDK and only one Arduino while still supporting FPGA version - just two separate firmware versions easily compilable from the same codebase by only turning preprocessor flags on/off. I got an idea how to do that.
I also like the idea of controlling dobot with only one Raspberry Pi (credit to Mike www.reddit.com/r/Dobot/comments ... erry_pi_3/), but it is rather not viable with popular distros (like Raspbian) as they aren't RT. BeagleBoneBlack (BBB) looks very interesting, but it is quite expensive compared to Arduino, plus I'm not too excited about reimplementing firmware to PRU.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Sun May 22, 2016 7:38 am
Thank you very much,dude.
It is great for me, I'm following you. I can't do anything other than to follow anyway. but I'm trying to figure out how you're doing your work.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sun May 22, 2016 8:31 am
This branch github.com/maxosprojects/open-dobot/tree/ramps has already support for RAMPS. I was able to execute example-sdk.py with it on RAMPS. Uses interrupts at only 50kHz rate for stepping, to save other timers for other things that one may need. I'd prefer to do stepping in hardware driven directly by timers, but there are only that many many of them (just 5) and every motor requres one timer - 3 steppers and 2 servos - so nothing will be left. The firmware would've been so much simpler with hardware stepping and stepping itself wouln't have any jitter, though you can't notice the jitter without an oscilloscope anyway, all works smoothly as with fpga board.
Right now there is no support for accelerometers for ramps version yet so the starting pose must be accurately set. This is the thing for today - add support for GY-521 (sporting MPU-6050) and then I'll release it. After the initial release with support for ramps I'll add PWM for servos and all done.
=======
Re: Open-dobot with Ramps?
PostPosted by mikef522 » Sun May 22, 2016 9:56 pm
Awesome stuff! Thanks for the RAMPS firmware rewrite Max! And on my birthday . I started really digging through your old ramps code about a week ago, after our reddit discussion in the raspberry pi topic. Your code is really quite impeccable (at least to my eyes). I watched a bunch of embedded systems lecture videos and did some reading and your code was really by the book!
After briefly looking into the BBB, I concluded (as you already know) that it would be absolute hell to program the PRUs. I decided instead to suck it up and learn how command queues and interrupts work and so forth and go back to the RAMPS route. I did get your old ramps code to work (see my github here if interested, I didn't change much), but I ran into a problem of not being able to execute the commands fast enough if I tried to send commands to rotate the motors one step at a time. I still need to look at the way you plan your linear trajectories, but the way I do it is for a given line, I generate a list of steps for each of the 3 stepper motors (associated with a direction). I then send each step and direction (one by one) serially to the arduino. I sort of have a hunch that it's a problem with the serial communication transfer rate or a timing issue (I think you said you have to give the arduino how many steps to execute within 30ms at a time or something like that), but I didn't have time to troubleshoot. If I send one command to take say 30 steps [dobot.Steps(1, 1, 1,30, 0, 0, 0, False)], the movement is smooth, but it starts to have to pause between each command if I try to send commands with smaller amounts of steps [dobot.Steps(1, 1, 1,1, 0, 0, 0, False)]. If it was a timing issue, I was just going to try to figure out how to determine direction of each step within a command of say 30 steps. If you have any ideas about what was going wrong for me, awesome; otherwise, I'll figure it out eventually (and it sounds like your new code will be a better replacement anyways).
This week is really busy for me, but I'll try and dive into your new code this weekend!
Also, for nad and anybody else reading this, I highly recommend watching the embedded systems lectures from the youtube playlists hereand hereif you want to really learn how to program the arduino microcontroller for use with Dobot. Also, I'll leave by adding some especially helpful links below (the following text is taken from comments in my code):
Resources to help you understand the code (can get fairly technical for non-electrical engineers, but the most useful stuff can be understood by programmers):
www.youtube.com/watch?v=kFweLvioovo Arduino IDE (near the end, it briefly discusses how fast serial data can be sent on the arduino)
www.youtube.com/watch?v=faCVhp7gm-g Arduino Timers and Counters
www.youtube.com/watch?v=twaeLkE6eS8 lecture describing serial communication basics, useful lectures afterwards too
www.youtube.com/watch?v=PGf98rGBEJk Queues in serial communication
www.youtube.com/watch?v=Mr7rkEX0SxM Serial communication examples (part 1 of 3 part lecture, discusses queues)
Timers and interrupts, concise, comprehensive, and intuitive explanation, good for quick references
www.instructables.com/id/Arduino ... nterrupts/
arduino-info.wikispaces.com/Timers-Arduino
"Interrupts are integrally woven throughout the whole fabric of the arduino" (i.e. they're super important and you should learn about them if you're messing with this code)
www.youtube.com/watch?v=BUubcDvvOPo Arduino Interrupt Processing Part I (of 2 part series) [This explains the use of the volatile keyword, summarized below]
A brief explanation of the volatile keyword: If a variable is shared between a normal function (e.g. the loop() function) and an interrupt function (aka ISR aka Interrupt Service Routine), it should be declared volatile. This is because the ISR interrupts the normal function and can change the shared variable in the normal function. Upon finished execution of the ISR, the program returns to the normal function and may use the modified shared variable (that was changed by the ISR). If the variable was not declared volatile, then the value of the variableas set by the ISR will not be used (because the normal function has not modified the memory to update the value of the shared variable). If the shared variable was identified as volatile,upon return to the normal function, the shared variable is updated to the value set by the ISR. So, I'm not sure if this is right, but it is only necessary to declare a shared variable voaltile if it will be modified by the ISR? and not simply used? though I imagine it's probably best practice to declare the variable volatile anyways, even if it's only read?
Posted by nad » Sun Apr 17, 2016 1:00 pm
Hi Everyone,
I did dobot myself, so i don't have dobot boards. I have Arduino mega,ramps 1.4 and a4988 drivers. Can i use open-dobot? Sorry for my amateur.
I tried to control but i couldn't. Firstly i used this code (github.com/erwincoumans/7433a9ea7951932b9d79) but i couldn't send position commands on the terminal. After i tried this way (github.com/paulmorrishill/armour) but when i started "ConsoleArmControl" on visualbasic, console window is empty. How can i control this dobot?
Thanks...
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sun Apr 17, 2016 5:24 pm
The first link you posted is broken. This is the correct one https://gist.github.com/erwincoumans/74... 51932b9d79
So, erwin's gist is just a proof of concept that just moves all three steppers for 1000 steps each with acceleration/deceleration and cannot be controlled from computer.
Paul made use of repetier firmware. That can be controlled with G-codes (like a 3D-printer). You can use Repetier host for that.
As for open-dobot, 0.1 is the only version that supports ramps github.com/maxosprojects/open-dobot/tree/0.1
You can get it into Arduino and control with corresponding python driver (python/ramps/Dobot.py). There is an example how to do that (python/ramps/example.py).
I plan no future releases for ramps version as there are certain limitations to what Arduino is capable to do without additional hardware and the protocol dobot's fpga board understands is now well known. So no point to not use fpga board. That said and the fact that I don't have time to support both versions and no one else has expressed any interest in doing so, right now prospect for ramps version doesn't look promising.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Mon Apr 18, 2016 8:49 am
Thanks for your helping reply.
I tried paul's way, when i started "ConsoleArmControl" in visual studio
this window is empty. but i can control on repetier firmware.
Image
How can i install open-dobot? Must i change files with original dobot software's files? Sorry, I would not be plagued you with this. I don't have enough information, I'm trying to learn.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Mon Apr 18, 2016 11:53 am
To get open-dobot 0.1 running on ramps open the Arduino project github.com/maxosprojects/open-d ... rmware.ino in Arduino IDE and click the upload button. I hope you've used Arduino IDE? If not, then there are plenty of resources and tutorials on the internet how to use Arduino IDE.
After you've flashed the firmware to your Arduino Mega, use the the example github.com/maxosprojects/open-d ... example.py
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Tue Apr 19, 2016 1:49 am
Thanks, its worked. İts only for test i guess, how can i control?
like with this codes? accel(254, 1, False)
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Tue Apr 19, 2016 9:21 am
nad wrote:
Thanks, its worked. İts only for test i guess, how can i control?
like with this codes? accel(254, 1, False)
accel() is a function in that example. It issues a sequence of Steps() commands with different number of steps and scalers for each joint to make a smooth and accelerated/decelerated move. See Dobot.py in the same folder for details.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Sat May 07, 2016 12:15 pm
Thanksvery much! Can i adjust new versions for ramps 1.4? Is there anyway?
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sat May 07, 2016 12:56 pm
nad wrote:
Thanksvery much! Can i adjust new versions for ramps 1.4? Is there anyway?
The fpga firmware version relies on the fpga board to handle stepping and execute commands at exactly 50Hz. If fpga firmware version was adapted to ramps these two functions would have to be implemented in Arduino, which would make the firmware more complex as interrupts will be required for both functions, which brings concurrency.
However, if there are at least couple of people wanting ramps and don't mind adding second Arduino I think it would be possible to emulate fpga on it and offload these functions to it. So the main firmware will remain without changes, but the second one, for the Arduino that will be actually connected to ramps hat, will have its own firmware, still quite simple: there will be no queueing there, no crc, no confirmations and it will set the 50Hz pace - no concurrency.
Adapting the Driver and SDK to the ramps firmware could be another option, but then ramps firmware would have to be extended to support all functions that fpga firmware version does. As I said before, you are free to do that. I can only provide guidance if someone needs, but I won't support ramps version myself - I simply don't have time to support two firmware branches.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Sun May 08, 2016 9:18 am
Max wrote:
nad wrote:
Thanksvery much! Can i adjust new versions for ramps 1.4? Is there anyway?
The fpga firmware version relies on the fpga board to handle stepping and execute commands at exactly 50Hz. If fpga firmware version was adapted to ramps these two functions would have to be implemented in Arduino, which would make the firmware more complex as interrupts will be required for both functions, which brings concurrency.
However, if there are at least couple of people wanting ramps and don't mind adding second Arduino I think it would be possible to emulate fpga on it and offload these functions to it. So the main firmware will remain without changes, but the second one, for the Arduino that will be actually connected to ramps hat, will have its own firmware, still quite simple: there will be no queueing there, no crc, no confirmations and it will set the 50Hz pace - no concurrency.
Adapting the Driver and SDK to the ramps firmware could be another option, but then ramps firmware would have to be extended to support all functions that fpga firmware version does. As I said before, you are free to do that. I can only provide guidance if someone needs, but I won't support ramps version myself - I simply don't have time to support two firmware branches.
oh,this sounds quite difficult for me. Sorry, i don't have enough technical knowledge to make them. I need to have its own control board for follow your works. Do you have any documents about dobot's control board(like pcb files..)?
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sun May 08, 2016 12:09 pm
nad wrote:
...I need to have its own control board for follow your works. Do you have any documents about dobot's control board(like pcb files..)?
Can you maybe rephrase? I didn't get that.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Mon May 09, 2016 9:40 am
Max wrote:
nad wrote:
...I need to have its own control board for follow your works. Do you have any documents about dobot's control board(like pcb files..)?
Can you maybe rephrase? I didn't get that.
open-dobot works with Dobot's original control board, right? I don't have Dobot's original control board because i made it, i didn't buy. Sorry for my bad english.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Mon May 09, 2016 12:05 pm
nad wrote:
Max wrote:
nad wrote:
...I need to have its own control board for follow your works. Do you have any documents about dobot's control board(like pcb files..)?
Can you maybe rephrase? I didn't get that.
open-dobot works with Dobot's original control board, right? I don't have Dobot's original control board because i made it, i didn't buy. Sorry for my bad english.
Oh, I see what you mean.
As I said:
if there are at least couple of people wanting ramps and don't mind adding second Arduino I think it would be possible to emulate fpga on it and offload these functions to it. So the main firmware will remain without changes, but the second one, for the Arduino that will be actually connected to ramps hat, will have its own firmware, still quite simple: there will be no queueing there, no crc, no confirmations and it will set the 50Hz pace - no concurrency.
That means that for people not having the FPGA board (who built the arm themselves, or fpga board got broken for any reason, or just don't want to use it for any reason) it would be possible to emulate it on a separate Arduino. So, instead of original set of "Arduino + FPGA board" you get "Arduino + Arduino". The second Arduino gets its own firmware to emulate the FPGA board. That way the stepping and PWM functions and fine resolution are still easily maintained, both firmwares are still simple (including being simple to extend functionality) and we still support both variations easily.
As this is an open-source project, anyone is free to implement the firmware for the second Arduino. I will provide guidance, but I will not participate in implementation other than that unless there are at least couple of people committed to this approach.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Thu May 12, 2016 10:46 am
That means that for people not having the FPGA board (who built the arm themselves, or fpga board got broken for any reason, or just don't want to use it for any reason) it would be possible to emulate it on a separate Arduino. So, instead of original set of "Arduino + FPGA board" you get "Arduino + Arduino". The second Arduino gets its own firmware to emulate the FPGA board. That way the stepping and PWM functions and fine resolution are still easily maintained, both firmwares are still simple (including being simple to extend functionality) and we still support both variations easily.
As this is an open-source project, anyone is free to implement the firmware for the second Arduino. I will provide guidance, but I will not participate in implementation other than that unless there are at least couple of people committed to this approach.
if emulated second arduino works with dobot tools and open-dobot, it would be great. I would love to try, but I do not have enough technical knowledge to do it. :roll:
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Fri May 13, 2016 11:21 pm
Can you help me?, I want to try to emulate.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sat May 14, 2016 11:50 am
nad wrote:
Can you help me?, I want to try to emulate.
You are so far the only person interested in this. I can only provide guidance in this case.
Here is an outline of what and how to do:
Don't use Arduino IDE or its libraries and program to AVR libraries instead. This is how open-dobot is built (the FPGA version). This way you avoid unnecessary interrupts (for millis() and such) and have perfect timing in your firmware. You can leverage the build script github.com/maxosprojects/open-d ... /upload.sh to build and upload the firmware. You can use a simple text editor with syntax highlighting. I use Sublime.
Program one of the simple timers to call ISR every 20ms (50Hz). This ISR will request next command from the main Arduino via SPI and program five other timers to do stepping for three steppers and PWM for two servos according to the previous command (there is one-command-latency in FPGA, which makes sense).
Rewire RAMPS to connect stepping pins to corresponding pins on Arduino so that stepping is driven directly by the timers avoiding software interrupts. This is required because while the two boards talk to each other the previous command has to still be executed at the same time (you don't want the arm to be stopped while receiving next command which would make it jerky). Timing is critical to maintain head-to-tail SPI flow. You can't afford stack operations in between. Besides, driving steppers with timers directly makes hardware take care of that which makes timing perfect and stepping independent to what firmware does at the same time.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Wed May 18, 2016 10:35 pm
Max wrote:
nad wrote:
Can you help me?, I want to try to emulate.
You are so far the only person interested in this. I can only provide guidance in this case.
Here is an outline of what and how to do:
Don't use Arduino IDE or its libraries and program to AVR libraries instead. This is how open-dobot is built (the FPGA version). This way you avoid unnecessary interrupts (for millis() and such) and have perfect timing in your firmware. You can leverage the build script github.com/maxosprojects/open-d ... /upload.sh to build and upload the firmware. You can use a simple text editor with syntax highlighting. I use Sublime.
Program one of the simple timers to call ISR every 20ms (50Hz). This ISR will request next command from the main Arduino via SPI and program five other timers to do stepping for three steppers and PWM for two servos according to the previous command (there is one-command-latency in FPGA, which makes sense).
Rewire RAMPS to connect stepping pins to corresponding pins on Arduino so that stepping is driven directly by the timers avoiding software interrupts. This is required because while the two boards talk to each other the previous command has to still be executed at the same time (you don't want the arm to be stopped while receiving next command which would make it jerky). Timing is critical to maintain head-to-tail SPI flow. You can't afford stack operations in between. Besides, driving steppers with timers directly makes hardware take care of that which makes timing perfect and stepping independent to what firmware does at the same time.
I guess There are few peoples who make itself dobot so hard to find another for who want emulate fpga.
Thank you Max, You've been very helpful. I regret to say, I couldn't.
I want to deal with dobot as a hobby project, I did mechanics. Software knowledge lack. I think fpga schematics to be shared as open source, but I was wrong.
And I agree wrote on reddit. The term open source used for advertising purposes.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Wed May 18, 2016 11:49 pm
Dude, you are killing me. I can't stand you feeling so upset. It made me think about that again, from the value perspective too.
So, given dobot team's dishonesty and obvious greed we can expect them releasing new versions of hardware to make it harder and harder to reverse engineer, so a backup plan may be of great value. This already happened with v1.1 where they replaced accelerometers and because I don't have one of used there and no one volunteered to send me one to reverse engineer there is currently no support for those new accelerometers in open-dobot.
What I can't promise right now is that we would get something working from the following.
What I do promise is that I will give it a good thought over the next couple of days and perhaps try to get RAMPS working with current open-dobot SDK and only one Arduino while still supporting FPGA version - just two separate firmware versions easily compilable from the same codebase by only turning preprocessor flags on/off. I got an idea how to do that.
I also like the idea of controlling dobot with only one Raspberry Pi (credit to Mike www.reddit.com/r/Dobot/comments ... erry_pi_3/), but it is rather not viable with popular distros (like Raspbian) as they aren't RT. BeagleBoneBlack (BBB) looks very interesting, but it is quite expensive compared to Arduino, plus I'm not too excited about reimplementing firmware to PRU.
=======
Re: Open-dobot with Ramps?
PostPosted by nad » Sun May 22, 2016 7:38 am
Thank you very much,dude.
It is great for me, I'm following you. I can't do anything other than to follow anyway. but I'm trying to figure out how you're doing your work.
=======
Re: Open-dobot with Ramps?
PostPosted by Max » Sun May 22, 2016 8:31 am
This branch github.com/maxosprojects/open-dobot/tree/ramps has already support for RAMPS. I was able to execute example-sdk.py with it on RAMPS. Uses interrupts at only 50kHz rate for stepping, to save other timers for other things that one may need. I'd prefer to do stepping in hardware driven directly by timers, but there are only that many many of them (just 5) and every motor requres one timer - 3 steppers and 2 servos - so nothing will be left. The firmware would've been so much simpler with hardware stepping and stepping itself wouln't have any jitter, though you can't notice the jitter without an oscilloscope anyway, all works smoothly as with fpga board.
Right now there is no support for accelerometers for ramps version yet so the starting pose must be accurately set. This is the thing for today - add support for GY-521 (sporting MPU-6050) and then I'll release it. After the initial release with support for ramps I'll add PWM for servos and all done.
=======
Re: Open-dobot with Ramps?
PostPosted by mikef522 » Sun May 22, 2016 9:56 pm
Awesome stuff! Thanks for the RAMPS firmware rewrite Max! And on my birthday . I started really digging through your old ramps code about a week ago, after our reddit discussion in the raspberry pi topic. Your code is really quite impeccable (at least to my eyes). I watched a bunch of embedded systems lecture videos and did some reading and your code was really by the book!
After briefly looking into the BBB, I concluded (as you already know) that it would be absolute hell to program the PRUs. I decided instead to suck it up and learn how command queues and interrupts work and so forth and go back to the RAMPS route. I did get your old ramps code to work (see my github here if interested, I didn't change much), but I ran into a problem of not being able to execute the commands fast enough if I tried to send commands to rotate the motors one step at a time. I still need to look at the way you plan your linear trajectories, but the way I do it is for a given line, I generate a list of steps for each of the 3 stepper motors (associated with a direction). I then send each step and direction (one by one) serially to the arduino. I sort of have a hunch that it's a problem with the serial communication transfer rate or a timing issue (I think you said you have to give the arduino how many steps to execute within 30ms at a time or something like that), but I didn't have time to troubleshoot. If I send one command to take say 30 steps [dobot.Steps(1, 1, 1,30, 0, 0, 0, False)], the movement is smooth, but it starts to have to pause between each command if I try to send commands with smaller amounts of steps [dobot.Steps(1, 1, 1,1, 0, 0, 0, False)]. If it was a timing issue, I was just going to try to figure out how to determine direction of each step within a command of say 30 steps. If you have any ideas about what was going wrong for me, awesome; otherwise, I'll figure it out eventually (and it sounds like your new code will be a better replacement anyways).
This week is really busy for me, but I'll try and dive into your new code this weekend!
Also, for nad and anybody else reading this, I highly recommend watching the embedded systems lectures from the youtube playlists hereand hereif you want to really learn how to program the arduino microcontroller for use with Dobot. Also, I'll leave by adding some especially helpful links below (the following text is taken from comments in my code):
Resources to help you understand the code (can get fairly technical for non-electrical engineers, but the most useful stuff can be understood by programmers):
www.youtube.com/watch?v=kFweLvioovo Arduino IDE (near the end, it briefly discusses how fast serial data can be sent on the arduino)
www.youtube.com/watch?v=faCVhp7gm-g Arduino Timers and Counters
www.youtube.com/watch?v=twaeLkE6eS8 lecture describing serial communication basics, useful lectures afterwards too
www.youtube.com/watch?v=PGf98rGBEJk Queues in serial communication
www.youtube.com/watch?v=Mr7rkEX0SxM Serial communication examples (part 1 of 3 part lecture, discusses queues)
Timers and interrupts, concise, comprehensive, and intuitive explanation, good for quick references
www.instructables.com/id/Arduino ... nterrupts/
arduino-info.wikispaces.com/Timers-Arduino
"Interrupts are integrally woven throughout the whole fabric of the arduino" (i.e. they're super important and you should learn about them if you're messing with this code)
www.youtube.com/watch?v=BUubcDvvOPo Arduino Interrupt Processing Part I (of 2 part series) [This explains the use of the volatile keyword, summarized below]
A brief explanation of the volatile keyword: If a variable is shared between a normal function (e.g. the loop() function) and an interrupt function (aka ISR aka Interrupt Service Routine), it should be declared volatile. This is because the ISR interrupts the normal function and can change the shared variable in the normal function. Upon finished execution of the ISR, the program returns to the normal function and may use the modified shared variable (that was changed by the ISR). If the variable was not declared volatile, then the value of the variableas set by the ISR will not be used (because the normal function has not modified the memory to update the value of the shared variable). If the shared variable was identified as volatile,upon return to the normal function, the shared variable is updated to the value set by the ISR. So, I'm not sure if this is right, but it is only necessary to declare a shared variable voaltile if it will be modified by the ISR? and not simply used? though I imagine it's probably best practice to declare the variable volatile anyways, even if it's only read?