Motor operation toggle to be shown on LCD

This is a discussion on Motor operation toggle to be shown on LCD within the C Programming forums, part of the General Programming Boards category; How do you show the motor operation toggle on an LCD (Motor:ON , Motor:OFF). Using an interrupt to toggle motor ...

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    1

    Motor operation toggle to be shown on LCD

    How do you show the motor operation toggle on an LCD (Motor:ON , Motor:OFF). Using an interrupt to toggle motor operation however cannot display the messages properly and cannot figure it out any help would be greatly appreciated.

    This is the code so far:

    Code:
    #include <htc.h> //standard header for Hitec ‘C’
    #include "bmc_code.h" //includes header file bmc_code
    #define Relayswitch RB0 //renames port B0 as But1
    #define CounterON RB1 //renames port B1 as But2
    #define Reset RB2 //renames port B2 as But3
    #define RELAY RA0 //renames port A0 as RELAY
    //declare function prototypes
    void interrupt ext0_ISR(void);
    //end function declares
    
    void main(void)
    {
     TRISB=0x0F; //Sets port B as Inputs
     TRISA=0x00; //Sets port A as outputs
     TRISD=0x00; //Sets port D as Outputs
     ADCON1 = 0x06; //ensure port A configured for digital IO
     PORTA=0; //Clears Port A
     PORTB=0; //Clears Port B
     PORTD=0; //Clears Port D
     INTE = 1;  //RB0 interrupt enable
     PEIE = 1;  //Peripheral interrupt enable
     GIE = 1;  //Global interrupt enable
     INTEDG = 0;  // interrupt on falling edge
    
     init_LCD();    //function to initialise LCD
     LCD_function(0x0C);  //function to turn LCD on
     unsigned char counter; //Stores counter in memory  
     while (1) //continuous loop
     {
     }
    void interrupt ext0_ISR(void)
    {
     if (INTF && INTE)    //ensure interrupt generated by transition on RB0
     {
      delay_ms(10);    //delay 10ms for contact bounce elimination
      if (Relayswitch == 0)    //test if button still pressed
      {
       RELAY = RELAY^1;   //YES - Toggle motor control
      }
      while (!Relayswitch){};  //do nothing while button is still pressed
    
     }
     INTF = 0;      //clear interrupt flag
    }

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    333
    It's unlikely that anyone can help you unless they have that exact same system installed. You're manipulating the LCD by writing values to various ports, but we've no way of knowing whether these values are correct, or if you're writing in the correct order.
    However I don't see any place in which you are telling the system what your interrupt routine is. Unless the compiler can somehow pick it out from the name,how is the interrupt set?

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    2,804
    In your while(1) loop in main you could test the status of your relay port and if the port is on print the MOTOR:ON to the LCD otherwise print MOTOR:OFF. I wouldn't try to do this in the ISR because you want to keep the ISR as small and fast as possible. Also you should only print the message when the relay port toggles.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stellaris® Stepper Motor RDK
    By brconner in forum C++ Programming
    Replies: 1
    Last Post: 06-12-2007, 12:18 PM
  2. function to run stepper motor
    By sunnycyboid in forum C Programming
    Replies: 1
    Last Post: 11-01-2002, 04:43 AM
  3. dialog box shown => message ?
    By vovor in forum Windows Programming
    Replies: 1
    Last Post: 10-14-2002, 11:31 PM
  4. Stepper Motor Control .......
    By svglolla in forum C Programming
    Replies: 1
    Last Post: 02-18-2002, 10:03 AM
  5. cheap uk motor insurance
    By iain in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-01-2002, 06:58 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21