tag:blogger.com,1999:blog-89055971809185427562017-09-27T12:58:00.023-04:00Joldosh's Electronic ProjectsJoldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.comBlogger59125tag:blogger.com,1999:blog-8905597180918542756.post-10991069688389208472015-12-27T17:16:00.000-05:002015-12-27T17:18:01.329-05:00Makevention 2015<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-LfSdP93gyVI/Vns-YtEh5rI/AAAAAAAAF7w/Py2s-5hBfTM/s1600/rsz_dscn3802_-_edited.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="254" src="http://1.bp.blogspot.com/-LfSdP93gyVI/Vns-YtEh5rI/AAAAAAAAF7w/Py2s-5hBfTM/s640/rsz_dscn3802_-_edited.jpg" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div style="text-align: left;">Makevention went really well! I was able to show everything I have been working on, although I didn't have time to finish everything. I made a poster board explaining some concepts related to calculators like RPN, BCD, and CORDIC on the left side with information about my RPN Scientific Calculator on the right. I also had a print out of how my external RAM preprocessor works. A few of the people who came by my table were programmers and understood the solution.</div><div style="text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-V62foO8iQfU/VntlVKm_yiI/AAAAAAAAF8E/VPF6Isg5fPs/s1600/rsz_1dscn3804.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="198" src="http://2.bp.blogspot.com/-V62foO8iQfU/VntlVKm_yiI/AAAAAAAAF8E/VPF6Isg5fPs/s320/rsz_1dscn3804.jpg" width="320" /></a></div><div style="text-align: left;">On the table itself I had different calculators and projects laid out in roughly chronological order. The first was an MK-61 RPN calculator I added to my collection over 10 years ago. Of course I didn't make it but I wanted to show an example of an RPN calculator and what inspired me to first make calculators. When I first got the calculator out to test it, it didn't show anything on the screen and I was afraid it was broken. I took it completely apart and looked for burst capacitors. I also brushed off the battery contacts since they didn't look very clean. When I turned it on, it still didn't show anything but when I pressed a number it showed up! It seems the calculator just doesn't display anything when first turned on, instead of the zero I was expecting. Somehow I had forgotten that in the 10 years its been since I last used it.</div><div style="text-align: left;"><br /></div><div style="text-align: left;">The Casio Algebra FX 2.0 was included to show the RPN stack program I wrote for it in 2002 or so. That program was designed to make the calculator function more like the HP-48GX I had at the time which I admired so much. First, I had to buy a calculator to replace the Algebra FX 2.0+ I sold in college. Loading the program onto the calculator took quite a while to figure out! In 2002 I used a serial cable, which I think was an SB-87, to load programs without any trouble. Nowadays I don't have a serial port, so I bought an FA-124 USB cable. It turns out that this cable doesn't work on Windows 7. I also couldn't get it to work correctly under Windows XP running in an emulator. Next I tried a lot of different third-party software and finally got the program to load using FlashCOM 1.4v and an FTDI cable. For the link port I bought a 2.5mm plug that I could easily wire to the FTDI cable. After that, the program I loaded kept crashing and I thought the transfer was corrupt. After more fiddling I got Turbo C up and running in an emulator and compiled the program source myself, which produced a fairly stable program that was good enough for exhibiting, although it did crash a couple times during Makevention. Someday I would like to fix the program up and make it more stable.</div><div style="text-align: left;"><br /></div><div style="text-align: left;"><a href="http://1.bp.blogspot.com/-Rf4cHaqQiSo/VnttHeL4opI/AAAAAAAAF8Y/3XQRjO1lZhU/s1600/rsz_dscn3805.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="183" src="http://1.bp.blogspot.com/-Rf4cHaqQiSo/VnttHeL4opI/AAAAAAAAF8Y/3XQRjO1lZhU/s320/rsz_dscn3805.jpg" width="320" /></a>The next thing I showed was a launchpad hooked up to a breadboard with a button and blinking LED to show how easy it is to get started with electronics. The next step was my binary LED calculator. I soldered a coin battery holder on to the board. After that I showed the RPN Scientific Calculator and explained that it was not too difficult to move to this stage after I managed to finish the binary LED calculator. The Programmable RPN Scientific Calculator was next. I printed temporary a colored keypad on poster paper which I taped to it, but it did not work very well. Unexpectedly, the calculator showed random keypresses when I put my hand near it. All the keys were in the same column on the keyboard, which makes me thing there is a bad connection in that row of the key matrix.<br /><br /><a href="http://4.bp.blogspot.com/-yBZuwLwZhIY/Vnt1JJDMbFI/AAAAAAAAF8s/TxtyXMY0vcU/s1600/rsz_dscn3799.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-yBZuwLwZhIY/Vnt1JJDMbFI/AAAAAAAAF8s/TxtyXMY0vcU/s320/rsz_dscn3799.jpg" width="320" /></a>Next I showed the Improved 6502 Virtual Trainer up and running on my laptop, along with the first 6502 Virtual Trainer. I also showed what I had accomplished with the 6502 graphing calculator. So far, I have most of the hardware for it installed but I am having problems keeping the buffer chips for driving the LCD at the appropriate voltage level. Maybe the pins joining the sections of the calculator together aren't making a good connection. In any case, I showed the calculator taken apart into its sections. I also showed the Logic Tool I have been using to debug the graphing calculator and the EEPROM programmer I built. The last thing I showed was the TI-86 I bought to hook up to an ESP8266. My plan was to relay text from the calculator over WiFi to a computer running Matlab or similar software to allow the calculator to solve more complex equations. I still haven't gotten the ESP8266 voltage levels to work right, but I want to finish this project when I have time.<br /><br />All in all it was a great day and I really enjoyed showing the public all the things I have been working<br />on.</div></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-15869090208752058442015-12-25T00:14:00.000-05:002015-12-25T00:14:22.363-05:00Summer Hackathon: Conclusion<div dir="ltr" style="text-align: left;" trbidi="on">The Summer Hackathon I started on in May came to an end in August when I displayed a lot of what I had been working on at Makevention. I finished some projects and abandoned some others. Here is the outcome of the projects I set out to work on.<br /><div><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>EEPROM Computer</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #cc0000; color: #cccccc; height: 20px; width: 100%;"><center><b style="text-align: left;">Abandoned</b></center></div></div></td></tr><tr><td colspan="3">As I mentioned in the last <a href="http://joldosh.blogspot.com/2015/06/summer-hackathon-update.html">update</a>, a 4-bit version of this kind of computer has already been made by someone else. In the future I may make a 32-bit version, but for the time being I am done working on this.</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>8-bit Homebrew Computer</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 20%;"><center><b style="text-align: left;">20%</b></center></div></div></td></tr><tr><td colspan="3">For this project, I designed a lot of the opcodes and most of how I want the computer to work. The chips I want to use don't seem to be simulated anywhere, so I will have to breadboard everything to test it out. So far I have one chip working just to test how it works.</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>Brainfuck Microcontroller</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 55%;"><center><b style="text-align: left;">55%</b></center></div></div></td></tr><tr><td colspan="3">Apart from a few counters and status LEDs on a breadboard, I started soldering some boards with double row headers to hold everything.&nbsp;</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>Juggalo Robot</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 70%;"><center><b style="text-align: left;">70%</b></center></div></div></td></tr><tr><td colspan="3">During the summer I didn't make much real progress on this project. I spent most of my time working on projects for Makevention instead.</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>ESP8266</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 50%;"><center><b style="text-align: left;">50%</b></center></div></div></td></tr><tr><td colspan="3">I got an ESP8266 up and running. At first I had problems with the power supply but the chip seems to run alright with those problems solved. It also lists and connects to networks. Next, I need to connect to a server and transfer data, which will be used for a calculator project.</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>Wireless Breadboard</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #cc0000; color: #cccccc; height: 20px; width: 100%;"><center><b style="text-align: left;">Failed</b></center></div></div></td></tr><tr><td colspan="3">This project was a failure. First of all I made a mistake with the spacing of the headers and it wouldn't fit the breadboard I was using. When I was working with it later I broke the entire header in half. The project wouldn't work anyway because the breadboard drops so much voltage. Unless I can find a breadboard that is much better, I don't intend to work on this project.&nbsp;</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>ATF1508 CPLD</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #00aa00; color: #cccccc; height: 20px; width: 100%;"><center><b style="text-align: left;">Done</b></center></div></div></td></tr><tr><td colspan="3">After a lot of trouble and replacing a bricked chip, I eventually found a way to reliably program this chip. I also soldered a board to use for testing. This should be everything I need for the project I will use it in.&nbsp;</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>BASIC Interpreter</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 30%;"><center><b style="text-align: left;">30%</b></center></div></div></td></tr><tr><td colspan="3">I also didn't make any progress on this project either. It would have been used with the Wireless Breadboard project if I had finished it. I will keep it for a later project I might need BASIC for.</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>LCD Programming</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 50%;"><center><b style="text-align: left;">50%</b></center></div></div></td></tr><tr><td colspan="3">I got an LCD working for the 6502 Graphing Calculator project, as well as a VFD (technically not an LCD) for the Improved RPN Calculator. I did not get the LCD on the STM32F429 Discovery board working because I didn't need it for the Improved 6502 Trainer. I also haven't gotten the monochrome 5.5 inch LCD that requires -27v working yet. It will probably be easier to get a color LCD of that size instead.</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>Improved 6502 Trainer</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #00aa00; color: #cccccc; height: 20px; width: 100%;"><center><b style="text-align: left;">Done</b></center></div></div></td></tr><tr><td colspan="3">I finished just about everything I wanted to for this project. It is much faster than the first 6502 Trainer. I will use it to develop for the 6502 Graphing Calculator.</td></tr></tbody></table><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>Improved RPN Calculator</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 95%;"><center><b style="text-align: left;">95%</b></center></div></div></td></tr><tr><td colspan="3">I finished almost everything for this project except a permanent keypad. I also renamed the project "Programmable RPN Calculator." The keystroke programming can repeat keystrokes, but it can't do any testing or branching. I will add those features eventually, but not in this version of the hardware. I shrank the size of numbers from 255 bytes down to 140. This lets me store all the temporary registers used during calculations on the chip, which makes calculations about five times faster. When I make a keypad I will be finished.</td></tr></tbody></table></div></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-85625853626484674162015-12-24T01:13:00.000-05:002015-12-24T01:13:35.298-05:00RPN Scientific Calculator on Hackaday<div dir="ltr" style="text-align: left;" trbidi="on"><a href="http://3.bp.blogspot.com/-OjQbvSelFeI/VnrZbA-qefI/AAAAAAAAF7I/YxVQ_HC30mQ/s1600/hacklet-featured-image1.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="172" src="http://3.bp.blogspot.com/-OjQbvSelFeI/VnrZbA-qefI/AAAAAAAAF7I/YxVQ_HC30mQ/s320/hacklet-featured-image1.png" width="320" /></a>In August my RPN Scientific Calculator was featured on Hackaday in <a href="http://hackaday.com/2015/08/14/hacklet-70-calculator-projects/">Hacklet 70 - Calculator Projects</a>. It was really great to see my project on Hackaday! There was also a small scientific calculator running a 6502 emulator, a <a href="https://hackaday.io/project/4802-kim-uno-a-simple-kim-1-replica">KIM-1 replica</a> with a calculator form factor, and a project called <a href="https://hackaday.io/project/2491-calchack">CalcHack</a>&nbsp;that adds functionality to TI graphing calculators. CalcHack is an awesome idea and one thing it adds is a 2.4GHz radio. One of my ideas for Makevention was adding an ESP8266 to the inside of a TI-86, but this solution is much better! Hackaday also created a page for <a href="https://hackaday.io/list/7200-calculator-projects">calculator projects</a>&nbsp;where I added my RPN Scientific Calculator, Improved RPN Scientific Calculator, and 6502 Graphing Calculator.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-605094802642016732015-12-23T12:15:00.001-05:002015-12-23T23:49:27.952-05:00Progress Update<div dir="ltr" style="text-align: left;" trbidi="on">The past few months I have not had enough time to update this blog because I had so much to do in school this semester. My laptop also stopped working properly and I haven't had time to fix it, so I have not done anything with my projects. The only thing I have done related to programming is a few problems on <a href="https://projecteuler.net/">Project Euler</a>, which I recommend to anyone who enjoys programming. In August, a lot of things happened leading up to Makevention. Now that I have some time during the holidays, I am going to try to catch up on some posts. Hopefully I will have more time this semester to work on projects.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-8986817033099919112015-08-12T00:57:00.002-04:002015-12-23T12:18:08.695-05:00New Project: Logic Tool<div dir="ltr" style="text-align: left;" trbidi="on"><a href="http://3.bp.blogspot.com/-WvZdOTyHGGA/VcrOpItTNXI/AAAAAAAAFsg/CzE6p441_zI/s1600/DSCN3778.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="171" src="http://3.bp.blogspot.com/-WvZdOTyHGGA/VcrOpItTNXI/AAAAAAAAFsg/CzE6p441_zI/s320/DSCN3778.JPG" width="320" /></a>Since my plan to make a wireless breadboard did not work out, I decided to use the MCP23S17 shift registers I bought for it to make something similar. It is similar to a logic analyzer but shows information in real time rather than recording a short period of time at high resolution. It has female headers for 64 pins but so far I have only soldered 32 of them in. As time gets closer to Makevention, I'm trying to save time however I can to get my last few projects working.<br /><br />With 64 pins I will have enough to monitor all of the lines of my 6502 project. Unlike a logic analyzer, I can <br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-2NT0tgLDmk8/VcrPdw6BN2I/AAAAAAAAFso/dthHDRI5OO4/s1600/Untitled.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="181" src="http://2.bp.blogspot.com/-2NT0tgLDmk8/VcrPdw6BN2I/AAAAAAAAFso/dthHDRI5OO4/s320/Untitled.png" width="320" /></a></div>also switch any of the pins to be outputs. Now I am doing this with a simple GUI I made that shows or controls the lines with virtual LEDs. This saves me from hanging loads of LEDs on all the lines of my project. Later I would like to add other forms of input and output that I can drag and drop to the dark gray area in the middle of the form. This could include buttons, sliders or hex readouts like I had for my 6502 Virtual Project. At the moment, only the LEDs work and I am using them to drive the address and data lines of the 6502 socket for my graphing calculator project. This lets me check the control signals of the CPLD fairly quickly.<br /><br />In the end I think this project will work out better than the plan I had for the Wireless Breadboard. When I tried the breadboard I was going to use with another project, it showed a big voltage drop across the rails. I did not know this could happen and it would have been unfortunate to build the whole project and then find out the board was not very good.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com1tag:blogger.com,1999:blog-8905597180918542756.post-56360194954123319282015-08-11T22:21:00.001-04:002015-12-23T12:18:48.064-05:00New Project: 6502 Graphing Calculator<div dir="ltr" style="text-align: left;" trbidi="on">One of the last things I want to make progress on before Makevention in a few weeks is a graphing calculator I have been planning for quite a while. It will use a 65C02 and is the main reason I started on my 6502 Virtual Trainer last year. Most models of Texas Instrument's graphing calculators use a Z80, which was a competitor to the 6502 in the past. Those models have a 6 or 15MHz clock. The Z80 needs roughly three times more cycles than a 6502 to accomplish the same task, so running this calculator at 5MHz should be as fast as one of those calculators at 15MHz. At the maximum speed of 14MHz, it should be nearly three times as fast. Interestingly, Hewlett Packard did produce several non-graphing calculators like the HP-35S, which used a 8502 chip based on the 6502. Later models of TI calculators used the Motorola 68000 and the latest use ARM processors. These will certainly outperform anything I could make with a 6502. My hope is to make something in power between the Z80 and 68000 series with a few added features.<br /><br />So far I have finished most of the decoding logic in the ATF1508 CPLD I have been working on. It has 57<br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-b798ucmLuSE/Vcqsrfqb5BI/AAAAAAAAFsE/NP7jCGIERKM/s1600/DSCN3784.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="207" src="http://4.bp.blogspot.com/-b798ucmLuSE/Vcqsrfqb5BI/AAAAAAAAFsE/NP7jCGIERKM/s320/DSCN3784.JPG" width="320" /></a></div>IO pins and I have managed to use them all without finishing all the functionality I need. My plan is to use a 512kB SRAM chip with the first 2kB of address space always mapped to the first 2kB of the SRAM. The next two 30kB chunks of address space will point to two windows in the SRAM controlled by the CPLD. This will let me copy large chunks of data between two parts of the SRAM without changing the window between copies. Hopefully 30kB is enough for any single program the calculator will need to run. The last 2kB will be the EEPROM. This is hopefully enough space for a small bootloader that will copy firmware from an SD card and into the SRAM banks. The peripherals like the keyboard and LCD are mapped into the last few bytes of the first 2kB of SRAM.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-DkB-NxeMakM/Vcqsz7M0n2I/AAAAAAAAFsM/WwlyEvLqtyM/s1600/DSCN3786.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="240" src="http://1.bp.blogspot.com/-DkB-NxeMakM/Vcqsz7M0n2I/AAAAAAAAFsM/WwlyEvLqtyM/s320/DSCN3786.JPG" width="320" /></a></div>For the LCD I found a fairly cheap 3.2 inch 320x240 color LCD on eBay. It is the perfect size for a calculator like this. It was also easy to get working with an MSP430 and some shift registers. The only downside is that I did not get an SPI version and I do not have enough CPLD pins to drive the 16 bit data port. The good news is that the LCD seems to expect 3v signals, so I will need some shift registers for level shifting anyway, which frees up a lot of pins. I don't think I will be able to finish very much more of this project for Makevention but I would like to get it drawing to the LCD from a program stored on an EEPROM by then. If I do have extra time, I will work on getting it to read a keypad.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-88200222566562100102015-07-12T15:20:00.001-04:002015-12-23T12:20:28.721-05:00New Project: Programmable RPN Calculator<div dir="ltr" style="text-align: left;" trbidi="on">One of the projects I started on for my <a href="http://joldosh.blogspot.com/2015/05/summer-hackathon.html">Summer Hackathon</a> is a new version of my RPN calculator. This version uses an LPC1114 instead of the two MSP430s the last version used. Hopefully this version will be much smaller and faster. Even though I'm not yet at a good stopping place I wanted to make a post about it so that the last post is not overly long.<br /><br /><a href="http://1.bp.blogspot.com/-M1-Ne9MZPuU/VaK9sS8pstI/AAAAAAAAFnk/O2uqB4AP30E/s1600/programming_screen.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-M1-Ne9MZPuU/VaK9sS8pstI/AAAAAAAAFnk/O2uqB4AP30E/s320/programming_screen.jpg" width="320" /></a>Porting the code from the MSP430 was not too difficult. The only real trouble was moving some of the memory registers from the external RAM to the internal RAM of the LPC1114. This really increases calculation speed since it eliminates the bottleneck of accessing external memory. On the MSP430 version I used a preprocessor function to identify and replace any array access to the external RAM with functions calls. This worked well since all of the registers were stored externally but caused a few headaches on the new version since internally stored registers need to be handled differently. One idea I had was to use 32 bit pointers, which wouldn't cause the performance hit they do on a 16-bit system, to somehow encode not only the memory address, but also the memory bank and whether an address is stored externally or internally. It also seems like it would make more sense to allocate memory buffers on a stack as they are needed, rather than hardcoding them in memory. This got me thinking about how other systems handle this problem and I decided to add a way to do that to my 6502 project with a CPLD.<br /><br />Along the way I also noticed a few areas where I could improve my code. For some reason I got in the habit of reusing generic counter variables like x or i in an effort to save memory. This just makes everything harder to read and does not save any memory since GCC optimizes how variables are used anyway. BCD numbers should also be stored with the smallest places first since that way extending the number by a decimal place only involves incrementing the length field rather than moving every byte of the number one space. In retrospect 255 decimal places is probably way too much for such a simple calculator. This didn't make much difference when I had lots of external RAM but is inconvenient now that I am trying to fit as many registers as I can into the LPC1114's memory.<br /><br />To read and write the external RAM I'm using the chip's SPI peripheral. It turned out to be somewhat difficult to configure since several of the steps to get it to work have to be done in a certain order. Debugging this was a lot easier with a logic analyzer. After I had it working and got the memory registers straightened out, I was a little surprised to see that calculating sine was slower than on the MSP430. This was a shock since it was so much faster in my microcontroller comparison. I tried raising the SPI peripheral speed to 24MHz, even though the max speed of the RAM is 20MHz, but it was still slower. My next step is to try and measure the clock speed of the SPI with the logic analyzer to make sure it really is going that fast. After I got sine to work, I uncommented other parts of the program in parts to see how much would fit in the flash. Compiling with GCC's -O3 option for speed optimization quickly overflowed the flash but all of it fit in less than 20kB with -Os. One of my gripes with GCC is that it doesn't tell you by how much the firmware is too large, so you have no clue how much you would need to shave off for it to fit.<br /><br />Initializing and toggling the pins of the LPC1114 is a bit more complicated than on the MSP430 since different pins have different configuration bits and the pins themselves are not mapped into memory in order. I had a look at the HAL library and it seems to use quite a bit of code for what I want to accomplish so I wrote a simple class for handling pins. Luckily I can use C++ since I am just compiling with GCC, unlike with OpenSTM32 where I was stuck with plain C. One neat thing someone showed me was how to use operator overloading so that something like "Pin=1;" does the same as "Pin.high();"<br /><br />Since I have so much space left over in the flash, I started adding a keystroke programming function. This was one of the neat things I have always liked about earlier calculators. I am nearly done with the editor on the screen for it, which I'm working on with the PC version of the program since it is much faster to test. The next time I do a project like this I will put the PC and embedded version in the same file and enable them with include statements instead of copying the changed sections of the PC version. So far I am only adding the ability to repeat keys and not loop or branch since I want to finish this and at least one other project in time for Makevention in August. When I have more time I hope to add that functionality.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-24430630959242048552015-07-06T19:54:00.000-04:002015-07-06T20:00:08.079-04:002015 Hackaday Prize<div dir="ltr" style="text-align: left;" trbidi="on"><a href="http://2.bp.blogspot.com/-z5BQxU8b15w/VZsUCMFOleI/AAAAAAAAFnQ/ec3s-Xlyokk/s1600/2269-00.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="150" src="http://2.bp.blogspot.com/-z5BQxU8b15w/VZsUCMFOleI/AAAAAAAAFnQ/ec3s-Xlyokk/s200/2269-00.jpg" width="200" /></a><a href="http://hackaday.com/">Hackaday</a> recently started a <a href="http://hackaday.com/2015/06/08/a-mountain-of-prizes-for-projects-using-these-parts/">competition</a> for projects that feature parts made by Atmel, Freescale, Microchip, or Texas Instruments. 50 prizes are being awarded for each group, so I entered my RPN Scientific Calculator into the TI competition. The winners were <a href="http://hackaday.com/2015/07/06/50-winners-using-texas-instruments-parts/">announced</a> today and my project was one of the 50. My prize was a&nbsp;<a href="http://store.hackaday.com/products/bluefruit-le-sniffer-bluetooth-low-energy-ble-4-0-nrf51822-v1-0">Bluefruit LE Sniffer</a>, which I was able to order from the Hackaday store for free. I'm not sure what I will use it for yet since I don't have a smart phone. My project page for the calculator is <a href="https://hackaday.io/project/6468-rpn-scientific-calculator">here</a>.<br /><br /></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-37966849530043449372015-06-27T21:00:00.000-04:002015-12-23T12:21:20.287-05:00Improved 6502 Virtual Trainer<div dir="ltr" style="text-align: left;" trbidi="on"><a href="http://2.bp.blogspot.com/-nJmgltC4P8U/VY9GbTNH4WI/AAAAAAAAFl8/mqL1bjK0ysw/s1600/DSCN3763.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="217" src="http://2.bp.blogspot.com/-nJmgltC4P8U/VY9GbTNH4WI/AAAAAAAAFl8/mqL1bjK0ysw/s400/DSCN3763.JPG" width="400" /></a>Over the last few days I have made a lot of progress on this project. The main hurdle was getting a USB Virtual Com Port example running with the toolchain. The code from the first 6502 Virtual Trainer, which used an MSP430, was pretty easy to port to the STM32. After I got single-stepping to work, as I mentioned in my last post, I worked on the mode that stores the entire address space on the chip. It was a little surprising at first that it only ran at about 23,000hz. This is not much faster than the 14,000hz I was running at with the MSP430 version. My initial suspicion was that the transfers between the chip and PC to keep their respective copies of the address space synced were taking too much time. Timing the transfers showed that the chip usually spent over 90% of its time executing code, however. The biggest speed up came by manipulating the GPIO registers directly, rather than relying on the cumbersome HAL functions. Another thing I tried was changing the baud rate, although I couldn't find where it was initialized in the code. Eventually I found out that the Virtual Com Port doesn't rely on any sort of baud rate setting. A few other small improvements got the speed up to 350,000hz or so. When I found out how to turn on GCC optimizations in the System Workbench IDE, the speed got up to over 770,000hz. That's 0.77MHz! It's not quite the 1MHz I had hoped for but it is over 50 times faster than the first version.<br />My original plan was to leave the IDE unchanged so that it would be compatible with both the old <br />MSP430 board and the new STM32 version, but I had to change a few things. For one, I was only transferring two bytes of data to count how many clock cycles had been executed since the last update, so I had to add a third one since the new board runs so much faster. The old version synced with the IDE when at least 64 bytes of data needed to be transferred. This is the most I could store in the MSP430's internal RAM. The new limit is 200, which wastes less time syncing when lots of data is transferred. A few thousand bytes would probably be even better, but the IDE wasn't able to keep up. This could probably be fixed but 200 is fine for now.<br /><a href="http://1.bp.blogspot.com/-1wH_mr1yfaA/VY9Gkk90uTI/AAAAAAAAFmE/w_RgDdz1feA/s1600/VT2_plot.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://1.bp.blogspot.com/-1wH_mr1yfaA/VY9Gkk90uTI/AAAAAAAAFmE/w_RgDdz1feA/s1600/VT2_plot.jpg" /></a>Another thing that changed was losing support for breaking on uninitialized reads. This was a very handy feature on the first version because it could catch many different kinds of errors. That version used a 65C816 in 6502 mode and separating read cycles from internal operation cycles (when the processor is not reading despite the RWB pin being high) was easy monitoring the VPA and VDA pins. There is no easy way to do this on the 65C02 I am using now without storing information on the microcontroller about the status of the bus for every cycle of every opcode in every addressing mode. Hopefully I can live without this feature now that I have a little more experience with 6502 assembly. To test the new version I used the same small RPN graphing calculator program I wrote for the first version. It works great but drawing to the screen, even with the GDI library, is still a bit of a bottleneck.<br />Now that I am finished with this project I can start on programming the calculator I hope to build for the Makevention in August.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-43884211040908783652015-06-25T19:22:00.002-04:002015-12-23T12:21:45.318-05:00Summer Hackathon: Update<div dir="ltr" style="text-align: left;" trbidi="on">During the past few weeks I have had a lot of time to work on the projects I planned for my <a href="http://joldosh.blogspot.com/2015/05/summer-hackathon.html">Summer Hackathon</a>. So far I haven't made as much progress as I hoped, mostly because two of them took a lot more time to get going than I expected. Here is my what I have done so far on the ones I have worked on.<br /><br /><b><span style="font-size: large;">EEPROM Computer</span></b><br />Basing a computer architecture on precomputed lookup tables seemed like a an interesting idea when I started working on an assembler program for a 4-bit EEPROM-based computer. On IRC I explained what I was intending and the creator of the <a href="http://kaput.homeunix.org/CADET/">CADET</a> computer showed me what he had accomplished. It is more or less the same thing I wanted to build, so I decided to stop work on this project for the time being. After discussing the idea with a friend at our hackerspace, I decided that it would only be worth continuing this project if I expanded it to a 16 or 32-bit architecture.<br /><br /><span style="font-size: large;"><b>Brainfuck Microcontroller</b></span><br /><a href="http://1.bp.blogspot.com/-aFHDPPcRLnE/VYyNGKnw2VI/AAAAAAAAFlo/VoueVEDzV9E/s1600/DSCN3744.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="165" src="http://1.bp.blogspot.com/-aFHDPPcRLnE/VYyNGKnw2VI/AAAAAAAAFlo/VoueVEDzV9E/s320/DSCN3744.JPG" width="320" /></a>For this project I have only hooked up four 74ALS193 counters since the last update. These will be the address counters for the program memory. My plan is to build the computer in small parts on a breadboard and transfer them to protoboard when I finish each piece. Rather than lay everything out on a a large board, I started soldering 8x12cm boards that will stack with double row headers. This way I will have plenty of pins to transfer signals between boards. I also plan to put LEDs on the topmost board to show signals like the address, jump buffer, op code, data pointer, and control signals.<br /><br /><span style="font-size: large;"><b>ESP8266</b></span><br />A guy at our hackerspace was having trouble getting his ESP8266 going, so I set mine up to figure <br />out how to do it. Luckily for me, mine worked fairly well on the first try. The 03 variant I bought last year looked especially good since it is a little smaller than the others I looked at, and has several GPIOs, which I will need for one of the projects I have planned. One inconvenient thing is the 2mm pitch of the pins, which is slightly smaller than the 2.54mm, or 0.1'', pitch of a breadboard, but I soldered a small adapter. The firmware behavior is a little different than what some of the tutorials say to expect, but I was able to get a list of wireless networks at my house and connect to the WiFi at our hackerspace.<br /><a href="http://3.bp.blogspot.com/-Zz8OCKYgbgo/VYyLEdUJYKI/AAAAAAAAFlE/dsUVYg7iw8w/s1600/DSCN3752.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-Zz8OCKYgbgo/VYyLEdUJYKI/AAAAAAAAFlE/dsUVYg7iw8w/s1600/DSCN3752.JPG" /></a>The LED of my friend's ESP8266 only lit dimly on my breadboard, as the voltage dropped down as low as 2.3v when run through the 3.3v LM1117 regulator I was running my repurposed 5v supply through. We haven't been able to figure out why this happens yet. For my chip the voltage also sank to about 3v, but it was still enough to keep the chip working. The supply itself seems to be good, as it delivers 5.18v, so I think the problem is with the regulator. When I tested the supply without the regulator on a breadboard with the 74ALS193 counters for the Brainfuck microcontroller, one side of the breadboard was down to 4.8v while the supply was still at 5.18v. Moving the jumper wires on the power rails around brought everything back to 5.18v<br /><br /><span style="font-size: large;"><b>Wireless Breadboard</b></span><br />This project was especially exciting to me because it can be used to debug several of the other projects. To begin with I cut one of my 8x12cm protoboards in half and soldered single-row female headers to them, so a breadboard with male headers soldered on could be plugged into it. Unfortunately, I miscalculated the width of the breadboard and soldered the female headers on too wide apart. My local shop has been out of headers lately, so I tried to desolder the headers and broke a row of them in half in the process. So far I would consider this project a failure.<br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-lhq9hF8yr4Q/VYyLdCinwrI/AAAAAAAAFlM/L6IdN3mN6iw/s1600/DSCN3750.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-lhq9hF8yr4Q/VYyLdCinwrI/AAAAAAAAFlM/L6IdN3mN6iw/s1600/DSCN3750.JPG" /></a></div><br /><span style="font-size: large;"><b>ATF1508 CPLD</b></span><br />This is an essential part of the 6502-based calculator I am hoping to build soon. Unfortunately, it has been my main source of headaches over the past few weeks. First of all, I tried to program the chip with an MSP430 generating JTAG signals from an svf file but this failed. After some searching, I found out that the JTAG standard is not really "standard" at all, and chips from different manufacturers handle the standard differently. Next, I tried generating a pcf file from the svf file, because it contains the actual states of every pin on every clock cycle. Although this worked and I could program the chip, the programming steps were ridiculously complicated. After using Atmel's WinCUPL program (which itself is rather unpleasant to use) to generate a JEDEC file, I convert it to an svf file with the Atmel ISP program. The problem with this is that the program offers a couple of nonsense error messages and just crashes if the FTDI cable I use to communicate with the MSP430 is still plugged in when I start the program or click the button to generate the svf file. Next, I have to switch to a virtual machine to generate the pcf file, since Atmel's SVF2PCF utility is 16-bit only.<br /><a href="http://2.bp.blogspot.com/-ZIurog2Erzg/VYyL7dyj47I/AAAAAAAAFlY/5wIR_SEK6AM/s1600/DSCN3761.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="192" src="http://2.bp.blogspot.com/-ZIurog2Erzg/VYyL7dyj47I/AAAAAAAAFlY/5wIR_SEK6AM/s320/DSCN3761.JPG" width="320" /></a>After generating this, I have to replug my FTDI cable into USB and start a program I wrote myself to stream the PCF bytes to the MSP430. In an effort to streamline the process, I tried using Altera's SVF2PCF utility to generate the pcf file, since it is 32-bit, but unbelievably it leaves out all delay statements necessary for programming. When I tried transferring this file, the CPLD stopped responding and is now essentially bricked. For some incomprehensible reason the pins necessary for programming can be reassigned to other purposes, rendering the chip unprogrammable. At $14 apiece, this was an expensive error to make.<br />When my troubles with this chip started, I ordered a Byteblaster JTAG programmer, as the Atmel datasheets list this as a possibility for programming the chip. When it arrived, I quickly found out that the USB Byteblaster I had ordered has nothing at all to do with the Byteblaster cable that Atmel ISP can use. The open source driver I tried for the programmer caused my Windows 7 computer to crash with the blue sreen. Next, I ordered a USB to parallel converter cable, since the schematic for the Byteblaster is just a 74HC244 chip connected to the parallel port. So far I have not tried programming with this chip and may go back to programming with the pcf files generated by Atmel's 16-bit SVF2PCF utility.<br /><br /><span style="font-size: large;"><b>Improved 6502 Virtual Trainer</b></span><br />In my post about <a href="http://joldosh.blogspot.com/2015/05/gcc-for-stm32f429.html">GCC for the STM32F429</a>&nbsp;I explained how difficult it had been to get a GCC toolchain running. While I did get the toolchain to work in the end, I was unable to make any of the USB-to-serial examples work. This is very attractive for this project because I could use the chip as a Virtual Com Port and wouldn't need an FT232 chip or USB-to-serial cable. Many examples used the <a href="http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF259242?icmp=stm32cubemx_pron_pr-stm32cubef2_apr2014&amp;sc=stm32cube-pr2">STM32CubeMx</a>&nbsp;program from ST to generate the base code. None of the generated projects, however, can be opened with Eclipse, This is especially disappointing considering that the page for the utility lists GCC as a supported toolchain (although it is not actually in the list of toolchains in the project generator!) and provides an Eclipse plugin form of the utility. As I stated before, developing for STM32 with free tools has been a real pain! I tried the <a href="http://www.openstm32.org/HomePage">OpenSTM32</a>&nbsp;IDE, which is based on Eclipse and the libopencm3 library. This was able to compile a USB project generated by STM32CubeMx, but not without a good bit of fiddling with the files generated.<br /><a href="http://3.bp.blogspot.com/-EARFW6-xsRI/VYyMkJ4QOrI/AAAAAAAAFlg/MeL-ilmf4po/s1600/DSCN3748.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="173" src="http://3.bp.blogspot.com/-EARFW6-xsRI/VYyMkJ4QOrI/AAAAAAAAFlg/MeL-ilmf4po/s320/DSCN3748.JPG" width="320" /></a>Next I soldered a small board for the 6502 that fits on the STM32 board. The pins of each port are not grouped together on the chip or on the headers on the board, but 8 of the 16 pins of port A are grouped together so I connected the 6502 data bus to them. Pins PA1 and PA2 only rose to 0.6v when driven high, which seems to be due to them being connected to some of the peripherals on the board. I connected PB1 and PB2 in those pins' place, so reading or writing the data bus means combining data from two different ports, but it does work. So far I have the chip working in single-cycle mode with the same software I made for the first trainer. My plan is to leave this software unchanged so it will work with either board.<br /><br /><span style="font-size: large;"><b>Makevention</b></span><br />Our hackerspace is sponsoring a convention for makers in August and I would like to show some of my calculator projects there, so for the next two months I plan to focus mostly on the Improved 6502 Trainer and ATF1508 CPLD. These will both be necessary for the next calculator I want to build.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-89814857434014733902015-05-13T01:10:00.000-04:002015-12-23T14:55:08.897-05:00Summer Hackathon<div dir="ltr" style="text-align: left;" trbidi="on">Over the past year, I have not had as much time as I would have liked to devote to my electronics projects because I have been so busy with school. Hopefully I will be able to catch up this summer. My goal is to finish some projects I have already started on and start on some others I have been planning for a long time.<br /><br />Here is a list of what I will be working on. Even though I probably won't have time to finish them all, these are my goals for the summer.<br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><b><span style="font-size: large;">EEPROM Computer</span></b></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 40%;"><center><b style="text-align: left;">40%</b></center></div></div></td></tr><tr><td colspan="3">As part of another project, I got interested in using an EEPROM lookup table to do four bit additions and ended up with this <a href="http://joldosh.blogspot.com/2015/03/4x4-full-adder-eeprom-lookup-table.html">test setup</a>. A 32 KB EEPROM can hold 64 tables, which is enough to implement all the op codes for a full CPU. Hopefully this will greatly reduce the amount of logic involved. All that should be needed are some counters, buffers, and a multiplexer.<br />So far I have finished most of a simulation in <a href="http://sol.gfxile.net/atanua/">Atanua</a>&nbsp;and started on a symbolic assembler. After I finish the assembler and have the simulation running, I will move everything to perfboard and program the op codes and source code into real EEPROMs.</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><b><span style="font-size: large;">8-bit Homebrew Computer</span></b></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><center><b style="color: #074df0; text-align: left;">0%</b></center><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 0%;"></div></div></td></tr><tr><td colspan="3">This project is something I have been thinking about for a long time. I won't say exactly how I plan to do it yet but looking on the internet I haven't found anything similar. It won't be possible to simulate this project in Atanua, so I plan to build it directly on a breadboard. The same assembler from the EEPROM Computer should be able to be changed to work for this also. I'm not sure yet whether it will be worth it to make a PC simulator for this project.</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>Brainfuck Micrcontroller</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 50%;"><center><b style="text-align: left;">50%</b></center></div></div></td></tr><tr><td colspan="3">After I finished the <a href="http://joldosh.blogspot.com/2015/01/brainfuck-microcontroller.html">simulation</a> for this project, I did not do much more work on it. The simulated version is four bits and will have to be expanded to eight in the final hardware. The software for the project is very simple, as all it does is convert Brainfuck commands into simple op codes.&nbsp;</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>Juggalo Robot</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 70%;"><center><b style="text-align: left;">70%</b></center></div></div></td></tr><tr><td colspan="3">My brother and I started work on converting a remote control car into a robot. It will have a baby doll on top with moving arms and a rotating head. He decided to paint the doll's face and make the robot juggalo themed. He got motor drivers working with an Arduino for servos in the arms and a stepper for the head. My work so far has been to reroute motor control signals on the car from the motors to a microcontroller. That way another microcontroller in the remote control can send motor control signals over the radio, which the microcontroller in the car will intercept and interpret. Then it can activate the motors, servos, or stepper according to the signal sent by the remote. The hardware is mostly finished. All that's left is the software, which should be pretty simple.&nbsp;</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>ESP8266</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><center><b style="color: #074df0; text-align: left;">0%</b></center><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 0%;"></div></div></td></tr><tr><td colspan="3">Last year we had a fun night doing projects with some <a href="https://www.spark.io/">SparkCores</a>&nbsp;at our hackerspace and I decided to get a hold of an ESP8266. At $4 it was much cheaper than a SparkCore, even if it is not as easy to program. Unfortunately, I have not had time to even hook it up and try anything with it. One of my plans is to install it in a calculator for an idea I have been thinking about for a long time. One of the challenges will be getting it to connect correctly to WiFi at my university or local cafes. Another idea is to use it to program MSP430s or EEPROMs from my Chromebook, since it can't program them directly over USB.</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>Wireless Breadboard</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><center><b style="color: #074df0; text-align: left;">0%</b></center><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 0%;"></div></div></td></tr><tr><td colspan="3">This is a project I put a lot of thought into before I found out that it has already been done. My plan is to use IO expanders to control every row of a breadboard with a microcontroller. For rows that should be connected wirelessly, the microcontroller will read and relay signals to the appropriate row. This will be comparatively slow because the microcontroller will be bitbanging both the input and output of the IO expanders. Another project I saw used an FPGA, which would be much faster, but using IO expanders will hopefully be an acceptable solution, even if it is much slower.<br />All the connections between rows will be set on the PC, which is hopefully more convenient than plugging in wires. The main advantage will be monitoring the rows and displaying data in an easy to read way on the PC. This should really speed up debugging. Also, output signals can be controlled from the PC, so programming EEPROMs or other chips should be easy.</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><b><span style="font-size: large;">ATF1508 CPLD</span></b></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 15%;"><center><b style="text-align: left;">5%</b></center></div></div></td></tr><tr><td colspan="3">For my next 6502 project I want to use a CPLD for the address decoding. The ATF1508 is one of the few ones left in production that runs at 5 volts. It can be programmed over JTAG, so I started soldering a programmer that will use an MPS430. The chip comes in PLCC. so soldering the adapter will be a little inconvenient. My plan is to add LEDs and dip switches so I can test my designs after programming.</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><b><span style="font-size: large;">BASIC Interpreter</span></b></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 30%;"><center><b style="text-align: left;">30%</b></center></div></div></td></tr><tr><td colspan="3">A couple of projects I would like to do eventually will need to run a BASIC interpreter. One of them is the wireless breadboard mentioned above. It would be better for new functionality, like device programming, to be done with some kind of script. That way, new scripts can be transfered to the chip at run time, instead of having to reflash the chip every time.</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><span style="font-size: large;"><b>LCD Programming</b></span></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><center><b style="color: #074df0; text-align: left;">0%</b></center><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 0%;"></div></div></td></tr><tr><td colspan="3">Some of the upcoming projects will need an output of some kind. A four inch LCD should work well for the ones that a 20x4 character LCD isn't enough for. Hopefully I can get one kind of LCD going that will work for several of the projects. Another option is a 5.5 inch LCD I got a few years ago. It is much larger but requires -27 volts for contrast. This is not easy to generate, but if I can get it going, I will hopefully be able to buy several more pretty cheaply. It would work well with homebrew projects if I can get it working without a microcontroller. The STM32F429 board I have been working with also has an LCD that I would like to get going.</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><b><span style="font-size: large;">Improved 6502 Trainer</span></b></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 20%;"><center><b style="text-align: left;">20%</b></center></div></div></td></tr><tr><td colspan="3">The <a href="http://joldosh.blogspot.com/2014/05/new-project-6502-virtual-trainer.html">6502 Virtual Trainer</a>&nbsp;was nearly finished when I stopped working on it months ago. It works really well, except that the max speed is just under 0.02 MHz. Now that I have my STM32 board running, I hope to port the code for the project from the MSP430. It ran the BCD multiply routine from the <a href="http://joldosh.blogspot.com/2014/03/microcontroller-showdown-conclusion.html">microcontroller comparison</a>&nbsp;about 15 times faster, although that's probably not a good indicator of how much faster it would be for this project. There are a few changes to how UART works that might speed things up also. Another speedup will come from driving the GPIOs directly, instead of through IO expanders. Hopefully all of this together will give me the 50x speedup I need to hit 1MHz. At first I intend to make a board that will plug into the STM32 board directly and possibly use a UART cable for communication. When I figure out how to design PCBs I will make a standalone board with an STM32F429 and an FT232.</td></tr></tbody></table><br /><br /><table border="0"><tbody><tr><td style="width: 45%;"><b><span style="font-size: large;">Improved RPN Calculator</span></b></td><td style="width: 10%;"><div style="text-align: right;">Progress:</div></td><td><div 20px="" class="goal" style="background: #4FABFF; border: solid; height: 20px; width: 180px;"><div class="progress" style="background: #074DF0; color: #cccccc; height: 20px; width: 40%;"><center><b style="text-align: left;">40%</b></center></div></div></td></tr><tr><td colspan="3">For one of my friends I would like to remake my original RPN Scientific Calculator. This time I will use an LPC1114, which will allow me to copy numbers to the chip's memory before calculating. This should greatly increase calculation time because the external memory won't have to be accessed during any calculations. This will also make the firmware smaller. It should easily fit into the 32 KB the chip has, so two microcontrollers won't be necessary. Also, I would like to use a 23LC1024 SPI SRAM this time instead of parallel RAM. Altogether, the circuit should be very small.</td></tr></tbody></table></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-64883428599636960092015-05-12T13:24:00.000-04:002015-05-12T13:27:10.991-04:00GCC for STM32F429<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-zXwti2TAg0g/VVIhIPHZWvI/AAAAAAAAE84/EHQPqAhtMcU/s1600/stm32f429i-disco.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="215" src="http://4.bp.blogspot.com/-zXwti2TAg0g/VVIhIPHZWvI/AAAAAAAAE84/EHQPqAhtMcU/s400/stm32f429i-disco.jpg" width="400" /></a></div><br />About a year ago I bought a <a href="http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF259090">Discover kit</a> from ST. This one has an STM32F429, which is an ARM M4 running at 168MHz with 256 KB of RAM and 2MB of Flash. This seemed like the beefiest microcontroller I would need for a long time. It also has a 2.4" LCD and an external 64 Mbit SDRAM. At only $24 it seemed like a really good deal.<br /><br />Last year when I had some free time, I tried to get a blinky program running for the board without much luck. The example I found had a makefile but I could not get make to work with it. For one, it could not find the rm utility to delete files. Since then I have found out that utilities like these can be installed on Windows also.<br /><br />Next, I tried getting GCC working with Eclipse. For all other microcontrollers I use Code::Blocks, but the tutorials I found used Eclipse. <a href="http://thehackerworkshop.com/?p=1056">One tutorial</a>&nbsp;had no less than 25 steps to get it working, which is absolutely ridiculous if all you want to do is blink an LED.&nbsp;Good for the author of the blog for being so extensive but I wish ST offered an easy way to get GCC working just to get started. Another option many websites pointed to was Sourcery CodeBench. There is a free version for five different processors but the ARM version is no longer free. Next, I tried OpenSTM32. This is the Eclipse IDE prepackaged with GCC and everything needed to compile. It installed fine but when I tried to update it, the installation failed. Using the old version, I tried to generate a new project using the Standard Peripheral firmware, which for some reason is not included in OpenSTM32. The download for that also failed. Next up was Keil. It seems to work well but I do not like being limited to only 32 KB of firmware. <a href="http://www.keil.com/appnotes/docs/apnt_230.asp">App note 230</a>&nbsp;from Keil shows how to get it working with the STM32F4 Discovery board, which is similar to the board I have. The app note shows how to use the Pack Installer in version 5.10 of the MDK software to download a blinky program or another blinky program based on an RTOS with threads. Unfortunately, the blinky program the entire app note is based on is completely missing from the packages in version 5.14 of MDK. There doesn't seem to be any way to install a simple example without the added complications of an RTOS, which is certainly overkill for blinking LEDs.<br /><br />What I settled on in the end was a set of <a href="http://sourceforge.net/projects/gnuarmeclipse/?source=typ_redirect">GNU ARM Eclipse Plug-ins</a>. There is only one thing to install in Eclipse and the plug-ins generate everything from a wizard. The included blinky program is set to work with the STM32F4 Discovery board, but it compiled and ran fine after I changed the LED pin defines. To upload I used ST-LINK, which is also quirky in that it does not actually use the file you select in the Program window. Instead it uses the last file that was "loaded," so if you select a file then recompile, it will not actually use the new version. This is annoying and took a while to figure out. After I was sure I had things working right, I set Eclipse to upload with ST-LINK automatically after each compile.<br /><br />To test the new setup, I ran the BCD multiply test from the <a href="http://joldosh.blogspot.com/2014/03/microcontroller-showdown-conclusion.html">microcontroller comparison</a>. Since I'm on vacation and don't have all my other stuff, I timed it with a stopwatch and got about 24 seconds. This is five times faster than the LPC1114, which is pretty good. Next, I would like to design an improved version of the <a href="http://joldosh.blogspot.com/2014/05/new-project-6502-virtual-trainer.html">6502 Virtual Trainer</a> with this chip.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-24258570953585703872015-05-04T20:44:00.000-04:002015-05-04T20:44:06.284-04:004x4 Full-Adder EEPROM Lookup Table<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/--zM5nZ8QJUk/VUgRleNM0QI/AAAAAAAAE74/fClQcMsbeCA/s1600/DSCN3735.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="352" src="http://1.bp.blogspot.com/--zM5nZ8QJUk/VUgRleNM0QI/AAAAAAAAE74/fClQcMsbeCA/s640/DSCN3735.JPG" width="640" /></a></div><br />My first use for the <a href="http://joldosh.blogspot.com/2015/02/eeprom-programmer.html">EEPROM programmer</a>&nbsp;I have been working on is a lookup table. This will be for another project I have not started on yet. Before I plan much more for that, I wanted to make sure my idea would work. This project will need to add and subtract 8 bit numbers and a lookup table is one way to do that. The 8k EEPROMs I'm using have 13 address lines which allow four pairs of bits to be added with a carry bit. When I first started I fed the carry output of each pair into the carry input of the next pair. This wasted outputs and inputs. It probably would have taken a long time for the carries to propagate also. Now, it only needs nine inputs and the remaining four could be used to select functions other than adding. The data in the EEPROM was simple to generate with a small script that calculates all possible input combinations.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-71274775814390770422015-03-01T01:54:00.000-05:002015-03-01T01:55:32.414-05:00RPN Scientific Calculator: Keypad<div dir="ltr" style="text-align: left;" trbidi="on"><a href="http://2.bp.blogspot.com/-2t_KW1IzdsQ/VPK3Wl7tY3I/AAAAAAAAE2Y/ti9y00CDdlY/s1600/calculator_keypad.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://2.bp.blogspot.com/-2t_KW1IzdsQ/VPK3Wl7tY3I/AAAAAAAAE2Y/ti9y00CDdlY/s1600/calculator_keypad.png" height="400" width="315" /></a>The last part of my RPN Scientific Calculator is the keypad. Before, I had considered trying to make individual key labels somehow. If I could print them on something like the material credit cards are made out of, I could cut them up and glue them to the keys. In the end, gluing on 42 labels without getting glue inside any of the buttons sounded daunting. Instead, I was able to make one out of stamp rubber on the laser cutter at our hackerspace. It turned out really well and I was able to paint the buttons different colors. At this point, there is nothing left to add, so I consider the project totally finished.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-32167093879968539662015-02-21T16:42:00.000-05:002015-03-21T01:45:23.483-04:00EEPROM Programmer<div dir="ltr" style="text-align: left;" trbidi="on">For a couple of projects I want to work on in the next few months I will need to use EEPROMs. Another member at our hackerspace I have been working with on the BrainFuck microcontroller gave me a few EEPROMs and UV-erasable EPROMs. Like I posted before, I was able to program some of the EEPROMs with an MSP430 on a breadboard and now I have it soldered onto protoboard.<br /><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-6rYtbusC5Wo/VOjw-p_A1GI/AAAAAAAAE1o/rKLMiak32zA/s1600/EEPROM_board.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-6rYtbusC5Wo/VOjw-p_A1GI/AAAAAAAAE1o/rKLMiak32zA/s1600/EEPROM_board.jpg" height="404" width="640" /></a></div><div><br /></div><div><div class="separator" style="clear: both; text-align: center;"></div><div style="text-align: left;">The UART is handled by an FT232R chip that I deadbugged. It gave me a lot of problems when I first soldered 24 gauge Ethernet wire to the pins. At first I tried to tin the pins and this led to several shorts. Because the chip was superglued to the board, there was no way to get at them to fix it. Pure acetone paint remover did not take the superglue off and neither did soaking the board in fingernail polish remover for several hours. The glue got gummy but would not come off, so I left the chip where it was and soldered female headers next to it. Then I soldered another FT232R onto a small piece of protoboard with male headers so I could plug it in to replace the other chip. You can see it on the left side of the picture with the red wirewrap wire. The old chip is partly visible just underneath. The first time I tried I accidentally shorted some of the pins together when I was soldering them, so I bent them vertically to make it easier to get at them. When I bent one down to make more room, it broke off. Unfortunately this was the Vcc pin which I couldn't do without so I had to start over with a third chip. Once I got everything soldered, it worked fine.</div><div style="text-align: left;"><br /></div><div style="text-align: left;">The local electronics store did not have any USB B connectors so I had to use a dual USB A connector. The MSP430 is running off the 3.3v provided by the FT232R, so I was afraid of programming it at 3.6v with a LaunchPad since 0.3v above Vcc is the absolute maximum rating in the datasheet. That's why I have the two programming lines running through diodes on the little protoboard above the MSP430. The third "bandaid" piece of protoboard holds two transistors for level shifting. Controlling the EEPROM WE and OE lines with the MSP430 worked fine but it turns out that TTL chips can source voltage from their inputs which would damage the MSP430. The EEPROMs I have now are not TTL but I might run across one at the hackerspace and I wanted to be safe. The ZIF socket on there also came from a hackerspace member who had found some and didn't mind sharing.</div><div style="text-align: left;"><br /></div><div style="text-align: left;">The shift registers that control the data and address lines are running at 5v. The data line going to the microcontroller from the 74HC165 shift register is switched by a PN2222A. This limits SPI speed to about 400k/s. When I find a faster transistor, I should be able to read and write much quicker. The software interface is just over a plain serial terminal. In retrospect, it would have been easier to design a custom program on the PC side but it's convenient that it can work with any operating system without special software. To transfer I use XMODEM which caused some headaches at the beginning. It turns out that <a href="http://ttssh2.sourceforge.jp/index.html.en">TeraTerm</a>&nbsp;transfers the first packet twice without being asked, which caused an overflow of my UART buffer and was hard to track down since that's not expected behavior for XMODEM. It burns about 100 bytes per second but with a faster transistor I hope to write fast enough to do page writes, which will speed things up a lot.</div><div style="text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-SNqRLzwce7c/VOj7Yd6OfuI/AAAAAAAAE10/opgXs1y_OGE/s1600/EEPROM_Blog.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-SNqRLzwce7c/VOj7Yd6OfuI/AAAAAAAAE10/opgXs1y_OGE/s1600/EEPROM_Blog.png" height="364" width="640" /></a></div><div style="text-align: left;"><br /></div></div></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-71753672014068697222015-01-18T03:30:00.001-05:002015-01-18T03:44:20.066-05:00Space Sombrero<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-Am-hvWxe9tc/VLtmPT6QZbI/AAAAAAAAEws/Re-WhEOkwS4/s1600/DSCN3710.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://1.bp.blogspot.com/-Am-hvWxe9tc/VLtmPT6QZbI/AAAAAAAAEws/Re-WhEOkwS4/s1600/DSCN3710.JPG" height="300" width="400" /></a></div>For Halloween I decided to put some LEDs controlled by an MSP430 on a sombrero. Unfortunately, I did not finish in time to take it to the Halloween party at our hackerspace but I did finish working on it the last week.<br /><br />The LEDs are soldered in three 4x4 matrixes, one matrix for each color. My plan was to combine red, green, and blue into one point diffused with ping pong balls. In the end I skipped the diffusers. The LEDs are bright enough on their own. They are taken from a string of Christmas tree lights so the total of 48 LEDs cost about a dollar. Something like <a href="http://www.adafruit.com/category/168">NeoPixels </a>(WS2812)&nbsp;would have been better for this project but would have been much more expensive.<br /><br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-tcvx_YucrVc/VLtpJXexrAI/AAAAAAAAEw4/zDAofkbVlLY/s1600/DSCN3713.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-tcvx_YucrVc/VLtpJXexrAI/AAAAAAAAEw4/zDAofkbVlLY/s1600/DSCN3713.JPG" height="300" width="400" /></a></div>Each color is run by its own 74HC595 shift register, so only one LED per color can be on at a time. This reduces apparent brightness when several LEDs are driven by PWM but is still brighter than using only one matrix for all the LEDs. With a 1k resistor they are very bright, which I noticed when experimenting with them before. Everything is controlled by a small PCB. Each matrix is connected to a Cat5 ethernet cable which has four twisted pairs, exactly enough to multiplex 16 LEDs. The two knobs control speed and color of the patterns and a button switches between patterns. Altogether the hardware is really simple, though there were some headaches soldering the board. The legs of the potentiometers are very weak so I soldered header pins to the back of them for stability. They are really sturdy now but Vcc was shorting through the body of the potentiometers. Once I fixed that, there still showed only about 4k resistance between ground and Vcc. A tiny fleck of solder on the metal body of the power switch was also causing a short. After fixing that there was still a 33k resistance between ground and Vcc. Desocketing and unsoldering narrowed it down to the L4931 voltage regulator. Several other L4931s I measured had the same resistance. After putting everything back together, it worked fine.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-fScfB-0r5mE/VLtr8bVMyYI/AAAAAAAAExE/aM9Q_F3TUUE/s1600/pot_points_edited.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://1.bp.blogspot.com/-fScfB-0r5mE/VLtr8bVMyYI/AAAAAAAAExE/aM9Q_F3TUUE/s1600/pot_points_edited.png" height="261" width="400" /></a></div>The potentiometers and knobs for them came from my local electronics store. They are logarithmic, although linear would work much better for communicating speed to the microcontroller. Converting the curve mathematically seemed pretty tricky, so I used a look up table of a few measured values instead. After soldering the potentiometers onto the board, I realized that the seven values I measured were not enough, so I plotted them on a graph and extrapolated more points. The values I came up with work pretty well, though when changing colors the distances between points don't feel exactly even. The next time I use potentiometers like this I will try to do a lot more exact measuring before soldering them so the points will be more even.<br /><br />Here is a short video of a few patterns I programmed in. You can see how the speed and color knobs work. There is a lot of room left in the flash for more patterns but this is enough to consider the project finished.<br /><br /><div class="separator" style="clear: both; text-align: center;"></div><center><iframe allowFullScreen='true' webkitallowfullscreen='true' mozallowfullscreen='true' width='480' height='399' src='https://www.blogger.com/video.g?token=AD6v5dwSCLo_s8DIKmtg25iH25YO-fgtcmzgsxAPOeRpXXTHQucCwn91JlUFz1xQw1lK-0ci3B_SRtfgG_lgbyikFA' class='b-hbp-video b-uploaded' FRAMEBORDER='0' /></center><br /></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-42261728199786359522015-01-06T03:55:00.000-05:002015-06-25T18:51:02.611-04:00Brainfuck Microcontroller<div dir="ltr" style="text-align: left;" trbidi="on">For a year or two I have been thinking about making a brainfuck computer out of 7400 series logic. Homebrew computers made out of logic chips are fairly common so my idea was to implement it as a microcontroller, with an input and output port instead of a screen or keyboard. This way I could drive LEDs, displays, shift registers, or anything else a microcontroller can. Before I made any progress on my idea, I stumbled on a neat project that is similar, <a href="http://grapsus.net/74/">The BrainFuck Machine</a>.&nbsp;It uses a UART chip for input and output. Running an HD44780 or LED matrix with my project using brainfuck code should be an extra challenge.<br /><br />Not long ago another member at the hackerspace I go to was talking about 7400 series logic projects and spontaneously asked me if I had ever thought about making a brainfuck computer. We had come up with the same idea independently and decided to work together. He already had quite a lot of chips including RAM and UV-erasable EPROMs to work with. His UV lamp didn't work any more so I got a replacement bulb for just a few dollars from <a href="http://www.bulbtown.com/">Bulb Town</a>. That didn't work either so I had a look inside the lamp. The ballast appeared to be sealed with some kind of gasket to the body and there doesn't seem to be any way to get inside it without breaking that. A few other chips were plain old EEPROMs that work at 5v. With some shift registers and a transistor for level shifting, it was pretty easy to program and read them with an MSP430 on a breadboard. When I finish transferring that to perfboard, I will make a post on it.<br /><br />My partner and I drew up a schematic that looked reasonable and he started on a wire-wrapped board for everything. Personally, I prefer to solder boards but it will be a good chance to see how wire-wrapping works. He also knows how to make printed circuit boards with the materials at the hackerspace. Over the winter break I haven't been at home with any hardware, so I started working on a simulated version of the project with the program <a href="http://sol.gfxile.net/atanua/">Atanua</a>. It is a 7400 chip simulator that was recently&nbsp;<a href="http://hackaday.com/2014/12/13/logic-simulator-atanua-goes-free-possibly-open-source/">released for free</a>. A year or so ago I was really interested in using it but gave up after all of the annoying pop-ups asking to pay. In principle I would not mind paying $5-10 for something like that if it had more features that in other programs are standard:<br /><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"><tbody><tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-o02Oh10Yh-g/VKuTza9tpfI/AAAAAAAAEv4/jcws62InHgA/s1600/BF%2BMCU%2Bcombined.png" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-o02Oh10Yh-g/VKuTza9tpfI/AAAAAAAAEv4/jcws62InHgA/s1600/BF%2BMCU%2Bcombined.png" height="366" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>Click to enlarge</i></td></tr></tbody></table><ul style="text-align: left;"><li>Cut, copy, and paste</li><li>Selection tool</li><li>Properties window for objects</li><li>Rotate for objects</li><li>Connection points for wires</li><li>Buttons with no letters</li><li>More 7400 chips</li><li>SRAM chips</li><li>Detailed screenshots</li></ul><div>Despite the above annoyances, the simulation turned out alright in the end. To make things a little easier, I only implemented an 8 bit address space. The only RAM chip that can be simulated is a 74LS89, so the data stack is only 4 bits wide and 16 elements deep. At first I connected all the control signals for the chips to buttons so they could be manually operated. After I got that working, I started using EEPROM data to control the signals. The first version pushed the address of every [ onto a stack and jumped back to that at the corresponding ] if the current data wasn't 0. This only used a few chips and worked well but test code failed. It took me a while to realize that a loop like this that always executes at least once is equivalent to a <i>do...while</i> loop, not the plain <i>while</i> loop it is supposed to work like. The next version used a jump instruction that stores the jump address as the byte after the instruction. Getting the signal sequence right so that the jump address is not treated as an op code but is loaded into a buffer then transferred to the address buffer on the right cycle according to the data stack value was pretty tricky. Sometimes backwards jumps loaded half a cycle early, so I inserted a NOP after every forward jump. This wastes space and cycles but is acceptable for this small conceptual test. The jump sequencer could also take less cycles and some of the glue logic could be reduced, which I plan to do when we start on the full version.</div><div><br /></div><div>In addition to the eight standard commands, it also supports # which many implementations use as a debug command to halt execution. The clock is run through a counter and XORed to produce two alternating clock signals. New EEPROM data appears on even cycles and is latched in as control signals on odd cycles so that the EEPROM output has time to settle before being latched. This probably doesn't matter in the simulation but seems like a necessary step on real hardware. Otherwise, I'm not sure how data appears on the bus and is latched in the same cycle. The control signals themselves use all 8 of the bits for convenience's sake, although they could be condensed. The data readout uses 74LS47 BCD converter chips connected to every three bits which gives an octal display.</div><div><br /></div><div><a href="http://1.bp.blogspot.com/-fk2Ir3YdSqA/VKuYlsXlTBI/AAAAAAAAEwE/OmbMwI5Zp8o/s1600/leds1.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://1.bp.blogspot.com/-fk2Ir3YdSqA/VKuYlsXlTBI/AAAAAAAAEwE/OmbMwI5Zp8o/s1600/leds1.gif" /></a>To test the setup I wrote this short program which clears the first 6 bytes of the stack then sets the first four to 1, 2, 4, and 8 using multiplication. Then it outputs each byte in turn to the output buffer for a Larson scanner effect. The program comes to 249 bytes when run through the very simple assembler program I wrote, which is just shy of the 256 bytes available with an 8 bit address space.<br /><br /><table bgcolor="#D0D0D0" border="0" frame="box" style="width: 500px;"><tbody><tr><td px="" valign="top" width="120px"><span style="font-family: Courier New, Courier, monospace;"><b><span style="color: #990000;">[</span><span style="color: #38761d;">-</span><span style="color: #990000;">]</span><span style="color: #073763;">&gt;</span></b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b><span style="color: #990000;">[</span><span style="color: #38761d;">-</span><span style="color: #990000;">]</span><span style="color: #073763;">&gt;</span></b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b><span style="color: #990000;">[</span><span style="color: #38761d;">-</span><span style="color: #990000;">]</span><span style="color: #073763;">&gt;</span></b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b><span style="color: #990000;">[</span><span style="color: #38761d;">-</span><span style="color: #990000;">]</span><span style="color: #073763;">&gt;</span></b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b><span style="color: #990000;">[</span><span style="color: #38761d;">-</span><span style="color: #990000;">]</span><span style="color: #073763;">&gt;</span></b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b><span style="color: #990000;">[</span><span style="color: #38761d;">-</span><span style="color: #990000;">]</span></b></span><br /><span style="color: #073763; font-family: Courier New, Courier, monospace;"><b>&lt;&lt;&lt;&lt;&lt;</b></span><br /><b><span style="color: #38761d; font-family: Courier New, Courier, monospace;">+</span></b><br /><b><span style="color: #990000; font-family: Courier New, Courier, monospace;">[</span></b><br /><span style="color: #990000; font-family: Courier New, Courier, monospace;"><b>&nbsp; &nbsp;[</b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b>&nbsp; &nbsp; &nbsp; <span style="color: #073763;">&gt;</span><span style="color: #38761d;">++</span></b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b>&nbsp; &nbsp; &nbsp; <span style="color: #073763;">&gt;</span><span style="color: #38761d;">+</span></b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b>&nbsp; &nbsp; &nbsp; <span style="color: #073763;">&lt;&lt;</span><span style="color: #38761d;">-</span></b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b>&nbsp; &nbsp;<span style="color: #990000;">]</span></b></span><br /><b><span style="font-family: Courier New, Courier, monospace;">&nbsp; &nbsp;<span style="color: #073763;">&gt;&gt;</span></span></b><br /><b><span style="background-color: transparent; font-family: 'Courier New', Courier, monospace;">&nbsp; &nbsp;<span style="color: #990000;">[</span><span style="color: #073763;">&lt;&lt;</span><span style="color: #38761d;">+</span><span style="color: #073763;">&gt;&gt;</span><span style="color: #38761d;">-</span><span style="color: #990000;">]</span></span></b><br /><b><span style="font-family: Courier New, Courier, monospace;">&nbsp; &nbsp;<span style="color: #073763;">&lt;</span></span></b><br /><span style="color: #990000; font-family: Courier New, Courier, monospace;"><b>]</b></span><br /><b><span style="color: #073763; font-family: Courier New, Courier, monospace;">&lt;</span></b><br /><b><span style="color: #990000; font-family: Courier New, Courier, monospace;">[</span></b><br /><span style="font-family: Courier New, Courier, monospace;"><b>&nbsp; &nbsp;<span style="color: #7f6000;">.</span><span style="color: #073763;">&lt;</span><span style="color: #7f6000;">.</span><span style="color: #073763;">&lt;</span><span style="color: #7f6000;">.</span><span style="color: #073763;">&lt;</span></b></span><br /><span style="font-family: Courier New, Courier, monospace;"><b><span style="color: #073763;">&nbsp; &nbsp;.&gt;</span><span style="color: #7f6000;">.</span><span style="color: #073763;">&gt;</span><span style="color: #7f6000;">.</span><span style="color: #073763;">&gt;</span></b></span><br /><span style="color: #990000; font-family: Courier New, Courier, monospace;"><b>]</b></span><br /><span style="font-family: Courier New, Courier, monospace;"><br /></span></td><td valign="top"><span style="color: #444444; font-family: Courier New, Courier, monospace;"><i>Zero first six bytes</i></span><br /><span style="color: #444444;"><span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span><span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span><span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span><span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span><span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span><span style="font-family: Courier New, Courier, monospace;"><i>Return pointer to 0</i></span></span><br /><span style="color: #444444;"><span style="font-family: Courier New, Courier, monospace;"><i>Start counter at 1</i></span></span><br /><span style="color: #444444;"><span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span><span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span><span style="font-family: Courier New, Courier, monospace;"><i>Add two for every one of counter</i></span></span><br /><span style="color: #444444; font-family: Courier New, Courier, monospace;"><i>Make a copy of counter</i></span><br /><span style="color: #444444; font-family: Courier New, Courier, monospace;"><i>Subtract one from counter</i></span><br /><span style="color: #444444; font-family: Courier New, Courier, monospace;"><i>Loop until counter==0</i></span><br /><span style="color: #444444;"><span style="font-family: Courier New, Courier, monospace;"><i>Point to copy of counter</i></span></span><br /><span style="color: #444444;"><span style="font-family: Courier New, Courier, monospace;"><i>Copy counter back to its place</i></span></span><br /><span style="color: #444444;"><span style="font-family: Courier New, Courier, monospace;"><i>New counter is next address</i></span></span><br /><span style="color: #444444; font-family: Courier New, Courier, monospace;"><i>Loop until counter overflows to 0</i></span><br /><span style="color: #444444;"><span style="font-family: Courier New, Courier, monospace;"><i>Set pointer to last value</i></span></span><br /><span style="color: #444444;"><span style="font-family: Courier New, Courier, monospace;"><i><br /></i></span><span style="font-family: Courier New, Courier, monospace;"><i>Output 8, 4, 2</i></span></span><br /><span style="color: #444444; font-family: Courier New, Courier, monospace;"><i>Output 1, 2, 4</i></span><br /><span style="color: #444444; font-family: Courier New, Courier, monospace;"><i>Loop forever</i></span></td></tr></tbody></table></div></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-47858945508162821582014-12-28T03:55:00.002-05:002014-12-28T03:57:31.937-05:00Microcontroller Showdown, Revisited<div dir="ltr" style="text-align: left;" trbidi="on">Back in March I finished the <a href="http://joldosh.blogspot.com/2014/03/microcontroller-showdown-conclusion.html">microcontroller comparison</a> of a few chips I was considering using. The 8051 based chips all fared poorly in BCD calculations, which is the main thing they would be used for in another calculator project. Some other 8051 fans pointed out that tests like mine test the compiler more than the chip and the SDCC compiler does a lot less optimizing than GCC. So, I decided to recode the BCD Add routine from the test in assembly. At the beginning I didn't consider this because I thought I would only ever write C for the 8051, but after writing assembly for the 6502, I was excited to try it for the 8051 too.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-mN2QmovkZwQ/VJ_FMkL8MtI/AAAAAAAAEvo/Eb-tgyrpPx4/s1600/8051.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://2.bp.blogspot.com/-mN2QmovkZwQ/VJ_FMkL8MtI/AAAAAAAAEvo/Eb-tgyrpPx4/s1600/8051.png" height="320" width="308" /></a></div>For this test I used the <a href="http://www.moravia-microsystems.com/mcu-8051-ide/">MCU 8051 IDE</a> simulator. It is really impressive! Being able to see all the RAM and registers helped a lot. It is similar in some ways to what I hoped to accomplish with my <a href="http://joldosh.blogspot.com/2014/08/after-i-got-my-new-hakko-fx-888-first.html">6502 Virtual Trainer</a>. When I translated the original BCD Add function from C, I left out the parts used for subtraction, since they weren't used in the test. Also, some of the values that don't change inside loops are calculated once before the loop and stored for use later. This makes sense because a good C compiler would do this for you. All values are stored in the internal DATA, although this would be far too small for real calculations. The simulator can also work with SDCC, so I was able to simulate the function in C after commenting out the parts for subtraction.<br /><br />The assembly took a simulated 440us to execute. The C version took between 1365 and 1732us depending on memory model and whether the BCD data was stored in DATA or XDATA. Curiously, storing it in XDATA was always faster. The medium memory model was faster than the large memory model. It seems then that hand-coding the routine in assembly is 3-4 times faster. To be fair, the routines for other architectures might also show a speed up if they were rewritten. Compared to the original numbers of the test, a 3x speedup would make the DS89C450 faster than the MSP430 for this routine. The difference might actually be a little bigger since this test used an upgraded version of SDCC that might optimize better. With that in mind, an 8051-based calculator with external bus (coded in assembly) would outperform an MSP430 with SPI SRAM. That is a bit of a surprise after the results of the first test.<br /><br />The LPC1114 could also be sped up a little. In the original test the chip was configured to run at 50MHz. Because the flash runs at a maximum 20MHz, 3 wait states are required when executing from flash. However, 3 wait states is a little wasteful since 2.5 would be enough. Running the chip at 40MHz would only require 2 wait states, and would let the flash run at full speed. I'm not sure this would give a whole 16% speedup but I imagine it would offer a little bit of a boost.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-26679405750173564272014-11-27T01:15:00.001-05:002014-12-24T04:42:12.703-05:00Progress report (sort of)<div dir="ltr" style="text-align: left;" trbidi="on">So I have not updated my blog in a while. Grad school is keeping me pretty busy. Most of what I do with electronics now is related to the local hackspace I joined. I was able to use some tools there to shorten the bolts for the case of my <a href="http://joldosh.blogspot.com/2014/05/rpn-scientific-calculator-case.html">RPN Scientific Calculator</a>&nbsp;and I also have access to a laser cutter and 3D printer that I eventually want to use to make keys for it. One of the members there and I decided to start on a project together. We have not made enough progress yet to post about but we did finish a schematic of what we plan to do. For this we have both EPROMs and EEPROMs. The EPROMs have a small window and can be erased with UV light, though the lamp we have does not seem to be working. They would also need a higher voltage source to write them and I want to make a voltage multiplier when time allows. If I can get that working, it might also help me with another project that needs -27 volts for LCD contrast.<br /><br />Another neat thing I have experimented with at the hackerspace is the <a href="https://www.spark.io/dev-kits">Spark Core</a>. One of our members was able to get a hold of several of these for us. These tiny little boards let you connect a microcontroller to Wi-Fi pretty painlessly. This would work really well for a project idea I have that I have not started on yet. One thing I don't like is the Arduino-like environment used to program them with but I think I could get used to it since I would probably use my own microcontroller for everything but Wi-Fi. Another idea would be to simply use the CC3000 chip the board uses without the Spark Core board, though that may be too complicated to be worth it. It seems that the newer <a href="https://www.spark.io/">Spark Photon</a>&nbsp;uses a different chip which could be easier to use by itself, though Spark Photons are not scheduled to ship until March.<br /><br />One thing I have been working on on my own is a sombrero with LEDs. It was supposed to be part of a Halloween costume, but I did not finish it in time. Each color (red, green, and blue) is soldered as a 4x4 matrix that has its own shift register. It might have been possible to solder all 48 LEDS (16 each of red, green, and blue) as a 6x8 matrix and use one less shift register, but this way lets me keep each LED on three times longer. NeoPixels would have worked well for this project but just one of them costs almost as much as all of the LEDs. The board for controlling everything is finished. Now all the LEDs just need to be sewed to the sombrero and the firmware written to control their flashing. In order to save time I only soldered buttons to the board for controlling the patterns of the LEDs, but I do have some nice potentiometers I bought that I now have time to use instead. Reading their value with an MSP430 worked great on the first try and I displayed it on my <a href="http://joldosh.blogspot.com/2014/09/one-wire-debug-display.html">one wire debug display</a>.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-35874958629226924372014-09-30T01:15:00.004-04:002014-12-24T04:40:59.223-05:00One wire debug display<div dir="ltr" style="text-align: left;" trbidi="on">Lately I haven't had much time to work on hobby projects but I did manage to do a few things. Sometimes for debugging I use an LED if the UART pins are not free to output to a serial terminal. This works alright for simple things but gets complicated when I start outputting different patterns of flashes. Instead I decided to wire a small screen to a microcontroller so that I can bitbang out debug information with just one pin.<br /><br /><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"><tbody><tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-kg6AUyys4m0/VCo09GYR9tI/AAAAAAAAAc0/jt6hYs2hgOc/s1600/DSCN3495.JPG" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/-kg6AUyys4m0/VCo09GYR9tI/AAAAAAAAAc0/jt6hYs2hgOc/s1600/DSCN3495.JPG" height="320" width="252" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">WM-1611-62C</td></tr></tbody></table>At the beginning, I considered using a WM-1611-62C LCD from Russian telephones that I have had for the last two years. It runs on 1.5v, so I haven't been in a hurry to do anything with it. The documentation for it shows Vdd supplied by 5v through a 4.7k resistor with two standard diodes between Vdd and Vss. Running from the 3.6v of the launchpad, the voltage between Vdd and Vss was well under 1.5v and the display was very dim. Adding another diode brought the voltage up and resulted in the clear display you see on the right. Poking at the pins revealed what some of them do and I was able to bitbang some characters to the screen. This was possible even at 3.6v through diodes since the inputs are open drain. Unfortunately, other than 0-9, only a few other specialized characters are possible. Displaying anything in hexidecimal would not be possible, so I scratched the idea of using it.<br /><br />The next idea I had was to use a cell phone screen. In Kyrgyzstan I found some 1202 cell phone screens for about $2 and I tried soldering 0.10mm wires to one of them. At 700°F the iron was way too hot and even at 550°F I managed to destroy the tiny ribbon cable of the LCD. The next LCD I tried was from a Nokia 3510i but I managed to lift the pads off of that LCD. It seems that the temperature displayed by the soldering iron might be wrong. Even at 350°F the iron melts solder very quickly.<br /><br /><a href="http://1.bp.blogspot.com/-zD8n1HLj0Qg/VCo6yUk_23I/AAAAAAAAAdA/L5AnzbqWk5U/s1600/DSCN3500.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-zD8n1HLj0Qg/VCo6yUk_23I/AAAAAAAAAdA/L5AnzbqWk5U/s1600/DSCN3500.JPG" height="250" width="320" /></a><br />Another idea I had was to use some small green 7 segment displays I have lying around. With one MSP430 I could multiplex all four of them. Even at the 6mA that a single pin can supply, these displays were very dim. Maybe it has something to do with running green LEDs at 3.6v. Next I tried a red 7 segment display from an answering machine that was very bright even at 1mA, so I soldered everything to perfboard like you see on the left. The MSP430 on there waits for data to come in on the purple line and flashes a number out digit by digit. It is probably not practical for displaying 32 bit numbers in decimal but seems to work well enough for 8 and 16 bit numbers in hex. The headers on the right are for relaying incoming data to a PC over UART, even if the UART pins on the main microcontroller are in use.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-24964390889624992082014-08-23T01:40:00.000-04:002015-08-12T01:01:18.365-04:006502 Virtual Trainer: Calculator Program<div dir="ltr" style="text-align: left;" trbidi="on">After I got my new Hakko FX-888, the first thing I did was solder the trainer to perfboard. It took some time to get used to the new iron but the board turned out well:<br /><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-DdgxEMUb3sQ/U_gnsrcSOcI/AAAAAAAAAO4/uONcjWO1KvY/s1600/IMAG0743.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-DdgxEMUb3sQ/U_gnsrcSOcI/AAAAAAAAAO4/uONcjWO1KvY/s1600/IMAG0743.jpg" height="446" width="640" /></a></div><div><br /></div><div>The FT232 cable connects to a few header pins soldered to a piece of perfboard connected perpendicularly to the main board by more pins that are bent at an angle. They make header pins at an angle but I used the last of mine on the board I made for programming the Z16F. There was also room to add some sockets and pins that can be used to program the MSP430, as well as power and status LEDs.</div><div><br /></div><div>After using the board for about a week I had a strange error where the chip jumped to address 8080 on reset instead of 8000 which is stored at the reset vector. After some investigating, it seems there was a short between the Vcc pin of the IO expander and the pin controlling A7 of the 6502's address bus. On the back side of the board there was clearly no bridge which had me stumped but it worked fine after scraping away some of the flux between the joints. The problem reappeared after a week or two but was fixed again by cleaning the space between the joints. In frustration I ordered a W65C02 thinking the chip might have been damaged due to some acidental bus contention that had happened during testing. It seems that the pinout is a little different from the W65C816 I am using but it will still be useful because I plan to use it for an improved version of the trainer.</div><div><br /></div><div>With the software I have made a little progress as well. The PC software skips sending any uninitialized memory and with a few other tweaks can program the whole 64kB memory in less than 3 seconds, down from 6 seconds. The microcontroller firmware is also a little better. Compiling with the -o3 flag in GCC brings average cycles per second up to about 16,000 from 12,000. However, setting the update rate to 100ms from 200ms to make typing more comfortable brings it back to around 14,000.</div><div><br /></div><div>To learn 6502 assembly I decided to make a little test calculator program. It has turned out to be a really good way to get to know the chip, even though it has taken a lot longer than I expected. Below is a screenshot.</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-FUuvyAbJGNk/U_goAPCU5hI/AAAAAAAAAPA/HxlKH_DF1-U/s1600/6502%2Bcalc.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-FUuvyAbJGNk/U_goAPCU5hI/AAAAAAAAAPA/HxlKH_DF1-U/s1600/6502%2Bcalc.png" height="514" width="640" /></a></div><div><br /></div><div>On the left is a text window for the 4-function RPN stack. It has 10 levels and each element is 8 bytes of packed BCD. This is convenient because the 6502 has a BCD mode. On the right is a window to enter formulas which can be graphed, like the first three, or repeated like the Celsius and Fahrenheit conversions. Formulas and graph colors can be selected with the dip switches. The toggle switch at the bottom selects between the two text windows and an LED above each window shows which one is selected. All of this could be done with a keyboard interface but I wanted to show off some of the peripherals that can be used. There is also a timer peripheral ticking every 500ms that the program reads to draw a flashing cursor in whichever of the two input text windows is active. The last peripheral is a multiplication ROM that works when single stepping the processor but not when running from SRAM yet.</div><div><br /></div><div>There are still several improvements to be made to the trainer but I am done working on it for the moment. My plan is to port the code I have to an STM32 which will be much faster and also be able to store all 64kB of the 6502 address space in its internal RAM.</div><div><br /></div></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-19765376252343525742014-07-03T16:21:00.000-04:002014-12-24T03:56:21.659-05:00Quiz Buzzer<div dir="ltr" style="text-align: left;" trbidi="on">About a month ago a friend of mine called and asked if I could make a buzzer system for a quiz game for students. Unfortunately, I only had two days until the competition and I did not get it working in time. Hopefully, I can fix it and send it to them to be used at the next competition in a few months.<br /><br />The plan was that each of ten students would have a button connected to a buzzer by a few meters of wire and the first to press the button after a question was asked would cause a sound and light to go off. The connectors are RCA style and the buttons are from an automotive store.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-luVNPr6iQ6I/U7WwLIjokkI/AAAAAAAAAN4/FubnVN2puqk/s1600/button+and+connector.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-luVNPr6iQ6I/U7WwLIjokkI/AAAAAAAAAN4/FubnVN2puqk/s1600/button+and+connector.jpg" height="238" width="640" /></a></div><br />These lead to an <a href="http://www.serpac.com/a42.aspx">A42</a> enclosure I was able to sample from <a href="http://www.serpac.com/">Serpac</a>. The enclosure felt really sturdy but the plastic was surprisingly easy to cut and work with with just a knife. I will definitely use them again when I need an enclosure. The circuit itself was fairly simple with just an MSP430 microcontroller, buzzer, two 595 shift registers, and two 165 shift registers. I did not get around to adding the LEDs, although the firmware does use the shift registers to turn on the correct light when someone buzzes in.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-IoKt_dDpt9k/U7Wytuc--qI/AAAAAAAAAOA/FQDpoldsGhk/s1600/102_1849.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-IoKt_dDpt9k/U7Wytuc--qI/AAAAAAAAAOA/FQDpoldsGhk/s1600/102_1849.JPG" height="480" width="640" /></a></div><br />To control things I made a separate detachable board with a 16x2 LCD. It will be easier to transport if the cable is detachable and it will also let me add a longer cable if the judges doing the scoring need to sit farther away from the enclosure. Other than the LCD, the board has a 555 to generate negative voltage for the LCD contrast and another 595 shift register to run the LCD. It also has buttons to change the time given to answer and to reset the counter.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-eLh1E24AFdY/U7W0wykjniI/AAAAAAAAAOI/1dq_EZs263E/s1600/102_1844.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-eLh1E24AFdY/U7W0wykjniI/AAAAAAAAAOI/1dq_EZs263E/s1600/102_1844.JPG" height="558" width="640" /></a></div><br />For the cable I used Cat-5 again and this may be part of the reason it does not work correctly. For the connector I wanted to make something that would only plug in one way so that people other than me could use it without fear of plugging it in backwards and shorting something. Each side has a pin that can only be connected one way.<br /><br /><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-DZpdn0LbIBY/U7W1nzfH1zI/AAAAAAAAAOY/kKAt8ibfY0Y/s1600/102_1851.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-DZpdn0LbIBY/U7W1nzfH1zI/AAAAAAAAAOY/kKAt8ibfY0Y/s1600/102_1851.JPG" height="388" width="640" /></a></div><br />A project like this would take me a week at least but I tried to finish in two days because my friends needed it. The night before I stayed up soldering until 7am and when I finally switched it on, the LCD came on as expected and the buzzer sounded when I pressed one of the contestants buttons, but it made a high pitched screeching noise when it was finished buzzing. When I turned it off and tried again the LCD wouldn't display anything and only worked some of the time when I tried it again, so we weren't able to use it in the competition after all.<br /><br />Why did it fail? In retrospect, I have had problems with this particular LCD in the past. When I was working on my calculator project I noticed that the LCD would often not work when being driven directly by a microcontroller but worked fine when being driven from a shift register like in this project. I'm not sure why it worked before and not now but the fact that it was flaky before might be a clue to my problem. Also, maybe my assumption that it will always work at voltages less than 5v is not correct or maybe supplying negative voltage to the display somehow has consequences. On the other hand, I observed the same faulty behavior with the contrast left unconnected. Another source of problems could be the Cat-5 Ethernet cable I am using for wiring. Each pair is twisted together and running a separate signal through each side of the pair instead of grounding one side might be leading to signal corruption. Finally, the loud screeching of the piezo buzzer is something I will have to figure out as well. Hopefully, when I understand more about this it will help me straighten things out with my clock project also.<br /><br />Going from nothing to a nearly complete project in only two days was a lot of work, but in the end there was not enough time to troubleshoot problems. When I move into my new apartment next month I will have time to figure everything out and then I can send the working system back to Kyrgyzstan for my friends to use.<br /><br /></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-60625699628302485362014-06-30T18:29:00.001-04:002014-12-24T03:48:42.000-05:00Clock Modification<div dir="ltr" style="text-align: left;" trbidi="on"><table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"><tbody><tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-SM8L0wkiqyQ/U7HiVMPGDoI/AAAAAAAAAM4/VMSr2ZP8850/s1600/102_1828.JPG" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-SM8L0wkiqyQ/U7HiVMPGDoI/AAAAAAAAAM4/VMSr2ZP8850/s1600/102_1828.JPG" height="273" width="320" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;"><i>The unfinished clock without the arms</i></td></tr></tbody></table>For Christmas 2012 I got a battery powered alarm clock. It felt pretty sturdy but only plays a beep when the alarm goes off and it does not have a backlight. There was plenty of room inside the case so I decided to add a microcontroller to play the unofficial national anthem of Kyrgyzstan <i>Кыргыз Жери </i>(Kyrgyz Jeri) instead of just the beep. Although I have been working on it on and off for the past few months I have not gotten the bugs worked out.<br /><br />The mechanism inside the clock runs from one AA battery and has a small buzzer that looks like a piezo. The positive side of the battery is connected directly to the buzzer by a wire. The other side of the buzzer is connected to a chip under an epoxy blob that switches the buzzer on and off. The 1.5v of the AA battery is not enough to run the MSP430 I am using so I wired in two AAA batteries. The clock case has just enough room for the extra batteries and a small piece of protoboard for the microcontroller. I opened the mechanism to solder in some wires so that the microcontroller can monitor the line switching the buzzer and drive the buzzer directly instead. One of the small gears inside quickly melted from the heat given off by the soldering iron a few inches away. Luckily, all of the local clocks use a similar mechanism and I replaced the whole thing for about $1. The wires from the mechanism are connected to a switch so that the buzzer can either be run by the microcontroller or by the original clock in case the extra batteries die. Another feature the clock is missing is a light, so I wired in an RGB LED I bought a few years ago. It has a light so that it can be used as a backlight but it also flashes colors in time with the music when the alarm goes off.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-JxitTxeEIYc/U7HiVzZmaPI/AAAAAAAAANE/dOKDYZkiioI/s1600/102_1829.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-JxitTxeEIYc/U7HiVzZmaPI/AAAAAAAAANE/dOKDYZkiioI/s1600/102_1829.JPG" height="624" width="640" /></a></div><br />At first I tried soldering components directly to a DIP socket but this was surprisingly difficult, so I added everything to a small piece of left of protoboard. The AAA batteries are too big to fit in the clock case side by side so I couldn't use a battery holder. Instead I soldered wires directly to the batteries. This will make them hard to change but hopefully the MSP430 will use very little power waiting for the alarm to go off. Once I got everything soldered, the microcontroller would play the music it should but it would not stop playing even when it was disconnected from the line switching the signal. This is a problem I still have not figured out but I'm sure it has something to do with fluctuating signals in the circuit.<br /><br /><table><tbody><tr><td><br /><a href="http://1.bp.blogspot.com/--a2rp28VyQA/U7HiWyAvlVI/AAAAAAAAANM/R6ATpscib98/s1600/102_1834.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://1.bp.blogspot.com/--a2rp28VyQA/U7HiWyAvlVI/AAAAAAAAANM/R6ATpscib98/s1600/102_1834.JPG" height="157" width="320" /></a></td><td><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-oA5qbQBF6v0/U7HpIz5GLoI/AAAAAAAAANo/3o-fdxpu7Lk/s1600/102_1832_new.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-oA5qbQBF6v0/U7HpIz5GLoI/AAAAAAAAANo/3o-fdxpu7Lk/s1600/102_1832_new.JPG" height="161" width="320" /></a></div></td></tr></tbody></table>There were a number of other strange problems as well. The P1IES register used to enable edge selects for interrupts on the MSP430 sometimes gives the wrong value when you read from it. It would be useful to read it in an interrupt to know which phase of the cycle the interrupt was last configured to fire for. There was also a problem working with 32-bit values. It seems that doing math with constants and assigning the result to an unsigned long does not automatically promote the constants involved to 32-bit values as well. When I got the wrong value, I tried it out on a PC and got the expected value, which was a little perplexing. It seems that constants default to the bit size of the processor, which seems silly from a portability point of view. To have the constants treated as longs, the L prefix has to be added. Another strange thing that happened was that the buzzer always made a high-pitched whining even when not being driven. The batteries for the microcontroller also drained alarmingly fast. It turns out that both of those problems are related to the buzzer being electromechanical instead of a piezo. These buzzers do not charge and stop current from flowing like a piezo. It seems they only have about 40 ohms of resistance and this is why the batteries drained so quickly.<br /><br />There are still a lot of bugs to be worked out but I hope to make progress soon and finish this little project quickly.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-907807897596197572014-06-23T23:06:00.002-04:002015-08-12T01:00:49.604-04:006502 Virtual Trainer: Update<div dir="ltr" style="text-align: left;" trbidi="on">Lately I have been working on several different projects and I have made a lot of progress on the 6502 Virtual Trainer. The first step was connecting the PC interface to an MSP430 over UART. This was easy because I have done it in other projects. <a href="http://www.microchip.com/">Microchip</a> let me sample some&nbsp;<a href="http://www.microchip.com/wwwproducts/Devices.aspx?product=MCP23S17">MCP23S17</a>&nbsp;IO expanders and I was really excited to be able to try them out to read and write the pins of the 6502. Unfortunately, they were a little finicky to get going because the datasheet incorrectly lists the reset pin as an output instead of an input. &nbsp;They do save a lot of space, though, because five shift registers would be needed to replace them. After that was solved, I was able to single-step the processor as I intended but only at about 90 cycles per second. For comparison's sake, with the processor doing nothing else, that is a little too slow to type comfortably. At the beginning I knew this would be slow but that is much slower than I expected. The bottleneck seems to be the USB&lt;-&gt;serial layer since the program sends lots of small packets of data instead of small numbers of large packets. To speed this up, I send 10 bytes of op codes every packet. Then the MSP430 can use the data sent if it needs to read a byte that is near. It will have to request more data if a jump takes place or data is read from another location in memory but in general this improvement led to a speed up of about 150 cycles per second. This was still not as fast as I had hoped for so I decided to keep a copy of all of the memory on an SPI SRAM chip. For this I used a&nbsp;<a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en559066">23LC1024</a>, also from&nbsp;<a href="http://www.microchip.com/">Microchip</a>, which holds 128k. Using an SPI SRAM might seem to make less sense than just hooking up a typical parallel SRAM but by letting the microcontroller control the memory I can hold extra <span style="font-family: inherit;">information</span> about the data such as which bytes have not been initialized and which should be ROM. This will let me break when reads and writes that would be illegal are performed. Even during testing this turned out to be useful as it is easy for a beginner to assembly to write something like <span style="font-family: Courier New, Courier, monospace;"><b>LDX $FF</b></span> instead of <b style="font-family: 'Courier New', Courier, monospace;">LDX #$FF</b><span style="font-family: inherit;">. As a compromise the MSP430 runs the 6502 as fast as possible then pauses and updates the PC every 200ms or when 64 bytes of memory have been modified, whichever comes first. Another way to speed things up was to increase the COM port speed from the 230,400 bps max of the MSComm control I'm using with Visual Basic 6 to 1,000,000 bps. At 1,200,000 bps the MSP430 could not keep up running the 6502 and reading data. With these changes I can run the 6502 at about 12,000 cycles per second. This is still pretty slow but fast enough to play with for learning purposes. To test things I made a few programs including one that draws a faded red pattern like below:</span><br /><span style="font-family: inherit;"><br /></span><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-XxbNAxHWezw/U6jmNATYHUI/AAAAAAAAAMk/xXkTmQPOWt0/s1600/6502_main.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-XxbNAxHWezw/U6jmNATYHUI/AAAAAAAAAMk/xXkTmQPOWt0/s1600/6502_main.jpg" height="514" width="640" /></a></div><a name='more'></a>To assemble the programs I am using CA65 which is part of <a href="http://www.cc65.org/">CC65</a>. Instead of compiling to binary I only generate a listing file. From that I can read not only the generated source but also the names of labels and what lines of the source the code was generated from, so that I show all of this information as part of the memory viewer.<br /><br />Another part I worked on is a window to load code and set the color of memory in the memory viewer in the main window. Regions of memory can be labeled and colored, and double-clicking on a title jumps to that location in memory. Regions can also be marked as code or read-only so the program can break on incorrect accesses.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-5YdrnXGPGpE/U6jmNHeMeiI/AAAAAAAAAMg/5JR05-eBMKQ/s1600/6502_memman.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-5YdrnXGPGpE/U6jmNHeMeiI/AAAAAAAAAMg/5JR05-eBMKQ/s1600/6502_memman.jpg" height="576" width="640" /></a></div><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">Next I plan to improve the cycle&nbsp;</span>diagram<span style="font-family: inherit;">&nbsp;at the top of the main screen to show which op-codes and which addresses&nbsp;were being accessed, as well as the status of&nbsp;</span>auxiliary<span style="font-family: inherit;">&nbsp;pins. Someday I would like to make another calculator using the 6502 and this will help me learn how it works. Unfortunately, I was not able to solder everything to perfboard before I left Kyrgyzstan. Now that I am back in the US it marks the end of the time I started this blog for. I look forward to doing more projects now that I have access to more components and better equipment.</span></div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0tag:blogger.com,1999:blog-8905597180918542756.post-15324226821325829832014-05-13T13:30:00.000-04:002014-12-24T03:52:46.978-05:00RPN Scientific Calculator: Case<div dir="ltr" style="text-align: left;" trbidi="on">After a few months of work, the case for my calculator is finally finished. Back in January I made a <a href="http://joldosh.blogspot.com/2014/01/rpn-scientific-calculator-hardware.html">post</a> with a picture of the clad I soldered together for the case. My plan at the time was to stuff all of the internals of the calculator into the case over the course of a few days but it ended up taking much longer.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-AVsEFImi7s4/U3JTEpCo0tI/AAAAAAAAALo/XrKn74IMu_Q/s1600/calc_front.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-AVsEFImi7s4/U3JTEpCo0tI/AAAAAAAAALo/XrKn74IMu_Q/s1600/calc_front.jpg" height="640" width="512" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div>The first hurdle was figuring out how to attach the front and back plates to the case. In the end I settled on epoxy. The first one I tried was still oily after 24 hours and did not hold very well but a much cheaper one held extremely well and I used it to glue four bolts to either side of the case body. Oddly enough the epoxy turned the clad green pretty quickly. From there I made holes with a box cutter in the front and back pieces for the bolts. Cutting out the hole for the keypad and LCD in the front piece of clad with a box cutter and wire cutters was a real chore and I don't plan on working with clad ever again without something like a dremel. For spacers between the clad and components I used rubber erasers.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-JO-rL_gQpx4/U3JTGdU_yyI/AAAAAAAAAME/9irWSdWuqys/s1600/inside.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-JO-rL_gQpx4/U3JTGdU_yyI/AAAAAAAAAME/9irWSdWuqys/s1600/inside.jpg" height="452" width="640" /></a></div><br />These are cheap and easy to work with. My only fear is that they may dry out and crack someday. At first I tried gluing one of the plastic battery holders to an eraser with epoxy but surprisingly the bond was very weak. Super glue worked very well, though, and I glued in more erasers to hold the LCD, PCB, and keypad in place. All of that added a noticeable amount of weight to everything. The front and back pieces also have erasers glued to them to help hold everything together.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-hNnWh_7plzg/U3JTEllZMZI/AAAAAAAAAL8/HqfUOk3bzxI/s1600/calc_front_2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-hNnWh_7plzg/U3JTEllZMZI/AAAAAAAAAL8/HqfUOk3bzxI/s1600/calc_front_2.jpg" height="432" width="640" /></a></div><br />There was not enough room to comfortably route the wires from the LCD and keypad to the PCB so I desoldered them and used Cat5 cable instead. The wires inside are much smaller and easier to work with. It is also possible to leave the individual wires inside the Cat5 cable to make routing neater and I did this for some of the keypad wires. After assembling everything it worked fairly well except the keypad buttons were hooked up upside down. This was easy to fix in software and I loaded the new version using the programming pins soldered to the PCB without having to take the PCB out of the case. There was another bug that caused the calculator to freeze after pressing escape. For some reason the program was going into sleep mode when I pressed escape. I must have added this during debugging but it does not make sense at this point.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-Yhli_1akeww/U3JTEuBEfWI/AAAAAAAAAL0/WrSC3QZFWDE/s1600/calc_back.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-Yhli_1akeww/U3JTEuBEfWI/AAAAAAAAAL0/WrSC3QZFWDE/s1600/calc_back.jpg" height="478" width="640" /></a></div><br />The next step will be to add some sort of labels for the keys and then paint it if I decide to.</div>Joldoshhttp://www.blogger.com/profile/17712416148503222652noreply@blogger.com0