Introduction: Simple Binary Converter and Display With DP32
Have a DP32 board and wondering if you could do it with something useful ?
: )
Here is an instruction that will show you how to turn it into a binary converter and display the results.
Step 1: Step 1: Getting Started.
You will need:
- DP32 board X 1
- ChipKit Programmer/Debugger X 1
- USB A to Mini-B Cable X 1
- Micro USB Cable X 1
- Computer with USB ports and internet connection X 1
Step 2: Step 2: Installing the IDE
You will need some software in order to program on the board and make it work.
MPLAB X : http://bit.ly/1qqu0Xm (Windows version)
Arduino IDE: http://bit.ly/1RJFw6X (Windows Version)
here I only listed the windows versions.
You could find other versions from:
http://bit.ly/1R2xniM (Arduino)
http://bit.ly/1R2xniM (MPLAB X)
Step 3: Step 3: Install the ChipKit Core
- open this site: http://bit.ly/1SSEnyl ,
- click on the chipKit core as underlined in blue.
- scroll down that page until you see this link:https://github.com/chipKIT32/chipKIT-core/raw/master/package_chipkit_index.json, save it for later.
Step 4: Step 4: Setting Up Your Arduino Preferences
- Open your Arduino
- click on "File" → "Preferences" to open the setting page.
- Then paste the link you just saved to the field "Additional Boards Manager URLs".
- Then click on "OK"
Step 5: Step 5: Setting Up the Arduino Board
- Click on "Tools" →"Board ...."→ "Boards Manager..."
- then search chipkit in the pop up window, you will see result similar to the second picture.
- Then click on "install" in the red circle.
- Then go back to "Tools"→"Board..."→ This time scroll down and choose "chipKIT DP32".
Step 6: Step 6: Download the Bootloader
- Open this page: http://bit.ly/1ptXXWh
- then scroll down to the "Design Resources",
- then click on the "Download" beside the Bootloader.
You will get a zip file which contains a file named chipKIT_Bootloader_DP32.hex
save it for later.
Step 7: Step 7: Setting Up the MPLAB X
- Connect your Board and Debugger to your computer.
- Open your "MPLAB X"
- Click on "File" → "New Project..."
- then choose "Microchip embedded" → "Prebuilt (Hex, Loadable Image) Project"
- then "browse" to your bootloader file which just downloaded in the last step,
- and then choose your debugger in the "hardware tool" (It may varies from the picture I show).
- Click "next", then name the project and then click on "Finish".
and now your project is built.
Step 8: Step 8: Install the Bootloader
- Find the icon in the red circle in your MPLAB X and then click on it.
Your output should look similar to the second picture, and the LED 1 on your board will flash.
- If not, try previous steps again and check your board connections.
(IMPORTANT: every time when you try to write code to the DP32 board, you will have to flash the bootlader again.)
Step 9: Step 9: Compile and Upload Your Arduino Code
- Keep your board connected.
- Open your code with Arduino
- and then click on the "check" mark (red circled in 1st pic)
- If error occurs, rewrite your program.
- Then click on the "Upload" button (red circled in the 2nd pic)
- If the terminal says "No Target Found" (Green Box in the 3rd pic),
- go to "Tools" →"Port" and then try a different Port (as in the 4th pic, yours may vary).
- It should look like this if the upload is successful. (as in the last pic.)
Step 10: Step 10: Time to Have Fun
Here I posted my code for one approach.
It will work as below:
- button 1 is used as the counter,and button 2 as the switch.
- Button 1 will record the entered number no bigger than 15, and press button 2 for 3 times will show the presses on button 1 in binary as the represent of the LED.
- Each time each button is pressed, there would be a single blink of an LED as the indicator.
- If the presses exceed the maximum number, the presses will reset to 0, and one LED will blink for 5 times as the indicator.
I also post the demo running video for the testings in the following steps.
- Since my button 1 seems have some issue contacting the board, it might not response sometimes when I press it, but it will eventually work.
Attachments
Step 11: Step 11: Test My Code for Input 7
- press the Button 1 for 7 times
- press the Button 2 for 3 times
- the LED show "0111", which represents as LED 4 off, LED 1,2,3 on.
Step 12: Step 12: Test My Code for Input 15
- press the Button 1 for 15 times
- press the Button 2 for 3 times
- the LED show "1111", which represents as all LED on.
Step 13: Step 13: Test If Button 1 Input Exceeds Maximum.
- press the Button 1 for 16 times
- LED 4 flashes for 5 times indicate the input out of bounds.
Step 14: Step 14: Test Button 2 Exceeds Maximum
- press the Button 1 for 4 times
- press the Button 2 for 3 times
- LED show as "0100"
- press the Button 2 for one more time
- LED 4 flashes and indicate exceeding maximum input for Button 2.
Step 15: Step 15: Test Open Switch at Beginning, Display Every Single Input and Test Bounds for Both Buttons
- Press the Button 2 for 3 times at the beginning.
- Keep presses the Button 1 and the LED display changes as the presses increment.
- When Button 1 presses exceeds 15, LED 4 flashes indicate exceeding maximum.
- Presses Button 2 for one more time, which results 4 presses for Button 2, LED 4 flashes indicate exceeding maximum.