help with 28X1 please..

xtech007

Senior Member
Hi.. and thanks for your time!
I'm trying to move a 24v DC motor using a 28X1 chip
I want it to move forward, center, and reverse when a switch for each is pressed. also a microswitch to stop when a distance is reached.

I'm using a MD03 motor drive to output the motor.
BUT I'm a bit confused on the programing side.
Should I use pwmout syntax, readadc, high & low, or forward & reverse syntax?

Any help would be very appreciated thanks!!!:confused:
 

hippy

Ex-Staff (retired)
Should I use pwmout syntax, readadc, high & low, or forward & reverse syntax?

No idea; what's an MD03 and how does it need controlling ?

If it's this ...

http://www.robot-electronics.co.uk/htm/md03tech.htm

You have a whole range of options - I2C, 2.5V +/-2.5, 0V-5V with separate direction control, RC ( servo pulse I guess ) and PWM.

Which would you like to use ? I'd probably go for I2C.
 

xtech007

Senior Member
Thank you for your reply.

thank you for taking the time to help me.
I'm new to coding.
You Reply "I2C" would be best.
How would I find out a little more about this I2C?

You got the MD03 page Correct.
 

xtech007

Senior Member
how about the 0, 2.5, 5 volt idea?

Once again thank you for your help.
I was thinking if I use the 0 Volt for backward 2.5 return to center and 5v for forward, what command can I use?
also use a limit switch to both ends of travel.
I have read the manual and datasheets but I'm still confused and how to write the program..

I'm sorry to ask so many questions.
I'm new to programing and I really like to learn.
 

westaust55

Moderator
thank you for taking the time to help me.
I'm new to coding.
You Reply "I2C" would be best.
How would I find out a little more about this I2C?

You got the MD03 page Correct.
For an i2c tutorial have a look at the Rev Ed document at:
http://www.rev-ed.co.uk/docs/axe110_i2c.pdf

Then as you have the 28X1 chip, in the PICAXE manual section 2 have a read about these commands:
hi2csetup
hi2cin
hi2cout

data specific to i2c comms and the necessary registers is provided under the heading I2C Mode in the MD03 document that Hippy has already mentioned.


as a starting point:
Code:
set up SYMBOL statements for direction and speed aliases to byte variables

then . . . .

;to initialise
HI2CSETUP  i2cmaster, %10110000, i2cfast, i2cbyte ; %10110000  = $B0 = default MD03 Slave Address


; to set direction
HI2COUT 0, (direction) ; for direction 0 = stop, 1 =FWD, 2 = REV

; to set speed
HI2COUT 2, (speed)     ; speed in range 0 to 255 gives stop to full speed.
 
Last edited:

Michael 2727

Senior Member
If you are not really sure what you are doing, hardware or software wise
I would go with the Analogue Mode 0V-5V Logic, 2 pins will give you full control.

STOP Hardware Version -
If you include the limit switches in the SDA line everything will stop.
You could use 2 other pins, via a small capacitor and Diode OR-ed to momentarily
overide the limit switches when the SCL is reversed.

At least this will get you going until you can work out the more elegant
ways of using a Picaxe.

24V with a 50A H-Bridge, is this motor/setup likely to take your
arm off if the limit switches fail etc?
Or are you just being very conservative with the Driver, BTW there should be
more of it. (with the correct fuses this unit should last a lifetime)
Would save a lot of "my XXXXXX H-Bridge smoked up, please help" posts.
 

Andrew Cowan

Senior Member
If I was you, I would connect it up as if the picaxe was an rc reciever, and use the 'servo' command.

servo 1,75 = full back
servo 1,150 = neutral
servo 1,225 = full forward

Andrew
 

hippy

Ex-Staff (retired)
My suggestion of I2C is because of the problems of using the others ...

Analogue voltages need generating and perhaps buffering so it needs hardware and software drivers; if using PWM to do that one could say go straight to the PWM option, save on hardware.

Servo should work for RC but that won't keep running if the PICAXE does do anything to interfere with that and it's just storing up problems for the future. It's also acknowledged that what the PICAXE puts out isn't 'perfect' and causes jitter on high quality, responsive servos. That might not be a problem but would need testing.

PWM should work, and work well if using a crystal / resonator, but resolution depends on the frequency. If the MD03 only accepts lower frequency PWM the resolution drops. If not using a crystal then what's going out isn't necessarily what's wanted.

I2C has the advantage that it's a direct line to the controller with no loss of resolution or data content ( excepting electrical interference ).

This seems to be a fairly capable and hefty controller which will be controlling something other than a lightweight motor and one doesn't want it doing things unexpectedly. I2C has the advantage that it will do whatever its told when it's told. All the others have some element of 'should work okay'.

The downside of I2C is that it seems to have a fixed Device Address which would make controlling two motors on a single I2C bus impossible. That is a major design oversight in my book. The firmware can be re-flashed but as it's only in Hex format that would take effort. The company looks friendly enough so they may be willing to help with doing that.

Bottom line - MD03 looks good, if wanting to use that do so, then try the various means of control to decide what does and does not suit.
 

Technical

Technical Support
Staff member
The downside of I2C is that it seems to have a fixed Device Address which would make controlling two motors on a single I2C bus impossible. That is a major design oversight in my book.
Not correct, you've missed that the module has 8 available addresses set by the DIP switch on powerup, so you can have 8 MD03s per i2c bus.
 

westaust55

Moderator
Correct and beaten to the mark by Techncial.

Mode Switches are covered 3/4 way down the info sheet.

The same 4 switches also select the various analogue and RC operating modes as well.
 

xtech007

Senior Member
westaust55 thank you for your Support and Effort.

Cheers. to You All who have Posted you response.

westaust55
Thank you for the PDF on I2C for Picaxe and also the Brief explanation.
I will start trying some coding and applying it to the MD03 controller to see what it will do.

Ps: If it works out it's most thanks to your efforts.
 

xtech007

Senior Member
Thanks for all the support you guys are Great..

I have been testing different codes following the data sheets and some of your sugestions on I2C code but I'm still a bit confused.
I used the following code:

set up SYMBOL statements for direction and speed aliases to byte variables
"HUMMM what goes Here????????????)
can someone give me an Example.. Please!
then . . . .

;to initialise
HI2CSETUP i2cmaster, %10110000, i2cfast, i2cbyte ; %10110000 = $B0 = default MD03 Slave Address
This Part I did get whitch is the adress of the MD03

; to set direction
HI2COUT 0, (direction) ; for direction 0 = stop, 1 =FWD, 2 = REV
Here I understand if i put 0 it stops, 1 FDW and 2 rev.
; to set speed
HI2COUT 2, (speed) ; speed in range 0 to 255 gives stop to full speed.__________________
:
Here I think it will be the speed the dc motors will run????

I have capture fragments so far and understand the code a little better.
Another question I have is that if I wanted the motor to move FWD with an input and back with another input do I have to re-write:
I2CSETUP i2cmaster, %10110000, i2cfast, i2cbyte
HI2COUT 0, 2
HI2COUT 2, (speed)

Once again thank you.
 

westaust55

Moderator
;set up SYMBOL statements for direction and speed aliases to byte variables
SYMBOL speed = b5 ; or any other byte variable that you have free
SYMBOL direction = b6 ; or any other byte variable that you have free


If you keep the line as
HI2COUT 0, (direction) ;
as opposed to:
HI2COUT 0, 2

Then you can change the direction variable any time you like.

Yes, each time you want to change the speed or direction you need to execute the commands again.
You could put them both in a subroutine then for each change just define values to speed and direction and then do a GOSUB to that subroutine.
 
Last edited:

xtech007

Senior Member
Hummmm ... Got lost again.

Got confused again. I'm so sorry,
The b5, b6 symbols where these came from?

SYMBOL speed = b5 ; or any other byte variable that you have free
SYMBOL direction = b6 ; or any other byte variable that you have free


If I keep the line as
HI2COUT 0, (direction) ; in here do I leave it blank ?
as opposed to:
HI2COUT 0, 2

how would the code look like if lets say I need the motor to move Fwd?
Thank you so much..
I have try to do it over and over but I just can figure it out yet.
 

westaust55

Moderator
Got confused again. I'm so sorry,
The b5, b6 symbols where these came from?

SYMBOL speed = b5 ; or any other byte variable that you have free
SYMBOL direction = b6 ; or any other byte variable that you have free


If I keep the line as
HI2COUT 0, (direction) ; in here do I leave it blank ?
as opposed to:
HI2COUT 0, 2

how would the code look like if lets say I need the motor to move Fwd?
Thank you so much..
I have try to do it over and over but I just can figure it out yet.
Xtech007,
Q. The b5, b6 symbols where these came from?

A. These are default or standard variable names. The PICAXE, depending upon its size has 14 to 28 variables: b0, b1, b2, b3 . . . . .
A value from 0 to 255 can be assigned to a byte variable (one starting with the letter "b".

The SYMBOL statement is covered starting part way down page 6 of manual 2.

Q. If I keep the line as
HI2COUT 0, (direction)
do I leave it blank ?

A. Sorry but I do not understand the question :confused:

It would seem that you have never read the PICAXE manuals or do not understand them. Might I respectfully suggest that you read the manuals a little more. Variables are covered in Manual 2 page 9 onwards.

If do have not previously downloaded the manuals go to the orange bar at the top of any forum page and click on PICAXE Manuals There are three parts to read. Programming commands are covered in detail in manual 2.
 

xtech007

Senior Member
Finally had time to do some reading...

Thank you again for your support..
I had time to do some re-reading and Understand the commads a little better.
Also the I2C arquitecture better.
Now I see you guys were helpful to answer some of my dumb questions and help me beyond my little knowledge.

You guys are great.. Thanks!!!!!!!

PS: to anyone who's new to picaxe Please do some reading, it will make a big difference when the forum tries to help you..
 

DirkBroekhoven

New Member
Take a look at this site

Hi Tech,

I'm currently building a motion platform for flightsim. It's basicly the same set-up you are trying to build. Here is discribed how to make a platform with interfacing software to FSX and feedback with encoders. This will help you a lot.

http://buggies.builtforfun.co.uk/Sim/

Here is another one. A site where they explain how to make a platform with interfacing software for racing games:

http://www.x-simulator.de/main/

Greets,
 
Top