Archive for Micro controller

A PIC based temperature controller for laminator – Part 3.

Posted in PCB Manufacturer, PIC Micro with tags , , , , , , on July 6, 2011 by Karel M

If you have followed along, I am making a custom temperature controller for a Scotch TL 901 laminator. I have designed and ordered a main control board based on a Microchip PIC24 microcontroller, as well as, a display board with 3 seven segment displays and 3 buttons to act as the user interface.

The first function I wanted to get working was the display. My reason for this was a working display would help with troubleshooting everything else by allowing me to display error codes and variable values.  The first thing I tried was simply selecting a digit and trying to set the pin outputs to display a zero. At first, It seemed that everything was going well, but when I tried multiplexing in the other 2 digits, I started getting weird issues like the display would flicker or be very dim.

It took some checking with an oscilloscope, but I found that the 3.3V supply would cut out when the 7seg display was powered on.  It ended up that the input bypass capacitor wasn’t large enough and the regulator would drop out.  I fixed the problem by adding a large electrolytic capacitor to the bottom of the PCB at the 3.3V regulator inputs.  I used a 470uF cap, but anything in that range will work fine.  Now the 3.3V supply is solid the rest of the functionality can be tested.

Soldered next to 3.3V Reg, with hot glue to keep it in place.

After fixing the power supply, I finished the led display multiplexing, which is handled by an interrupt from a timer. The interrupt very quickly blanks all the digits, then sets the outputs to the next digits value, before enabling the next digit. The blanking is required because the leds respond so quickly that changing whats being displayed while changing the digit to be displayed causes the display to flicker with incorrect values.  The interrupt routine gets the values to be displayed from an array that gets updated in the main code. This keeps the interrupt short and fast, allowing the main program to make changes when it needs, without having to be concerned with display timings.

Here is what the display look like mounted in the laminator:

Display Installed in laminator

The control board installed in the PCB, the wires will be cleaned up later. The board fits very well.

Control Board Installed

Once the display was working, I decided to tackle the temperature measurement.  My goal was to use the PIC24 CTMU with the A/D to read the temperature from the sensors that came with the laminator.  There are 2 sensors that need measured. The first is in direct contact with the roller, the second is attached to the aluminum housing that holds the heating element.  The second sensor could be important because the heater will heat up much faster than the roller, and the roller might overheat.  The basic idea for measuring the temperature is based on a diodes voltage drop changing with temperature. There is a lot of good info on the internet so I won’t go into detail(look up band gap voltage), but just know that for a silicon diode the voltage drops about 2mV for each degree C rise in temperature.

I had a lot of issues getting the CTMU/AD providing a correct value. I found that what I was trying to do was very possible but it’s better to take it one small step at a time.  I was trying to get the PIC24 to automatically take a sample and convert 16 times, then trigger an interrupt because the A/D buffer was full. I was then going to average the samples to give better noise immunity.  What I should have done is try to take one sample manually to get the circuit working right.

I ended up working through the issues with a multimeter and the 7seg display for debugging. There was lots of reading of the PIC data sheet and the PIC24 family reference manual.  The biggest issue was little code errors, like forgetting to actually turn on the A/D interrupt. The PIC24 hardware worked very well once I had it setup right. Don’t forget to double-check every bit of code step by step when you run into odd problems. More than likely it’s not the hardware, but the code that is to fault. However, do make sure to check the errata document for the device too, sometimes there are hardware issues that could be causing problems.

Once I was able to get reliable data, I quickly found that the 2 temperature sensors didn’t seem to behave quite the same. There was no number on them so it was impossible to look up a datasheet.  After experimenting with them, I concluded that is would just be easier to replace them.  Both sensors were replaced with a very common 1N914/1N4148 diode.  This made the results line up very well and allowed the temperature measurement routine to progress quickly. The diodes with the 10bit PIC AD provide about 2-3 degrees of temperature resolution. This should provide enough accuracy to allow for good control of the laminator. The accuracy could be improved by going to a PIC with a 12bit A/D or using a separate lower voltage for A/D Vref. For this project the standard 10Bit A/D and 3.3V Vref will do fine.  The only issue is that the sensor will need to be calibrated once at room temperature. I plan on adding a calibration routine to the code to make this very easy, but that will be done later.

With the led display working and the temperature measurement working reliably, I decided to get the buttons setup, and allow the setting of desired temperature. With the PIC24s abundance of timers and having plenty to spare in this project, I decided to use one to help make a simple but reliable button debounce function.  Every millisecond or so the buttons are read and a count incremented for each pressed button. If a button is released the count is reset. When the count passes a threshold a flag gets set, letting the rest of the program know the button is active.  The main code never reads the buttons directly, but only checks the status flags that are controlled by the interrupt.  The only thing that makes troubleshooting difficult is one button being shared with the programmer.  The programmer must be disconnected to use the button. This was a trade-off of using a lower pin count part.  With the button status now available to the main program, it will be possible to finish the user interface and actually try to set and control the temperature of the laminator. Stay tuned for part 4, the finished project.


A PIC based temperature controller for laminator – Part 2.

Posted in PCB Manufacturer, PIC Micro, Uncategorized with tags , , , , , , on July 6, 2011 by Karel M

During my last post I started working on a custom temperature controller for a Scotch TL 901 Laminator.  I have finished the control PCB schematic and layout. Here is what the final PCB looks like.

Blank Controller Board

Next, I removed the stock temp control PCB and did a test fit of the new board to make sure the mounting holes lined up, and there was enough clearance. Everything looked good so it was time to install the components on the board.  There is a lot of surface mount components used to save space, but the packages are all easy to work with. It just takes a bit of practice.

Now that the main controller board is built ,  its time to work on the PCB that will hold the three 7segment displays and 3 buttons that will make up the user interface.  Here is what I came up with:

Laminator Display Schematic

On the left is the header to connect to the main control board, along the bottom there are 3 buttons for user input, and finally along the top the 3 seven segment displays.

The three 7 segment displays are a LSD3021 common anode unit.  Any common anode with the correct pin out should work. If it is not a red display, the current limiting resistors will need to be changed because of the different voltage drop for each color of led.  Make sure to keep the current around 10-15 mA maximum per LED. All the same segments are tied together, then go through a 100 Ohm resistor before going to the header which connects to a PIC Micro IO pin.  To control each display separately, a P channel MOSFET is used to the Common Anode connections for each digit. The MOSFETs are required because each digit will draw about 80mA when showing the number 8, this is a lot more than an IO pin can provide. The digits will be multiplexed inside an interrupt routine to provide the final 3 digit output.

The three buttons are normally open momentary push buttons from Electronic Goldmine, but any similar switch will work just fine. The pull up resistors are located on the main PCB instead of the display board. This is done in case the connecting cable gets broken or disconnected so the pull up resistors will still hold the button inputs in the default state.

Overall the display board is pretty simple and designed so it could be used in many other applications that need a very readable numerical display. It will work well with a 5v microcontroller as well, but current limiting resistors might need to be changed.

Here is what the blank display board looks like.

Blank Display Board

In the next post I will start to write code and try out the functionality of the circuit.

A PIC based temperature controller for laminator.

Posted in PCB Manufacturer, PIC Micro with tags , , , , , , on January 29, 2011 by Karel M

Please bear with me as this is my first blog and there will be a bit of a learning curve.

So I have made PCBs at home now for a few months using the toner transfer method and get decent results but there is room for improvement. The main issue I have is not getting consistent transfer from the paper to the PCB and I believe it’s because my laminator, a Scotch TL 901, doesn’t run hot enough to melt and fuse the toner well to the PCB.

I’ve decided to gut the control electronics out of the laminator and build my own PIC based control board that will allow variable temperature selection and display the current temperature of the laminator.  Here is what the laminator looks like new and unmodified.

It’s a basic model that is inexpensive and works fairly well. Taking it apart just involves removing the screws from the bottom. Once it’s apart is nice to see just how simple the design is. On the left there is a small synchronous motor, on the right there is the stock control board that is surprisingly small, and touching one of the rollers there is a diode that used as a temperature sensor.

The most difficult part of this project will be creating a controller board and display that will fit into the limited space. I measured that there is 1.6 x 2.8 inches of space that should be usable for the control board. I plan on doing a custom PCB for the controller and a separate board that will contain the three 7 segment displays that will show the temperature.

Here is the schematic I came up with for the control board:

The rough parts list will be:

  • PIC24F08KA101 as the brains, has enough pins and I already have a few.
  • SPX1117M3-L-3-3 Low drop out 3.3V reg
  • BTA06-600SW Triac to drive the heating element. I already have some and they are rated well enough.
  • Digikey 567-1025-5-ND – a small PCB mount xformer. Anything very small and ~6-9V AC should be fine
  • 3 x seven segment displays. Could maybe use a LCD but the LEDs will be easier to read I think.
  • Diode for temp sensor, plan on reusing the current one from the laminator.
  • various caps, resistors and other small components.

The PIC24F08KA101 has way more power than is needed for this application but they are not expensive at just over $2.50 each and the PIC24 from Microchip are very nice to work with. I’m using a DIP package since that’s that I have on hand but the surface mount version would have saved some space.  The voltage regulator is a low cost SMD part that will save space on the board and provide plenty of power for the PIC and LEDs.

Here is what I have so far for the layout:

You can see the 20 pin PIC, 6PIN opto-isolator for driving the triac, the triac itself, the 20 pin header that will connect to the display board, the 6 pin programming header, and the large area that the transformer will occupy, as well as the two mounting holes. Overall I think it’s a pretty compact design that should bolt right in where the old control board was located. I will provide the layout for download once it has been finalized. Part 2 will be creating the display board.