We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Arduino dock 2 always high value



  • I'm using a omega 2 Arduino dock 2 and have it connected to a easydriver to run a stepper motor. I'm trying to remotely turn a stepper motor. The omega has a python server that is waiting for http requests. This is the python code.

    --

    import onionGpio
    from flask import Flask, request
    app = Flask(name)
    gpioLeft = 4
    gpioMiddle = 2
    gpioRight = 3
    gpioObjLeft = onionGpio.OnionGpio(gpioLeft)
    gpioObjMiddle = onionGpio.OnionGpio(gpioMiddle)
    gpioObjRight = onionGpio.OnionGpio(gpioRight)
    status = gpioObjLeft.setOutputDirection(0)
    @app.route('/',methods=['POST'])
    def gpio():
    if request.form['blind'] == 1:
    status = gpioObjLeft.setValue(1)
    elif request.form['blind'] == 2:
    status = gpioObjMiddle.setValue(1)
    else:
    status = gpioObjRight.setValue(1)
    print 'GPIO%d set to: %d'%(gpioNum, value)
    time.sleep(10)
    status = gpioObjLeft.setValue(0)
    return 'success'
    if name == "main":
    app.run(host='0.0.0.0')

    --

    Then on the arduino I have the following code:

    --

    #define DIR_PIN 2
    #define STEP_PIN 3
    #define INPUT_PIN 4

    void setup() {
    pinMode(DIR_PIN, OUTPUT);
    pinMode(STEP_PIN, OUTPUT);
    pinMode(INPUT_PIN, INPUT);
    Serial.begin(9600);
    Serial.print("SETUP Value");
    }

    void loop() {

    //rotate a specific number of degrees
    if (digitalRead(4) == HIGH){
    rotateDeg(3600, 1);
    Serial.print("High Value");
    delay(4000);
    } else {
    Serial.print("Low Value");
    delay(4000);
    }

    }

    void rotate(int steps, float speed) {
    //rotate a specific number of microsteps (8 microsteps per step) – (negitive for reverse movement)
    //speed is any number from .01 -> 1 with 1 being fastest – Slower is stronger
    int dir = (steps > 0) ? HIGH : LOW;
    steps = abs(steps);

    digitalWrite(DIR_PIN, dir);

    float usDelay = (1 / speed) * 70;

    for (int i = 0; i < steps; i++) {
    digitalWrite(STEP_PIN, HIGH);
    delayMicroseconds(usDelay);
    digitalWrite(STEP_PIN, LOW);
    delayMicroseconds(usDelay);

    }
    }

    --

    The problem is the stepper motor is running constantly. So it seem that that green wire listed below (Pin 3) is always giving a high value. Does anyone know what I'm doing wrong? I'm very much a software guy not hardware.

    I currently have the Omega2 powered by a microUSB to an outlit.

    The easydriver has its own power supply.

    alt text



  • @florbus About your hardware connections (only):
    It is not a good idea to connect directly the Omega2(+)'s GPIOs / Expansion Header (a 3.3V powered device)
    to the Atmega's pins / the Arduino Header (a 5V powered device) - usually some voltage level shifting needed.
    For example ATmega's output (output high voltage min 4.2V) may damage Omega's input (input high voltage max V_3.3V + 0.3 V).

    On Onion's Arduino Dock 2 - according to the constructor's conception - Omega2(+) and ATmega328 (the Arduino) can communicate with each other via I2C and / or serially (Omega's UART1 - ATmega's UART).
    Omega2(+)'s GPIO4 is designated as I2C SCL, GPIO5 is designated as I2C SDA by default (omega2-ctrl gpiomux get).



  • Thank you.

    I think one of these bad boys should do the trick.

    https://www.sparkfun.com/products/12009



Looks like your connection to Community was lost, please wait while we try to reconnect.