Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PWM motor control using buttons

Status
Not open for further replies.

taiwofolu

Newbie level 2
Joined
Jan 20, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,304
PWM motor control using dtmf

Hello people!
I am building an embedded system and want to control the speed of a brushed motor with DTMF signals through a microcontroller such that when i press a button, the speed inreases and it reduces when i press another button but when theres no input, the speed remains constant. I have an ESC i intend to use for this but i have no idea how to implement this. Any help will be very much appreciated. Something like this: https://www.edaboard.com/threads/150409/ but with dtmf.
Thank you.
 
Last edited:

A DC brushed motor will increase its speed if the voltage across it increases, so you need someway of electronically storing a voltage which is applied to the motor. One way would be to dedicate, say 4 outputs of your processor to the motor drive. Each one having a digital value so you can store 1,2,4,8, this would give you up to 16 different speeds/direction ( say make output 2 = motor stationary larger numbers equal faster forward speeds, lower reverse speeds). This would only give you relatively coarse speed control - not suitable for berthing a super tanker :) . These outputs would then feed an digital to analogue convertor ( 4 resistors each four times the value of the preceding resistor) which are summed by an opamp. The output from the OPamp would then feed a power amplifier to supply the actual voltage to the motor.
If you need more motor speed steps then output available, then you need an up/down counter with an oscillator driving it. So you use your "speed up" output to allow the counter to run forward (output numbers increase) and your "slow down" output to reduce the number count. The outputs are then dealt with as before. You will then have to buy a suitable D to A convertor chip.
Frank
 

Thanks for your reply Chuckey. I'm sorry I didn't post again on this thread since your reply. I had to do some more reading and research because many terms weren't clear to me. After my study, I wrote this code:


Code C - [expand]
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
41
42
43
44
45
/* PROGRAM WRITTEN BY TAIWO FOLU. PWM CONTROL OVER BLUETOOTH WITH DTMF TONES. INPUT ON ATTINY2313 PINS PB4 TO PB7. PWM SIGNAL OUTPUT ON PB2 (OC0A) AND PD5 (OC0B) USING TIMER0. TWO EXTRA I/O PINS ON PB0 AND PB1*/
 
#include <avr/io.h>
 void initPWM()
{
 TCCR0|=(1<<WGM01)|(1<<COM01)|(1<<CS00);
//Freq=FCPU, phase correct pwm, non inverted PWM (mode3)
 DDRB|=0xE0; //Set PB0, PB1 and PB2 for output and the rest for input
 DDRD|=(1<<PD5); //Set PD5 for output
}
 void SetPWMOutput(Uint8_t duty)
{
 OCR0A=0; //Set dutyA to 0%
 OCR0B=127; //Set dutyB to 50%
}
 void main()
{
 Unsinged int f;
 while (1)
{
 f=PINB;
 switch (f)
 {
  case 0x04: //when key 4 is pressed
  {
   OCR0B++; //increment OCR0B
   break;
  }
  case 0x05: //when key 5 is pressed
  {
   OCR0A++; //increment OCR0A
   break;
  }
  case 0x06: //when key 6 is pressed
  {
   OCRB--; //decrement OCR0B
   break;
  }
  case 0x0A: //when key0 is pressed
  {
   OCR0A--; //decrement OCR0A
   break;
  }
 }
}





I intend to use the dtmf tones to control the duty cycles of pwm channels A and B on timer0. Please look through the code and help me if i've made any mistakes or unnecessary statements. Here, i've not used the PB0 and PB1 pins yet so I don't get confused, I want to get the duty cycles control right first.

Cheers
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top