|
|
View previous topic :: View next topic |
Author |
Message |
doguhanpala
Joined: 05 Oct 2016 Posts: 120
|
Motor drive fuse settings |
Posted: Thu Dec 15, 2016 7:29 am |
|
|
hello,
I am driving 2 motors with L293d. I use 18f2550.
I tried the motors of makeblock. They work without a problem. The current is about 200 mA (for 2 motors, 100 for each). But when i connect a more powerful motor, the pic stops working. I connected the second motor to the voltage source and it works without a problem, and the current about 150 mA (for one motor). At first i thought it was because of high current and L293d did not work correctly but after measuring currents it made no sense.
I think there is something wrong about my fuse settings. I think one of it blocks the pic about current or voltage (i don't use crystal.)
Any ideas?
thank you.
Note: I changed the 'put' to 'noput', no luck. I changed the nobrownout to brownout, the motors which have worked, stopped working.
Code: |
#include <18F2550.h>
#fuses INTRC_IO, NOWDT, PUT,NOMCLR,NOPROTECT,NOLVP,NODEBUG,NOBROWNOUT
#device ADC=10
#use delay(clock=4000000)
#define motor1_pin1 PIN_A1 //pin2 on l293d
#define motor1_pin2 PIN_A2 //pin7 on l293d
#define motor2_pin1 PIN_A3 //pin15 on l293d
#define motor2_pin2 PIN_A4 //pin10 on l293d
unsigned int speed=255;
//motor komutları
void motor1_Forward() //motor 1 ileri
{
OUTPUT_HIGH(motor1_pin1);
OUTPUT_LOW(motor1_pin2);
}
void motor1_Backward() //motor 1 geri
{
OUTPUT_HIGH(motor1_pin2);
OUTPUT_LOW(motor1_pin1);
}
void motor2_Forward() // motor2 ileri
{
OUTPUT_HIGH(motor2_pin2);
OUTPUT_LOW(motor2_pin1);
}
void motor2_Backward() //motor 2 geri
{
OUTPUT_HIGH(motor2_pin1);
OUTPUT_LOW(motor2_pin2);
}
void motor1_Stop() //motor 1 dur
{
OUTPUT_LOW(motor1_pin2);
OUTPUT_LOW(motor1_pin1);
}
void motor2_Stop() //motor2 dur
{
OUTPUT_LOW(motor2_pin2);
OUTPUT_LOW(motor2_pin1);
}
//motor komutları bitti
//====================================//
//robot_komutları
void robot_Forward() //robot ileri
{
motor1_Forward();
motor2_Forward();
}
void robot_Backward() //robot geri
{
motor1_Backward();
motor2_Backward();
}
void robot_Stop() //robot dur
{
motor1_Stop();
motor2_Stop();
}
void robot_goRight_one_motor()
{
motor1_Forward();
motor2_Stop();
}
void robot_goLeft_one_motor()
{
motor1_Stop();
motor2_Forward();
}
void robot_goRight_two_motor()
{
motor1_Backward();
motor2_Forward();
}
void robot_goLeft_two_motor()
{
motor1_Forward();
motor2_Backward();
}
void main()
{
setup_oscillator(OSC_4MHZ);
setup_timer_2(T2_DIV_BY_16,250,1);
setup_CCP1(CCP_PWM); // pin 1 on l293d
setup_CCP2(CCP_PWM);
set_pwm1_duty(speed);
set_pwm2_duty(speed);
while(TRUE)
{
robot_Forward();
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Dec 15, 2016 8:00 am |
|
|
It's most likely hardware.
Problem is that a motor, first of all draws a lot more than it's 'running' current as it accelerates to speed. Your supply may well be able to cope, but how well is the voltage maintained when this happens?.
Then (and the most likely problem). The L293D has the motor clamp diodes internally. To work, the Vcc2 pin has to be able to take the energy from these and absorb this without going too high. A simple DC supply, could easily go overvoltage for a moment as the motor decelerates. Even if it still remains inside the legal voltage for the chip, if it rises at all significantly, this can result in spikes being coupled into the PIC pins. With a bigger motor, there is more energy involved.... |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Thu Dec 15, 2016 8:06 am |
|
|
Quote: | Note: I changed the 'put' to 'noput', no luck. I changed the nobrownout to brownout, the motors which have worked, stopped working. | I assume the last part of this sentence means nothing now works.
Looks like you've bricked the PIC.
As Mr T. says "hardware problem".
Mike |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Dec 15, 2016 8:27 am |
|
|
It may just be that the PIC supply is drooping so badly during startup, that even the small motors now stop it working.
It's worth understanding that this is why the chips have two supply pins. Vcc1, is for the 5v supply that connects your processor. Should have it's own decoupling.
The Vcc2 is for the supply that feeds the motors. Even if these are '5v', the supply should be separate. If you are using a single source supply, then have a reasonably large decoupling capacitor (470uF+), feed this to the Vcc2 pin. Then separate the processor supply. Have a power inductor in the 5v rail (220uH), feeding another smaller capacitor (47uF), and have this feeding the PIC and the Vcc1 pins, with 0.1uF ceramic or polyester capacitors adjacent to the supply pins on the PIC, and to the Vcc1 pin.
This way the supply should only spike a very little as the motor is controlled. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Thu Dec 15, 2016 9:45 am |
|
|
I have to agree, power supply problem...
It should be rated for at LEAST 5-6 amps, 10 preferred.
Also the motors will need EMI components added
And as stated proper EMI caps,etc near the PIC !
Have to wonder why only 4MHz clock when it can easily to 48MHz ?
Jay |
|
|
doguhanpala
Joined: 05 Oct 2016 Posts: 120
|
|
Posted: Fri Dec 16, 2016 2:12 am |
|
|
Hello again,
Thank you all for replies.
Mike Walne wrote: | ]I assume the last part of this sentence means nothing now works.
Looks like you've bricked the PIC. |
it was a 'those fuses are about voltage so lets try it, what have i got to lose approach'
temtronic wrote: | Have to wonder why only 4MHz clock when it can easily to 48MHz ? |
I will use some other pic for the project. After deciding what will be in the project and what will not, we will choose a more suitable pic. I don't need that speed so i don't use a crystal.
As for Ttelmah replies, i assumed it might be the 'spike' when the motor starts running. The reason i am confused, i used the same motors (the ones don't work now) with same pic and same motor driver. Since the low current motors worked and the high current ones worked before, i thought it could be from software (i wrote it a while ago and was not careful about fuse settings). I did not use capacitors that time too.
I will build the circuit one more time, with capacitors. and with feeling
Thank you all. You all have been very helpful. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Fri Dec 16, 2016 2:30 am |
|
|
Think about what you said.
Small motors. No brownout fuse. System ran.
Same motors. Brownout fuse. System no longer works.
Since the 'brownout' fuse will reset the PIC if the supply goes down to the specified brownout voltage, while without this, the processor 'may' keep working, implication is that the processor supply is dropping during the boot, below the brownout voltage. If this is happening because of trying to start the motor, then it'll probably never run, instead you might get a little noise from the motor as it 'tries' to start, and the processor keeps resetting..... |
|
|
doguhanpala
Joined: 05 Oct 2016 Posts: 120
|
|
Posted: Fri Dec 16, 2016 2:45 am |
|
|
Ttelmah wrote: | Think about what you said.
Small motors. No brownout fuse. System ran.
Same motors. Brownout fuse. System no longer works.
Since the 'brownout' fuse will reset the PIC if the supply goes down to the specified brownout voltage, while without this, the processor 'may' keep working, implication is that the processor supply is dropping during the boot, below the brownout voltage. If this is happening because of trying to start the motor, then it'll probably never run, instead you might get a little noise from the motor as it 'tries' to start, and the processor keeps resetting..... |
I tried the brownout fuse but after that i changed back and saw the motors run again. I just tried it. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Fri Dec 16, 2016 3:06 am |
|
|
So it is telling you exactly what is happening. The supply to your PIC is reaching the 'brownout' voltage range, when the motors try to start.
It is 'limping' through it with the small motors, but right at the voltages where the PIC is not guaranteed to work reliably....
You have a major hardware problem with your supply/layout.
It's worth perhaps saying that for a typical DC brushed motor, the 'startup' current will be at least 10*, and more typically perhaps 15* the 'free' current (what it draws rotating with no load). If your small motors are drawing 100mA running free, then I'd be looking at a supply rating of at least 1.5A to handle startup, and you will also be very close to the 'maximum' rating of the L293 (the -D variant is only rated for 1.2A, while the standard variant without the internal diodes is rated for 2A)..... |
|
|
doguhanpala
Joined: 05 Oct 2016 Posts: 120
|
|
Posted: Fri Dec 16, 2016 4:44 am |
|
|
Ttelmah wrote: | So it is telling you exactly what is happening. The supply to your PIC is reaching the 'brownout' voltage range, when the motors try to start.
It is 'limping' through it with the small motors, but right at the voltages where the PIC is not guaranteed to work reliably....
You have a major hardware problem with your supply/layout.
|
At first i tried supplying pic and motor driver from same source (both logic input and motor input) because my project will work with batteries and won't have a second source. I tried supplying pic from computer's usb voltage. (I remembered i did it this way first time) now all motors work. Thank you so much! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Fri Dec 16, 2016 6:23 am |
|
|
You still have a 'power supply problem', though you can't see it. A USB port typically can supply 500ma of current but depending on the PC operating system, the USB port can be limited to 100ma ! I found this out the hard way when a project that 'used to work' didn't. By running USBView, it showed me the USB port was indeed limited to 100ma,yet another port was set for 500ma.
Also, as has been pointed out, the initial motor current can be quite high,so that will drop the USB 5 volts down. Adding large(470 or 1000 mfd) caps on the +5 will lessen the effect, but sooner or later, you'll have to build a proper supply for testing. Something good for 5 amps would be OK.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Sat Dec 17, 2016 4:37 am |
|
|
What he is doing Temtronic, is using the USB for the 'logic' supply, and the existing supply for the motors. Since the consumption of the logic is probably only a few mA, this should be OK.
However if he has to switch back to a single supply, problems will start to appear again.
Batteries will be able to deliver for a few moments a lot more current than the wall wart type adapter. However with whatever type of supply you use, you need to create a 'virtual' separated supply. As I already described, an inductor and separate capacitor, so that the logic rail can 'keep going' for a few mSec at least, when there is a droop on the main rail. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|