8 comments on “DC Motor Control

  1. Hi Aisling,

    I think the problem with the state changes are to do with missing curly brackets in the if statement where you check _RD3 (the switch input). I think you need something like this:

    if(state == OFF) // Motor Off
    {
    LATD = 0b00; // off
    if (_RD3 == 1)
    {
    while(_RD3 == 1);
    __delay32(pause);
    state = LOW;
    }
    printf(“OFF\n”); //monitoring
    }

    Without those middle set of curly brackets, “__delay32(pause);” and “state = LOW;” are not conditional on the if statement – they’re just executed every time.

    Ted

    Like

      • There’s no rush at all. It won’t make a significant difference to the grade, but it would just be nice to have it fixed for any readers who find their way here in the future. Your blog is excellent overall.

        Ted

        Liked by 1 person

      • Just tried it out there and it worked, I’ve updated the blog (just continued on from the last paragraph) with the footage and the new code thanks Ted 🙂

        Like

      • Well it just so happened I had all my electronics kit out on the desk as I was working on my 3D printer last night (which ill be putting up on the blog). Essentially I just had to log in and change my code everything else I’ve shortcuts to on my desktop. This semester has made my work rate very efficient.
        Thanks again Ted.

        Like

  2. Pingback: Last updated 20/04/2016 | Aisling Lee

Leave a comment