Tuesday, January 31, 2012

Suzuki V-Strom (DL1000) Gear Position Indicator Project


-----
UPDATE July 4, 2016:  
No longer for sale.  Get the source code for free by sending a request with your City/State/Country (only so we can pin our map) to:
 
 In addition to the V-Strom; the GPI is now working on several Suzuki motorcycles!!!  Thanks go out to the many dozens of brave DIY'ers that have successfully built and installed the rig proving that the instructions are complete and the design solid.  If your rig is not working double/triple check your wiring. 
-----
The objective was to provide a low cost gear position and ambient air temperature display for my 2009 Suzuki V-Strom (DL1000). Also, to open source the project design with documentation so that anyone with basic electronic skills can duplicate the design for their motorcycle.
-----
Theory of Operation:
Most modern motorcycles have a Gear Position Indicator (GPI) signal wire from/to the Engine Control Module (ECM) that outputs a voltage reading of 0 to 5VDC depending on which gear is selected. This project uses a PICAXE 18M2 microcontroller to measure the voltage on that GPI signal wire, process that measurement, and display the selected gear on a 7 segment LED display. At the press of a button, the PICAXE 18M2 reads the ambient air temperature (as measured from a DS18B20 temperature sensor) and displays the reading in Celsius or Fahrenheit on the 7 segment LED display.

A few comments before you do anything....
This is a DIY project. I guarantee nothing other than the project works on my 2009 Suzuki DL1000, that many (many, many...) others have successfully duplicated the build.  If you have done DIY electronic projects you understand that wiring errors, etc. happen and have to be debugged. If you haven't done an electronics DIY project, this build is not that difficult and you should be successful but expect delays as you check your work, decided where you what to mount the components, route wires, etc. Check your work often during your build. Even the very experienced make wiring errors and create solder shorts (among other things). Basically, you are taking on some risk.

With the exception of the PICAXE 18M2 microcontroller, all the components are readily available and cheap. If you have done a few electronics projects you likely have many of the parts already your 'spares' kit. The PICAXE 18M2 microcontroller needs to be loaded with some customized software I wrote to make the project work. I can install this software and ship the programmed PICAXE 18M2 directly to you if you like.
-----
A few answers to common questions:
- Why do I have to get the PICAXE 18M2 from you? Can't I program my own?
- You can write the software and program your own PICAXE if you have a development board. Goto www.picaxe.com to learn more.

- Will it work on my motorcycle?
- Currently the design has been tested on the:
    • Suzuki DL1000 V-Strom
    • Suzuki DL650 V-Strom
    • Suzuki TL1000
    • Suzuki Bandit
    • Suzuki Hayabusa
    • Suzuki Quadracer LT-R450

It should work if you have a late model bike with a Gear Position Indicator (GPI) signal wire. The GPI signal wire puts out a voltage (between 0-5VDC) for each specific gear. The software for the PICAXE 18M2 will likely need minor adjustments for motorcycles not yet tested. I can quickly make these adjustments if you tell me the voltage readings of the GPI wire for each gear (and neutral) of the target motorcycle.

- What's is the most difficult part of duplicating the project?
Avoiding wiring and solder mistakes. Also, after you get the project wired and soldered up, deciding what to mount it in and where to place it on the motorcycle.
-----
Bill of Materials (the PICAXE 18M2):

Before we get into the general bill of materials list, let's talk about getting the PICAXE 18M2:
- the PICAXE 18M2 microcontroller is the "brain" of the project.
- the PICAXE 18M2 can be purchased on the internet for about $7.00; however...
- you must have my software downloaded into the PICAXE for the project to work
- PayPal me and I will mail the programed PICAXE 18M2 to you.
         - As of July 4, 2016: No longer for sale.  Get our source code for free by sending a request to:

- BE SURE to tell me if you want the temperature displayed in degrees C or F.
- BE SURE to provide a shipping address.
- BE SURE to provide the make/model info on the target motorcycle for the project.
- If you are designing to a motorcycle not listed, give me the GPI signal wire voltages for each gear and neutral.  I will custom program the PICAXE for your bike.
- At this price it should be obvious that the project was not done to make money.  I have provided donor hardware/software for well over two decades and like the model. 
-----
"All the Other Stuff" Bill of Materials (~$15):

Listed below is The Bill of Materials (B.O.M) for the other components. You can find these components in many places. I like Mouser.Com because their prices are good, they are fast, they have good shipping rates, and they will let you order in single qualities. I have included Mouser.Com part numbers for each item (valid at the time of this writing). 

QTY - Description

1 - DIP socket (18 pin) for the PICAXE 18M2
- allows easy removal of the PICAXE 18M2 in the event of a re-program.
- allows you not to solder directly to the PICAXE 18M2 if this concerns you.
- allows you to start the project without the PICAXE 18M2 in hand
- One of many examples is PN#4818-3000-CP from Mouser.Com ($0.20)
1 - Seven segment display with decimal point. Must be Common Anode!!!
- Forward Voltage spec = 1.8-2V
- One of many examples is PN#LDS-HTA514RI from Mouser.Com ($1.09)
 - If  you don't order LDS-HTA514RI the project will work, but you MUST CONFIRM THE LED SEGMENT PINOUT locations

1 - 5 Volt DC Regulator
- PN#926-LM2940T-5.0/NOPB from Mouser.Com ($1.68)
- LM7805 could also work if you already have one handy

1 - .47uF capacitor for voltage regulator input on the LM2940T-5.0
- any current rating or tolerance is fine
- One of many examples is PN#UFW2AR47MDD from Mouser.Com ($0.08)

1 - 22uF capacitor for voltage regulator output in the LM2940T-5.0
- any current rating or tolerance is fine
- One of many examples is PN#REA220M1CBK-511P from Mouser.Com ($0.06)

1 - Temperature Sensor (optional, but does not make the project more difficult)
- PN#700-DS18B20+ from Mouser.Com ($2.76)

1 - Push button switch (optional for temperature, but does not make the project more difficult)
- any current or voltage rating is fine
- One of many examples is PN#104-0013-EVX from Mouser.Com ($0.91)

1 - 4.7K resistor for DS18B20+ temperature sensor (optional for temperature)
- any current rating or tolerance is fine
- One of many examples is PN#299-4.7K-RC from Mouser.Com ($0.10 each)

8 - 330R current limiting resistors for the gear readout display
- any current rating or tolerance is fine
- One of many examples is PN#299-330-RC from Mouser.Com ($0.10 each)

2 - 10K pull down resistor for temperature button switch and PICAXE (not optional)
- any current rating or tolerance is fine
- One of many examples is PN#299-10K-RC from Mouser.Com ($0.10 each)

2 - 22K pull down resistor for PICAXE
- any current rating or tolerance is fine
- One of many examples is PN#299-22K-RC from Mouser.Com ($0.10 each)

1 - PCB "perf" board to attach the parts to
- Many examples are available. Select one that aligns the design of your final packaging
- One of many examples is PN#854-SB300 from Mouser.Com ($3.99)

- some 22 gauge solid core hook up wire, solder, mounting 'box', and electronics DIY know how...
-----
After you get your parts, connect them as shown in the schematic below. You may not (or may) want to mimic by component placement as shown in the picture above. A common adjustment is to use longer wires to connect the 7 Segment Display to the PICAXE 18M2. That is fine and may give a cleaner look because the 7 Segment Display could be remoted and would be the only thing visible to the rider; the other circuity could be hidden. I'm sure there are many other packaging considerations.

Check your work often with an ohm meter to verify your connections and that there are no accidental shorts created in the solder process. It is a lot harder to debug an error if you wait until the end; sometimes seemingly impossible...
(click the schematic to make it larger)
-----

Now that you have the components installed and soldered down it is time to connect the unit to the bike. But first, be patient... Let's check a few things:
- Apply 12VDC power the the unit. Take note of + and GND; don't hook it up backwards!!! The unit should go through a "Count Up/Count Down" Self Test followed by displaying the temperature (in C or F; whichever you asked for).
- Then the unit will try to display the current gear. Since the unit is not connected to the bike this number will not mean anything. The number may jump around some as well. That's normal right now.
-----
Now... To the bike:
On the 2009 Suzuki DL1000 you are looking for a PINK wire on the ECM; that is the GPI signal wire. I simply unplugged the ECM connector located behind my battery to find it. This is the GPI signal wire and may not be PINK on other motorcycles. See pic below:
-----
We want to connect leg 18 on the PICAXE 18M2 to this PINK wire. Many ways to do this, but in the pic below you can see I removed a small piece of insulation, wrapped the wire from leg 18 on the PICAXE 18M2 around it. I then soldered it on for a solid, reliable connection.
-----
Congratulations. After connecting those three wires (12VDC, Ground, GPI signal wire) to your motorcycle you will now have a working digital gear position indicator with temperature readout and you will have the bragging rights of building your own 'farkle'. Mount it in a handy place and send us a picture of your final product. 
-----
A few more visuals:
Video of finished product connected to the bike:
-----

Video of the prototype functioning on the bike:
-----

Video of the prototype functioning "on the bench":
-----
Another example of a build with a remote display mount:
-----


Friday, January 20, 2012

H-Bridge Motor Driver Tutorial w/ OWI Edge Robot Arm and PICAXE 20M2

Complete wiring diagrams, parts list, and PICAXE source code provided below.

Even in its "natural" state the OWI Edge Robot Arm is a pretty interesting toy. It comes with DC motors and a cable switch box that allows you to manually control 1) Grip, 2)Wrist, 3) Elbow, 4) Shoulder, and 5) Base. Prices for the unit are typically less than $40.

The greatest thing about the OWI Edge Robot Arm is that you assembly it yourself so you understand it well and it is easy to customize.

Intrigued by the idea having a robot that I could personally program to do my evil bidding was overwhelming. Just imagine the possibilities..... Also, I am lucky enough to have a sister that was willing to give an adult a child's toy as a Christmas gift.


The Objective: Replace the wired control box with a programmable microcontroller to let the OWI Edge Robot Arm run autonomously.

In the end, the project results were in some ways underwhelming. Due to the lack of position feedback and the "slack" in the gear/joint movement mechanics it is impossible to control the robot with any precision. In other words, if you move an axis one direction for 1.5 seconds it does not mean it will be in the original starting position if you simple reverse the movement for 1.5 seconds.

That said, having a controllable robot is still pretty cool and it does make a excellent platform to to demonstrate motor drive and control capability with a microcontroller.

Let's go through the build....

The following hardware was chosen because it is cheap, easy to use, and readily available:
  1. OWI Edge Robot Arm (it that is not obvious then stop reading now)
  2. Three SN754410NE motor driver ICs to supply the drive current to the DC motors.
  3. One PICAXE 20M2 to control which direction to spin the motors.
  4. A "strong" 5VDC power source.
-----

Let's take a look at the SN754410NE motor driver IC. First, why is it even required? Motors draw a lot of current. The motors on the OWI Robot measured up to 800mA at full load. That's way too much current to expect from a microcontroller output to drive, so the SN754410NE is required to supply that current. The outputs of the PICAXE 20M2 are programmed to "tell" the SN754410NE motor driver what direction to spin the robot's motors.

Understanding the SN754410NE is simple and straight forward in the configuration we want to use it in. Take a look at the SN754410NE pinout diagram:

One SN74410NE motor driver can control two DC motors to spin in any direction you like; clockwise or counter clockwise. Sure, there are 16 legs on this SN74410NE motor driver chip to wire, but not to worry. If you break it down it is simple. The designers were clever and grouped all the legs for one motor on one side and the legs for other motor on the opposite side. And really, for this application all but four wires on each side are connected to power (+5VDC) or ground. So really, you are only concerned about connecting four "special" connections per motor used. Two will go to the motor and two will go to the PICAXE 20M2 microcontroller.
---
So connecting one motor to the "lower" legs of the SN74410NE motor driver IC will look like this:
See; it's easy. Most legs of the SN74410NE motor driver are connected to +5VDC and ground.
To +5VDC: Legs 1, 16. Legs 8, 9
To GND: Legs 4,5. Legs 12, 13

As for the four "special" connections mentioned above:
Legs 3 and 6 connect to the motor.
Legs 2 and 7 will go the the PICAXE 20M2 microcontroller (more on that later).

Let's point out how the SN74410NE motor driver works:

Condition of Leg 3 Condition of Leg 6 What does the motor do?
------------------ ------------------ -------------------------
0 Volts 0 Volts Motor does not spin
0 Volts 5 Volts Motor spins Clockwise
5 Volts 0 Volts Motor spins Counter Clockwise
5 Volts 5 Volts Motor does not spin

Basically what the table is trying to show is that if Leg 3 and Leg 6 have different voltages the motor will spin. If Leg 3 and Leg 6 have the same voltage the motor will stop. You can "test" this before you connect the PICAXE microcontroller if you like by just connecting the legs straight to the supply voltage and ground. Later, the PICAXE 20M2 will be programmed and connected to control the motor (stay tuned).

But wait, the OWI Edge Robot Arm has five motors and the SN74410NE motor driver can only control two motors. That's no problem if three SN74410NE are used.
----
Below is what the three SN74410NE motor driver ICs look like on a breadboard after the power and grounds are connected. Six motors can be controlled with this set up. Only five motors are needed so we will not connect a motor to the upper side of the right most SN74410NE motor driver.
-----
Let's move from discussing the SN754410NE motor driver IC and switch to controlling how the motors spin control with a custom programmed PICAXE 20M2 microcontroller.

The PICAXE 20M2 is a low cost microcontroller (less than $4) that is easy to program for this application. To control five motors we need 10 outputs; two outputs for each of the five motors. The PICAXE 20M2 has 18 outputs and that is plenty.
-----
Notice how the PICAXE 20M2 legs are labeled; b.7, b.6, etc. The drawing below shows how to wire up the whole system. It shows where to wire power and ground. It shows where wire the motors. It shows where to wire in the PIXACE 20M2 so it will work with the program source code below.
Again, notice nothing is connected to " upper" portion of the SN754410NE motor driver on the far right. Good engineering practice would say the inputs (Leg 10 and Leg 15) should be tied to ground. But, we aren't designing for a Mars rover or anything critical, so everything should be fine. As a general rule leaving inputs floating can lead to a risky design.

The PICAXE 20M2 is programmed (again, example source code below) to control the direction of each motor. From above we know that varying the condition of the SN754410NE motor driver IC inputs has a resulting spin on the motor. The source code for the PICAXE 20M2 simply forces the two SN754410NE motor driver IC inputs high and/or low to make the robot motor spin in the desired direction. High/Low will spin the motor one way. Low/High will spin the motor the other way. The PICAXE 20M2 output conditions are held static in the source code with the PAUSE command to determine how long the motor will spin. If the PICAXE 20M2 is programmed to output High/High or Low/Low the motor will stop moving.
----
Let's wrap this up. These wires connect to the five motors on the OWI robot:
These are the wires that go to straight to the SN754410NE motor driver ICs. If you connect these wires straight to Power and Ground you can document which connector wires control what motor and in what direction.
-----
After you wire the PICAXE 20M2 to the SN754410NE motor driver ICs your breadboard will look something like this:

-----
Add in the wires from OWI Robot motors and your done with the hardware. It will look like this:
-----
Picture of the final build with everything wired in:
-----
A short video demo of all five motors being controlled on the OWI Robot. Be aware that the motors can pull over 500mA each. Running several motors at once can demand a lot of current, so if your design doesn't work suspect the power supply may not have enough output current.
----
A below is source code for the PICAXE 20M2 to make it all work. Basically, the PICAXE 20M2 outputs are set HIGH and/or LOW to control the motors. A PAUSE statement determines how long that motor should stay on. Both outputs LOW stop the motor movement. It is possible to move more than one motor at a time if you have a 5VDC power source that can supply enough current. In the example below all motors are excerised one at a time. The code can be modified to make the OWI Robot dance to your wishes:

; *************************************
; ***** www.whiskeytangohotel.com *****
; *************************************
; Project Name: OWI Robot Arm "Nancy"
;
; Start Date: DEC 2011
;
; Program Rev History:
;
;
; *******************************
; PICAXE PE Rev: MacAXEPad 1.3.2
;

#picaxe20m2

'Define the outputs to be discriptive
symbol Grip_Close = b.0
symbol Grip_Open = b.1


symbol Wrist_Up = b.2
symbol Wrist_Down = b.3

symbol Elbow_Up = b.4
symbol Elbow_Down = b.5

symbol Shoulder_Out = b.6
symbol Shoulder_In = b.7

symbol Base_CCW = c.0
symbol Base_CW = c.1

'Subroutine move commands are:
' GripOPEN GripCLOSE GripSTOP
' WristUP WristDOWN WristSTOP
' ElbowUP ElbowDOWN ElbowSTOP
' ShoulderIN ShoulderOUT ShoulderSTOP
' BaseCCW BaseCW BaseSTOP
' StopAll
' (motion referenced from behind the robot


main:

gosub WristDOWN
gosub StopALL
pause 1000
gosub WristUP
gosub WristUP
gosub StopALL
pause 1000

gosub ElbowDown
gosub StopALL
pause 1000
gosub ElbowUP
gosub StopALL
pause 1000

gosub GripOPEN
gosub GripCLOSE
pause 1000
gosub GripOPEN
gosub GripCLOSE
gosub StopALL
pause 1000

gosub ShoulderIN
gosub StopALL
pause 1000

gosub GripOPEN
gosub GripCLOSE
pause 1000
gosub GripOPEN
gosub GripCLOSE
gosub StopALL
pause 1000

gosub ShoulderOUT
gosub StopALL
pause 1000

gosub BaseCCW
gosub StopALL
pause 1000
gosub BaseCW
gosub BaseCW
gosub StopALL
pause 1000
gosub BaseCCW
gosub StopALL
pause 1000

gosub GripOPEN
gosub GripCLOSE
pause 1000
gosub GripOPEN
gosub GripCLOSE
gosub StopALL
pause 1000

gosub WristDown
gosub StopALL

goto main
' ------GRIP------
GripOPEN:
high Grip_Open
low Grip_Close
pause 1000
return 'GripOpen

GripCLOSE:
low Grip_Open
high Grip_Close
pause 1000
return 'GripClose

GripSTOP:
low Grip_Open
low Grip_Close
return 'GripStop
'-----------------

'------WRIST------
WristUP:
high Wrist_Up
low Wrist_Down
pause 1800
return 'WristUp

WristDOWN:
low Wrist_Up
high Wrist_Down
pause 1800
return 'WristDown

WristSTOP:
low Wrist_Up
low Wrist_Down
return 'WristStop
'------------------

'------ELBOW------
ElbowUP:
high Elbow_Up
low Elbow_Down
pause 3000
return 'ElbowUp


ElbowDOWN:
low Elbow_Up
high Elbow_Down
pause 3000
return 'ElbowDown

ElbowSTOP:
low Elbow_Up
low Elbow_Down
return 'ElbowStop
'------------------

'------SHOULDER------
ShoulderIN:
high Shoulder_Out
low Shoulder_In
pause 2500
return 'ShoulderUp

ShoulderOUT:
low Shoulder_Out
high Shoulder_In
pause 2500
return 'ShoulderDown

ShoulderSTOP:
low Shoulder_Out
low Shoulder_In
return 'ShoulderStop
'------------------

'------BASE------
BaseCCW:
high Base_CCW
low Base_CW
pause 3000
return 'BaseCCW

BaseCW:
low Base_CCW
high Base_CW
pause 3000
return 'BaseCW

BaseSTOP:
low Base_CCW
low Base_CW
return 'BaseStop
'------------------

'----StopAll-------
StopAll:
gosub GripStop
gosub WristStop
gosub ElbowStop
gosub ShoulderStop
gosub BaseStop
return 'StopAll
'----------------