Evolution of a Blog

This blog has evolved as I have as a maker. It starts at the beginning of my journey where I began to re-tread my tires in the useful lore of micro electronics and the open-source software that can drive them. While building solutions around micro-electronics are still an occasional topic my more recent focus has been on the 3D Printing side of making.

Saturday, September 29, 2012

Propulsion (e.g. Making Motors Go)

The combination of the Rover 5 and the Explorer PCB make connection of the motors pretty easy.   The Rover 5 comes wired to plug into the bottom of the Explorer PCB and the PCB then provides connections for power, control, and feedback of current being drawn.   Power needs to be connected to the 5v supply provided by the Explorer PCB.

Speed is controlled by the PWM pin and takes a value of 0 to 255.   Direction is set by a digital high or low.   I have not gotten the current feedback to work yet but the documentation says it should be read on the processors "analog to digital (ADC) inputs".  I am not sure what exactly that means but I am not getting anything on the pins that I have tried to date though I am not losing sleep about it at the moment.

Code for running a test on the left motor is shown below.  Note that this code is based on my Python to Arduino Interface but the commands, less error handling, are 1-1 analogous to what you would code in Arduino directly.

    import time
    from Py2Ard import interfaceClass
   
    # Specify the port as an argument
    my_board = interfaceClass('/dev/ttyUSB0')
   
    leftMotorDir = 26
    leftMotorSpeed = 7
   
    print "Setting Pin Mode for Speed"
    if my_board.pinModeOutput(leftMotorSpeed) == -1:
        print "Error" + my_board.extraReturn
   
    print "Setting Pin Mode for Direction"
    if my_board.pinModeOutput(leftMotorDir) == -1:
        print "Error" + my_board.extraReturn
   
    print "Commanding Direction Forward"
    if my_board.setHigh(leftMotorDir) == -1:
        print "Error" + my_board.extraReturn
   
    print "Commanding Speed of 100"
    if my_board.pwmWrite(leftMotorSpeed, 100) == -1:
        print "Error" + my_board.extraReturn
    time.sleep(2)
   
    print "Commanding Direction Backward"
    if my_board.setLow(leftMotorDir) == -1:
        print "Error" + my_board.extraReturn
   
    print "Commanding Speed of 100"
    if my_board.pwmWrite(leftMotorSpeed, 100) == -1:
        print "Error" + my_board.extraReturn
    time.sleep(2)
   
    print "Commanding Stop"
    if my_board.pwmWrite(leftMotorSpeed, 0) == -1:
        print "Error" + my_board.extraReturn

No comments:

Post a Comment