Thread: Help! DIY 4 amp L297/6203 driver

1. Can you program a pic at all?
What you actually want it to do is pretty trivial.

However I'd change the circuit slightly. In my experience you don't generally want the holding current to fall too much - to about 25% is about right.

So:
The current voltage across the VR is about 1v. Get another resistor which will give you approximately 0.25v and wire that up to the top of the VR. You now have two resistors which if either is connected to the supply will either give you the desired current or 1/4 or it.

Next take the two resistors and wire them to two of the output pins of the PIC (obviously the existing 3k9 will need disconnecting from the supply).

What we've got now is the ability of the PIC to pull either resistor high (+5v) and thus select the current as either 1x or 0.25x.

Some psuedo code for your pic.

Code:
```start:

loop:
if (clock == valid)
counter = 5Seconds;

if (counter <> 0)
{
Line1x = high;
Line0.25x = tri-state;
}
else
{
Line0.25x = high;
Line1x = tri-state;
}

if (counter > 0)
counter = counter - 1;

goto loop;```
As you can see, there's not a lot required...

If you've got interrupt on port change - that would be best for the clock (although it'd be unlikely in sampling it over 5 seconds that you'd miss an event).
counter can be done using a timer or in software - whatever your comfy with.

2. Can you program a pic at all?
No not at the moment. But tribbles has kindly offered to program one for me (and make the board ) but wasnt 100% sure on the best way to go with the code so thanks vmuch.

Would it be ok to use 2 trim pots instead of resistors, so i can adjust for diferent motors/ applications? and is it feasable to to use a 1 sec or less timing?

Thanks again, I'll have a go at another schematic to see if I've got the the right idea.

3. The code could be pretty much as kwacker has suggested (obviously not pseudo-code though). I'd use timer interrupts.

Using two of the PIC's pins to control Vref is a neat idea - and two trimmers should be fine.. You could use a third pin with a trimmer for configuring the timeout (should be very easy to do).

4. Exellent. This is moving along nicley now.

Good idea on the trim pot for time out, I like it...

So the only decision now is what pic to use and the pin out? It looks like im not going to use the short circuit protection so the the tripple 3 input AND gate is wasted in this circuit.

Are there enough pins on the pic to implment the 1/2 step boost, or will it make the code difficult?

Last question. dose this need a crystal or can it be linked to the sync pin on the L297 for external clock?

5. The PIC doesn't really need a clock (it depends on which one you use).

Since I've got them, you may as well use 12F683 - it doesn't need an external crystal or clock (it's got an 8MHz clock built-in). It's 8-pin: 2 power, 1 input and 5 I/O.

If you're referring to replacing the 7415, then I would keep it as it is - you'd need to monitor the lines, and there would be a delay. But then, if you're not clocking the circuit very fast, then it would probably be okay. But, as you mention, it does save on code complexity

For the PIC, you can use any of the output pins (pins 2, 3, 5, 6 and 7) for the VREF generation signals, but use one of the analogue pins (5, 6 and 7) with a trimmer (between VCC and GND) to set the delay.

6. For the PIC, you can use any of the output pins (pins 2, 3, 5, 6 and 7) for the VREF generation signals, but use one of the analogue pins (5, 6 and 7) with a trimmer (between VCC and GND) to set the delay.
Ok think I've got it sorted. I'm not sure if the trim pots are configured properly as it looks like they will interfer with each other :naughty:. Just reread Kwakers post and I think i should have used the pic to pull them high not low. :whistling:

I've also left the 3.9 res in as I presume it will limit the Vref to 3v mav as per the data sheet. If the pots are pulled high could this be achived with a common 3v supply?

7. Originally Posted by Ross77
Ok think I've got it sorted. I'm not sure if the trim pots are configured properly as it looks like they will interfer with each other :naughty:. Just reread Kwakers post and I think i should have used the pic to pull them high not low. :whistling:

I've also left the 3.9 res in as I presume it will limit the Vref to 3v mav as per the data sheet. If the pots are pulled high could this be achived with a common 3v supply?
Just to clear any confusion - you the 3k9 res should be removed from the +5v line and connected to a port. The voltage at the other end will never exceed 1v.
Another resistor is connected the same (19k??) one end to the junction of the VR and the 3K9 the other to a second port.

Basically the PIC will pull either of the lines high - if it pulls the 3k9 one high you get whatever current you've set the VR for, if it pulls the 19k one high you get a quarter of that.
The pic avoids interference by essentially disconnecting the unused resistor (tri-stating the output).

I've also realised in my pseudo code there's no need to set the port pins high in the loop - this can be done outside - plus I don't show the pin being 'un-tri-stated' - which obviously it would need.

8. Just thinking about it - I don't think it's necessary to have two pins controlling VREF.

In the original circuit, there are three possible states:

GP 2is open circuit; VREF would range from 0 to ~1V (depending on R23)
GP2 is 0V; VREF would be 0
GP2 is 5V; VREF would be between 0 and 5V (again, depending on R23)

The last mode of operation isn't what I suspect is used, so I'll discount that.

However, GP2 can easily create a PWM signal by going from open-circuit to 0v, which at a 25% duty cycle would bring VREF from between ~0 and 0.25V. C23 is used to smooth the signal.

I'm beginning to have an idea about a (possibly) better way to do this.

GP2 is used for the CLOCK signal for the L297 - this is the PIC's interrupt pin, and would be easier to deal with there.

GP1 has a 10K trim resistor which is used to control the minimum hold voltage.

GP0 is connected DIRECTLY to VREF. This is used to monitor VREF.

GP5 is used to control VREF using the same circuit as the original does.

GP4 has a 10K trim to control the delay time for the circuit.

1) The hold VREF can be easily adjusted, and measured with a volt meter
2) The PIC has voltage comparison circuits on GP0 and GP1, and this would be using them
3) Interrupts can easily be used for everything (VREF going below voltage, clock signal coming in, timeout occurring)
4) The PIC shouldn't need to be reprogrammed at all (once it's all working)

If there was a spare output pin, then the L297's RESET pin could be controlled (removing the need for R15, D12 and C16 on your circuit). If we didn't monitor the VREF signal (GP0), then this could be done instead - the trim for GP1 would actually control the minimum PWM duty cycle.

9. Hi tribbles,

Yep, all that would work - I was just demonstrating that what was required could be done simply.

In the past I've used PWM to modify the VRef voltage - however I've always spotted some ripple with a single stage of RC filtering (I think my PWM was at about 5khz) so always added another. Don't think it matters that much as long as the voltage is approximately right though.
Usually I didn't bother with the VR, having options in the PIC to set the current (either with links setting the most common values, or via a menu on whatever display device I'm using).

Monitoring the VRef voltage I've never found to be necessary - although my initial attempt did exactly that. I have in the past though (when building buck/boost converters to drive LED's) made self starting regulators using the PWM on the PIC and used the analogue inputs to monitor the voltage and adjust the PWM. That's a very interesting experiment in feedback loops... )

10. Just to clear any confusion - you the 3k9 res should be removed from the +5v line and connected to a port. The voltage at the other end will never exceed 1v.
Another resistor is connected the same (19k??) one end to the junction of the VR and the 3K9 the other to a second port.
See first attachment, is this what you meant? if not Im afraid I dont know what you mean, sorry

1) The hold VREF can be easily adjusted, and measured with a volt meter
2) The PIC has voltage comparison circuits on GP0 and GP1, and this would be using them
3) Interrupts can easily be used for everything (VREF going below voltage, clock signal coming in, timeout occurring)
4) The PIC shouldn't need to be reprogrammed at all (once it's all working)
Sounds good, especially not needing to be reprogramed , see 2nd attachment. hope Ive at least got 1 right

If monitoring the vref isnt necessary then the reset option would be best. I see the data sheet says the reset must be initially be set low and then set high but this is the only circuit I have seen that dose this, all the others just tie it to +5v.

The only question is what can we make GP3 do? Flashy lights, make the tea?

Usually I didn't bother with the VR, having options in the PIC to set the current (either with links setting the most common values, or via a menu on whatever display device I'm using).
Nice idea but I think I'll save that for the next incarnation...

Page 5 of 9 First ... 34567 ... Last

Posting Permissions

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