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

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s