Guest User

driver.cpp

a guest
Jul 17th, 2012
55
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "driver.h"
  2.  
  3. Driver::Driver(byte picoAddr, byte outVal){
  4. PicoAddr = picoAddr;
  5. MinSpeed = 1;
  6. RunCurrent = 0;
  7. HldCurrent = 0;
  8. ADLimit = 0;
  9. EmAcc = 255;
  10. Mode = SPEED_8X;
  11. Mode |= IGNORE_LIMITS;
  12. OutVal = outVal;
  13. }
  14.  
  15. int Driver::setParameter(){
  16. if(!StepSetParam(PicoAddr, Mode, MinSpeed, RunCurrent, HldCurrent, ADLimit, EmAcc))
  17. return 0;
  18. StepSetOutputs(PicoAddr, OutVal);
  19. return 1;
  20.  
  21. }
  22.  
  23. void Driver::enable(byte mode){
  24. StepStopMotor(PicoAddr, mode);
  25. }
  26.  
  27. void Driver::loadTraj(byte mode, long pos, byte speed, byte acc, unsigned short int steptime){
  28. Mode = mode;
  29. Pos = pos;
  30. Speed = speed;
  31. Acc = acc;
  32. StepTime = steptime;
  33. StepLoadTraj(PicoAddr, mode, pos, speed, acc, steptime);
  34. }
  35.  
  36. void Driver::setGroup(bool isLeader){
  37. LdcnSetGroupAddr(PicoAddr, GROUP_ADDR, isLeader);
  38. }
  39.  
  40. void Driver::stopMotor(byte mode){
  41. StepStopMotor(PicoAddr, mode);
  42. }
RAW Paste Data