Some questions on motor speed control


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Some questions on motor speed control

    Quote Originally Posted by joseph Degorio View Post
    Hi everyone,
    I'm starting to explore on motors specifically on 12v DC motor. Basically first I want to make it stop, turn it half speed and full speed using 10K resistor on PortA.0. Can I apply the following code from markedwards?
    Code:
    ADCIN 1,AD1 'read channel 1...AN1
    AD1 = AD1 >> 6 'justify data
    
    ADJUSTFAN: 
    IF AD1 < 2 then FANSPEED = 153 '60% min speed
    IF AD1 >= 3 then SPEED = 178 '70%
    IF AD1 >= 5 then SPEED = 204 '80%
    IF AD1 >= 7 then SPEED = 229 '90%
    IF AD1 >= 9 then SPEED = 255 '100%
    IF SPEED > SPD THEN SPD = SPD + 1 'accelerate
    IF SPEED < SPD THEN SPD = SPD - 1 'de-accelerate
    hpwm 2,SPD,32760 ' PWM 20,000 Hz
    As I understand I need a pic that support HPWM, please forgive me if this may sound very basic but how I connect the assigned port pin to the motor?

    I have tried using L298N, which I can stop, turn cwise and ccwise the motor, can I also control the speed and can anyone show simple code how to do this?

    Thanks in advance,
    joe
    I am not sure about the logic of the code.
    But a very easy way of having the control of a motor by analog pin (with a pot) should be like:

    Code:
    ADCIN 0, CCPR1L ' Read Pot, and put the result directly to PWM register. Assuming 8-bit adc reading.
    Why don't you first try to see the result of this one line of code and then go on?
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Some questions on motor speed control

    ADCIN 0, CCPR1L ' Read Pot, and put the result directly to PWM register. Assuming 8-bit adc reading
    Hi sayzer, thanks for the time. I settle to use L298 because that's what I have right now. Can you help me check my connection between the PIC and L298..is this okay? Like I said in first post I was able to control the L298 but without PWM conttrol on PortB. Now I want to apply the PWM on PortC.1, but not really sure how is the connections...

    thanks in advance,
    joe
    Attached Images Attached Images  

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Some questions on motor speed control

    Quote Originally Posted by joseph Degorio View Post
    Hi sayzer, thanks for the time. I settle to use L298 because that's what I have right now. Can you help me check my connection between the PIC and L298..is this okay? Like I said in first post I was able to control the L298 but without PWM conttrol on PortB. Now I want to apply the PWM on PortC.1, but not really sure how is the connections...

    thanks in advance,
    joe

    I never used L298, I always made my own H-Bridge.
    Using PWM on L298, some people drive Enable pin by PIC's PWM output. I am not sure how effective this is.
    I would, however, use 7408 AND gate (two gates, one pin common to PWM pin), others to direction pins.
    This way, you always have a PWM channel, and also have the control of the direction.

    ______________________
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Some questions on motor speed control

    thanks, sayzer. I will try to take time to study it.

    regards,
    joe

Members who have read this thread : 0

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

Posting Permissions

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