2012/8/19 Viesturs Lācis <viesturs.la...@gmail.com>: > 2012/8/19 Gabriel Willen <gabewil...@gmail.com>: > >> Its really easy to write a hal component using halcomp and >> attach the python handlers to those i/o pins you create. > > I feel familiar with comp, I have customized HAL components for some > of my machines.
Sorry for bothering, but it is late and I am not sure, if I have got it all right, so I would appreciate if anyone could take a look at my little piece of code and share some insights, if I am on the right track. I took John's THC module and "slightly" edited it, so that it should: 1) start homing when "home" input bit goes true; 2) increase "offset" value in positive direction until "home_sw_in" goes true; 3) retract ~3 times slower until home_sw_in goes false and set "homed" bit true; 4) keep the previous "offset" value untouched, when "home" bit is false; I will have classicladder logic, which will set "home" bit true, when user will press appropriate button and will reset it to false, when "homed" bit goes true. That way user can always rehome by pressing that button again. Here is all the contents of module: component homing "Module to home a simple stepgen controlled motor"; description """ Based on John Thornton's THC module """; author "Viesturs Lacis"; license "GPLv2 or greater"; option singleton yes; // Input Pins pin in bit home "Do homing"; pin in bit home_sw_in "Homing switch input"; // Output Pins pin out float offset "Stepgen position offset"; pin out bit homed "Indicates, when homing is completed"; // Parameters param rw float home_vel "Home search velocity in user units per second"; // Global Variables variable bit home1 "Indicates, when home search has succeeded"; function _; ;; #include "rtapi_math.h" FUNCTION(_) { if(home && !home_sw_in){ offset += (0,001*home_vel); } if(home && home_sw_in){ offset -= (0,0003*home_vel); home1 = 1; } if(home1 && !home_sw_in){ homed=1; } } -- Viesturs If you can't fix it, you don't own it. http://www.ifixit.com/Manifesto ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users