4. Make the motors move (yay!)
Features:
- Pulse integrity
- Motion profiles
- Inverse kinematics
- Sensor integration
- Limits and exclusion domains
- Gcode library support
- Speed, speed, speed, speed
Single Motion Domain
START HERE
System Integration Level Features:
- Optimal job planning
- Collision avoidance (or not)
Acceleration management Const Jerk
Coordinated movement XYZ
Path planning Optimal path planning
Hardware device integration
Multiple motion domains
Cross-domain coordination
Exception handling and reaction
ABC UVW
5. Accessibility
•Arduino-level users
•Web programmers (e.g. JavaScript, node.JS, Python)
•Domain experts with little or no programming experience (or desire)
•Professionals: system builders, process engineers, etc.
Components
•Canned motion components and other pre-packaged functions
•Simple way to package arbitrary hardware components
Tools
•Motate hardware abstraction and simplification
•Kinen standards provide a powerful toolbox without soldering
•Hardware mashups / RESTful hardware
How do we get from motion domains to complete systems?
6. Easy enough for beginners.
Powerful enough for pros.
Making beginners into pros.
7. For Beginning Programmers:
Motate is an easy to learn embedded “language.”OutputPin<13> ledPin;
ledPin = 1; // set to high
ledPin = 0; // set to low
“Turn pin 13 on and off”
InputPin<12> buttonPin;
if (buttonPin) {
// do something
}
“Read the level of pin 12”
Timer<1> myTimer(kTimerUpToMatch, 50000);
// in a routine:
myTimer.setInterrupts(
kInterruptOnOverflow);
myTimer.start();
// define your interrupt:
namespace Motate {
MOTATE_TIMER_INTERRUPT(1) {
dda_timer.getInterruptCause();
// do something
}
}
“Tell timer 1 to run my special routine at
50kHz”
8. For Beginning Programmers:
// enable write to registers
REG_TC1_WPMR = 0x54494D00;
TC_Configure(TC1, 0, TC1->CMR0);
// set frequency
REG_TC1_RC0 = (VARIANT_MCK / 50000UL / 2)
// enable interrupts
REG_TC1_IER0 = TC_IER_CPCS;
NVIC_EnableIRQ(TC3_IRQn);
pmc_enable_periph_clk(ID_TC3);
TC_Start(TC1, 0);
// define the interupt
void TC3_Handler(void) {// read SR to clear interrupt condition
dummy = REG_SR_DDA; // do something
}
}
}
Native
(Atmel SAM3X8E ARM on the Arduino Due)
<< Code for Atmel ATMega line >><< Code for Atmel ATTiny line >><<
Code for Atmel ATXMega line >><< Code for Atmel ARM line >><<
Code TI MSP430 line >><< Code TI ARM line >><< Code for LPC
ARM line >><< Code for ST ARM line >>
Native
timer_number myTimerNum = 3;
Timer<myTimerNum> myTimer(kTimerUpToMatch, 50000);
// in a routine:
myTimer.setInterrupts(kInterruptOnOverflow);
myTimer.start();
// define your interrupt:
namespace Motate {
MOTATE_TIMER_INTERRUPT(myTimerNum) {
dda_timer.getInterruptCause();
// do something
}
}
Motate
“Tell timer 3 to run my special routine at 50kHz”
9. For Professional Programmers:
Motate is hardware abstraction layer, written in optimized C++.
All the good parts of C/C++, none of the bad ones:
Bad:
•RTTI, virtual functions, malloc, exceptions
•C++ Standard IO, C++ STL
Good:
•Good UI design techniques for designing APIs.
•An API is a UI.
•Don’t compromise performance for usability.
•Play with the compiler, not against it.
•“If it’s hardware, it’s compile time.”
•Use mirage interfaces, opaque interfaces that, upon
compiling, boil down to nothing.
•Judicious use of metaprogramming.
10. For Professional Programmers:
How fast is Motate?
With mirage interfaces, the HAL can boil away.
With this definition:
OutputPin<13> ledPin;
This code:
ledPin = 1; // set to high
Compiles down to one instruction on the AVR, and
executes in two cycles!
On the SAM3X8E ARM Cortex-M3, it compiles to two or
three instructions, which executes in two to five
cycles.
11. Hardware Mashups
•System with multiple coordinated domains and/or devices
•Controlled as single unit
•REST basics: resources, representation, state transfer
•Complex systems are composite resources
Why JSON?
•Flexible
•Relatively concise
•Already in most modern languages
On the device itself
•Running on ARM, ATXmega and ATMega328p
•Kinen project to define protocol and hardware compatibility
things line of JSON get it, set it
many different things
RESTful hardware
•REST does not require HTTP. We run over USB, SPI, RS-485
12. What you can do with JSON
What we’ve learned about JSON
•Subset of the JSON spec
• 7 bit ASCII only
• Single line, limited length (e.g. 128 to 256 chars)
• Limited number of name:value pairs (e.g. 24 per line)
• Decimal only, no hexadecimal
•Dispatch tables, tokens and indexes
•No mallocs
Commands: {"gc":"n20g0x20"}
Configuration: {"2":{"ma":1,"sa":1.800,"tr":36.540,"mi":8,"po":1,"pm":1}}
Status reports: {"sr":{"posx":1.230,"posy":4.375,"posz":-2.500,"posa":0.000,"vel":175.0,"stat":5}}
Filtering: {"sr":{"posx":2.670}}
Addressing & Routing: {"a_master":{"2":{"ma":1,"sa":1.800,"tr":36.540,"mi":8,"po":1,"pm":0}}}
{"a_slave":{"2":{"ma":1,"sa":1.800,"tr":360.0,"mi":4,"po":0,"pm":1}}}
13. What about efficiency?
•It’s not as bad as you think
•Timings for set-X-axis-max-velocity to 16000 mm/min {"xvm":16000}
•NoJSON command is $1=16000
SAM3X8E Xmega192A3 atmega328P No JSON
Commands / sec ~1000 cps ~1000 cps ~1000 cps ~1600 cps
FP marshaling (strtof()) <7.5 uSec <25 uSec <70 uSec <70 uSec
FLASH footprint ~8 Kbytes ~8 Kbytes ~4-6 Kbytes
RAM footprint ~2 Kbytes ~2 Kbytes ~500 - 800 bytes
malloc() no no no no
Assumptions
•USB running at 115,200 baud
•FLASH / RAM footprints include JSON parser/serializer, dispatcher, floating point libs
14. For More Information: Synthetos.com
Alden Hart - alden.hart@synthetos.com
Rob Giseburt - rob.giseburt@synthetos.com