3
AN706: Motor Mind C control using a Microchip PIC16f73 1 Overview: This application note describes how to control the Motor Mind C (MMC) with Microchip's PIC16F73 microcontroller using the MMC's SetDC command as well as how to detect and clear fault conditions. This application note implements a simple serial control interface of the Motor Mind C (MMC) in both PIC assembly language and PIC MCU C. Five PIC16F73 pins are used as button inputs. Each button press sends a specific motor speed and direction command to the MMC. Button 1 = -75% duty cycle Button 2 = -25% duty cycle Button 3 = 0 duty cycle Button 4 = 25% duty cycle Button 5 = 75% duty cycle The PIC monitors the status byte of the MMC once a second to determine if a fault condition has occurred. If a fault occurs, an LED will light up. The fault condition will be cleared on the next button press prior to altering the duty cycle, turning off the LED. Schematic: C6 27 pF NOTE: PORTB INTERNAL PULL-UPS ENABLED U2 PIC16F73 20 2 21 3 4 11 12 13 5 6 7 14 8 19 1 18 17 22 23 24 25 27 28 16 15 9 10 26 VCC RA0 RB0/INT RA1 RA2 RC0 RC1 RC2 RA3 RA4 RA5 RC3 GND1 GND2 MCLR RC7/RX RC6/TX RB1 RB2 RB3 RB4 RB6 RB7 RC5/SDA RC4/SCL OSC1 OSC2 RB5 R1 1.0 Ohm VCC_MOTOR SW4 NO momentary detector 1 2 NOTE: SECOND MOTOR NOT SHOWN FOR CLARITY VCC_MOTOR C3 0.1 uF + C1 330uF 35V SW2 NO momentary detector 1 2 SW1 NO momentary detector 1 2 U1 MC7805B-D2T 1 2 3 VIN GND VOUT C5 27 pF VCC_5VDC C4 0.1 uF Y1 4.00MHz 2 1 4 3 R3 1.0K + C2 10uF 25V D1 Green R2 1.0K VCC_5VDC MOTOR M- M+ SW5 NO momentary detector 1 2 MOTOR MIND C 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 VMOT VMOT VMOT M1- M1- M1- M1+ M1+ M1+ NC GROUND GROUND GROUND AIN1/RC1 AIN2/RC2 NC NC NC NC TM FM ADDR NUM_MOT MODE0 MODE1 NC NC GROUND GROUND GROUND NC M2+ M2+ M2+ M2- M2- M2- VMOT VMOT VMOT SW3 NO momentary detector 1 2

AN706

  • Upload
    chelcho

  • View
    22

  • Download
    0

Embed Size (px)

Citation preview

Page 1: AN706

AN706: Motor Mind C control using a Microchip PIC16f73 1

Overview:This application note describes how to control the Motor Mind C (MMC) with Microchip's PIC16F73 microcontroller using the MMC's SetDC command as well as how to detect and clear fault conditions. This application note implements a simple serial control interface of the Motor Mind C (MMC) in both PIC assembly language and PIC MCU C. Five PIC16F73 pins are used as button inputs. Each button press sends a specific motor speed and direction command to the MMC.

Button 1 = -75% duty cycleButton 2 = -25% duty cycleButton 3 = 0 duty cycleButton 4 = 25% duty cycleButton 5 = 75% duty cycle

The PIC monitors the status byte of the MMC once a second to determine if a fault condition has occurred. If a fault occurs, an LED will light up. The fault condition will be cleared on the next button press prior to altering the duty cycle, turning off the LED.

Schematic:

C627 pF

NOTE: PORTBINTERNAL PULL-UPSENABLEDU2

PIC16F73

20

2

21

34

111213

567

14

8

19

1

1817

22232425

2728

1615

910

26

VCC

RA0

RB0/INT

RA1RA2

RC0RC1RC2

RA3RA4RA5

RC3

GND1

GND2

MCLR

RC7/RXRC6/TX

RB1RB2RB3RB4

RB6RB7

RC5/SDARC4/SCL

OSC1OSC2

RB5

R11.0 Ohm

VCC_MOTOR

SW4NO momentary detector

1 2

NOTE: SECONDMOTOR NOT SHOWNFOR CLARITY

VCC_MOTOR

C30.1 uF

+C1330uF 35V

SW2NO momentary detector

1 2

SW1NO momentary detector

1 2

U1MC7805B-D2T

12

3VINGND

VOUT

C527 pF

VCC_5VDC

C40.1 uF

Y14.00MHz

21

4 3

R31.0K

+C210uF 25V

D1Green

R21.0K

VCC_5VDC

MOTORM-

M+

SW5NO momentary detector

1 2

MOTOR MIND C

123456789

1011121314151617181920 21

22232425262728293031323334353637383940VMOT

VMOTVMOTM1-M1-M1-M1+M1+M1+NCGROUNDGROUNDGROUNDAIN1/RC1AIN2/RC2NCNCNCNCTM FM

ADDRNUM_MOT

MODE0MODE1

NCNC

GROUNDGROUNDGROUND

NCM2+M2+M2+M2-M2-M2-

VMOTVMOTVMOT

SW3NO momentary detector

1 2

Page 2: AN706

AN706: Motor Mind C control using a Microchip PIC16f73 2

Flow Chart:

Update PWM registersand send duty cycleinformation to MMC

Is a buttonbeing

pressed?

Has 20mselapsed?

PIC Port and Register Initialization

Yes

No

Decrement mainloop counter

Have we gone through the

main loop 50 times?

No

No

Yes

Reset loopcounter

Check MMCstatus

Yes

Clear faultLED

Is therea fault

condition?

No

Set faultLED

Attempt toclear fault

Yes

Page 3: AN706

AN706: Motor Mind C control using a Microchip PIC16f73 3

Source Code:

Complete source code can be found on the Solutions Cubed website: www.solutions-cubed.com . See AN706_asm.zip and AN706_c.zip.