TechToys SSD1963 eval kit on a PIC32 I/O Expansion Board

Now that I’ve gotten all the leaks taken care of on my new aquarium I decided I should at least figure out if the new SSD1963 eval kit with 7 inch 800×480 LCD that came from TechToys. com.hk works. Officially it is listed on the site as SSD1963EVK-R3B + 7″ WVGA color TFT with Touch Panel Part #: SSD1963EVK-R3B-TY700TFT and as of July 2011 was listed as a bundle price of $119 USD plus shipping. This includes the LCD, SSD1963 board with a cable between them, and 40 jumper cables.

This kit is intended for a development board created by TechToys that fits the connector perfectly. On that board you can then place a PIC32 starter kit. For my purposes this is not usable because I do not need the devices on that board such as the MP3 player. I also need to add a variety of I2C and SPI devices for sensing environmental conditions. For my project sticking with the PIC32 I/O expansion board is the best bet.

I decided I would leave the original breakout boards attached and wire the LCD and graphics chip on. I removed the Microchip Graphic boards from the side and popped out the riser card. To properly find the wiring you need to use you need to consult both the schematic for the Multimedia Evaluation Kit for Microchip PIC32 Starter Kit and the Evaluation Kit for SSD1963QL9. You are looking at the diagrams for MCU interface and SSD1963 EVK Interface. What you will find is that not all of the pins are diagrammed through to both sides. They need wired through though and the correct connections can be determined elsewhere on the schematic. Wire everything from the SSD1963 EVK Interface diagram and then add onto it the Reset, LE and other pins. Once you do this you end up… with a mess:

Then I began the process of trying to compile the modified MultiApp Demo. I selected one of the hardware profile includes for the 7 inch LCD and SSD1963 that involved a PIC32MX795 and tried to compile it. I’ve read about people potentially having to modify when using a Graphics Library higher than 2.0. Turns out this was not the reason I had errors. Instead I needed to fix the driver file because it mentioned parts I was not using and didnt match the name of the driver. I commented out a few lines and uncommented the lines that matched the actual names from the driver. It reports not having a compatible Controller prior to that and worked fine following that. However, the tech toys modifications stopped other graphic apps from compiling so you need to do a diff comparison to figure out changes necessary to newer libraries.

Once the lines were commented out I compiled, uploaded and launched the app. Success was short. Within a few moments I realized while pressing around on the touch screen calibrating the corners and pressing to save the calibration I noticed that the program didnt continue any further. Stepping through a debug I noticed it was at a point waiting for the EEPROM to respond. That’s when it hit me. TechToys sells a development board which happens to include an Atmel SPI EEProm. On the Microchip boards this is found on the graphics board because they expect you to change graphics boards potentially with your own and they supply it on their graphics board.  For TechToys it’s on their development board and not with the graphics boards.

Upon removing the microchip boards I thus no longer have an EEPROM. Upon playing around I found that pressing in the upper right corner instead of calibrating results in the board eventually skipped the write and reload of the calibration and jumped to the home page though I had issues reproducing this reliably. Ultimately just to test it working I ended up triggering buttons about 2/3 of the way from the bottom to trigger the lower buttons and then gradually moving up until it selected another item.  The various graphical items displayed and I managed to get some of the apps to launch though not be able to control them very well.  All that mattered to me is it technically worked as wired.

From what I can see there is an acceptable write speed to the LCD for setting up a coffee roaster control screen but I will need to test further once I can store the configuration data and switch to the original roaster program on the larger screen. I’m thinking I should actually be able to store this to a file on a SD memory stick instead of an EEPRom. Both are SPI but will require a different process to read/write but there’s been others who have done so without much issue into a config.ini file.

Writing to SD memory…

Soo… the latest update… I had wired in the SD memory stick reader and had been testing it separate from the main roaster program. I’ve found having a “dedicated” programs for a particular sensor with the rest of the sensors and displays attached but not initialized has resulted in easier testing and troubleshooting.  Occasionally it works right away but other times conflicts come up.  Generally once I have manage to confirm it works without the other code running I at least have a reasonable assumption that it may actually work and is wired properly.   Since I’m pretty new to the whole wiring these things up it’s a pretty good idea to test my wiring out.  So far I’ve actually done pretty well reading enough about each sensor to figure out what I need to make it work the first time.  If I go too long not getting it to work I try to disconnect everything else and run it by itself which usually helps me identify conflicting pin usage that I didn’t see initially.

So far I tend to find issues with the LCD interface / graphic chip / memory config chip to conflict with a particular pin here and there.  If it works without the LCD boards attached it obviously has a much smaller number of pins from the new sensor to try to find a conflict with. Usually by the time I isolate the LCD away from the system I’ve managed to throw together code that works within minutes of starting things up again.
My last success with the SD memory was short lived because I discovered there were pins that I had not noticed on the SSD1926 that apparently do something even though I’m in 8 bit mode instead of 16 bit.  They seem to have ended up being connected when I was trying to check my Write Protect and Card Detect pins.   It took probably about 3 hours of looking at the schematic for the graphics board assembly to figure out which wires (15 minutes) it was and then find some (the rest of the time) that were not being used already.   Since I am using 8 bit communication instead of  the 16 bit mode I would have assumed them to be “dormant” and potentially available.   Not quite sure what is going on with that since I have not obtained the data sheet for the SSD1926 chip yet.

I had an unexpected guest show up early in the week and didnt get much time to work on this.  After making a few adjustments to the wiring I got it up and writing to the SD with the LCD attached.  This weekend I got it loaded inside the Coffee Roaster programming.  I ran into a few initialization problems that resulted in a momentary “stream of gibberish” coming out the UART port that I was using for watching status of some of the code I was troubleshooting with in a terminal window.  It seemed as if the system had a baud rate to the com port of the computer that suddenly “shifted” up and down a few times in the middle of the machine starting up and then returned to normal. After I removed some of the apparently duplicate excess code from the init area it resumed working normally.

I then had to move the “write to SD” down through the startup past the time and date retrieval area.  This results in accurate time/date stamps on the file now being written to the SD memory card.  I then began to modify the SD demo write into a command that builds the buffer data using a sprintf template inserting date and time on a line separated by commas and a few sections (with 0.00’s right now) for sensor data as well.  I’m going to bundle the write commands up into a function so that I can insert it into roaster loop as a external function.  Every time it samples the temperatures and other future sensors it will shove it into the call to the “write to SD” function where it will get formatted and append to the file it created during the initialization of a new roast loop.

As I said, I havent had much time to work on it this past week but probably tonight and tomorrow I’ll get significantly closer to figuring that part out and probably test running the roaster with nothing in it just to get some temperaturee logging as it goes up/down for a few seconds and then exit the roast to close it to check the accuracy. Then when I’m sure that’s working I’ll try to do a regular roast with it out in the kitchen and see if I can get “good numbers” that I can post.

If I can get that working then the next step will be to get a “file management” function going to come up with names of files to make them unique and maybe let me load the data into the system to preview it on a graph on the PIC32 LCD as well as delete files. THEN I get to start figuring out how to program it to control things by itself based on my normal data.  😀

Close Encounters of the SD Memory Kind…

Sooo generally annoyed with sensors I decide to take a different direction, SD Memory.  Fun things happen with SD Memory.  You rip one open and you’ll usually find a single little flash memory chip and some other chip in front of it.  I haven’t identified the “guts” yet but that’s not really important.  What’s important is that generally you talk to that little flash memory chip using SPI (usually unless you wanna pay for licensing fees to use the direct SDIO method it sounds like.  Crazy licensing costs = faster SD Memory.  Free method = slow access.  If you need every bit of speed you can get then you’ll likely need that expensive method.  If you can buffer up data internally and then write it out later then you’ll use the SPI method).  This is likely to be preferred to have a built in memory chip to buffer items up just like working with a document on your computer.  It then isn’t until you save the file that it then transfers it from the internal memory out to the SD memory for transportation to the PC.

There is not much to it other than that except for having some structures that issue a few reads and writes to find a spot on the chip and make a file name and fill the file full of stuff.  That portion is the “FAT” portion that makes you able to read it on a computer etc.  This slows things down considerably in an SPI Method.  Apparently people have experimented with reading/writing to the SD memory chip with no

After a few days of poking at it and moving a couple wires around I’ve now managed to get it to make a file… and I can see that file on a PC.  The problem is I can’t get it to put anything INSIDE the file.   It just keeps getting stuck on the portion where it’s expanding the size of the file…  further it’s been quite a pain that any SD memory sample code out there is written focused on the 3xx series PIC32 and from looking at the various forums my issues are pretty common.  Most people get the 3xx series working just fine.  Many people seem to get files with no contents on 6xx and 7xx series PIC32s.

The only published successful people I’ve found seem to be commercial product developers who don’t want to share any code samples clarifying how to handle the failures properly.  The only exception I’ve found was some code modified by the user bmorse on mypic32.com.    His code appears to be modified to work specifically at 60mhz and using SPI2 which worked for initial testing to ensure I had things wired properly.   I needed to put a pull up resistor on the CS and the DO of SD to SDI2 on PIC32 and everything started working properly.

I’m now trying to isolate the portion of the code that affects the timing to increase the system speed back up to 80 mhz and scale the SPI back down again.   To assist in this department I’ve procured a FT232 UART to USB Com port chip on a breakout board from SparkFun.   This board is commonly used to take the UART output of various text and data from the running PIC and interact with it in the terminal window instead of watching the raw data on the debug watch.  I’ve learned that the watch window often “messes up” a lot of SPI states by constantly inspecting the information.  The idea is that it interrupts the normal state (data waiting etc) flags due to having read it for the watch window  blocking the rest of the circuit from detecting it.

I’ve also obtained a DS3234 clock.  At time time I only have the one I2C DS1307 clock and I may wish to eliminate the I2C bus unless I come up with something else that needs it.  Even if I use I2C elsewhere it seems as if 5 volt I2C is more of a rarity meaning I can’t really use that bus for other things anyway.

Graphing Temperatures from the MAX6675 on PIC32

Turns out graphing temp data is pretty simple.

Using the standard Graphics Library from Microchip just to display the output right now. Ultimately it’s working pretty much as necessary to show temperature graphically. I need to be able to adjust the top/bottom a little better using some formulas to come up with a scaling percentage dynamically to make it fit the minimum and maximum possible temperatures into the display without squishing it too much. Additionally I need to decide how quickly to scroll from left to right and possibly a way to redraw scrolling backwards to see starting graphs and archive the raw data to be reanalyzed later possibly zooming etc.

The input to the system is using a development board by Ryan J McLaughlin (dot com). The board was designed to be connected up to Arduino microprocessors but I figured out it could be plugged up directly to a PIC32 too. I decided I needed an easy to interface board with a thermocouple socket already on the board and this one fit the bill nicely.

image

Right now it blinks the status LED every time it makes a reading which is somewhere around 2-3 times per second.

I’m not dead… And finally having SPI progress.

So with all the holidays and other things going on I didnt get to spend much time working on the roaster. In addition due to the complications with the SPI not working all this time I wasn’t feeling very motivated.

Last night after spending hours over many days reading blogs of people who regularly participate on Microchip’s forums I finally managed to get the MAX6675 to start transmitting actual temperature data to the PIC32. I’m not entirely sure why it works now but need to emphasize that it only works OUTSIDE my prototype roaster programming. In other words it is literally a single purpose program that reads a single temperature value from the MAX6675 chip.

It seemed almost reliable by reporting similar temperatures most of the time for each reading for air temperatures and then goes up when I press the thermocouple against my hand and then drops significantly when I press it against a cold soda can. There was a rare spike to 120 plus degrees here and there but infrequently. Otherwise the temperatures appear to be pretty close.

When I return to my roaster program there appears to be something significantly wrong with the speed it communicates with a potential “shift” to the left. If I drop off several of the rightmost (0) bits the resulting numbers are what they are supposed to be with a random wrong bit mixed in. About 60% of the time the results are completely erroneous no matter what. I’m pretty sure now that there is a setting somewhere affecting the communication speed that I’ve lost track of that is disrupting things.

I’ve found that adding some longer delays around the CS changes seems to make the temperatures returned significantly more stable eliminating the 100 plus degree spikes and need to try them out in the roaster code too.

Ugh… they really should sell a manual for this thing.

On my way through the I2C problems I downloaded the PIC32 Family Reference Manual from Microchip. I was looking things up and it wasn’t so bad due to it being broken into different sections. There was one section on I2C so I mainly focused on it. I then started figuring out that perhaps it would be nice to search around for things across the whole manual. At that point I discovered that you cannot join each chapter/section together to form a big master PDF file.

I then started considering actually just printing it out instead but realized it was kind of big. I then decided I wanted it to be bound together and began looking at Staples to have them just do the whole binding thing into a single book with a stiff cover on it. I started uploading files one at a time (because they don’t have a bulk upload function)… and then discovered that they don’t have all the chapters/sections written yet. There is probably like 4-5 sections that simply don’t exist. You have no idea what they talk about because there is no master index yet. Reading through the manual there are sections that have been revised in 2007, 2008, 2009, etc. They’ve been working on writing the manual for almost 4 years now and STILL are not done yet.

I decided if it wasn’t complete I wasn’t going to take it to Staples and have them bind it together. Instead I’ve now been printing it out for the past few days on my laser printer and binding it using those plastic coils. I’ve now made it to section 20 printing duplex pages. I think there’s about 10 more sections to go. It’s getting pretty close to a ream of paper it looks like. I’m going to do the 5/6/7xx family data sheet too I think since I reference that a lot. That’s another 230+ pages (130ish double sided… not sure the exact number of pages it is off the top of my head)

I’m also considering getting the pin out graphic (or making my own) and colorizing it and having it blown up to print on a wide 30-40 some inch color plotter. It’s really difficult to program all these things without looking up which pins are being used on the starter kit. It’s FURTHER complicated not knowing how the starter kit hooks to the header pins and the various accessories. There also seems to be several pins that probably do not connect at all making things even more fun!

I’m “taking a break” from coding for the moment. I’m trying to use SPI to get it talking to one of the temperature sensors. I’ve got it initializing the SPI area and it SEEMS to be talking to the sensor. I had worked on another sensor earlier and it downloaded calibration data from the eeprom but none of it seems to mathematically make sense. Everything seems to be off pretty significantly. The only thing I can think of is I’m off a few decimals or something somewhere in the process. I think I really need to start printing out more sensor data sheets and start comparing them side by side with the manuals for the PIC32. There is something wrong with the reading process where it seems to hang sometimes and not others. The eeprom read comes back with the same numbers each time when I randomly bounce around in any order so it SEEMS to work but I can’t really get anything usable out of it yet.

I also discovered another problem at the end of last month. Apparently on the 30th and 31st of the month the real time clock doesnt show the right date. I can set it into the clock chip and back out. When it goes into the PIC32’s clock it converts it back to a 1. It is my guess now that there is some sort of Decimal / Binary / BCD / Hex conversion problems.