+ Reply to Thread
Results 1 to 27 of 27
  1. #1
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Hi all!

    I'm NOT an electronics engineer! That said, I am doing my best. What I do not have is a scope to look at the PWM output and so I am leaning on you good folks to guide me. Please.

    Pardon my sketch. I never could draw a descent relay. :-P So I drew it like it is wired. The relay is used to reverse polarity to the motor outputs. I forgot to draw a diode for the motor supply circuit to the relay contacts but it's in there too.

    I am using a logic level N-Channel Mosfet. This is where I am the most unsure. I do not know what resistors or capacitors I should use to give it a clean PWM signal. I have drawn up what I currently have but it does not appear to work. It does work when I just make the GPIO.0 High or Low, turning the MOSFET on and the LED on and off. That works. Also, the relay works fine. But there is no joy with the PWM. I suspect the resistors and capacitor.

    I don't read electronics data sheets too well. So I don't know if the MOSFET gate input is high impedance or if it turns on like an LED drawing a lot of current. I suspect high impedance but I put a resistor R1 (270 ohms) in series with the gate so I don't source too much current from the PIC output pin. Don't know if it was needed (or wanted).

    The 15k resistor to ground was suggested from another similar circuit to prevent the MOSFET from staying on. And the .1 uf cap to ground was suggested in the Picbasic Pro manual to clean up the PWM output signal. Sooo... I hodgepodged all three in there. That's my mechanical mind working on electronics. Moo HAA HAA!

    If a couple of electronics geniuses could look this over I would be much obliged!

    GPIO.4 and 5 were for adding an external crystal which I haven't done so they are disconnected. I have turned on the internal pull-ups and made them inputs in the program.

    I'm sorry the attached jpg is coming in sideways. :-P I will follow this posting with my current program.

    Thank you!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  2. #2
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    This my current program. I'm using a 12F675. Currently, the program is intended to test the ADCIN to insure I captured POT_CNTR and to test the PWM output of the MOSFET.

    But alas, the only thing I have verified that works is buzzing the relay and turning the LED on and off with HIGH LED and LOW LED.

    The CHECK_POT subroutine did not produce anything leaving me to wonder, "did I "grab" POT_CNTR or not?" I have scrutinized my configuration setup and poured over the 12F675 data sheets. Everything looks right! Leaving me to wonder... is it my program? the circuit board? the configuration? or is MPLAB changing something when I program the chip?

    Ultimately, I am trying to control both speed and direction with a single potentiometer input. The on-board relay determines motor direction. I will also control acceleration and deceleration in software.

    Here's my code...

    Code:
     Define OSCCAL_1K 1  ' Calibrate internal oscillator (4mhz)
      
        TRISIO = %00111100  ' GPIO.2,3,4 and 5 INPUTS, GPIO.0 and 1 OUTPUTS
        ANSEL  = %01010100  ' Fosc /16, Set AN2 analog, the rest digital
        ADCON0 = %10001001  ' Turn on A/D module, Enable AN2, R Justify Result
        CMCON = 7           ' Analog comparators off
        WPU = %00110000     ' Turn on weak pullups on GPIO.4 and 5
       
        DEFINE ADC_BITS 10          ' Set number of bits in result
        DEFINE ADC_CLOCK 5          ' Set clock source (16 Tosc)
        DEFINE ADC_SAMPLEUS 50      ' Set sampling time in uS
        
    '*******************************************************************************
    'VARIABLES:
        
        MOTOR VAR GPIO.0        'MOTOR ON PIN 2, START WITH IT OFF
        LOW MOTOR
        LED VAR MOTOR
        
        RELAY var GPIO.1        'RELAY DETERMINES MOTOR DIRECTION, PIN 3
        HIGH RELAY              'START WITH RELAY DE-ENERGIZED
        
        POTT VAR GPIO.2         'POT ON PIN 4, INPUT
        
        BUTN VAR GPIO.3         'START/STOP SWITCH (ALSO REMOTE FOOT SWITCH), PIN 5
                                'BUTTON PULLS PIN LOW (WHEN PUSHED)
                                
        POT_CNTR VAR WORD       'THIS VALUE TO BE STORED IN EEPROM DURING 
                                'INITILIZATION ROUTINE.
                                
        TEMP VAR BYTE
                                    
        I var byte              'VARIABLES USED FOR GENERAL COUNTERS. INIT AS ZERO.
        I = 0
        J VAR BYTE
        J = 0                   
    
        SPEED_NEW VAR WORD      'VARIABLE TO STORE A/D VALUE
        SPEED_OLD VAR WORD      'VARIABLE TO STORE PREVIOUS A/D VALUE
        
        DIR VAR BIT             'VARIABLE TO DETERMINE CW OR CCW REVOLUTIONS
        
        RUNN VAR bit            'RUN / STOP BIT. MACHINE COMES UP IN STOP MODE
        runn = 0
       
        high led
        PAUSE 500               '1/2 SECOND PAUSE BEFORE CONTINUING
        low LED
    
    '******************************************************************************
    
    'INITIALIZATION ROUTINE... POT IS TURNED HALF-WAY TO MIDDLE POSITION AND 
    'START/STOP SWITCH (BUTTON SW) IS PUSHED AND HELD WHILE MACHINE POWER IS TURNED
    'ON. AFTER HOLDING THE BUTTON FOR TWO SECONDS ADCIN GRABS THE CURRENT POT VALUE
    'AND STORES THAT VALUE IN WORD VARIABLE "POT_CNTR". NEXT, IT WRITES THE UPPER 
    'AND LOWER BYTES OF POT_CNTR INTO EEPROM POSITIONS 1 AND 0 RESPECTIVELY. THESE
    'VALUES SHOULD BE HELD EVEN WHEN THE POWER IS TURNED OFF. THEN THE ON-BOARD 
    'RELAY BUZZES TO GIVE AUDIBLE FEEDBACK THAT INITIALIZATION WAS COMPLETED.   
        
    INITIALIZE:
        WHILE BUTN = 0          'CHECK FOR BUTTON PRESS
        IF I = 100 THEN
        ADCIN GPIO.2, POT_CNTR
        WRITE 0, POT_CNTR.BYTE0
        WRITE 1, POT_CNTR.BYTE1
        GOSUB BUZZ
        ENDIF
        PAUSE 20
        I = I + 1
        WEND
        i = 0                   'Reset Variable I
        
    '******************************************************************************
    'THE POT ONLY NEEDS TO BE INITIATED ONCE AS THE EEPROM SHOULD HOLD THAT VALUE
    'AFTER POWER IS REMOVED. THE FOLLOWING LINES READ THE LOWER AND UPPER BYTES
    'FROM THE EEPROM BACK INTO THE VARIABLE POT_CNTR (IN CASE INITIALIZATION WAS
    'NOT PERFORMED DURING CURRENT POWER-UP).    
    
        READ 0, POT_CNTR.BYTE0
        READ 1, POT_CNTR.BYTE1
        
    '******************************************************************************    
    'FROM HERE, THE PROGRAM LOOPS THROUGH TWO SUBROUTINES. FIRST IT GETS THE CURRENT
    'VALUE OF THE POT WITH ADCIN AND PLACES IT IN WORD VARIABLE SPEED_NEW. THEN IT 
    'CHECKS THAT NEW VALUE AGAINS WORD VARIABLE POT_CNTR. SEE TEXT BELOW
    
    
    MAIN:
        PWM LED,TEMP,200
        GOSUB GET_POT
    '    GOSUB CHECK_POT
        GOTO MAIN
        END
    
    '******************************************************************************
    'THIS PUT IT TO BUZZ RELAY. PROGRAM FEEDBACK.
    
    BUZZ:
        for J = 1 to 10
        toggle relay         
        pause 20
        next J
        return
    
    '******************************************************************************
    'READ POT POSITION AND PUT IT IN WORD VARIABLE "SPEED_NEW".
    
    
    GET_POT:                    
        ADCIN POTT, SPEED_NEW
        TEMP = SPEED_NEW / 4
        RETURN
       
    '******************************************************************************
    'TURNING THE SPEED POT CCW FROM CENTER POSITION CAUSES LED (ON MOTOR CIRCUIT) TO
    'COME ON. TURNING THE SPEED POT CW FROM CENTER POSITION CAUSES LED TO BLINK.
    'LED IS OFF WHEN THE POT IS NEAR CENTER POSITION ("20" WAS ADDED TO LOWER 
    'SENSITIVITY OF THE CENTER POSITION.
    
    CHECK_POT:
        IF SPEED_NEW >= (POT_CNTR - 20) AND SPEED_NEW <= (POT_CNTR + 20) THEN
        LOW LED
        ENDIF
        
        IF SPEED_NEW < (pot_cntr - 20) THEN
        HIGH LED
        ENDIF
        
        IF SPEED_NEW > (pot_cntr + 20)  THEN
        TOGGLE GPIO.0
        PAUSE 50
        ENDIF
        RETURN
    Thank you again for your help!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  3. #3
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    I just noticed in my program notes that I called out incorrect pin numbers. Please disregard. I numbered the chip pins backwards in my head. :-P

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    I don't read electronics data sheets too well. So I don't know if the MOSFET gate input is high impedance or if it turns on like an LED drawing a lot of current. I suspect high impedance but I put a resistor R1 (270 ohms) in series with the gate so I don't source too much current from the PIC output pin. Don't know if it was needed (or wanted).
    for a switching cct as pwm control is the idea is to switch the mosfet completely on to completely off and vice versa as quickly as possible to minimise switching loss and heat, the 270 ohm resistor will not help , a gate R rg is often employed to reduce the possibility of "ringing" being introduced at high switching speeds 10 to 20 ohms is more realistic





    The 15k resistor to ground was suggested from another similar circuit to prevent the MOSFET from staying on.
    won't hurt




    And the .1 uf cap to ground was suggested in the Picbasic Pro manual to clean up the PWM output signal.
    very bad idea , it will only serve to make the mosfet switch more slowly and generate lots more heat for no good reason at all
    we are not trying to generate a linear voltage here at all.its all about switching ,the motor will do the integrating
    This is more entertaining than Free to Air TV

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    one thing i have noticed is that when mosfets fail they always go short circuit drain to gate in their best effort to take out the pic chip on the way.
    i have taken to use a driver circuit between the pic and the fet when prototyping with more expensive chips
    IR2106 and the like (not that they are really cheap)
    This is more entertaining than Free to Air TV

  6. #6
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    867

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    I am out of touch with Picbasic for quite some time now, but, I guess you will be able to follow what I'm trying to communicate

    For now, this section of code should be rewritten
    Code:
        PWM LED,TEMP,200
        GOSUB GET_POT
    '    GOSUB CHECK_POT
        GOTO MAIN
        END
    as
    Code:
        low motor                                     ' on time
        delay speed_new                         ' proportionate to the control
        high motor                                    ' turn off the motor
        
        gosub get_pot
        goto main
    Hopefully you will find some activity out of the motor proportionate to the speed control

    After this is found to work satisfactorily, you can try to implement the PWM function call at a frequency that works for the hardware setup

    Regards
    Jerson
    Last edited by Jerson; - 2nd February 2019 at 03:38. Reason: oops

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    if you plug a few pot values into your code you get this response, i cant imagine the pwm pulse width value TEMP is really what you intend
    i would expect the pw to be zero in the pot centre posn and 255 at either extremity
    Code:
    spn	temp 	led
    0	0	on
    50	12	on
    100	25	on
    150	37	on
    200	50	on
    250	62	on
    300	75	on
    350	87	on
    400	100	on
    450	112	on
    500	125	off
    550	137	tog
    600	150	tog
    650	162	tog
    700	175	tog
    750	187	tog
    800	200	tog
    850	212	tog
    900	225	tog
    950	237	tog
    1000	250	tog
    Last edited by richard; - 2nd February 2019 at 05:48.
    This is more entertaining than Free to Air TV

  8. #8
    Join Date
    Feb 2013
    Posts
    546

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Sorry but why not use dedicated motor control ICs? like TA8050P or similar? They have logic level inputs of all kinds, so no need for relay or extra mosfets. And these IC's are cheap...

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    re relay

    1 i would be surprised if a pic pin could source enough current to drive a relay ,do you have any specs fior the relay ?
    2 you have no diode across the coil to suppress back emf , it will destroy the pic very quickly.
    3 buzzing relays is seldom a good move they are not designed for it and if carrying any current will very quickly burn out the contacts
    4 nowhere in your code do you calculate any direction setting to even control the relay

    i'm curious as to why you need to set and store the pot centre posn surely its at the mid point of travel and at a wiper voltage of vcc/2
    seems unnecessary to be any different that i can see
    This is more entertaining than Free to Air TV

  10. #10
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Quote Originally Posted by Jerson View Post
    I am out of touch with Picbasic for quite some time now, but, I guess you will be able to follow what I'm trying to communicate

    For now, this section of code should be rewritten
    Code:
        PWM LED,TEMP,200
        GOSUB GET_POT
    '    GOSUB CHECK_POT
        GOTO MAIN
        END
    as
    Code:
        low motor                                     ' on time
        delay speed_new                         ' proportionate to the control
        high motor                                    ' turn off the motor
        
        gosub get_pot
        goto main
    Hopefully you will find some activity out of the motor proportionate to the speed control

    After this is found to work satisfactorily, you can try to implement the PWM function call at a frequency that works for the hardware setup

    Regards
    Jerson
    I'll give that a try.

    Thank you,

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  11. #11
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Quote Originally Posted by richard View Post
    if you plug a few pot values into your code you get this response, i cant imagine the pwm pulse width value TEMP is really what you intend
    i would expect the pw to be zero in the pot centre posn and 255 at either extremity
    Code:
    spn	temp 	led
    0	0	on
    50	12	on
    100	25	on
    150	37	on
    200	50	on
    250	62	on
    300	75	on
    350	87	on
    400	100	on
    450	112	on
    500	125	off
    550	137	tog
    600	150	tog
    650	162	tog
    700	175	tog
    750	187	tog
    800	200	tog
    850	212	tog
    900	225	tog
    950	237	tog
    1000	250	tog
    The code written was to check that I was getting good numbers from reading the pot with ADCIN. And it's not. :-P

    I will re-write the code when I have this working.

    Thank you,

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  12. #12
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Quote Originally Posted by richard View Post
    re relay

    1 i would be surprised if a pic pin could source enough current to drive a relay ,do you have any specs fior the relay ?
    2 you have no diode across the coil to suppress back emf , it will destroy the pic very quickly.
    3 buzzing relays is seldom a good move they are not designed for it and if carrying any current will very quickly burn out the contacts
    4 nowhere in your code do you calculate any direction setting to even control the relay

    i'm curious as to why you need to set and store the pot centre posn surely its at the mid point of travel and at a wiper voltage of vcc/2
    seems unnecessary to be any different that i can see
    I'm sinking rather than sourcing and this part of my board is working well. I don't have the relay part number but it's made for logic level use. The buzzing of the relay is temporary only to test the program and circuits. I'm not certain but I'm pretty sure there is an internal diode in the relay. I originally had the polarity to the coil reversed and it wouldn't work. :-P It is socketed so I can replace it if damaged. But it's not under load while i'm testing this way so the contacts should be fine for now.

    Thank you!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  13. #13
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Quote Originally Posted by CuriousOne View Post
    Sorry but why not use dedicated motor control ICs? like TA8050P or similar? They have logic level inputs of all kinds, so no need for relay or extra mosfets. And these IC's are cheap...
    This is where my electronics knowledge is poor. I am driving a 12v 30 watt motor but there is very little load on it in use. I haven't measured the current draw yet. My bad. Anyway, I've used Mosfets in the past and they seemed to work well. I am open to all opinions on this. Can you share more information around this and compare them... advantages, drawbacks of either?

    Thank you!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  14. #14
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Code:
     ADCIN POTT, SPEED_NEW
    thats a problem should be
    Code:
     ADCIN 2, SPEED_NEW
    its adcin channel, var not adcin pin alias, var

    I'm sinking rather than sourcing and this part of my board is working well. I don't have the relay part number but it's made for logic level use.
    just cause its a 5v relay does not mean its operate current is less than the 25mA a pic can sink or source.
    This is more entertaining than Free to Air TV

  15. #15
    Join Date
    Oct 2009
    Posts
    597

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Quote Originally Posted by richard View Post
    re relay

    1 i would be surprised if a pic pin could source enough current to drive a relay ,do you have any specs fior the relay ?
    2 you have no diode across the coil to suppress back emf , it will destroy the pic very quickly.
    3 buzzing relays is seldom a good move they are not designed for it and if carrying any current will very quickly burn out the contacts
    4 nowhere in your code do you calculate any direction setting to even control the relay
    I've always sourced current rather then sink it from a PIC, and in the case of a relay, the PIC drives an NPN transistor such as a 2N2222, which in turn switches the coil (with a 1N4001 - 1N4004) diode across the coil.

  16. #16
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Richard,

    I need to correct the cap value I mentioned on the PWM (for others that might read this). I had a 1 uf cap to ground. The PIC manual called for a 1 nF cap. I removed the cap.

    I also changed the resistor to 10 ohms and the PWM output is now working. There is a lot of ringing in the motor that is undesirable and it seems like I have to turn the pwm up pretty high before I get the motor to start moving. Maybe that's normal for the motor size I am currently using. I'm pretty sure the motor is overkill for this application. But I like a little overkill and the shaft configuration is perfect for attachment of a 3d printed pulley. Still, if i could find a cheap 10 watt motor I'd like to try that.

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  17. #17
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    I need to correct the cap value I mentioned on the PWM
    the correct value is none at all
    There is a lot of ringing in the motor that is undesirable
    its not ringing its the coils vibrating at the pwm frequency , the solution is to increase the freq till its out of human hearing range
    things to watch are , heating of the motor/mosfet . some motors don't play well at high frequencies and can get quite hot for no good reason
    i would chose the lowest freq that results in an acceptable noise level ,mosfet losses are proportional to freq


    I have to turn the pwm up pretty high before I get the motor to start moving.
    thats to be expected there are many losses to overcome before the motor can move ,its not unusual to actually operate the motor at a higher voltage than rated
    to help overcome inertia
    Last edited by richard; - 2nd February 2019 at 13:29. Reason: convert from gibberish to english
    This is more entertaining than Free to Air TV

  18. #18
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Ok... no cap to ground. Got it.

    I am aware that I can specify the frequency for HPWM. But can I specify frequency for PWM? I thought all I could do was set duty and the number of cycles with PWM. I'm using a 12F675. No hardware PWM available.

    Ross

  19. #19
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    just fyi

    if you were to use a chip with a few smarts like a 12f1822 you can use the pwm output in bridge mode and you don't need a relay at all
    and better still the adc result can be fed into the pwm module directly as it read . pot centre is motor stopped anti clockwise increases speed in one direction clockwise the other . no calculations the hardware does all the work and you can set the pwm frequency et al .
    This is more entertaining than Free to Air TV

  20. #20
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    I am aware that I can specify the frequency for HPWM. But can I specify frequency for PWM? I thought all I could do was set duty and the number of cycles with PWM. I'm using a 12F675. No hardware PWM available.


    agreed , you could try tricking the compiler and try using
    DEFINE OSC 3
    for a slightly higher freq
    or
    DEFINE OSC 8
    for a slightly lower freq
    This is more entertaining than Free to Air TV

  21. #21
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    not sure how this would go with a motor [it can dim leds so its a possible method]
    http://dt.picbasic.co.uk/CODEX/MIBAM
    its a challenge to do high speed pwm with a very old limited chip @4mhz ,i don't think i could get far even using asm these days .
    advanced core chips are cheap and make me lazy
    This is more entertaining than Free to Air TV

  22. #22
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Quote Originally Posted by Scampy View Post
    I've always sourced current rather then sink it from a PIC, and in the case of a relay, the PIC drives an NPN transistor such as a 2N2222, which in turn switches the coil (with a 1N4001 - 1N4004) diode across the coil.
    Coil current is 16ma.

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  23. #23
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Quote Originally Posted by richard View Post
    just fyi

    if you were to use a chip with a few smarts like a 12f1822 you can use the pwm output in bridge mode and you don't need a relay at all
    and better still the adc result can be fed into the pwm module directly as it read . pot centre is motor stopped anti clockwise increases speed in one direction clockwise the other . no calculations the hardware does all the work and you can set the pwm frequency et al .
    OK... so... I'm working with PBP 2.41. Can't do the new fun chips. But I do have a couple of 16f88s around here. That would at least get me HPWM and a spare output or two.

    By the way, thanks for catching the ADCIN channel mistake. That took care of that problem. I didn't know I had to call out the analog channel. These are the things that will drive us newbies crazy!

    I still need to verify that I am storing POT_CNTR and retrieving it properly. That's the last hurrah. Then it's just writing a descent program. My code still hasn't managed to verify that yet.

    The one caveat that I now have is the "singing" motor and possibly overheating the FET. It's getting hot and I have no heat sink on it as yet. If I turned it on harder with a FET driver that might help. (...another board change. :-/ ) Everything else works (thank you!). With some head scratching (banging) I can write the code to do everything I want. I would still need to use the relay but no big deal.

    The singing motor is a show stopper. Can't have the noise in my application. Nope. That may be reason enough to move to the hardware PWM. That would give me higher frequencies.

    I do have an H-Bridge chip around here somewhere. It would likely need a heat sink but it may do the job. Still need to measure the current draw.

    Thank you for your continued support. This is hobby stuff for me. I'm having fun but it can get hard from time to time.

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  24. #24
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    I didn't know I had to call out the analog channel. These are the things that will drive us newbies crazy!
    you can always read the manual

    5.3 ADCIN
    ADCIN Channel, Var
    Read the on-chip analog to digital converter Channel and store the result in Var. While the ADC registers can be accessed directly, ADCIN makes the process a little easier.
    I still need to verify that I am storing POT_CNTR and retrieving it properly.
    i still can't see any need to do that ,if its not vcc/2*1024/vcc or there abouts then something is wrong


    the FET. It's getting hot and I have no heat sink on it as yet
    your fet expects a 10v vgs to achieve minimum rds on , removing the gate resistor will help .a driver is better .
    a heatsink is most likely required too pic chips don't really have the drive capacity to shift the gate charge on power mosfets quickly enough
    This is more entertaining than Free to Air TV

  25. #25
    Join Date
    Jan 2014
    Posts
    81

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Here you have full schematic . I suggest:

    - D1 and D2 are absolutely necessary !!! ( some relais have diode inside, so D1 is not necessary )
    - the best drive for relay is a NPN transistor ( the pic gate have 20-25mA limit )
    - use a microcontroller with CCP , its simply to use HPWM in programm ( PWM have a pause in pwm signal)

    The problem will occur when you want to change the direction of rotation because will be possible some shocks in the engine. Attachment 8865I suggest you think of a protection for reversing the direction of rotation

  26. #26
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    Thank you Midali,

    I appreciate your nice schematic. I will look at using a 16F88 for HPWM. D2 is in place now... I will plan to add D1. I will measure the current draw for the relay but by specs, it is only drawing about 15ma so I'm not sure the transistor is necessary. But I may do that anyway as well when I make up the new board.

    Thanks again!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  27. #27
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,914

    Default Re: Motor Control Circuit (JPG Attached) for scrutiny and discussion...

    At 5V I doubt the relay has 15mA current to set it ON.

    Do use a transistor to drive it.

    Ioannis

Similar Threads

  1. PIC 16F877A circuit for stepper motor...
    By kristina in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th June 2012, 08:13
  2. Replies: 11
    Last Post: - 6th November 2008, 10:27
  3. dc motor control using pic16f876
    By parinshah in forum General
    Replies: 0
    Last Post: - 1st April 2006, 15:29
  4. IrOBEX transfer JPG to mobile phone
    By Jumper in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th March 2006, 18:19
  5. HPWM Motor Control
    By hughgoodbody in forum General
    Replies: 7
    Last Post: - 30th January 2005, 22:41

Members who have read this thread : 25

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts