Just published two new blog posts on a C Library I created using the HD44780 controller.
Check out the posts on my new blog http://joepitz.blogspot.com/
Due to some limitations with WordPress.com I have decided to move my blog to Blogger.
Here is the link to my new blog site. I have not decided if I am going to move all of my posts, or leave them where they are.
Please pass the word.
Thanks for reading.
The other night I was riding my NordicTrack Bike and all of a sudden the display quit and the tension on the peddles went slack. The wife has been on me for quite some time to start exercising as I sit behind the computer the major part of the day.
So I decided to take the thing apart and see If I could trouble-shoot what was causing the control and display not to function.
I will get into showing you the tear down shots later. Right off of the bat I thought, cool if the controller is shot I could replace it with a micro-controller solution. This would be a cool project.
But then reality set in and I realized that this project would take some time and I am currently working on some other micro-controller projects.
So back to tearing the thing down and see if I could fix the darn thing.
The display has two sets of connectors coming out of it. I had no clue to what they were connected to. So I decided I had to tear the plastic off the bike and take a look at how the bike was wired.
Grabbed the multimeter and some tools. Stripped the bike down to the frame and started taking a peek how this bike works.
Lets take a look at the key sections of the bike.
We will start at the front of the bike. Notice the ac adapter, 12 volts, 1 amp DC adapter.
A bit further back, The peddle assembly, Notice the Halls Effect sensor and the magnet mounted to the peddle assembly.
The Hall Effect sensor is used to count the number of wheel rotations and calculate things like speed and distance traveled. Along with the hall effect sensor and the weighted wheel potentiometer, calories burned can be calculated.
At the rear is the business end of the exercise bike, there is a weighted wheel with a tension adjuster and a motor.
Here are some pics:
That is it not a lot in the sensor and mechanical portion of the exercise bike.
Lets take a closer look at the motor assembly.
On the motor we have a lever and a gear wheel no unlike a RC servo motor. So this motor my be controlled like an RC servo motor? maybe lets troubleshoot some more.
So we flip the motor over and notice how the motor is wired:
The motor has two wires connected, a yellow wire and a blue wire, no this motor is not an RC servo, it is just a DC motor. Also on the motor control casing there is a label.
On the label it indicates “6V tension motor P/N 241949″ I did some web searching and found that many exercise bike use this same motor. But I could not find any specifications on the motor. Just a few posts where other people have had some issues and one article on a vague description on how to test the motor by applying some current to the motor to see if the motor gear turned or not.
I flipped the motor to the other side and had a look:
Interesting, There is a 5000 ohm potentiometer on attached to the gear of the motor.
This would mean that when the motor is adjusted to increase the tension of the skid closer to the motor the resistance would increase and likewise when the motor reduced the tension against the wheel the resistance would decrease. At least that is what I guessed. Lets do some testing.
So I installed the motor back into the exercise bike and put some batteries together for some testing.
I applied some voltage to the yellow and blue wires and sure enough the motor started to turn to move the skid closer to the wheel. Just like a servo though there is a stop and you have to be careful not to keep the motor running against the stop.
So then the question is if I reversed the wiring on the motor would the motor reverse direction and turn pull the skip away from the wheel. Tired is and sure enough the motor changed direction and moved the skid away from the wheel.
I then attached my ohm meter to two of the terminals of the potentiometer and ran the motor forward and backward and the ohm meter read from 0 – 477 K ohms.
The potentiometer readings along with the hall effect sensor are used to calculate calories burned, speed and distance traveled.
I traced the wires back from all connections to the 10 pin wire connector and found out which wires applied power to the display and controller. I also noted where all of the wires from the potentiometer and halls effects sensor came into the wire harness.
It was time to take a look at the controller/display.
I removed the connectors and display unit from the exercise bike and took it to my work bench.
I opened up the display/control unit and took a peek inside, not a good sign, other than a few capacitors there were no discrete parts, just a bunch of chips. So I disconnected the keypad and speakers and the iphone dock connectors and applied power to the unit. Instant current overload on the adjustable power supply. I tried to check a few connections but not much else could be tested. It appears to be a chip issue. There were no burn marks on the pcb traces. So it looked like the controller was fried.
I looked on line and a new controller was over $300.00. No freaking way was I going to pay that much for a replacement controller.
So I did some thinking and came up with a quick and dirty way to get the excerise bike working for around $15.00.
Really all I needed was a way to increase and decrease the wheel tension on the exercise bike. I really do not need the fancy data that comes off the bike for the time being. I could get the bike working and then when I had some time I could come up with a replacement controller using an inexpensive micro-controller solution with a LCD display.
Did a bit of web searching and drew up a wiring diagram, after a quick trip to radio shack I started to put together a workable solution.
Here is the wiring diagram I came up with:
I picked up a DPDT switch, a DC adapter voltage connector and a momentary push button and a project case that I had laying around on my desk and some wiring.
After wiring up the new controller box I mounted the box to the exercise bike and connected the yellow and blue wires to the new control box:
Notice I connected the output leads to the wire connector using some female jumper connectors. That way when I come up with a micro-controller solution it will be an easy fix to use the existing wire connector.
If you decide to wire up one of you own, you may have to swap the yellow and blue wires in order to have the DPDT switch increase the tension when the switch is pressed in the forward position and pressed rearward to decrease the tension.
There you have it, a working quick and dirty exercise controller.
Now I can keep my wife off of my back and get back to my other micro-controller projects.
Apparently Radio Shack has changed the link to where you can download the program code for the Make:it Robotics Starter Kit. I will put the zip file here on my site so everyone can download the files directly from my blog site.
WordPress does not allow the uploading of .zip files so I renamed the file as Program_Files.doc.
To download just click on the below link. Once downloaded just double click on the files to unzip or rename .doc to .zip, if you want to keep the .zip file for archive and cannot remember that the extension name change.
In this blog post we are going to take what we learned in “Make:it Robotics Starter Kit – Wireless Connectivity” and “Make:it Robotics Starter Kit – Capturing Sensor Data” and combine this data to capture sensor data in real time and send this data to a program running on our computer wirelessly.
So if you do not have your robot configured to use the Transmitter and receiver, take a look at the blog post “Make:it Robotics Starter Kit – Capturing Sensor Data” and re-configure your robot and FTDI cable.
In order to send sensor data to our computer we again have to make a few small changes to our lineFollow.ino Arduino program:
Comment out the following line, as we no longer need our counter variable.
// int counter;
Comment out the variable initialization of the counter variable:
// counter = 0;
In the loop() function of the program comment out the following lines:
// mySerial.println(counter, DEC);
Add the following line to the loop() function:
if(action1 != action2)
if (action1 == 3 )
if (action1 == 1)
if (action1 == 2)
if (action1 == 0)
When we run the robot our sensor data will be send out wirelessly to our computer, but we do not want to just capture the serial data using the Serial Monitor with the results being displayed as hex numbers.
We want to display in real time the actual directions the robot is being given based on the sensor data.
In order to do this we cannot use the Serial Monitor. We must write a program that has similar logic as our lineFollow.ino program.
So we are going to develop a Python program that reads the serial port data and print out the directions that the Robot is being given in plain English.
Here is the Python program, we will analyze the program in a bit.
If you have not done so, refer to the earlier blog post “Make:it Robotics Starter Kit – Binary Part 1″ and watch the Video on how to setup Python on your computer.
Author: Joe Pitz
reads the serial port and prints out the
direction the robot is turning.
go forward, turn right, turn left.
ser = serial.Serial('COM3', 1200, timeout=0)
value = ser.read(1)
if value >= '0' and value <= '3':
if value == '0' or value == '3':
print "Go Forward"
if value == '1':
print "Turn Left"
if value == '2':
print "Turn Right"
if __name__ == "__main__":
The import statements provide library functions that our Python program need in order to communicate to the serial port.
The statement defines a function called main()
ser = serial.Serial('COM3', 1200, timeout=0)
This statement creates a serial object and tells the object what serial port to listen on, what baud rate to use and timeout=0 is used to read the data when it is available without waiting.
The while 1: statement is used to start a loop that repeats and does not end as the condition of 1 is always true.
value = ser.read(1)
Here we read one byte of data from the serial port and store this value to the value variable.
if value >= '0' and value <= '3':
If the contents of the value variable is between 0 and 3 execute the contents of the if statement
if value == '0' or value == '3'
print "Go Forward"
If the value variable is either 1 or 3 then execute the print “Go Foward”
if value == '1':
print "Turn Left"
If the value variable is 1 then print the message “Turn Left”
if value == '2':
print "Turn Right"
If the value variable is 2 then print the message “Turn Right”
if __name__ == "__main__":
If this program is being executed and not a library file then execute the main function.
Remember Python is an indent sensitive sensitive language. If your indentation is not correct your program will generate syntax errors when you try to execute it. Count your indentation spaces when coping the code in your text editor.
Remember when you plug your USB cable into to program the Arduino you will have to make sure your serial port is correct for the Serial Port Settings in the Arduino IDE. Refer to the blog post “Make:it Robotics Starter Kit- Capturing Sensor Data” for information on how to determine the correct Serial Port and how to setup the Arduino IDE.
If you use a different USB Port for your FTDI USB cable, your Serial Port will be different as well.
Place your readSerial.py program in a folder on your computer and start a Command Prompt and change directory to the same folder location of your readSerial.py program.
Run the command from your Command Prompt:
If you encounter any errors, check that your runSerial.py program is set to the correct serial port. make sure you have your driver board and FTDI cable wired correctly. If you are getting strange characters being printed to your command prompt, check to make sure your baud rate is the same in the Arduino lineFollow.ino and readSerial.py programs.
If you did everything correct, when your robot is following the black line your Python program should output something like the following:
In this blog post we are going to take the information that we learned in the earlier blog post entitled “Make:it Robotics Starter Kit – Software Part 2″ and capture real time sensor data and send this data wirelessly to our computer.
In order to complete this section we need to purchase a few items:
RF Radio Transmitter and Receiver, (5 volt, not a 3.3 volt)
Male Female jumper wires
In addition we will need our FTDI USB cable, or a FTDI USB dongle.
I did a bit of searching on the web and found a RF Data Module Tx/Rx kit. This kit has a 315 MHz transmitter and receiver. I paid $9.00 plus shipping for this kit.
(Click on the Images to make them larger)
This male FTDI USB adapter would be more compact and have a nicer form factor for your computer. But since I already had the FTDI USB cable I will use this for the tutorial. Later if you want to make a permanent configuration, you can always order the male version of the FTDI adapter.
You can purchase any frequency transmitter/receiver kit as long as the frequencies are the same between transmitter/receiver.
This blog post will explain in detail how to connect the RF radios to the robot and your computer. We will make a few small modifications to our original lineFollow.ino program. But the changes to get the robot communicating using the RF radios is pretty easy.
First we must identify the components of the radios. Your kit might be different than mine, My kit did not come with any documentation. So I had to do a bit of searching on the web to find out pin configuration, transmitter/receiver identification etc.
The nice thing is there is lots of info out on the web about configuring RF radios.
First let us determine which board is our transmitter and which board is our receiver.
Look very closely at the pin labels on both boards that you have:
This is an image of the boards that I received. Your boards might look different.
Size and number of pins will not determine which board is a transmitter or receiver.
On the above image look at the pin labels on the smaller board. The pins are labeled VCC, GND, DATA and ANT.
VCC is voltage applied to the board.
GND is the ground (earth) connector.
DATA is the pin that transmits the data to the outside world
ANT is the Antenna.
Chances are that the board that has the Antenna pin is your transmitter.
Lets look at the other larger board.
GND, OUT, OUT, VCC
This board is the receiver.
Important, your boards may be configured differently. On your receiver you may only have one OUT, or data pin.
Check the instructions that came with your RF kit or perform the same identification process that we just did in this post.
Looking at our driver board, we need to find the following pins.
We will now wire our transmitter to the robot. Get three female to male jumpers, Red, Black and Green, if you have them, if not choose three different color jumpers and write the colors down.
Take the (Red wire) female socket end of the jumper, plug it into the pin labeled VCC on the transmitter, take the male end of the same jumper and plug it into the 5V socket on your driver board.
Take the (Black wire) female socket end of the jumper and plug it into the pin labeled GND on the transmitter, take the male end of same jumper and plug it into either GND socket on the driver board.
Take the (Green wire) female socket end of the jumper and plug it into the pin labeled DATA on the transmitter, take the male end of the same jumper and plug it into pin 5 (lower right header bank) of the driver board.
Your transmitter has been wired to the robot.
For the time being I just laid the transmitter on the top of the driver board for testing. Once we want to run the robot we will tuck the transmitter in away from the wheels.
Let us wire the receiver to our USB cable.
Select three more female to male jumpers, Red, Black and Yellow, again if you do not have these colors choose 3 different colors and write down their use.
Take the (Red wire) female socket end of the jumper and connect it to the VCC pin on the receiver, take the male end of the same jumper and plug into the socket of the FTDI connector that has the Red wire.
Take the (Black wire) female socket end of the jumper and connect it to the GND pin on the receiver, take the male end of the same jumper and plug it into the socket of the FTDI connector that has the black wire.
Take the (Yellow wire) female socket end of the jumper and connect it to the OUT pin on the receiver, take the male end of the same jumper and plug it into the socket of the FTDI connector that has the Yellow wire.
Your receiver has been wired to your USB FTDI.
We now need to modify our lineFollow.ino program as the RF radio kit has slightly different requirements than our hard coded serial port does.
Here are the changes we need to make:
#define rxPin 4
#define txPin 5
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
In our definition section we need to add a counter variable that will be used to test the wireless serial port. This counter will have a data type of int.
Serial.begin(10420); //tell the Arduino to communicate with Make: it PCB
delay(500); //delay 500ms
line_following.line_following_setup(); //initialize the status of line following robot
line_following.all_stop(); //all motors stop
// set the data rate for the SoftwareSerial port
counter = 0;
In our setup() function we need to make the following changes:
We need to comment out the mySerial.begin(9600); command and add the following command:
1200 is the baud rate (speed of data transfer) that the RF radios can communicate with each other. This value may be different for your radios. Check your documentation. In my situation the radio came with no documentation, so I first tried 2400 baud, which did not work, so I then lowered the baud rate to 1200 baud, which did work.
We also initialize the counter variable to a value of 0.
In the Loop() function we need to add the following:
// mySerial.println(sensor_in, HEX);
First we comment out the mySerial.printLn(sensor_in, HEX); line and add the following line:
In order to test that we configured our RF radios properly we just want to send some numbers to our workstation. Later when we make sure that our RF connections are working we will change the mySerial.printLn() back to what it was before.
These are all of the changes we need to make.
Just attach the USB cable to the Arduino USB connector on your robot. we will first compile and upload the program to our Arduino.
Remember we need to check to make sure that we are using the correct serial port number, Check the earlier blog entry “Make:it Robotics Starter Kit – Software Part 2″ for details on how to accomplish this task.
Remember you do not need to turn on the battery box switches in order to have the robot communicate across the serial port.
Once your lineFollow.ino program has uploaded to the Arduino, plug your FTDI USB cable into your computer. Load the Arduino IDE, select the correct serial port and open the Serial Monitor program.
Select the correct baud rate, in my case I selected 1200 baud.
If you performed all of the tasks correctly then you should see the following in your serial monitor program. Your program should look a bit different as this screen shot was taken from the ATMEL Studio IDE:
If your serial monitor is receiving, what appears to be a lot of junk characters or a bunch of question marks. Then either your baud rate on the serial monitor does not match the baud rate you set in your lineFollow.ino program or you need to change the baud rate that the program is using as the RF radios may not support this baud rate:
In the next blog, tutorial we will setup the lineFollow.ino program to send sensor data to our computer while the robot is running around the black circle sending real time data to our computer wirelessly.
In this blog post we will take a look at the driver board that comes with the Make:it Robotics Starter Kit. There is no documentation that comes with the Start kit concerning the Driver board other than the schematic.
Unless you have some experience reading schematics the task of understanding what is on the driver board and how to use it beyond the kits that Radio Shack provides might be a bit daunting.
So we are going to show some images of the driver board and the schematic and point out some of important parts and map these to the schematic so everyone can follow along and learn more about the driver board.
Lets start out easy:
(Click on the images for a larger view of the image)
Here is a an image of the motor board with some terminal connectors marked in red and yellow.
The yellow box drawn on the driver board image is the terminal connector for power into the driver board from the battery boxes.
If you remember when you built the robot, you wired the two battery boxes in series (the black lead from one battery box was wired to the red lead of the other battery box. Then one lead from each box was wired to the terminal connectors on the driver board). If you take a voltage reading on the two connectors of the driver board, you should get a reading of around 12 volts.
Unless you are interested in understanding how the power circuit was built, you really do not need to speed too much time reading the schematic.
The two red boxes drawn on the image of the driver board are the motor terminal connectors. The left terminal connector is for motors 1 and 2. The right terminal connector is for motors 3 and 4. Below are images of the schematics of the motor driver circuit. Again if you are not interested in learning how the circuit is designed then you should not have to spend much time looking over the schematic.
Let us now look at some more built in sensor inputs that our driver board has. Look at the below driver board image, I have drawn some square boxes on the image:
If you have built the line following robot than you should be familiar with the 4 sets of pins on the right side of the board, marked in red. These are the connectors for the two line following optical sensors.
The 4 sets of pins on the left side of the board, marked in yellow are for the the IR (infrared) proximity sensors. These sensor pins are not used in the Make:it Robotics Starter Kit. They are used on one or both of the later add on kits that are available from Radio Shack or the Maker Shed store.
At the time of this writing, I have not purchased the add on kits. I will update this section after I purchase the kits.
The 4 sets of pins, marked in green are for LED (light emitting diodes), again not used in the Make:it Robot Starter Kit.
The three pins, marked in blue are for the remote IR sensor, another add-on kit that you can purchase.
I have not included a schematic for these sets of pins, as the schematics are quite large. But the connectors are labeled quite clearly on the schematic. If you are interested, take a look at the schematic to become familiar with what other components they connect to.
One of the most critical jumper pins on the Driver board is marked in red below:
These jumpers when connected, as shown, allow the program running on the Arduino to communicate through the serial port to the driver board.
If the pins are not jumpered as shown in the image, the robot will not move when you turn on the battery boxes. The purpose of the jumpers, when removed, is to allow you to use the USB port on the Arduino, to upload a new program to the robot. After uploading the program you should re-attach the jumpers as shown so the Arduino can communicate to the driver board.
One of the nice features of the Driver board that comes with the Make:it Robotics Starter Kit is that there are extra Arduino pins on the Driver board that are not used. These extra port pins can then be used to enhance the robot with features of your own design.
For those that are not familiar with the Arduino design. A board that plugs into the Arduino is called a Shield. The Arduino family of micro-controller boards have rows of female headers around the board. These header pins are used to interface sensors and other external devices that can be used to communicate to the outside world.
An Arduino shield has male header pins on the bottom of the board that fit directly into the female header pins on the Arduino.
In the case of the Driver board that comes with the Make:it Robotics Starter Kit, not all of the port pins are used.
So if we want to add some new sensors or external devices, like Wifi communications to your robot, the extra port pins are available to do so.
These extra pins are not documented anywhere except on the Schematic. So this blog post will show the Driver board image and the schematic image and map these available port pins so everyone see where they are on the Driver board.
Below is the image with the port pins marked in red on the Driver board, and an image of the same header pins from the schematic:
One method that is common on printed circuit boards (PCB) is to label the connections. If you look at the schematic and closely on the Driver board you can see some of these labels. Note some of the labels are covered up by the actual black female header port pin sockets. You will just have to make an educated guess by comparing these ports with other pins where the labels are actually visible.
Notice on the Driver board image, the upper left header pins, marked in red, If you look closely you can see the soldered male pins that are on the bottom of the driver board. These pins are also shown on the schematic. Notice that these pins are attached to the female header sockets on the schematic by a single black line.
On the schematic the female header pin sockets are labeled A, B, C, and D.
You should have no trouble in matching these header pin sockets, on the driver board to the ones shown in the schematic.
Remember in the earlier blog post, “Make:it Robotics Starter Kit – Software Part 2″ we used pins 4 and 5 so we could send our sensor data to our software serial port and then on to our computer. By looking at the schematic I was able to determine that pins 4 and 5 are extra pins not used by the driver board.
Notice that in section A on the schematic that all pins, upper left bank, are used, so there are no extra pins that we can use in this section for data port pins, But the pins marked 3.3 V, 5 V and GND can be used to power sensors or devices that we want to connect to any available port pins in section B and D.
If we look at section B, we can see that pin A0 is being used. The A pins are analog pins, All other pins on the Arduino are digital pins.
Google the difference if you need an understanding.
That means that pins A1 – A5 are not being used and we could use these analog pins for our own modifications to our robot.
Also look at section C. Notice that all port pins are being used in section C. So we cannot use these port pins for our own use.
Look now at section D, Notice that port pins 2 and 3 are being used, in fact port pins 2 and 3 are being used to communicate between the processor on the driver board to the Arduino.
The rest of the port pins 4 – 7 are available for use to use.
By looking at the schematic, port pins 1 and 2 appear to be not used on the driver board. Remember the driver board is a shield and plugs directly into the Arduino. On the Arduino pins 1 and 2 are used to communicate to the outside world using the built in hardware serial port. So we normally do not want to use port pins 1 and 2 on the Driver board.
More to come.