AXIS: EMC2 Blog|
Blog
About AXIS Get EMC2 Documentation Translations ETCH CNC Developer Homepages: Chris Radek Jeff Epler Related sites: linuxcnc.org linuxcnc wiki |
Building on my earlier work, I've now improved
the interface between HAL and the Arduino board
to have:
First, load the sketch (firmware source code file) in the Arduino GUI, compile it, and transfer it to the board. The program will remain in the microcontroller's flash rom until it is replaced by another one. Now, if you don't already have it installed, install python-serial using apt-get or Synaptic Package Manager. (if this command doesn't print an error, python-serial is installed: python -c 'import serial') Next, copy arduino.py to the name arduino (no extension) in a directory on your PATH. Make it executable: chmod +x bin/arduino To demo it, in the sample hal script, change the loadusr -W arduino line to reflect the serial port where the arduino is connected. In the directory with the hal file and the pyvcp definition file, halrun arduino-vcp.hal. A control panel should appear which shows the arduino's inputs and allows the outputs to be manipulated.
In addition to the standard pins and parameters for digital and analog inputs and outputs, the digital inputs offer the '-pullup' parameter. Setting this to TRUE enables the corresponding weak pull-up built into the AVR microcontroller. For the analog inputs and outputs, the default gain/scale of 1.0 makes 1V correspond to 1.0. The effective range is thus 0.0 to 5.0. The items on the 'loadusr' commandline are: the serial port where the Arduino is connected to the PC, and the number of digital I/O pins to use as outputs. The lower-numbered digital pins are outputs, and the higher-numbered pins are inputs. If not specified, these pins are split 3 "in" and 3 "out". Technical detailsThe protocol is similar to the earlier revision: 2-byte packets with the top bit signifying "first" or "second" byte. 3-bit address. 11 bit payload. 6 of the 8 addresses are used.For the 6 "input" addresses, the low bits of the payload are an ADC input value. The high bit of the payload is an input pin value. For the 6 "output" addresses, bits 7..0 of the payload are a PWM output value. Bit 8 is the pin direction, and bit 9 is the pin value (or pull-up enable for inputs).
Files currently attached to this page:
| ||||||||||||||||||||||||||||||||||||||||||||
| [æ] |