# L293N enquiries for Robots with PIC microcontroller

#### Lambo Av

Joined Apr 24, 2019
59
Hi, all. I have downloaded an L293N motor driver for my Proteus 8 Professional from the following website.
https://www.theengineeringprojects.com/2017/09/l298-motor-driver-library-proteus.html

), it says that the 2 pins (unknown to me) must be grounded. Kindly refer to the image below where I have circled the area of the 2 pins that I meant.

I tried simulating without connecting any of the 2 pins and the motor will not spin. Connecting 1 of them to the ground makes only 1 motor spin. That is in simulation. In reality, may I know where I can ground it? I will insert a diagram below for easier referencing. I tried connecting everything as above on the bredboard except the grounding and the motor will not move.

Any help will be appreciated, thank you.

This post is related to https://forum.allaboutcircuits.com/threads/obstacle-avoiding-robot-using-pic-microcontroller.164564/, it is just that this is on the motor driver itself.

#### KeithWalker

Joined Jul 10, 2017
890
The L298N module does not have the two pins that you mention that should be grounded. All there is on the circuit board at that location is one of the four mounting holes in the bare board. The post you refer to is incorrect.
I suggest that you access a different post to get the device working correctly. Here is one that may help:
https://projectiot123.com/2019/03/25/l298-motor-driver-simulation-in-proteus/

Regards,
Keith

#### Lambo Av

Joined Apr 24, 2019
59
The L298N module does not have the two pins that you mention that should be grounded. All there is on the circuit board at that location is one of the four mounting holes in the bare board. The post you refer to is incorrect.
I suggest that you access a different post to get the device working correctly. Here is one that may help:
https://projectiot123.com/2019/03/25/l298-motor-driver-simulation-in-proteus/

Regards,
Keith
How do program a PIC to enable pin ENA and pin ENB using MPLab or XC8?
Thank you

#### Dodgydave

Joined Jun 22, 2012
9,157
To make the Port bit High on th Pic, just use the command BSF and the bit number 0 to 7,

First set which port you want to use like A B C etc, so if you want to use port Bbit 3, then ' BSF PORTB,3 ' will make that pin go high, to make it low use. BCF PORTB,3..

#### Lambo Av

Joined Apr 24, 2019
59
To make the Port bit High on th Pic, just use the command BSF and the bit number 0 to 7,

First set which port you want to use like A B C etc, so if you want to use port Bbit 3, then ' BSF PORTB,3 ' will make that pin go high, to make it low use. BCF PORTB,3..
I usually use TRISB3 = 1, am I stating the correct codings or am I missing something?

#### Dodgydave

Joined Jun 22, 2012
9,157
whichever works for you..

#### jpanhalt

Joined Jan 18, 2008
9,399
Has similar questions but is a different controller that uses the same chip.
1) Which controller do you plan to use?
2) Which programming language(s) can you write?
3) Generally speaking, setting TRISx = 1 for a pin will not drive it high. Quite the opposite, that sets the pin to an input that has high impedance.
4) I can only do Assembly. In that language, "TRISB3" would not be recognized by MPLAB 8.92. What you want is TRISB,3. The comma is important.
5) I am not sure which PIC chip you are using. If it is a midrange (not enhanced midrange), you can write
Code:
      BSF     PORTB,3
to set the pin corresponding to that bit high. You must have set TRISB,3 =0 in C or used BCF TRISB,3 in Assembly. That is not a particularly good coding practice, but it usually works in a simple program. It is better practice to do this or something like it:
Code:
     MOVLW     b'xxxx0xxx'
MOVWF     TRISB
Of course, the x's must be replaced with 1's or 0's as appropriate.

Moreover, depending on your chip, in Assembly you must always be sure you are in the correct memory bank for the register you are modifying. If you aren't, strange things might happen, which may explain why setting TRISB,3 =1 may have worked for you. For example, if you are using the 16F877 chip, PORTB is in Bank 0 and TRISB is in Bank 1. They have the same offset from the beginning of each bank. Thus, in Assembly, if you are in Bank 0 and write BSF TRISB,3 , that will actually do this: BSF PORTB,3 . I do not consider that good practice, but some clever individuals do it -- I think to obfuscate their code. Where you are most likely to see that is in "disassembly" of hex code.

Last edited: