Control of a MD23 Motor Controller with 28X

Billericay-Boy

New Member
Hi, i have just bought my first PicAxe (a 28x) and all i have done so far is had different colour LEDs flashing after a button is pushed - that is the extent of my building and programming experiance.

i would now like to get my platform moving. so i bought a MD23 H-bridge motor controller (see http://www.robot-electronics.co.uk/htm/md23tech.htm ) for the spec. i understand the basics of how to wire it up in accordance with page 26 of the PicAxe manual but dont understand how they interact.

can anyone give me some insight.
 

Mycroft2152

Senior Member
Hi BB,

Thanks for the link, it gives the basic info.

You've got a lot more than a standard H bridge there! It is based on the I2C bus. The manual will have a set of commands for you to send to control it. Check out I2C interfacing in the PICaXE manuals.

Nyc

 

BeanieBots

Moderator
That is certainly a very nice peice of kit. Much, much more than just an H-Bridge.
How to use it will only come from a thorough read of the manual. At a quick glance, it should be easier to use this device for a robot than trying to interface a PICAXE directly because it does much of the hard work for you.
 

Billericay-Boy

New Member
Thanks guys, I am now reading "Using I2C with PicAxe" - I think i understand what to do from the examples, although i expect i will have to read it again while testing my experiment.
 

Billericay-Boy

New Member
Ok, i give up. i have wired it all together and tried to put some control cods in but i dont seem to be able to grasp how the i send a command to the motors to move. can anyone send me a few lines of code to move the wheels forward for 2 seconds and then to stop. then hopefully i will be able to pick over the code and it may drop into place.

thanks
 

Mycroft2152

Senior Member
For us to help you, start by posting the code that you are using that doesn't work.

You must realize that the motor driver that you selected is unusual and most of us have never used it. It has its own 'language' that must be learned.

what we can do is help you understand how to set up communications between the it and the PICAXE over the I2C bus.

TANSTAAFL!

Myc
 

Billericay-Boy

New Member
Sorry about not including the code, it is below :-

<code><pre><font size=2 face='Courier'>
i2cslave 0xB0, i2cfast, i2cbyte
high 4
writei2c 0, (300)
pause 5000
writei2c 0, (128)
writei2c 1, (300)
pause 5000
writei2c 1, (128)
low 4
</font></pre></code>


When I upload the code the LED comes on for 10 seconds and then goes off so the code is running but the green LED on the MD23 does not light to say there is i2c activity and the motors dont turn.

My set up is on a 28-pin project board and I have connected in-pin-4 (pin 15 on chip) to the data cable and in-pin-3 (pin 14 on chip) to clock cable. My power is comming in at 12.15v to the MD23 and I am using the power take off +5v-off &amp; ground from the MD23 to power the project board. The LED is connected from output 4 to a 330k resister and then to +5v line.

For some reason the i2c is not responding, I have cheched the i2c address and is says 0xB0 in the manual and the green led flashes once for 1 second when the power is turned on. I have a nasty feeling that I am miss-reading the address setup as I have read somewhere that it is normally 8 or 10 digits lond but can be different.

Any help you can give would be much apreciated. Flashing lights are good but moving flashing lights would be much better.
 

Billericay-Boy

New Member
I thought i had solved my problem in so far as the address was listed in Hex and the program needed Binary, so i converter B0 to 10110000 thus giving me an opening address of :-
<code><pre><font size=2 face='Courier'>i2cslave %10110000 </font></pre></code>

But it still did not work. however my led still comes on and off so the Picaxe &amp; project board are working OK.

I just cant think how the address is wrone - if it is the address.
 

Billericay-Boy

New Member
I have just received the message below from the Gerry of <A href='http://www.robot-electronics.co.uk' Target=_Blank>External Web Link</a> who i bought the board from - and it works.

QUOTE
<code><pre><font size=2 face='Courier'>
symbol speed1 = 0
ProgStart:
i2cslave $b0, i2cslow, i2cbyte ' setup i2c port for MD23
t1:
writei2c Speed1, (192,64) ' set motor1 half speed forward,
'motor2 half speed reverse (128 is stopped)
pause 100
goto t1
</font></pre></code>

Make sure you have pull-up resistors on the SCL and SDA lines. We used 2k2 on our test, but 1k8 to 10k is fine.

Also note the MD23 will timeout motor commands after 2 seconds if there is no I2C comms. Your pause 5 seconds won't work, the motors will run for a couple of seconds and stop. This is to prevent your robot running wild if the controller fails. Version 2 adds commands to turn this off if required. You will need to return your MD23 for reprogramming if you want this new feature.

UNQUOTE

Looking at the code, it looks like I entered the address correctly but the command code wrong.

Edited by - Billericay-Boy on 30/05/2006 20:31:15

Edited by - Billericay-Boy on 30/05/2006 20:31:53

Edited by - Billericay-Boy on 30/05/2006 20:33:13

Edited by - Billericay-Boy on 30/05/2006 20:35:00
 
Top