is a nifty way to get what you want when they just wouldn't give it to you :)
https://docs.python.org/2/library/stringio.html#module-StringIO
Sunday, July 10, 2016
Saturday, December 19, 2015
RAMPS + DRV8825
I have ordered this Arduino Mega 2560 + RAMPS + 5 * DRV8825 + LCD 12864 set, loaded it with Repetier firmware and found out that it works nicely, hooray!
Things to keep in mind: DRV8825 boards were configured for Vref = 1.6-1.7 V, which is way too high. This translates into output current of 3.2-3.4 A, as the formula for DRV8825 is
Or, as Rs is 0.1 Ohm (resistors are labeled as "R100") -
which is the same as
See these links -
http://reprap.org/wiki/A4988_vs_DRV8825_Chinese_Stepper_Driver_Boards
https://www.pololu.com/product/2133
This current can damage your motors, so before connecting the motors to RAMPS you must adjust Vref. Thankfully it's not that hard: plug in 12 V power supply into RAMPS (Arduino is powered from RAMPS board), and measure Vref between the ground pin of DRV8825 board and top of adjustment potentiometer, as shown:
I have soldered a wire to the ground pin and wound it onto the ground probe of my multimeter because I only have two hands. With the red probe touching my screwdriver that I used to turn the potentiometer I was able to adjust Vref and check its value on the multimeter.
The first link recommends setting Vref to 0.5 V (which translates into 1 A current) and using that as the starting point to further tweak Vref. However when using puny CD / DVD stepper motors, I think 1 A is waay too high, so I started with ~0.1 V, and went up to 0.16 V. With this Vref my motor works just fine and doesn't seem to overheat. I may end up increasing Vref when I add mechanical load to the motor though.
Things to keep in mind: DRV8825 boards were configured for Vref = 1.6-1.7 V, which is way too high. This translates into output current of 3.2-3.4 A, as the formula for DRV8825 is
I_TripMax = Vref / (5 * Rs)
Or, as Rs is 0.1 Ohm (resistors are labeled as "R100") -
I_TripMax = Vref / 0.5
which is the same as
I_TripMax = 2 * Vref
See these links -
http://reprap.org/wiki/A4988_vs_DRV8825_Chinese_Stepper_Driver_Boards
https://www.pololu.com/product/2133
This current can damage your motors, so before connecting the motors to RAMPS you must adjust Vref. Thankfully it's not that hard: plug in 12 V power supply into RAMPS (Arduino is powered from RAMPS board), and measure Vref between the ground pin of DRV8825 board and top of adjustment potentiometer, as shown:
I have soldered a wire to the ground pin and wound it onto the ground probe of my multimeter because I only have two hands. With the red probe touching my screwdriver that I used to turn the potentiometer I was able to adjust Vref and check its value on the multimeter.
The first link recommends setting Vref to 0.5 V (which translates into 1 A current) and using that as the starting point to further tweak Vref. However when using puny CD / DVD stepper motors, I think 1 A is waay too high, so I started with ~0.1 V, and went up to 0.16 V. With this Vref my motor works just fine and doesn't seem to overheat. I may end up increasing Vref when I add mechanical load to the motor though.
Friday, October 9, 2015
Supervisor program groups
"Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems."
Simply put, it's a program that can run other programs for you. It does its job, it is mature and straightforward - just define your programs in a plain Windows-INI-style configuration file (although Supervisor doesn't run on Windows) and you're set.
But what if you've got a whole bunch of programs to run, isn't starting/restarting/stopping them one-by-one using supervisorctl going to be a major hassle? Yes, but Supervisor offers a solution: program groups! Define your programs as usual, but add a group entry to the conf file:
Now, instead of issuing commands for each program like so:
you can just do
And just imagine having 10 or 20 or even more programs to control!
Simply put, it's a program that can run other programs for you. It does its job, it is mature and straightforward - just define your programs in a plain Windows-INI-style configuration file (although Supervisor doesn't run on Windows) and you're set.
But what if you've got a whole bunch of programs to run, isn't starting/restarting/stopping them one-by-one using supervisorctl going to be a major hassle? Yes, but Supervisor offers a solution: program groups! Define your programs as usual, but add a group entry to the conf file:
[program:a-program] command=command-to-run-a-program ; etc. [program:another-program] command=command-to-run-another-program ; etc. [program:yet-another-program] command=command-to-run-yet-another-program ; etc. [group:my-group] programs=a-program,another-program,yet-another-program
Now, instead of issuing commands for each program like so:
supervisorctl start a-program supervisorctl start another-program supervisorctl start yet-another-programor
supervisorctl restart a-program supervisorctl restart another-program supervisorctl restart yet-another-programor
supervisorctl stop a-program supervisorctl stop another-program supervisorctl stop yet-another-program
you can just do
supervisorctl start my-group:*or
supervisorctl restart my-group:*or
supervisorctl stop my-group:*
And just imagine having 10 or 20 or even more programs to control!
Monday, February 9, 2015
Contrary to what I considered possible, LDAP server
somehow notifies connected clients when being shut down.
So when you have an open connection to said server, you don't receive ldap.TIMEOUT exception as I expected. You get ldap.SERVER_DOWN.
Something to watch out for when you're working with LDAP.
Like so:
So when you have an open connection to said server, you don't receive ldap.TIMEOUT exception as I expected. You get ldap.SERVER_DOWN.
Something to watch out for when you're working with LDAP.
Like so:
try: data = conn.search_s(base_dn, scope, search_filter, retrieve_attributes) log.debug("Searched for attribute(s) of LDAP base DN {0}, filter {1}".format(base_dn, search_filter)) return data except (ldap.TIMEOUT, ldap.SERVER_DOWN) as ex: # catching just ldap.TIMEOUT is not enough! log.error("Exception: {0}".format(ex))
Thursday, January 1, 2015
Vortex Ring State
happens when a helicopter (even a small quadcopter!) descends too quickly and its own downwash (turbulent air beneath the rotor(s)) envelopes the rotor(s). The machine basically runs into its own downwash. This may happen for instance due to a piloting error and leads to severe loss of lift.
Simply put, you go down too quickly and find that you start falling down and can't pull up! And Going full throttle doesn't help! The most straightforward way of getting out of VRS is to move horizontally to get out of the turbulent air as quick as possible.
Wikipedia article.
Quadcopter demonstration:
Simply put, you go down too quickly and find that you start falling down and can't pull up! And Going full throttle doesn't help! The most straightforward way of getting out of VRS is to move horizontally to get out of the turbulent air as quick as possible.
Wikipedia article.
Quadcopter demonstration:
Monday, December 22, 2014
Exporting to MS Excel format (XLS)
from Python is relatively easy with xlwt package. The linked page says that xlwt is a
Library to create spreadsheet files compatible with MS Excel 97/2000/XP/2003 XLS files, on any platform, with Python 2.3 to 2.7
To that I can only add that it's fast, too!
I've heard it doesn't support creation of XLS files with formulas, which might or might not be true (haven't tested that myself).
Installation is easy as usual:
To create yourself an Excel file, you basically do this:
Library to create spreadsheet files compatible with MS Excel 97/2000/XP/2003 XLS files, on any platform, with Python 2.3 to 2.7
To that I can only add that it's fast, too!
I've heard it doesn't support creation of XLS files with formulas, which might or might not be true (haven't tested that myself).
Installation is easy as usual:
$ pip install xlwtHere's the link to PDF tutorial covering xlwt along with xlrd (read Excel files from Python) and xlutils (utulities for both xlwt and xlrd). You may also want to check out this site for some information.
To create yourself an Excel file, you basically do this:
import xlwt from datetime import datetime book = xlwt.Workbook() sheet = book.add_sheet('SheetName', cell_overwrite_ok=True) # Ability to overwrite may be extremely handy # You might want to change column widths. 700 is 0.21" as I've found out experimentally sheet.col(0).width = 700 # Or row hights, but in this case enabling height_mismatch helps you achieve the desired effect. sheet.row(0).height_mismatch = 1 sheet.row(0).height = 260 # 0.18" sheet.write(0, 0, u"Current date/time:", xlwt.easyxf('font: name Arial, height 160; align: vertical bottom, horizontal left; ' 'pattern: fore_colour white, pattern solid;')) sheet.write(0, 2, datetime.now(), xlwt.easyxf('font: name Arial, height 160; ' 'align: vertical center, horizontal center; ' 'borders: left thin, right thin, top thin, bottom thin; ' 'pattern: fore_colour white, pattern solid;', num_format_str="DD/MM/YY H:MM:SS;@")) sheet.col(2).width = 4000 # Hopefully this is enough to show datetime sheet.write_merge(1, 1, 0, 2, 123.55, xlwt.easyxf('font: name Arial Cyr, height 160; ' 'align: vertical center, horizontal right; ' 'pattern: fore_colour white, pattern solid;', num_format_str="#,##0.00")) book.save("out.xls")
Need to create a nice PDF from Python?
pdfkit is a package that can help. This package can cook you some PDFs from HTML. It's a wrapper around wkhtmltopdf, so make sure you install that. On Debian/Ubuntu I wouldn't apt-get it from the standard repository - those wkhtmltopdf QT patches sure provide nice functionality.
Installing pdfkit is as simple as
Installing pdfkit is as simple as
$ pip install pdfkitThen you can do this:
import pdfkit pdfkit.from_url('http://google.com', 'out1.pdf') pdfkit.from_file('test.html', 'out2.pdf') # Provided you have test.html in your current folder pdfkit.from_string('Hello!', 'out3.pdf') pdfkit.from_string('<html><table><tr><th>Header</th></tr><tr><td>Row 1<td></tr><tr><td>Row 2<td></tr></table></html>', 'out4.pdf')
Subscribe to:
Posts (Atom)