MAX6675 with PIC32MX795F512L

As I mentioned earlier I’m using the USB Starter Kit II, the PIC32 Expansion Board, the SSD1926 PicTail Plus board, and a Truly 3.2″ 320×240 LCD display board to develop the roaster system. This has resulted in some “fun” trying to figure out which pins are really going where on the board and the PicTail cards that you can build your own circuits on. Occasionally some of the pins are not exactly labeled the right way or else there are a few pins that are wired together on the circuit boards making you unable to use one of the pins that are wired together or in some cases both cannot be used etc.

I’ve been working through various demos and trying to understand some of the libraries and still trying to identify all of the pins on the expansion board that are already attached to the LCD / graphics chip. So far I have not found any that involved the SPI1 Pins, which I’m sure is incorrect now.

I’ve now managed to get real time readings to occur while using SPI2 instead of SPI1. Originally I was using pins B2 (SS1), C4 (SDI1) , and D10 (SCK1). to communicate with the MAX6675 thermocouple. When the system launched it would begin to read temperatures from those pins properly but only while in animate debug mode. As soon as I would let it run in full speed to get to a break point later it would be partially or completely erroneous in the received readings. I’ve now switched it to the SPI2 pins and using G9 (SCK1), and G7 (SDI1). (The MAX6675 does not use the SDO pins since it only transmits readings and does not receive using SPI data)

I’m now opening the SPI port to communicate with the MAX6675 using 16bit word mode:
OpenSPI2(SPI_MODE16_ON | SPI_SMP_ON | SPI_CKE_ON | MASTER_ENABLE_ON | CLK_POL_ACTIVE_HIGH | SEC_PRESCAL_8_1 | PRI_PRESCAL_16_1, SPI_ENABLE);

[After I clean up all the “Dead code” that I’ve been testing various things with I’ll insert some additional SPI stuff HERE]

Which appears to work properly talking to the MAX6675. Further I’ve gotten the text to display on the screen of the current temperature where it runs a rolling average of the last 3 readings updating the screen after each additional reading. At the moment it flips on one of the starter kit’s LEDs based on the temperature when it needs to heat and turns it off when it’s reached a preset temperature.

I need to work more on getting the LCD display to show the activity that is going on in terms of heating/cooling and run a timer to begin estimating what stage the roast would be in based on temperatures and time-wise. Additionally I’ll need to figure out how to graph the temperature across the bottom of the screen too. I’m thinking screen real estate is somewhat limited so I may want to upgrade the LCD to the wider board to move some of the data to the side leaving a larger graph area to represent the roast curves.

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.

Progress on I2C

So I previously had tried to get things working using a PIC24 and had both the thermocouple and a battery backed real time clock interfaced and communicating as well as some other items over SPI and I2C. Over time I decided I needed to focus on the PIC32 due to the memory, speed, and ease of interfacing with an LCD. I thus ordered the development kits for the PIC32 and a series of other parts and started this blog about them since I had to start over.

I have so far had tremendous problems with the I2C on the PIC32 hardware. In addition I seemed to show slightly more success with the other sensors over the RTC chip in particular. The RTC was provided by SparkFun as a breakout board. It does not have the pull up resistors on the break out board so it can be chained on to something that already has them… or else you need to insert your own resistors and power between the holes on the breakout board and the microprocessor pins.

After digging through an old box full of parts scavenged off of computers and an old 32 Port Audio Mixer that was destroyed while I was moving due to falling off the lift gate as I was finishing moving out of an old house I lived in. I’ve managed to create an I2C bus using a ribbon cable with some connectors pressed into it close together. I was then able to use a female header socket with some long pins and plug the DS1307 breakout into it for SDA and SCL. On the second connector I inject power into the other side of a header (the resistors are too thin to make contact in the normal connector for some reason). I then connect the third connector to the PIC32 pins using Female to Male jumper wire. Due to the length of the pins on the female header connectors I am able to clip the probes for a Logic Analyzer to the system.

After trying and trying and changing resistor values etc I was getting nowhere. I measure 5 volts on the I2C pins and with other sensors I could get confirmation of the bus going from on to off occasionally. With the RTC chip I was stuck at on. I had no idea what was happening and finally after several days of banging my head I yanked the backup battery out of the RTC.

Sparkfun claims that they have pre-programmed the time on the RTC and they are thus ready to be used/read etc without requiring time to be placed on the chip to start the oscillator. They also comment somewhere in the pages about how it should last about 9 years on the lithium battery provided blah blah. Apparently this is not entirely accurate. I have stumbled across several people commenting on the system NOT being programmed on their boards. In my case it turns out that the RTC chip simply is “hung” possibly caused by a malfunction of the battery. Upon removing the battery I noticed that it had “exploded” in one of the corners like they typically do when they get old. There was some rusted/acid crusted bits and leakage on the surface of the battery AND on the circuit board. I plugged it in again and ran some testing to it and it appeared to be accepting programming from the PIC32. After going to Radio Shack looking for a new battery I cleaned up the board and installed the new battery. The programming seems to stick now and all is well having provided a new battery. The old battery is currently reporting .8V instead of the normal 3.3v and is generally rusted and fouled up.

Unfortunately this story does not have freedom from flaws. It turns out that while running the routines normally I get results of either 0x0000 or 0x00FF. When I force it to debug mode, however, things appear normal displaying hours/minutes/seconds/date/month/year/etc in the appropriate slots and upon returning form debug mode back to normal show in the spaces I forced it to display the text. Further when I try to program it into a demo program Microchip wrote it seems as if the year is actually the “date”, the date is the “day of the week”, the month is the correct month, the hours and minutes dont make any sense. I’m not sure what is going on there. Taking a wild guess I’m thinking the date/year thing being weird is coincidental and that in reality there is perhaps some sort of Hex vs BCD problem going on.

Since I have achieved some level of success at this point though I am going to do a commit to the SVN repository on my server at home to make sure I don’t lose this code. I can see, with the Logic Analyzer, that the SCL and SDA pins switch from 0 to 5v and 5v to 0v from time to time so I know the pull up is functioning. What is troublesome is that the SCL pin never appears to have a functioning clock signal. Immediately after applying a Start command it appears to register a bus collision. I cannot figure out why this is happening and it further baffles me that I could program AND read I2C data without a functional I2C bus.

I was reading on the Microchip forums about how they, apparently, recently changed the I2C Library on the PIC32 making it function different than the PIC24. This is causing significant problems for PIC32 users. It seems to have something to do with the Idle state not being checked on the PIC32 causing collisions or something like that. How exactly this applies to what I’m doing I’m not sure because while the symptoms are the same it does not seem to follow the same circumstances.

In addition this weekend I obtained some LCD screen protectors (typically used for GPS) and removed the original covering provided by Microchip and installed the new protector. It is a lot smoother and easier to read the screen. I should be able to record the video on the screen without it being distorted once I get the I2C (and some SPI) sorted out and working.

Ordered parts this weekend for roaster controller.

I’ve ordered some parts from Maxim/Dallas as well as from Microchip this past weekend. The stuff from Maxim is supposed to be coming US Postal Service so I don’t really know when they will arrive. I forgot to add a temperature sensor (ambient) to the order though so I will need to come back to that later. I need to compare it with a similar chip offered by Microchip to see which one I want to use. I believe the chips by Microchip are actually smaller and more accurate but I will need to confirm later.

According to Microchip’s website / my invoice the IO board, graphics board and LCD touch screen, Prototype cards, and a 9V Power Supply will ship sometime in the next couple days. They are scheduled for arrival on the 17th. The Network Card and PIC32 Starter Kit is not due to be available for 2 weeks and is supposed to arrive on the 30th.

Freshroast SR500 apparent “safety” mechanism. Adding new thermocouple.

Due to the microprocessor installed and the sensor mounted at the top of the roaster base where you install the roasting chamber.

NTC Thermistor mounting

It appears that when you turn the roaster on to High and lower the fan knob to the lowest setting the roaster will reach (unloaded) 430 degrees.  At that point the fan automatically revs up slightly (possibly due to the heater being off)  and the heat stops climbing at 433 degrees.  Occasionally it drops sooner but always between 430 and 433.  It then drops from 430ish degrees down to approximately 420 degrees and then resumes climbing again.  The heat appears to always stop at 420 and then goes back up.  The highest it stops dropping at is 422.

Temperatures were measured with a new K type thermocouple mounted approximately where the center of the bean mass would be.  I obtained this at OSH (Orchard Supply Hardware) since I needed some sort of multimeter for the moment.  They had one inexpensive “Craftsman” model with the ranges I need for measurements with the Digital Multimeter side with an included K type thermocouple mode.  I’m expecting the thermocouple to not last very long due to the temperature rating they put on it.  I will likely get one from eBay or something that is compatible with the K thermocouple sensors in the meter.  I’m guessing the protective covering they put on the tip end insulation area to keep the insulation from unraveling is not able to withstand the high temperature for very long but the insulation looks like it can take a lot more.   I’m going to probably get some high temperature silicone and put a little dab right at the end above the tip to hold the insulation better so it won’t fray.

Ultimately I’ll source out a thermocouple that can do more properly as I get further into this.   I’m going to switch to using the previous thermometer as a timer (was a secondary feature… you get one or the other on screen at any point in time) and the thermocouple as the new temperature sensor since it actually responds faster on temperature changes.

Let there be coffee…

And God said, “Let the earth put forth vegetation, plants yielding seed, and fruit trees bearing fruit in which is their seed, each according to its kind, upon the earth.” And it was so. The earth brought forth vegetation, plants yielding seed according to their own kinds, and trees bearing fruit in which is their seed, each according to its kind. And God saw that it was good.

That happened on the third day…. probably because by the end of that third day he was getting really tired without some coffee to help him keep working all day and night.  As a result the vegetation came forth allowing a little pick me up from the fruit of the coffea plant with perhaps a little sugar from the sugar cane.  It wasn’t until the 6th day he got to add some cream though.

So on to more serious things starting my experiences coffee roasting.  Today I received via UPS a FreshRoast SR500 from sweetmarias.com in Oakland, CA.  In addition to the roaster I had ordered the 8 pound “regular coffee” sampler.  The samplers can be Regular, Decaf coffee or half-caf.  The full Decaf sampler costs a little more since it does tend to cost more.  You can also opt for an Espresso sampler or just the regular coffee beans depending on your preferred use of green coffee beans.  The beans I received were part of a Regular Coffee sampler.  The random assortment I received were described by Sweet Maria’s as:

  • Honduras Organic – Michelle Guevara Microlot
    • City+ to Full City+
    • Honey-drenched sweet flavor, lemony-bright snap, jasmine tea hints, very pleasant, lively and clean.
  • Java Kajumas Organic Wet Hulled
    • Full City to Full City+
    • This is a low-toned, bass-note flavor profile, foresty flavors, wet earth, humus, dark chocolate, herbal notes, butterscotch sweetness, and low acidity.
  • Ethiopia Fair Trade Organic DP Sidamo Shoye Union
    • City+ to Full City
    • Intense fruit, strawberry, brown sugar sweetness and cinnamon, aromatic wood, sweet caramel finish.
  • Brazil Joao de Campos Yellow Catuai
    • City+ to Full City+
    • Nicely balanced cup with caramel and chocolate roast tones, pungency, spice, and dark chocolate finish.
    • Versatile, great for espresso blends.
  • Sumatra Grade 1 Mandheling
    • Full City to Full City+
    • Very heavy body, complex earthy flavor.
    • This is a deep brooding, pungent, bass note coffee with dark chocolate undertone.
  • Guatemala Bourbon – Finca San Diego Buena Vista
    • City+ to Full City
    • Classic Guatemala cup, balanced between sweet and bittersweet.
    • Vanilla and caramel, citric zest, red apple finish, syrupy mouthfeel.
  • Kenya Nyeria Gathaithi Peaberry
    • City to City+
    • An interesting blend of “Kenya” characteristics:  bright citrus, zesty finish, winey dark fruits, and a touch of sweet Meyer lemon.
  • Rwanda Gkongoro Nyarusiza
    • City+ to Full City
    • A balanced and graceful cup with restrained acidity, sweet citrus, rose, tea-like flavors, floral brightness, medium body, dried orange peel.

Obviously your mileage may vary on what you get when you order.  More to come when I start roasting the beans and brewing.  Next up… observations on the Fresh Roast