Hi.
I have added a few lines to the eggbot extension to be able to "read" the motor voltage.
See this link; (See updated link in post below)
Anyone brave enough to test my code?
Is it OK to post a link to "unofficial" code or does it have to go through "Evil Mad Scientist" for check first?
The EBB also reports motor current as a reference voltage, does anyone know the "factor" for this number?
In the EBB command manual it is only described as a 10 bit number from 0 to 1023.
The schematics for the V2.1 Board have some info:
REF_RA0 Current:
0.0V = 46mA
2.58V = 1.35A
Can we assume a linear range?
What "raw" value does the EBB report for 1.35A?
My EBB shows a "raw" reading of 513 for a (idle or holding) current of 0.56A,
(1.917V across a 3.4Ω winding).
The table for the motor voltage given in the EBB command manual seems quite accurate with a max error of around 0.1V on my EBB using a Fluke 89IV for actual measurement.
My code interpolates from the table given in the manual.
RGDS
Ragnar
Comments
Ok, here's a link to a zip file containing the eggbot.py and eggbot.inx.
http://bit.ly/1juocaa
Code will work on EBB hardware v1.3 and above. (The white boards from EMSL are
v2.0, and all boards from SparkFun are v2.0 and above)
Another small change I made a while ago, on reporting the EBB version the com port settings will be listed as well, you will have to make the window larger to see it. Handy to know which com port to use when sending commands directly to the eggbot.
When making a table for the current measurement I discovered the reported motor voltage is dependent on the setting of the current potmeter, my input voltage was 12.22V and the lowest reported motor voltage was 6.97V!
This with the pot meter set fully counter-clockwice for 0 current. (The silkscreen on the board is incorrect! Counter-clockwice rotation will decrease the current.)
Max reported motor voltage was 14.46V at a motor current of 1.04A.
Any idea on why the reported motor voltage is dependent on the current potmeter setting? The two readings (A & V) uses their own AD input on the microcontroller.
I am not sure of the board revision on my eggbot as there are no version info on the board. Board layout date is 10/27/2010. Maybe my board version is too old?
Update: from the schmalhaus web page; "As of hardware version 1.4, the name changed to EiBotBoard". My board has the "EiBotBoard" printed, board must be at least V1.4.
RGDS
Ragnar
The extension is now updated to include current setting as well.
Link to new version; http://bit.ly/1dvSQO7
My spare board which had firmware 2.0.1 reported too low voltage, works ok after upgrading to 2.1.5.
The reported voltage is still dependent on the current-potmeter setting, is this due to a bug in the firmware - using the incorrect reference voltage for the DA converter? Would be nice if the source code for the EBB board was open-source. ;-)
( Edit; the source IS open - YIPPIE !!, found it here; http://bit.ly/1l7M0OG :-) )
The EBB reports current setting = 0 for the first 10-15 degrees of rotation of the pot from fully counter-clockwise (min current) position, the extension will now "catch" this.
Please report errors and bugs.
RGDS
Ragnar
Thanks for the nice words and the long answer with a very nice explanation on how your code works.
I figured most of the details as you have explained from your very well commented code!
I would love to test the 2.2.3 code but I have one "small" problem, I can't find it!
The highest version I can find is 2.2.1, here; http://bit.ly/1peWqOi. Where do I find the 2.2.3 version?
I understand the implications of testing the new "cutting edge" versions but as long as I can revert back to a "proven" version I find it exciting.
One question on the current measurement, when measuring the current vs counts I measured the coil having the highest current (for simplicity I measured the voltage across the coil and calculated the current). My values came out lower than stated in the EBB command reference documentation. See here for a plot; http://bit.ly/QlA0iq. Looking at the values I realized they are "off" by a constant. The difference might be close to √2 = 1.41 less which to me implies the current setting is for peak current through the coil and my measured values are the RMS values. Is this correct? I have not had time to study the data sheet for the Allegro 4983 motor driver chips yet but will do in order to get a better understanding of the "inner" workings of the EBB board.
Keep up the good work!
RGDS
Ragnar
Thanks once more! Using firmware v2.2.3 I am happy to say that the reported motor voltage is no longer varying with different pot meter settings. I am very impressed with your code! I am curious about what was the "bug" in previous versions?
(I am currently participating in the edx - Course; "Embedded systems - Shape the world", programming a TI Launchpad (ARM chip), see http://bit.ly/1jBkc80. Challenging as I never dipped my toe in the 'C' before! )
I had to edit the v_points in my code to get the correct voltage reported. I set the 0 count voltage to 0.0V and the 1023 count voltage to 36.3V ((3.3V/4700Ω)*51700Ω). The measurement is almost spot on with a count value of 333 reporting a voltage of 11.99V. Actual voltage applied is 12.21 which would account for the voltage drop over the diode. With the motors enabled the reported voltage falls to 11.88V due to a slightly larger drop over the diode.
To get "my" code to report correct replace the v_points with this; v_points = [(0,1),(36.3,1023)]
(As the slope is now linear I am re-writing the code, the table interpolate is no longer needed, stay tuned for update.)
A am also curious about the pen arm "failing" code, I have plotted several "hours" of eggs without noticing any problems using version 2.2.1.
Thanks for the explanation on the motor current, will study it closer when time permits.
I am impressed with your coding skills and learn a lot by reading your code!
RGDS
Ragnar
Once again thanks for the detailed explanations, it's appreciated!
I am "sucking up" the info like a dry sponge!!
For the pen arm code failing doing long moves using the SM command, most of my latest plots have been very fine detailed with a lot of short moves and very few long moves. ( Example ) I also make sure to use the "optimize" feature of the eggbot extension to limit long "air-moves". To test Iong moves I can make some designs with a lot of long moves. What's the reported "failure mode"? Loosing steps, failing to move, crashes? Due to the mechanical constraints of the eggbot the pen arm movement is limited to about 900 pixels, by removing the pen arm and using a circular disk (graduated in degrees) much larger pen movements can be simulated. I remember running into problems with large sheet sizes trying to plot a 128000 pixel long line from upper left to lower right corner of the sheet (canvas in Inkscape lingo), this was to make a line spiralling 40 times around the egg. At the time I attributed the problem to inkscape/eggbot/EBB_board using 16 bit numbers (max 65536 or 32768 if signed). Have not tried this experiment lately with latest versions of inkscape/eggbot/EBB_board.
I have one question regarding the motor current setting calculations, where does the 46mA at 0 counts come from? I have studied the A4983 motor driver data sheet but could not find any relevant info. (Reading datasheets is difficult (for me at least), try the TI Tiva™ TM4C123GH6PZ Microcontroller datasheet - 1452 pages!)
Quote: "You can see the changes yourself if you compare SVN 289 with SVN 290."
Again, where to find? ;-)
Here are my new eggbot.py and eggbot.inx files eggbot.zip
Please be aware that this only works on EBB firmware version 2.2.3 and higher.
EMS does not recommend to upgrade past version 2.0.1 d.t. a possible
pen arm movement bug in the newer versions.
RGDS
Ragnar
I have now done two tests, one EBB pen move command turning the motor one complete revolution in one second.
This was done for over 12500 moves without error. The second test was random length moves - in random direction - restricted to the range available on the eggbot. This test ran for over 21500 moves (Six hours) without errors. Video snippet of test.
The EBB board seems to "behave" OK but is very unforgiving on incorrect parameters. The EBB board will hang after a while if the duration for a move is 0 (zero). A negative number causes the EBB board to crash.
RGDS
Ragnar
After testing the pen move using the 2.2.3 version I reckoned - why not try "the real thing" - running the eggbot from Inkscape.
When setting up the eggbot after flashing the EBB on the Eggbot ( I used my spare EBB board for testing on the bench) I found the pen-up pen-down to be reversed in v2.2.3.
When I perform - "Raise pen - turn off motors' the pen is lowered. By reversing the upper and lower values in the setup I can still use version 2.2.3 but it might confuse users having a lower number in the Up position than in the Down position.
Flashing the EBB back to V2.1.5 changes to "Normal' behavior.
From looking at the commands sent to the EBB from Inkscape using a USB device Monitor (software) when performing a "Raise the Pen" manual command Inkscape sends; - According to the EBB bot board command manual it is supposed to be the other way around "SP,0" to raise the pen and "SP,1" to lower. From manual; Looking at the eggbot.py confirms this error to be in the eggbot.py extension code. The EBB code works according to the manual. I have verified this using my standalone python test program.
By the way the "Command manual" is missing a section on the "QB" (QueryButton) command.
RGDS
Ragnar
Another fruitful run without errors.
Dump of last four lines from program;
I am pretty confident in the pen arm code being bug-free.
RGDS
Ragnar
Reverse engineering of Brian's file ebb_demo.c in python. Plotted with standalone python test program used for above tests.
Front and Back
RGDS
Ragnar
Experimenting with the EBB board and "extending" my test program I discovered that the pulse output from the EBB is acting a "little strange". When pulsing at a low rate the pulses stop briefly every 16th pulse causing the motor to "stop" briefly every 1.8 degree of rotation. Driving a camera pan head the stops can be easily seen in the video recorded. I reckon the "jitter" or stops also happens at higher motor speed.
Without access to a oscilloscope or logic analyzer it's difficult to estimate the duration of the stops. For smooth operation I am assuming the spacing between the end of a "major step" and the beginning of next "major stap" has to be the same as a between micro-steps, Is my assumption correct?
When experimenting with different stepped drivers, motors and controllers it can often be difficult to figure out where the fault lies when the motor does not move as expected (sometimes it does not move at all!). Visiting different CNC forums over the years the need for a simple tester can be seen. Googling for a "stepper fault finding tool" came up with nothing so I set out with pencil and napkin and "designed" my own.
Result can be seen in this video snippet; Simple_Stepper_Driver_Tester.
The stepper tester is connected to the output of the stepper driver in parallel with the motor.
As can be seen in the video even the micro-stepping can be seen as varying intensity of the LED's. (From approximately 0:30 when rotation changes to CCW) The micro-stepping can bee seen even better running the motor slower.
By removing power to the driver and rotating the motor (by hand) will cause the LED's to light up if the motor is OK and wired correctly.
The (extremely complicated ;-) ) schematic for the tester will be uploaded as soon as I have translated "from napkin to PDF".
Have fun.
RGDS
Ragnar
Thanks for the feedback, I know there are too much info to digest in one go!
No rush on the answers.
My code for the "automatic check of the motor voltage before plot" is almost finished, it now works with all the firmware versions I could find on the net. For the hardware I have "simulated" the earlier and later versions. Both my EBB board are ver 13.
RGDS
Ragnar
Thanks for the feedback, I will try the different suggestions to your 'microstep' fix - as a 'hardware guy' I just assumed the problem to be in the code!! - (As Jerry Pournelle (Byte Magazine - Chaos Manor - now Circuit Cellar) - once said "My favorite programming language is solder!" - ;-) ).
Will be able to have a closer look at the timing once I receive my Digilent Analog Discovery kit.
An interesting observation when checking the different datasheets from Allegro is that in later versions of the motor driver chip there are a mode to avoid loosing steps in slow micro-stepping, see page 8 of this data-sheet; A4988 datsheet. I don't know if this is applicable in this case.
I am aware of the limitations in the current settings - without the proper voltage or too high coil resistance you will never achieve the set current.
For other use of the EBB board an acceleration / deceleration feature would be nice. The motor is capable of high RPM but will have to be 'ramped up' and 'down' to avoid stalling or loosing steps.
Again; Thanks for the feedback, it's really appreciated!
RGDS
Ragnar
Testing of 2.2.4 started,
Operation of servo now back to 'normal'. ;-)
Will try some of my plots.
Plots started OK.
(What's the difference between EBF_v224.hex and EBF_v224.unified.hex?
(I have loaded EBF_v224.hex to my EBB board)
Edit; - Plotted Great!
RGDS
Ragnar
The plot is a copy of "Zentangle art" by Stoshi - see her blog page here: Stoshi's Blog
( I got her permission to post the image as long as she got the credit she deserves. )
She called the image "La Bella", a great work of art! I traced the image by hand in Inkscape to get a SVG file.
Link to original image; "La Bella"
It is a nice test as the plot consists of a lot of small line segments causing a lot of pen-up/downs and moves. Takes about half an hour to plot. As you see I have 'elongated' the image somewhat to improve resolution. Will try to improve resolution further by smooting the egg surface. Right now the 'rough' surface causes the 'jagged' lines.
Are you posting the source code for 2.2.4?
RGDS
Ragnar
Great news Brian. I just made a plot in Inkscape of a one layer "Wave Winding" coil.
(See Wave Winding machine post.)
The image is 102400 pixels in width. This plots fine. For a 10 layer coil the width will be 1024000 pixels which does not work at the moment.
RGDS
Ragnar
A few observations on the 2.2.5 version.
Inkscape is unable to make any plots with this version.
Inkscape receives an incorrect return on Pen Up/Pen Down as it's inserting a 'Null Move" SM command according to the EBB Command manual recommendation. This can be seen by setting the pen height using the eggbot extension in Inkscape. Seems like the return value from the SM command is incorrect or not being accepted by Inkscape. When trying the SM command in my standalone program the response seems OK.
Response trying to plot: BadResponce.txt
Note that the 'Pause' button was never pressed, I have seen this behavior on the previous versions as well where the plot stops with inkscape reporting that the 'pause' button was pressed - when it was not, trying to 'resume' never returns to the correct place ruining the plot. I have tried to lower the baud rate as I thought it might be caused by 'incorrect' commands sent to the EBB, but this does not help. Maybe a bug?
The 'QC' command is 'broken' as well; the reported value for voltage is always '0001' no matter if motor voltage is applied or not.
A last comment on the pen arm servo behavior; on resetting the board the servo is always returned to mid position, in my opinion this is bad as the eggbot will lower the pen onto the egg 'ruining' my plot! I would much rather have it to lift the pen using the last stored pen-up value.
On a more 'positive' note;
The 'long move' command is working like a charm! (Running from standalone python program.) Well done! This opens up a plethora of new possibilities for the eggbot and EBB board! (I can now draw a line from upper left to lower right corner filling in the egg in one move or - issue a 'long move' and 'manually' draw or fill in close to the end of the eggs. This is the closest thing to continuous rotation! I am doing the 'happy dance' right now!!
Happy Coding!
RGDS
Ragnar