Arduino roaster controller with zero crossing dimmer

With all the time I’ve put into the Pic32 roaster I’ve always had this nagging worry that any of my sensors may have had damage during testing. When you try to get something working and keep getting gibberish you need to find a way to rule that out. As a result I decided to purchase an Arduino a few months back to confirm everything works. Turns out (so far) that everything IS actually working and I didn’t damage any sensors.  In the months I’ve been working with the Arduino I’ve actually learned a few reasons why some of the sensors didnt work on the PIC32 the way I had programmed them because learning to program an Arduino is sooooooooooooooooo much easier and better documented for “average people” to figure out compared to reading the hundreds of pages of technical manual for the PIC32 that isn’t ACTUALLY even finished being written yet.  There is a ton of code out there to test every single sensor I’ve purchased so far on Arduino. In addition I decided it would be a great way to start the dimmer using zero crossing detection in a system that runs outside the PIC32 before I convert it.

My intention is to get basic functions working on Arduino, then get the PIC to talk to the Arduino to send it commands to switch power by itself while the PIC reads all the sensors and logs data and then decides what to do as it comes from the Arduino.  Finally it will eventually be migrated entirely to PIC32 when I learn more about the interrupts on PIC32. At the moment I’ve put together a board that takes in 120VAC and uses Q4015L5 Triacs and MOC3052 drivers to control power to two receptacles. It reads the zero cross on my power using a H11AA1 and gets an interrupt used to trigger power switching. During my initial testing I confirmed the zero cross detection circuit worked and switching the triacs manually on or off worked without  regard to the zero cross state. It unfortunately didn’t seem to actually switch automatically for some reason when I wanted it to dim.  After a few days of testing I realized the Arduino Mega and the Uno had the interrupt timer pins in different places.

Since this is the first mains power circuit I’ve worked on I started running it with a variac out in the garage (and then fed that out into the driveway at the end of an extension cord…) and gradually turned the power up from 0 to 120VAC testing each section as I built it to ensure nothing arced or got hot or burnt up.  During late November I hooked it to the Arduino and got it to begin adjusting fan and heater under PC control as well as using two separate knobs.  Later in December and January I got it to begin logging to SD memory and following a programmed profile.  After that I added a bunch of additional environmental sensors and mounted it in a RadioShack project case.

 

First working prototype in Radioshack Project Case

I’m now at a stage where I’m looking to consolidate the various sensor cards either down onto a circuit board or attached to a set of pins directly.  I’ve grown tired of accidentally unplugging random wires carrying it back and forth from the garage to my office area and out to the kitchen stove / vent at various stages.  My hope is to shrink it down to a much less complicated arrangement being mostly on a single circuit board and interfaced by a few short cables to the Arduino.  It’s a bit complicated currently and getting worse.

Jumble of Arduino stuff

For the Arduino I’m using the MEGA 2560.  It is attached to the power control box pictured above via the DB25 cable.  At this time the box only controls power but I’ve mapped out pins on the DB25 to use for future boards to allow sensor breakout boards from a variety of DIY electronics companies to plug into them.   I’ll break this out to various header pins that match various breakout boards so they can be directly attached.  I’ll probably also design positions for eventually soldering chips directly to a board later once I order them when I’m further along and jumper the headers into those sections.  This will let me test a circuit on the board while still ensuring it actually works with the breakout board first.  The board will be designed to replace the items in the RadioShack box using SMD parts in some cases where cheaper and more convenient to shrink the board down smaller.  I hope to have it all shrunk down and consolidated to a single board with a DB25 connector to get to an Arduino I’ll be mounting inside an Arduino Crib case.

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.

Further shipping… I2C problems

So I received my new order with a few more sensors, memory sockets, and a new set of cables that were Female/Female. Not only did I have problems with the shipping involving the first order going to the wrong city and being REALLY slow…. THIS TIME I purposely switched to FedEx and bumped it to Next Day delivery because I was tired of waiting for things. My package “went walking in Memphis” or perhaps went on safari in the Jungle Room or something. Apparently FedEx had mechanical problems and as a result my package did not leave the Memphis hub until after the time it was already due to be delivered to my door in California. It was thus NOT next day.

Once I finally received it I figured I’d start off with attempting to read the real time clock chips I have using I2C. The PIC32 has built in hardware commands for accessing I2C so normally this shouldn’t be too difficult following the address strings and writing/reading according to the patterns required in the datasheet. This even further so since I managed to get it working on a PIC24 in the past so I’m not completely clueless in the I2C (or SPI or One Wire) world.

I tried a few things making adjustments and generally did not get anywhere. I’ve checked the voltage on the bus and I do indeed have 5 volts. At first I had only 4.8 volts due to the LCD backlight sucking most of the power off the USB port. I dug out the AC adapter I ordered and plugged it into the system and brought the power up the rest of the way and all was normal voltage wise. As I change the resistors and play with the speed of the bus I go from having NO responses to 0x00 responses to 0xFF responses… to 0x01 responses. ONCE I managed to get some numbers out of it that made absolutely no sense at all. They were returning things like 80 for the seconds and some 140 something for other things… 12 for others that should have been something else. It was just all over the place.

I don’t have an oscilloscope to try to look at anything closer and one of my co-workers said he had an old scope but no leads anymore. Since I knew I’d need to order some new leads if I borrowed his scope I started digging around to see what’s out there to see what I wanted to do. I have since that expedition ordered a logic analyzer that supposedly I can decode/time/process/log/graph/whatever all the various I2C channel data. I’m not entirely sure how exactly I do this still since documentation is a bit rough to come by properly on the internet the is explicitly involving I2C and the capabilities. It generally just mentions these things in passing and shows a screen shot.

In addition I run into a possible problem having Windows XP x64 bit and having had to host my PIC32 development work out of a virtualized XP 32 bit with USB pass through and trying to get some drivers installed so this should be fun.

I’m still waiting for the logic analyzer to ship. I ordered it on the 9th (here and at the seller’s location during their business day). The seller has updated the order status to “processing”. They indicate they typically ship within 1 to 3 business days. They are located in China so it’s “tomorrow” there now. It was ordered with UPS Worldwide Express delivery so it is SUPPOSED TO be “next day” delivery. I’m not sure how the next day works exactly in terms of time zones. Is it next day shippers time zone? Next day from calendar time/date between both of us? I just don’t know how that one works since I’ve only had the one package from Bulgaria and a couple more from Thailand in this project and neither was the spendy UPS.

I’m guessing if it ships “today” in China it will ship Thursday the 12th China time while it is still Wednesday the 11th here. It will then arrive to me Friday the 13th (sheesh) US time giving them about a day and a half for delivery. I could be entirely wrong though…. doubt it. I just don’t see how they could get something from China to Northern California that quickly. I mean they have what appears to be a 3 hour flight inside China to another airport and from there straight on to San Francisco for 12 hours. With time zone differences etc it appears that flights leaving there around 4 PM China time arrive in the US in San Francisco at 11:30 in the morning “the same day” Pacific Time. From there it would be a normal in the US “overnight” delivery. Actual flights are probably 4-8 hours later. It would catch a smaller flight to Sacramento overnight and then continuing onwards up to where I live for delivery the following day since they seem to fly UPS packages into the local airport whether it’s ground or next day air etc from Sacramento.

Guess we’ll see what happens. I’m guessing I’ll need to sign for it since it’s an international delivery. Everything I’ve gotten international so far required a signature. Other people I’ve talked to said the same things with their international deliveries. Perhaps there is some sort of rules saying someone needs to sign for stuff coming from out of the country. I won’t be here because they’ve quoted around 10am as their delivery time guarantee. I’ll have to sign for it and leave the “door hanger/sticky” for Monday I guess unless I can pick it up after work at the airport when I get the sticky at lunch time when I’m home.

More ordering

I have now ordered a series of parts from Mouser. This includes some lead free solder (ouch that stuff is expensive), flux, several different crystal oscillators and what I THINK to be matching capacitors, as well as a ton of headers for jumper cables. I entered a ticket for Microchip more than a week ago and have received no response whatsoever from them regarding the oscillator. Reading the instructions there was no mention of a type of crystal to use beyond 32khz. They mentioned 11pF capacitors of 0603 size. From what I can understand it SOUNDS LIKE in a properly designed board if you have a 6 or 7pF crystal you install an 11 to 14pF capacitor when it has short runs for the wiring etc. HOWEVER yesterday I found on the ethernet board they explicitly defined the crystal as a 12.5pF crystal. In my observations it appears that if you use 12.5pF crystals you should use 22-27pF capacitors, though.

The unfortunate problem is some people report using 11/12 capacitors with 12pF crystals and other report needing to use 27 etc. I’m thinking it MAY depend on the manufacturer of the crystal as to how sensitive it is and needing more or less power from the caps to be held up to trigger the oscillations of the crystals in addition to the variables of the individuals circuit layout. In other words some times it works no matter what and others it does not.

I still need to get some solder paste in addition to the rolled wire solder. I had issues identifying this on the Mouser website in the search except for a couple versions that had more than five tubes as a minimum. I do not have need for / ability to consume more than one syringe/tube right now so I need to find a vendor to procure some from that does one at a time. I stumbled across one a few nights ago that sells one at a time but I’ve not had time to dig through the browser history to find my way back there yet.

Once I have the solder paste and after the parts arrive mid week I can solder in the crystal and caps to see if they work for the timing functions and continue my efforts at programming the interface. Most of my programming is going to wrap around being able to gauge time changes happening so I need to wait for that to happen.

Currently I have a thermocouple breakout board that I will be attaching to some of the IO lines. I also have on order a relay board that has not arrived. Once the relay board arrives I can attach it to the development board and configure it to turn on the fan when the program run starts and not to turn it off until after the heat drops to a safe level. The heat will trigger on and off to maintain the desired ramp at this time. I will eventually replace it with a variable “dimmer” once I work out the other kinks in the system to give it finer control.

Early July Update. Observation on SR500.

Having been offered full time employment starting the middle of July after approximately 2 years of unemployment things are looking good for getting some progress on this project. LOL! While this may sound odd this is actually good due to the fact that I’m building (if all goes properly) a somewhat professional-esque coffee roasting computer. It takes a lot of money and resources to design this thing. I’m already into the project around $300-400 worth of circuit development kit gear and need a lot more stuff. In the end I’ll have a complete system that will be significantly cheaper to build but still have all the development kits to make other projects. I chose that route because of the “other projects” for down the road instead of only buying the things I need right now. While having full time employment will limit my available time it DOES however allow me money to keep purchasing all the parts.

Most projects you find on the internet for a coffee roaster use something like a Basic Stamp or some other very limited processor. It also usually involves hooking together a few things someone finds off eBay hooked together with some various wires and connectors salvaged off some old computer equipment and other devices abandoned in the garage. By the time it’s done you get a picture on the internet of some “finished” popcorn popper that looks like it’s about 30 seconds from taking out a corner of your house into a huge crater or like it’s some sort of industrial wiring project of conduit and electrical boxes.

I’m intending on making this thing as small as I can make it and sealing it up inside a electronics case with a single cord or perhaps a cord and a sensor wire that plugs into the back of the case that leads to the roaster. I don’t want 50 million little cords and sensors and clunky switches and other doo-dads spread across my counter. I also want to be able to pick the whole thing up and move it somewhere else without accidentally cracking off a wire and needing to re-solder it. I don’t know about you but I love my coffee. I don’t love having to re-solder the wiring just to roast some more or being unable to use my kitchen for anything else.

My Kitchen is not that big. It cannot accommodate a lot of “stuff” strewn around it. so the entire thing will need to be compact. As a result I intend on having a case that has a LCD touch screen installed. It will probably have a LED or two and at most probably a single power switch on the front edge or side. I will likely try to design the circuitry so that it fits onto one or more circuit boards stacked on top of one another. The LCD will be mounted on top with various connectors and other items stacked below it. I’m reasonably sure I can shrink the majority of this down into a space about 4″ by 6″ and about 1.5 to 2″ tall.

As mentioned I recently purchased the PIC32 development gear. At the moment I’ve been working on the GUI. This is a lot more complicated programming than I’m used to. Additionally I’m having a few “weird” situations where LED’s on the starter kit are lit that I don’t seem to understand why. When I turn on an LED that is normally off things work fine but then when I programmatically turn that one off the LCD turns off too though they shouldn’t be connected at all. The other LED works fine turning it on and off the same way. One of these LEDs simply stays on all the time no matter what.

At the moment I now have a “splash screen” functioning. I touch the screen and it continues to a “Home” menu. From there it offers several buttons to run the manual or the automatic roasting menu. There is also a provision for a Setup menu. I am still waiting for the ethernet to arrive that will allow me to download roasting data out of the system or pre-configure a roast from a web page. It currently draws temperature onto the screen from some “made up numbers” I have the thermocouple and the chip that will convert the sensor reading to numbers but need to solder it to a board that I can connect to the processor. I also need to do the same with the clock chip that I have as well. The processor has built in clock routines but they only work while the system is turned on. As soon as you cut power that clock loses it’s data. As a result I will program the system to read the clock chip every time the system turns on.

Over the next few days I will program the roasting screens to change certain display areas based on the simulated temperature numbers and then integrate the “control” portion where it then stops the increase in temperature and then tries to increase it appropriately. I still need to figure out the timer stuff… it doesnt seem to run on the demo and I was thinking it had to do with an oscillator being missing but this seems to be related to USB stuff in the documentation for the starter kit. This doesnt seem right though. I need to figure that out and then the next step is to start ordering all the pin headers and not included on some of the other boards. I’ll try to figure out a few more of the parts that I’ll need and order those in the next few days as well so I can keep working on this. Assuming I’m right that the crystal is required apparently Microchip decided to save 83 cents by not including the oscillator.

Also as a side note. Due to the job offer I completed a move to Northern California from Central California which has kept me from messing with the coffee much until now. A variety of coffee that I roasted here with the Fresh Roast +8 took approximately 6 minutes to hit second crack. Using a SR500 where I used to live took about 6 minutes as well while running the fan at half speed for the first two minutes. To do the same thing here with the SR500 appears to take around 7-8 minutes with a lot more slowing down the fan to around the 25% setting once movement starts to flow more easily and first crack was reached.

Pic32 Starter Kit USB 2

As mentioned there was a problem getting the main “brain” for the development kit. It was on “backorder” to June 28th and supposed to arrive on the 30th. While watching the website I saw the date slowly tick longer day by day. Eventually I got an email that said the date was going to change. It claimed the new delivery date was going to be July 30th to ship. I watched the date and it continued to tick forward only one day at a time even though they told me via email that it was due on the 30th of July to ship. I wrote an email complaining. They indicate on the website that they will respond to questions (I was seeking a ship date clarification due to the website saying one thing and the email yet another) within 24 business hours. Assuming they have 8 hour days this would be 3 business days. No response came so I watched the live sales chat which showed for almost a week with nobody available.

Finally one day there was a person online and I asked them. They said that their scheduling people said that the 30th was the best date they had and agreed that the info on the website was problematic that it didnt agree with what I was being told and would mention it to a manager. I seriously doubt that ever occurred but whatever.

I’m currently moving and the day I got unloaded a notice came in the email about a change of status on the Starter Kit. It indicated that the order had been shipped on the 30th. The package is due to arrive today according to FedEx. This leaves the ethernet circuit board to ship. It claimed the same 30th of July delivery date in a previous email so who knows when that will arrive. The website continues to click forward day by day not matching what I was told.

I still need to finish setting up the office area where I will be programming the development kit from so it will be a few days before I start work on the user interface.

Parts received some not…

As mentioned some of the items had later ship dates than others. As of June 16th I have received the IO board, the prototype boards, the LCD graphics w/LCD kit, and a power supply.

In addition to the development kit I have on order a few engineering samples for a few parts to test out before I pick vendors to program things based on and start purchasing real parts. These engineering samples will be mounted on “prototyping” boards that will either be custom built or ordered off the internet pre-made. Occasionally chips are used in a variety of ways so I will simply build a board to solder them down to and install pin headers to attach to on the board. These will also serve as “test” printed circuit boards as I learn to make boards on my own.

The ones I have received so far are a chip that has a real time clock/calendar in it and a chip that reads temperatures from a thermocouple probe. I still have requests out for a few ambient air temperature sensors and a few other things that will be used in additional projects that will eventually connect to/from the roaster computer.

The surprising part is that the clock chip is more or less around the size I expected (about guy little/pinky finger nail sized) BUT that the temperature chip is significantly smaller than I expected. It’s REALLY small. It’s so small that you could literally put at LEAST 16 of them on top of a single computer laptop keyboard key.

I am still waiting for the “brain” starter kit to arrive. This is where things get funky. When I ordered it the availability date for it and the ethernet card were listed as June 28th with an estimated delivery date of June 30th. This is good because I’ve got some free time from then until the middle of July so that arrival date was going to be good to let me work on things some. Today, though, I get this email. It now says that the ship date is changed to July 30th. My online invoice still shows the ship date as June 28th. The microchipdirect.com website says the availability date is July 2nd. So I’m thinking my chances of seeing this anytime soon are completely random and probably not likely.

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.

Building a roast controller system.

As alluded to earlier in the blog I am intending on building a roaster controller system.  I’m probably a bit of an over-achiever in terms of my projects because every time I create something on the internet for one of my websites, as part of a building project in the yard, or whatever else I’m creating I always over-analyze it.  In my career one of the areas I’ve been responsible for was “Disaster Recovery” planning for computer systems.  In other words my job was to over-analyze all the things that could go wrong and figure out a plan to deal with them.  At the same time I also have to plan all the ways for it to go right and have a plan so anyone can do it even without strong computer skills.

Focusing on a roast controller as mentioned I’ve already purchased some testing equipment for measuring temperature using a K type thermocouple. I am now finalizing the equipment that I’m going to use to build this and test it.  I’ve focused on using the PIC32 microprocessor due to its abilities to work easily with Ethernet, LCDs, and having many input/output circuits.  In addition it seems to be a robust platform for RTOS systems allowing a lot to be going on all at the same time.

To ease development I am choosing to embrace the development tools provided by the manufacturer.  This of course adds to the startup cost of the system but allows me to “try new things” in the future too using the development platform.  Once I finalize the project I would then order the individual components and manufacture my own circuit boards.  To start off I expect to need the following.

The Starting Parts

  1. DM320003-2 – PIC32 USB Starter Kit II – $55.00

    • Main processor (MCU) test board.
    • Contains PIC32MX795F512L processor.
    • 80 MHz with 512K Flash, 128K RAM. (this is actually a lot for a simple coffee roaster but is necessary for drawing graphical LCD, developing complex roasting profiles, and loading Ethernet overhead.)
    • Allows USB, Ethernet, LCD, I2C and SPI communications. 
  2. DM320002 – PIC32 I/O Expansion Board – $72.00

    • Connector to access pins and interface auxiliary boards.
  3. AC164132 – Fast 100Mbps Ethernet PICtail Plus Daughter Board –$49.99

    • Physical wired ethernet board for interface to DM320002.
  4. AC164126 – Prototype PICtail Plus Daughter Board – $20.00
    • Prototype boards to solder additional parts and extensions such as temperature probe chips, time devices, relays, etc.
  5. AC164127-3 – Graphics PICtail Plus Daughter Board with 3.2 Display Kit – $154.99

    • SSD1926 Graphics chip (kind of like a video card)
    • 3.2 QVGA (240X320) TFT LCD with 18-bit parallel RGB interface
    • Touch Screen

The Later Parts

The above parts allow me to start testing User Interface functionality without worrying too much about the circuit boards except for the occasional prototype board communicating with a sensor or two.  I’m doing that to determine the final touch screen configuration and “what is possible” on the screen real estate to determine if I want to pursue additional sensors and features.  It will also allow me to begin testing response time of various sensors on the prototype boards.  Some parts I expect to need:

  1. MAX6676 Thermocouple Amplifier
  2. DS3232 Real Time Clock
  3. Lots of resistors
  4. Lots of capcitors
  5. Various Transistors
  6. Lots of diodes
  7. Photosensitive PCBs
  8. PCB etch Chemicals and developer
  9. SMD soldering and hot air rework station
  10. Infrared circuit board pre-heater station
  11. Small Drill Press w/ bits for drilling PCBs
  12. Oscilloscope for dimmer testing
  13. Several relays and/or some dimmer circuits that need to be designed still.
  14. Probably a video camera at some point to demonstrate progress/results.