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.
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.
i am a PIC newbie. since i wan to build a car which its speed is able to vary, can i use the PWM pulse from the PIC to vary its motor speed.as i know, there is a PWM command in PIC basic. can i use it for that purpose?
is it the transistor is used as amplifier and switch and i just need to send the PWM pulse to it so that it can switch ON and OFF? that means i dont need any motor drive circuit?
The MOSFET's or transistors in this case would be a switch, and no external motor drive circuit would be necassary but....
1-This could only control the motor in one direction, so some form of direction control would be need to be used(such as an H-Bridge)
2-The PWM command outputs a pretty ugly signal, so minor filtering is needed(not sure how much for a motor circuit) such as a cap.
3-No other instructions will work during execution of the PWM command(so your pic couldn't do anything else while driving the motor)
If you are using Pic Basic Pro and your PIC has a hardware PWM module(CCP Module) the HPWM command would be better.This is a cleaner signal and runs in the background(so other commands will work while the pwm signal is used).I'll see if I can find some examples and post them.
thank u Eclipsed.
but in my project, the motor will only rotate in one direction, and its speed it able to vary. so i think H-bridge is not necessary. isnt it?
actually the speed is varying according to the distance of the transmitter source. when the transmitter source is far, the motor speed is increased in order to maintain constant distance with the transmitter.
and when the source is near with the car, the motor will rotate slowly. so that the car will not hit the trasnmitter. and when the transmitter is OFF, the motor will stop rotating.
do u have any idea on how to implement it with PIC16F877?
i use an IR and some comparator circuits. it is just a simple circuit. and it works fine.what i need now is the circuit to control the speed of the motor with PIC.
i need to submit the project by the mid of next month. hope somebody can help me
thank u Eclipsed.some of the links are useful
as i mentioned before, my car needs to vary the motor speed according to the distance of the transmitter source and the car will stop when the transmitting source is OFF. i have few questions:
(1) which command is appropriate?HPWM or PWM commands in PIC basic pro?
(2)i have read the programming manual and i know that the HPWM command is running continuosly in the background. that means the motor will continue to run without stopping, although the transmitting source is OFF?
You can do it either way(melabs example or with the HPWM command).That sample program will work for your app too.Just swap your distance calc code with their duty cycle sweep code and you should be set to go.Use their DUTY variable to alter speed ,for example, DUTY = 200 your motor speed = %20 or DUTY = 800 your motor speed = %80 or DUTY = 0 your motor speed = %0 or DUTY = 1000 your motor speed = %100.
Oh yeah, you shouldn't need to filter PWM from the CCP module of the pic.Just use a transistor or MOSFET and make sure your frequency is high enough, otherwise you will get a high pitch noise from the motor.
can anyone plz help me again?
today i hooked up the circuit to test the HPWM feature of the PIC16F877 but it doesnt seem to be work properly.
my testing code is shown below:
HPWM 1,0,0 'DUTYCYLE 0%
IF PORTA.0=1 Then 'CHECK PIN 0 STATE
HPWM 1,191,20000 'OUPUT 75% DUTYCYLE 20KHZ
IF PORTA.1=1 Then 'CHECK PIN 1 STATE
HPWM 1,127,20000 'OUTPUT 50% DUTYCYLE 20KHZ
What's wrong with the code? i just want to output certain frequency on pin RC2 when port A pins receive signal, but it doesnt work properly.
by using the oscillosocpe, i can see that the output is not a pure square wave, but is distorted. the frequency is only 50Hz!!!! the duty cycle doenst change at all.
is that anything wrong with the code? plz help me.my motor circuit wont run without it..
in this case,do i need to pull down all the unused pins?i only use two pins to detect signal and one pin as an output?
i connect the PIC based on the following diagram. but i also saw slightly different type of connection at **broken link removed**
they dont connect both Vcc and Vdd. which one is correct connection?