18M2/L293 mess

ZOR

Senior Member
I have nodded off putting an 18M2 and a L293D together on a board.

My original stripboard version which worked is the top item, and my messup is below. Am I doomed the way ports are wired from the 18M2 to the L293D, will it ever work like this as trying it is dead.

L293D.jpg

Hope my diagram is clear showing 18M2 port pins into L293M.

M1A/B and M2A/B being to the stepper
 
Last edited by a moderator:

westaust55

Moderator
Looks like it should work in principle, but what about the other signals?
Are the enable pins permanently pulled high.
If enables are controlled by the PICAXE have you also swapped those (pins 1 and 9) also?


More information (full schematic and program would help folks get to the bottom of your problem.
 

hippy

Technical Support
Staff member
You should be able to drive each of the L293D pins from any PICAXE output pin. If it works for one set of PICAXE output pins it should work for any other.
 

ZOR

Senior Member
Thanks westaust55, I was trying with this code which was working on the original breadboard.
Yes the enable pins are connected to +ve, permanently high.

Code:
#picaxe 18M2

Start0:
Symbol Rest1 = 20

let dirsB = %11110000

BT:
let pinsB = %01010000 '  B.4/B.6
pause Rest1
let PinsB = %10010000 '  B.4/B.7 
pause Rest1
let PinsB = %10100000 '  B.5/B.7
pause Rest1
let PinsB = %01100000 '  B.5/B.6
pause Rest1

GOTO BT
 
Last edited:

ZOR

Senior Member
Thanks hippy. maybe the order of my code lines is wrong?. i.e. let pinsB = %01010000 ' B.4/B.6 etc
 

hippy

Technical Support
Staff member
Thanks hippy. maybe the order of my code lines is wrong?
Possibly. Perhaps post your full code.

For your first setup ...

Code:
;                cadb       abcd 
Symbol STATE0 = %01010000 ; 1100
Symbol STATE1 = %10010000 ; 0110
Symbol STATE2 = %10100000 ; 0011
Symbol STATE3 = %01100000 ; 1001
Then you have moved pins around ...

Code:
(b) B.4 -> B.7 (b)
(d) B.5 -> B.6 (d)
(a) B.6 -> B.5 (a)
(c) B.7 -> B.4 (c)
so what was 'cadb' becomes 'bdac'. Which gives ...

Code:
;                bdac       abcd
Symbol STATE0 = %10100000 ; 1100
Symbol STATE1 = %10010000 ; 0110
Symbol STATE2 = %01010000 ; 0011
Symbol STATE3 = %01100000 ; 1001
And, if you want to directly sequence that ...

Code:
let pinsB = %10100000
let PinsB = %10010000
let PinsB = %01010000
let PinsB = %01100000
That assumes the motor is still wired to the L293D exactly as it initially was. If you have changed that then it will be different to the above. You will have to explain exactly what has changed and how.
 

ZOR

Senior Member
Thanks hippy. I am going to print that out and study it with a cup of coffee. Your explanation is well laid out, thanks for taking time doing it. The code in #4 is all that exists at present. Have a good weekend
 

ZOR

Senior Member
Was enjoying my coffe when I read

That assumes the motor is still wired to the L293D exactly as it initially was
Unfortuneately not, as in #1.

My wiring to L293D from the Picaxe pins is not the same as originally wired/working. I made the mistake on my board.

The original wiring (above) and current wiring below.

L293D.jpg

I don't know if there is only one way the L293D will work.
 

hippy

Technical Support
Staff member
As you have altered the connections from PICAXE to L293D and changed the connections from L293D to the motor, you will have to explain exactly what changes were made to the L293D to motor connections to figure out how the code should now be.
 

ZOR

Senior Member
My picaxe pins to the L293D got mistakenly changed when I did a PCB layout. The motor has only 4 wires, 2 coils. The pair of coils just go to M1A/M1B = M2A/M2B. I cannot supply any further information to help other than my connection changes in the diagram.

B.4 went to Pin2 on L293D - but now B.7 goes to Pin2
B.5 went to Pin7 on L293D - but now B.6 goes to Pin7
B.6 went to Pin15 - but now B.5 goes to Pin15
B.7 went to Pin10 - but now B.4 goes to Pin10

All a bit of a mess to say the least. Maybe I should study flower arranging
 

ZOR

Senior Member
Thanks, yes they are wired same to L293D

Don't know if this picture helps. Red lines are links

L293PCB.jpg
 

hippy

Technical Support
Staff member
If the motor itself is wired to the L293D the same as it was, the changes I determined should work.

Why are you running your B.4-B.7 lines through a ULN2803 rather than direct to the L293D ?
 

ZOR

Senior Member
Sorry hippy, I do appologise, I misread your question whether the motor was wired the same to the L293D, thinking it read was the wiring to the L293D still the same. So red faced will make another coffee and study the earlier information from you again.
 

ZOR

Senior Member
Something else must be making this board dead. I have unplugged the L293D from the board. I now only have the 18m2 and ULN2803. I put this part code in

Code:
RT:
high B.4
high B.5
high B.6
high B.7
pause 2000
low B.4
low B.5
low B.6
low B.7
pause 2000
Goto RT
I look on my meter on 18M2 outputs and see the outputs swing high/low. (4.8v/0v)
I then look at these outputs going straight into the ULN2803 inputs and see they are getting from the 18M2 outputs and going high/low. However the ULN output reads 0.63v/0v. Is this normal. As the L293D is no longer on the board there is no load on the ULN outputs. I have tried another ULN2803 but no change, and I have looked at these outputs with the L293D installed on the board and same. Checked board for partial shots/nothing. Any ideas?
 

westaust55

Moderator
As hippy already asked:
Why do you have the ULN2803 between the PICAXE and L293D?
It is :
- unnecessary
-inverts the signals [that is when the input is taken high (=1) the output goes low impedance and low voltage (=0) and when the input is low the output is high impedance (=off) but not a high voltage level]
-open collector so cannot generate a high level (= 1) level on its own - needs a pull-up resistor

With the L293D installed try removing the ULN2803 and bridge directly from PICAXE to L293D with jumper wires across ULN2803 pins.

If the ULN2803 must stay then add a 4k7 to 10k resistor from +5V to the output of ULN2803 = to input of L293D to enable the signals to be pulled high.
 
Last edited:

ZOR

Senior Member
Thanks westaust55. I woke up this morning and realised the ULN inverts the signals, so I should have put my meter from the + volts. Now found swing high/low.
I used the CH1030A board in my original tests which had a ULN on board and everything worked okay. Also laying tracks on the PCB was far easier/straighter going through the ULN.
However I unplugged the ULN and put a dip switch in it's place, and bingo the motor woke up. Now looking at my breadboard design which I left built (normally breakup but this time was alive to compare) and realised in the early stages I had put 4 LED's to ground on the Picaxe outputs/L293D inputs so I could visibly see coil driving sequences. So from what you suggested with resistors was possibly happening??

Put hippy's code answers in and I am there. Unfortunately my ULN is driving a Unipolar 5 wire motor otherwise I would remove ULN. I could cut pins off the IC and put links accross tracks, will think.

However many thanks to hippy and yourself. Best regards
 

SAborn

Senior Member
A unipolar 5 wire motor only requires a ULN2803 to drive it and not a L293D at all, you really seem to have complicated a very simple circuit to do a basic task, with adding a ULN2803 to drive a L293D, which either of the 2 chips could have done the job on its own.
Over engineering come to mind here.
 

ZOR

Senior Member
Unfortunately my ULN is driving a Unipolar 5 wire motor otherwise I would remove ULN
Thanks Saborn, my board is for 1 Bipolar stepper and 1 Unipolar stepper. No over engineering here.
Don't quite understand this bit:
which either of the 2 chips could have done the job on its own
In #17 I explained I ran my PCB tracks through the ULN as it was a straight path through. My prototype breadboard worked like this without problem using the CH1030 board because I had added LED/Resistors to ground on the 4 ULN outputs feeding the L293. This had been done so I had a visual on coil sequences. I had not twigged this had acted as pulldowns.

Sometimes threads do get long, and it's easy to answer latter parts without having read all. However thanks for coming in to comment.

Regards

EDIT:
Just found this. Is it what you were meaning? Can I run a Bipolar motor with Picaxe/ULN2803 WITHOUT L293d?

BIPOLAR.jpg
 
Last edited:

hippy

Technical Support
Staff member
I look on my meter on 18M2 outputs and see the outputs swing high/low. (4.8v/0v)
I then look at these outputs going straight into the ULN2803 inputs and see they are getting from the 18M2 outputs and going high/low. However the ULN output reads 0.63v/0v. Is this normal.
Yes. The ULN2803 is an open collector driver, can never pull high of its own accord. You need pull-up resistors to make it carry a digital signal from input to output.

I woke up this morning and realised the ULN inverts the signals, so I should have put my meter from the + volts. Now found swing high/low.
No, it isn't actually swinging high and low. What you are observing is the ULN2803 driver conducting or not. If it were actually swinging high and low you would see that when measuring with respect to 0V.

Consider this circuit -

Code:
  .----------------- V+
  |
__|__ +                 
 -.-          /
  |      .---O  O--- OP
  |      |
  `------^---------- 0V
There is no way you can put a voltage on "OP" whether the switch is open or closed. A meter between 0V an OP will show that. A meter between OP and V+ will however show a voltage due to current flow when the switch is closed, but the "0.00" shown is not 0V being put on OP when the switch is open, just the default display when no current flows.

When used digitally, the ULN2803 drivers are electrically controlled switches just like that, or solid state relays which close and open the switch.
 

ZOR

Senior Member
Thanks hippy for confirming that. It's all working now. I don't think it was over engineered although darlington transistors for the unipolar motor might have been a saving in size, not so sure. However appreciated your help, thanks again.

EDIT:
Sorry hippy, just caught up with your edit on #20. Now understood, thanks
 

StigOfTheDump

Senior Member
There was some discussion a couple of years ago about cutting ULN2803s in half with a dremel. I just snapped one with 2 pairs of long nosed pliers and it worked for me. Then you could bridge the other 4 lines.
 

ZOR

Senior Member
Many thanks for murdering one of your ULN2803's, funny it went through my mind but I thought it would not work. I will give that a shot and call it a ULN2403. Regards
 

hippy

Technical Support
Staff member
Rather than snap the ULN2803 in half, bend the unused pins up or cut them off, then jumper the in pins to out pins on the board.

Or cut the socket pins out and insulate so the 'dangling in space' legs don't short to the board.
 

ZOR

Senior Member
Thanks hippy. I tried cutting them off however the small remains close to the chip still made contact with my IC sockets (not the turned pin type)
Had they been turned it would have worked. I just cut the chip in half and it works fine.
 

westaust55

Moderator
@ZOR,

This is a case where providing the full schematic at the start would have likely resolved your "problem" within one or two responses as folks would have the full situation known and not have to guess at possible omissions and obscure arrangements.

Not "knocking" but hopefully this thread serves as an example of why it is better to post as much information at the start rather than why you think is the problem area.

For all (though most may unfortunately not read this) with queries relating to project that do not function as sought, it is best to post the full schematic and related code from the onset.
 

nasi

New Member
I read it and that sounds reasonable.
I didnt know you could cut a ULN2803 in half.

Learn something new everyday.

:)
 
Top