Showing posts with label LCD. Show all posts
Showing posts with label LCD. Show all posts

Tuesday, October 20, 2015

A working dsPIC-EL

After deciding a long time ago that I wouldn't do a dsPIC-EL, nor an Elmer 166, I decided to do a dsPIC-EL, but the Elmer 166 is only kind of.

When I broke down and did the club thermometer project (http://elmer166.blogspot.com/2015/08/club-project-thermometer.html) I realized how straightforward a PCB can be.  OK, I am clumsy at it and it takes a few cycles, but the result is very satisfying.

The PIC24FV16KM202 used in the thermometer, and it's sister the PIC24FV32KA302 were something of a revalation.  The peripheral complement is absolutely breathtaking, and the peripheral pin select allows for a lot more flexibility than the dsPIC30F family.

I ran into to project where I wanted a little more speed, and tripped across the dsPIC33EV256GM102.  Astonishing!  70 MIPS, gobs of memory, PPS like the 24FV, and the family of dsPIC33EVxxGMyzz lets you select memory size, pin count, and network from a family of otherwise identical parts.

I started working on a dsPIC-EL board based on this part, and realized that the pinout was virtually identical to the PIC24FV series.  I could choose between dsPIC33EVxxGMx02, PIC24FV16KM202, and PIC24FVxxKAy02 parts by the simple addition of a jumper.



dsPIC-EL

From the work on the dsPIC30F board I recognized that Arduino-style header connectors were a worthwhile addition.  With the thermometer project I had also recognized that I could get proto boards custom made for less money and higher quality than I could buy already made. It was a short step to realizing that if I bought the long pin headers used by Arduino shields in quantity, I could have shields for under three bucks.

dsPIC-EL with proto shield fitted


Somewhere around this time I got roped into working with the high school electronics club.  The students early on expressed a strong interest in building stuff they could program.  This, of course, pushed me into moving along much quicker on the dsPIC-EL, and I can pretty much call it soup now.

Of course, I want to share this development, so all the work is on GitLab, but I have no interest in kitting the thing.  The good news is that the boards can be had quite cheaply, and there are really no hard parts (although some parts are a lot cheaper in quantity).  If all the parts were purchased in quantity one, I suspect it could be had for around the cost of a PIC-EL.  Buying things like connectors in quantity cuts the cost to less than half.  The main disadvantage to some of the large quantity parts is lead time.

The dsPIC33EV256GM102 is kind of pricey, but the 32K version without the CAN (which is unlikely to be needed) can be had for less than the price of a PIC24FV, which itself makes 16F and 18F parts look expensive.

So, the main features:
  • PIC with pins brought out to Arduino connectors for easy prototyping
  • Extra connector to allow ordinary perfboard to be used as a shield
  • LCD and buttons on the base board.  You always want these, and they have the annoying feature of needing to be on the "top" shield which really limits flexibility if they are on a shield.
  • All used pins jumpered so they can be used for prototyping without interference from on-board parts
  • A few LEDs thrown in for good measure
  • Power from a cell phone charger with an XH connector for batteries or some other external supply
  • PICkit connector for programming
  • Jumper to allow PIC24FV to be used

Schematic


I don't plan to do another Elmer 160 type class, but I will be guiding the high school club's members through learning the dsPIC, and I will be putting my materials on GitLab, so they will be available to anyone who is interested.  Rather than PDF prose, most will be PowerPoint (well, actually LibreOffice).  Of course, high school kids pick up things a lot quicker than us old hams, so the material will be quite a bit different.

The key repositories are:

The PCB including Gerbers.  The README for this repository includes the schematic and a red/blue image of the board.  The BOM in this repository also contains information on sources.
https://gitlab.com/33E-simple/dsPIC-EL-GM

The ProtoShield gerbers
https://gitlab.com/33E-simple/ProtoShield

An LCD library
https://gitlab.com/33EV-GM1/LCD.X

An I2C library
https://gitlab.com/33EV-GM1/I2C.X

Presentations (under development)
https://gitlab.com/33EV-GM1/dsPIC-presentations

Construction instructions (under development)
https://gitlab.com/E-WCC/dsPIC-EL_Build_Instructions

If you want to get boards made, simply upload the zip file containing the Gerbers to
http://makerstudio.cc/index.php?main_page=product_info&cPath=8&products_id=14
The price is around $16 for 10 boards including shipping.  Shipping seems to vary a bit, I assume based on exchange rates.  It takes about three weeks for the boards to reach the U.S.  I have also used Accutrace in cases where I want boards a little sooner (8 days).  Their price of $40 for 10 is quite a bit higher than MakerStudio, but not crazy, and their customer service is tops.  Their boards are a little higher quality than the Chinese boards, but you need to look really close to tell the difference.

Saturday, August 8, 2015

Club Project - Thermometer

Recently the local radio club needed something to spice things up, and the idea of a construction project based on a PIC seemed to be well received.  I came up with the idea of a PIC based thermometer, a little off the beaten path perhaps, but easily done.




An awful lot of PIC projects involve nothing more than an LCD and a sensor of some type.  Everyone has done some sort of test instrument; counters, capacitance meters, dip meters, signal generators, and on and on.  But a lot of the club members don't do a lot of building, and while a counter is kind of cool, it only appeals to the more technical members.

A thermometer, on the other hand, is something that everyone can get behind.  Perhaps you won't play with it for very long, but you will play with it.  You will hold the temperature sensor and watch it warm up, you might put it in the freezer, perhaps it will find a permanent home in the greenhouse.  But it is something everyone can at least play with, if only briefly.

I also wanted to try to inspire folks to pick up a soldering iron and perhaps grok a little code long after the build session.  A thermometer based on the Maxxim/Dallas DS1821 is dead simple, and as a totally digital solution requires no calibration, and the adventuresome could easily stick the sensor on the end of a long wire to put it in the garage, or in the garden, or wherever.

For similar reasons I chose the PIC24FV16KM202.  It has a lot of left over pins to tempt people to try other stuff, it has an amazing complement of peripherals to play with, and it is dirt cheap.

We milked the project for several months. First, I did a presentation on PICs in general, went on about how easy they are to use, how cheap, and how flexible they can be.  The next month another ham did a presentation on microprocessors in general, and the differences between microprocessors and microcontrollers.  Then I did presentations on the hardware and software for our build project.  Finally, on a Saturday, we all got together and melted solder.

We also did the project at the local high school radio club.  That was a lot shorter.  Kids of that age are like sponges when it comes to knowledge, and they were no virgins to electronics, so the whole process was a lot quicker!

We did a total of around 30 of these thermometers, only one didn't work when first powered up, and that was a cold solder joint dealt with in just a few minutes.  Not bad for a group that mostly had never held a soldering iron before.  I credit part of that to the very detailed construction instructions (see link below).

We have had some success with folks going out playing on their own.  Not as much as I would like to see, but something is better than nothing.

I had the boards made at Maker Studio.  They will make boards up to 10x10cm for a fixed price.  I filled the unused part of the board with prototyping area in an attempt to get people to try things.

The Circuit


 



Basically, the circuit is nothing more than a PIC, an LCD, and the temperature sensor.  In order to make it simple to get going in the build session, the project was powered by 3 AA batteries.  Because of this, the LCD backlight was not used, although the board provided a jumper to enable it, and a micro-USB connector to enable powering the project from a cell phone charger.  An LED was also provided to indicate the program was working, but also to provide experimenters with something else to play with.


In addition to the PIC, LCD and temperature sensor, the LCD requires a contrast pot, the LED a current limiting resistor, and the DS1821 a pull up resistor.  A reset button was added, along with a few caps.  The PIC24FV16KM202 requires a 10u cap because it is basically a 3 volt PIC running at 5 volts, and it is always good to sprinkle a bypass cap here and there.

The odd values on the resistors are simply because I had bought thousands of those values cheap, and they are in places where the actual value is horribly non-critical.

The PCB

The initial plan was to build the project on perfboard.  That way folks could get the idea that they could simply build whatever they wanted.  But eventually it was decided to do a printed circuit board.  Perfboards are pretty expensive, and if you are willing to wait a few weeks, a PCB can be real cheap.  Plus, it makes it harder for new builders to make errors, especially if the PCB is heavily silk screened.  Later I actually had custom perfboards made,  Turns out that one can get very high quality glass-epoxy boards exactly to your own specifications cheaper than crummy phenolic boards locally.



Of course, the PCB had to include a programming connector (left edge).  As mentioned before, a connector for a cell charger (right) and a simple, two-pin connector for the batteries which are mounted on the back.  The PIC's internal oscillator was used for the project, but pads for a crystal and the associated caps were provided in case the experimenter felt a need for crystal control.  The remainder of the board is filled with prototyping space.

The Software

The PIC is run at a low speed to maximize battery life, and mostly sleeps.  The watchdog timer wakes the PIC about once a minute to take a sample and then go back to sleep.  The PIC only draws microamps when sleeping, although much of that advantage is swamped by the LCD which draws significant current even without the backlight.

The LCD and DS1821 code was buried in libraries to make it easier to talk about the overall logic without getting buried in the details of the specific devices.



The Links

Other clubs might find this a useful project.  All of the source code, schematics, PCB layouts, Gerbers, presentations and the construction manual are all available on GitLab.

The presentations are in OpenOffice Impress format, although the repositories also contain a PDF version.  The construction manual was developed using Publican, but the final result is PDF.  The schematics and PCB were developed using the gEDA tools gschem and pcb.  The source is all MPLAB-X/xc16 code.

Monday, December 24, 2012

Older LCDs

After the previous post on LCDs, I was reminded that it only covered current displays.  Getting from there to here was, in some ways, something of an adventure.

It is probably worth mentioning that when I say LCD, I am speaking of LCD Character Display Modules.  There are other types of LCD displays, both more and less elaborate, but for 90% of hobbyist projects we use LCD Character Display Modules.

My first exposure to these was an interesting board from B. G. Micro that contained an Optrex 20434 20 character by 4 line display, and a PIC that served as a serial to parallel converter.  This was also part of my introduction to PICs, and may well have served to get me interested.

This display from a standard parts house would have been quite expensive, probably in the $50 neighborhood, but B.G. Micro deals in surplus, pulls and other goodies, so although it was a little expensive with the board, it wasn't horrible.  If I recall, it was in the $25 neighborhood, about what a 16 character LCD would have cost at the time from the typical parts house.

The Optrex had some interesting quirks which probably turned out to be a good thing as it prevented me from being blindsided by later, less obvious, quirks.  You see, most LCDs at the time had 128 bytes of memory for the display.   Line 1 started at address 0, and line 2 at address 64 in that memory.  The Optrex was a little odd in that line 3 started at address 20, and line 4 at address 84.   If you went past the line length, line 1 wrapped to line 3, and line 2 to line 4.  Perhaps more curious, line 4 wrapped back to line 1.

For a long time I pretty much only bought LCDs from B.G. Micro.  They had a beautiful, backlit, 40x1 which made a perfect display for a Morse code decoder.  This was one of my first major PIC projects.  The original code was from IK3OIL, but he used a 16 character display, and he left out a number of Morse characters.  For a long time, improving that code provided many hours of PIC programming experience.

This display had another annoying feature that provided a memorable lesson in LCDs.  It was what was called a "low temperature" LCD.  What that really means was something of a nasty surprise.  You see, LCDs have a contrast pin on which you provide a low voltage, usually through a pot, to control the contrast.  On these "low temperature" LCDs, that voltage has to be negative.  Normally you don't have negative voltages laying around on PIC projects, so this required another supply.  Fortunately, the current demads aren't severe, so a simple charge pump can often do the trick.  Not insurmountable, but certainly annoying.

Back then it was critical that a display had a Hitachi HD44780 controller.  Any other controller and the code was likely to be a problem.  The controller was almost always visible on the back of the LCD, so at a hamfest you could usually tell what you were getting.  More recently, the controllers are potted, so you can't see what they are, but HD44780 clones have gotten a lot better so it is no longer an issue.

B. G. Micro had a cheap 16-character LCD they called a "Medical LCD" as it was pulled from some piece of medical equipment.  They had a plastic bezel in an odd shape that could not be removed without destroying the display (although it could be filed down to something sensible), and the connection was a very obnoxious cable with 0.05" spacing, making it very hard to work with.  But they were cheap.  At the time they were $3.  It is a lot easier to experiment with a three buck part than a fifteen buck part, so they became the display to use for quick experiments.  Although the physical aspects of this display were annoying, it turns out the display itself was quite nice.  B.G. still occasionally has this display, and the most recent price was fifty cents!

When the original PIC-EL came out, it had an 8 character display, quite a nice display if somewhat limited in size.  The display was not backlit - the green color is due to a green reflective background behind the display.

The original PIC Elmer lessons worked within the confines of this 8 character display.  Although a lot of applications require more characters, the limited 8 character display wasn't too much of a problem for lessons, and it did provide an excuse to demonstrate techniques like scrolling.

Quite soon after the introduction of the PIC-EL, the 8 character display was replaced with a 16 character display.  While a lot more flexible, this turned out to be something of a problem.

You see, the Hitachi HD44780 controller could not display a 16 character line.  To go beyond 8 characters required the addition of an HD44100.  This was fairly expensive, although the "cheap" medical LCD contained this addition.  To get around this, many early 16 character displays were actually two line 8 character displays, with the two lines side by side.  This required some programming gymnastics, and of course, code that worked on these displays would not work with a "proper" 16 character display.

Later PIC-ELs had a backlit, 2 line by 16 character display which AA0ZZ was able to get at very attractive quantity prices.  These are quite a bit nicer, and in fact, almost all current LCDs avoid a lot of the quirks of the older displays. Prices have dropped quite a bit as well.  Backlit LCDs, which used to start in the $20 neighorhood, can now be found for around $10, even from the major suppliers.  Cheaper houses like B.G., Sparkfun, etc. often have some very interesting displays for half that.  White or blue backlights, which can look a lot nicer than the traditional yellow-green are often inexpensive and take quite a bit less current than the older displays as well.


Tuesday, December 18, 2012

Displays

For some time now I have had almost an obsession with LCD displays.  In the past, there was a wide range of displays with a wide range of prices, generally more characters being a little more expensive, backlit displays being very expensive.

The most common backlight was the sickly, yellow-green LED backlight, which not only looked bad, but tended to be a real current hog.  Electroluminescent backlights were available, but they tended to require unfortunate voltages; typically AC and somewhere in the 60 to 400 volt range, not generally what we have lying around on a microcontroller project.

More recently, white LED backlights which are far more efficient have become available.  And, they have become a lot less expensive.  It seems as if a white backlight is often available for close to the cost of a non-backlit display, and while a yellow-green backlight may take almost an amp, the white ones tend to be in the 20 mA neighborhood.

N8ERO picked up some Newhaven negative displays which show white letters on a blue background.  I had seen these before, or something similar, on some FDIM projects, and while they don't look as nice as their pictures, they do look a lot better than the ugly green.

LCDs exhibit two kinds of slow.  The processor on the LCD takes some time to do it's thing, so code either has to delay or read the LCD's busy signal.   Reading the busy signal is kind of a pain, so most hobbyist projects simply wait long enough.  The actual display itself is a chemical change, so compared to electronics, it is very slow.  A result of this is that there it rarely a real penalty for waiting far longer than necessary for the display's processor to do it's thing.

However, in experimenting with different displays, it appears that negative displays are slower, as are 3 volt displays.  In the case of the blue Newhaven display, part of this slowness results in some rather ugly brown artifacts when the display is changing.

I found a blue, positive Newhaven display that was very inexpensive, but 3 volts.  3 volts is pretty handy for PIC24, PIC32, or dsPIC33 projects, not so much for the more common 5 volt projects.  This display is quite small, something that is also sometimes nice.  LCDs tend to take a lot of the panel space, and depending on the project, having a 20x2 display in a small space is an advantage.  However, small also means that the connections to the part are different than most LCDs, and kind of a pain.





Well, with LEDs now available in umpteen colors, and plummeting in price, it couldn't be long before someone came up with a display with an RGB backlight.  I picked one up, the price, while a little high, wasn't crazy.    This display is, interestingly, a 3 to 5 volt display.  Unfortunately, the 3 volt part means it is slow, and the negative display, which looks a lot nicer, makes it even slower.  This is a pretty slick choice for projects that have a display that mostly isn't changing.

More recently, displays based on organic LEDs have become available.  OLEDs have the advantage of very nice contrast, high speed, and relatively low current compared to backlit displays.  This particular OLED display has both the traditional 4 or 8 bit parallel interface as well as a serial interface.  I have to say, I think this one is my favorite.  It is slightly thinner than the LCDs, and the display is extremely crisp.  And it doesn't exhibit any of the shadow artifacts that LCDs tend to show when they are changing.

The one downside is that it appears to require that you use the busy flag.  While this is annoying, especially when using the 4 bit interface, once the code is written and wrapped in a library, that detail becomes invisible.  It is a little more expensive than an LCD, but boy is it nice.