Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ‘Code for Sorting Robot
  2. Program by Tyler Funk, Richard Schoellhammer, Ethan Bressler
  3.  
  4. MCount = 0
  5. HOpen 1
  6. Mov P1
  7. GoSub *ConnectCognex ‘subroutine used to connect cognex
  8. While MCount = 0
  9. EBRead #1, ,M, U, ANGLE1, ANGLE2 ‘read and name the desired output string
  10. If M = 0 And U = 0 And M_In(14) = 0 Then
  11. GoTo *ReRead
  12. EndIf
  13. If M = 1 And M_In(14) = 1 Then ‘conditional for detecting M on block
  14. P3.C = -Rad(-ANGLE1 - 12) ‘calibrated from output string to reorient block while placing
  15. Mov P2, +60
  16. Mov P2
  17. Dly 0.1
  18. HClose 1
  19. Dly 0.1
  20. Mov P2, +120
  21. Mov P3, +120
  22. Mov P3
  23. Dly 0.1
  24. HOpen 1
  25. Mov P3, +60
  26. EndIf
  27. If U = 1 And M_In(14) = 1 Then ‘conditional for detecting U on block
  28. Dly 0.1
  29. P4.C = -Rad(-ANGLE2 - 98) ‘calibrated from output string to reorient block while placing
  30. Dly 0.5
  31. Mov P2, +60
  32. Mov P2
  33. Dly 0.1
  34. HClose 1
  35. Dly 0.1
  36. Mov P2, +120
  37. Mov P4, +120
  38. Mov P4
  39. Dly 0.1
  40. HOpen 1
  41. Mov P4, +60
  42. EndIf
  43. If M = 0 And M_In(14) = 1 Then
  44. EndIf
  45. If U = 0 And M_In(14) = 1 Then
  46. EndIf
  47. WEnd
  48. *ReRead
  49. Dly 0.5
  50. End
  51. *ConnectCognex ‘connects to cognex program
  52. If M_NvOpen(1) <> 1 Then
  53. Dly 0.1
  54. NVOpen "COM2:" As #1
  55. EndIf
  56. Wait M_NvOpen(1) = 1
  57. NVRun #1, "SortCam1" ‘finds the program to open
  58. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement