• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Controlling DC motors speed using SD21(21 Channel Servo Driver Module) by PIC18F4520

Status
Not open for further replies.

Ecappp

New Member
Specifications:
Microcontroller: PIC18F4520
Crystal: 4 MHz
Language: C Programming (not assembly codes)
Compiler: MPLAB C18 C Compiler (MCC18)

Hi everyone. Basically, I would like to use the SD21(with reference from this website, " SD21 " ) to control DC motors speed by PIC18F4520. I have tried Google and have looked through the SD21 link but I totally don't understand the codes.

I need help on how I can use the SD21 to control DC motors speed using PIC18F4520 (in terms of C programming, how do I start, what registers do I need to use, from the PIC controller to the SD21 - how do I signal to the pins, steps to help me start). Any help would really be much appreciated.
 

Pommie

Well-Known Member
Most Helpful Member
You just need to connect the power and I²C lines in order to get it to work. You then send the commands via the I²C bus. However, that board (SD21) is a servo controller - not a motor controller. You would need a motor speed controller from the SD21 to each motor.

It seems a rather complicated way of doing things. If you describe what you are trying to do there may be a simpler way to achieve it.

Mike.
 

Ecappp

New Member
What I wanted to do initially was to control 4 motors individually using PWM. For PIC18F4520, I can only control 2 motors because there are only 2 PWM ports, CCP1 and CCP2. This was the reason why I thought of using the SD21 to generate multiple pulses at a time. I would like to ask if there are any other ways I can accomplish this with or without the use of the SD21?
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
An 18F4520 can easily control 4 servos (and hence 4 motors) using just one of the PWM channels. How good is your C? I posted an example of controlling a servo in this thread and the interrupt version could easily be extended to control 4 output pins.

Mike.
 

Mr RB

Well-Known Member
Motor PWM only needs to be a few hundred Hz. You can easily generate the 4 PWM signals manually using the PIC timers and software.

Try a google search for "PIC 18F software PWM" or "PIC generate 4 PWM in software" etc. :)
 

Ecappp

New Member
Thank you for all your replies. I only have 6 months of experience with PIC18F4520 and I am not very experienced with PWM. I think I'll need to re-phrase my question. Therefore, my question is, how can I control 4 DC motors individually using PWM?

I have tried using simple delays to generate pulses for the different speeds but the delay time for the 1st pulse seems to overlap with the other pulses, causing unstable voltage and speed. This is the main reason why I dropped the idea of using delays of generating pulses.

Instead, I tried using PWM to vary the DC motors' speed. I was successful in controlling the DC motors by PWM but there is only 2 PWM ports, CCP1 and CCP2 when I need to control 4 DC motors individually.

Is it possible to control multiple DC motors using the SD21, which I have mentioned above? Or is there any other simpler method to do so with just PIC18F4520 itself?
 

Ecappp

New Member
I am using just 4 DC motors and only 1 wire for each motor is required for speed control as I am feeding the PWM from the PIC18F4520 to the drivers which eventually drives the motors accordingly.

Also, I am just intending to stick with just PIC18F4520 for now as I am only familiar with this. Therefore, are there any suggested solutions to control multiple DC motors using the SD21, which I have mentioned above? Or are there any other simpler methods to do so with just PIC18F4520 itself, in terms of C programming?
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top