This is an I2C twin DC motor controller with end stop input. Ideal for small robots, SmartCar robots etc. Easy to drive with I2C requiring only 2 lines from the host microcontroller.
There are two digital inputs, these can be connected as End Stops and the end stops can be used in two different ways. First as an end stop where if something is inserted into the slot the motor will stop and. Second it can be used as a step counter whereby a disk containing slots is connected to the motor, the slots can be counted as the motor turns round thus giving feedback as to the position of the motor.
This is an example of an end stop being used to determine the motor position on a 'SmartCar' type chassis (google SmartCar robot).
Motor driver incorporated into a SmarCar with End Stops used as positioning inputs.
Motor 1 is connected to pins 1 and 2, Motor 2 is connected to pins 3 and 4. The power supply for the motor can be up to 30V. This is supplied separately.
Pin 1 on the slot inputs is designated by a white triangle(arrow). Pin 2 is slot 2 and pin 4 is slot 1. Pin 1 is also a ground pin. The other pins are not used.
End Stop Wiring
Some end stops come with a few components on a PCB, these are the easiest to use as only a power supply is required.
Power & I2C (3v3)
The L293 requires 5V to operate the logic and so a 5V supply (low current) is required. If the host is 3V logic then simply connect the 4 pins on the I2C connector to provide power for the L293 and the I2C signals. If the host uses 3.3V logic then just connect the 2 signal lines and ground with 5V being provided separately. There are no pull up resistors on the board and so the host will take care of the 5V logic high.
Logic is supplied from the 5V but the SCL and SDA lines will only be pulled to 3v3 because of the pull up resistors on board the RPi or external resistors on a host that does not have pull up resistors.
** NOTE: Most Arduino will work with 5V logic.
|A||10||0 to 3 see below|
|B||20||0 to 3|
|Both||30||0 to 3|
Sets direction us 0,1,2 or 3 to set direction:
Sets motor power 0 is off and 1023 is full on. This is sent as two bytes high first.
This will only work if the end stop devices are set up to receive pulses from the motor as described above in the SmartCar example.
<dir> is from 0 to 4 as above
<setps> is a 16 bit value split into high and low bytes so for example to send 1500 steps with a direction of 2 this would be:
Designed for continuous operation, sets the direction and power in one command. There is a step counter which is reset at the beginning of this command and so if the end stop device is connected as a step counter the steps will be counted. A rollover will take place at 65535. This command can be used without regard to the steps.
Returns two bytes high and low of the counter position, can be used with the Continue command.
Returns either 1 or 0 depending on the slot input.
0 is when there is noting in the slot
1 is when there is an obstruction in the slot (i.e. the end stop is detecting something)
This is the same as the Continue command except that if the end stop reads 1 the motor will stop.
Applies to Both
Emergency stop. Applies to both motors. Resets direction and power to 0.
|14||I2C Address Copy 1|
|250||I2C Address Copy 2|
Changing I2C Address: The address can be changed by changing the value of TWO EEPROM locations, say 1 and 14 then resetting. Use the write to EEPROM command (0x91). The system at start up will take a vote on the correct address and change the third one to match.
*** The address is the 8 bit address and MUST be an even number.
- 0x90 reads a single EEPROM value, e.g. i2c_read(1) returns the I2C address
- 0x91 write a single EEPROM value e.g. i2c_write(1,94); i2c_write(14,94); changes I2C address to 94
- 0x95 resets device
- 0x96 send back ack character
- 0xa0 returns firmware version as 2 bytes
- 0xa1 returns device id as a 16 bit number (2 bytes)