Click here for part 2.
Normally I don't write posts and blogs so bare with me, this is new territory for me.
I have somewhat of a scatterbrain when it comes to projects and ideas. Before I can finish the first one, I usually come up with a million more and before you know it, I have more than I can handle. One of my projects involve an entire Home Automation system completely DIY to be able to handle things like security, lighting, general comfort and awareness and even the HVAC with Environmental monitoring. Why? Cause I can. So please spare me the trolling later.
This is where this sub project comes in. I have done quite a bit of research and had parameters I decided on for the design of a touch interface that will handle the Environmental monitoring via other sensors throughout the home, HVAC control, and other things with hopefully a well laid out GUI that I have yet to design(poor graphics artist, I'm a technical person.) all using ip and designated cheap switches powered with a Linux Server using MQTT (have not implemented yet, just data gathered thru research, this was what I wanted to tie everything together with.) The screen I wanted to be a decent size, so I looked up eBay and purchased this screen with resistive touch.
So it came with a 40 pin Interface along with 2 8 pin interfaces, one to access the MicroSD on the board and the other to access the Font Chip and the Flash Memory chip. Mind you, the chips aren't on the board, had I known ahead of time, I'd have ordered the chips and they'd have been mounted for me. No big deal, I now have the chips just a matter of soldering them to the boards. They have ribbon cable connections which I like for this application better than the pin headers as it allows for maneuvering the screen when I need to service or upgrade the firmware I'll be writing for it. Now what I'll use the Flash Memory for, as of right now, I have no idea but I've incorporated it into my design so I have access for it when i do decide what I'll do with it. Originally I decided upon using an Arduino Mega to drive the board but after some research on screen driving speed with other similar screens, I decided on the Arduino Due instead due to it's faster speed and 32bit ARM Processor.
The pinouts for this screen left existing shields out of the question and the libraries and code I've found for other screen driving firmware all want to use the 16 bit display mode which might have been ok for my project but I like to take it to it's fullest potential. Besides others might like this idea and take it to the next level if it works out. So my final decision was to drive it using the screens 8080 interfacing scheme using 24 bit parallel which will give me full access to the color range instead of 5/5/6 or however 16 bit splits it up. So using the ribbon cable, interfacing to this particular board, using my Due meant one thing a custom shield made by myself is in order. Of course, if I decide to build something I want to go all out. So upgraded my Eagle program which I think now after the fact was an unnecessary step, decided upon what functionality I wanted to add to my board on top of this screen and purchased all components I would need. One arm, one leg, 3 weeks of fustration and cold before finally sending off to OSH Park for a PCB and behold:
Just got to wait for it to come back. I ended up using every digital pin + 1 Analog pin as digital(non essential, I think it was just for the Write Protect line for the MicroSD) So this shield will interface to my LCD using the ribbon cable with the connectors I got from the supplier, has full access using the MicroSD in Full SD mode, not SPI. Has full access to the Font chip and the Flash Memory, Threw in the buzzer, cause I want some audible interaction when this screen is doing what I want it to. RJ45 Ethernet connection along with an ENC28J60 Ethernet controller, a MAC Address EEPROM on the I2C bus and PoE using the AG9812M module. Also with 5 status LEDs in the center, Power, UART RX and TX, Ethernet Link and Activity, and the Back-light on/off for the LCD. I even made sure to put a reset button on the shield as obviously the original would be unreachable. And some other passives and goodstuffs to make it all work. I'm excited to see it work, just as long as I didn't overlook something that I might have needed to make the shield work and have to start over. I decided on PoE cause when I did install this, I don't want to run 2 cables to it just to turn it on, I wanted to use the one and power the device of the same cable. Full credit for some of the ideas going into this, would be SmartHouseTV that I watched on Youtube. Now the beauty about the Due's processor chip is the fact that it is 32bit and it's PIO are 32 bit. I needed 24 data pins so after looking at the Pin Mapping, Port C turned out to be the best match so after I had my pin mapping for my data, I came up with a mask to manipulate only those pins with ODSR and a routine that will take a 24 bit value and convert it to the 32 bit parameter needed for ODSR to ensure all 24 bits went to their respective pins. As my shield isn't back yet of course, I'm limited on my testing. However before I ordered the board, I made sure I would be able to use this method like I'm wanting. For visual feedback, I used 24 LEDs on a breadboard to ensure that whatever value I passed to my functions would turn on those pins showing the data on the LEDS. That was the first step. It worked. Next I wanted to get a preliminary idea of how long it would take for the Due to update the screen's 800x480 pixels using these routines. However I'm limited what I can do, and just tested a single value, both pre-converted to the 32bit parameter and having to be passed thru. pre-converted and using the conversion routine both show 68,671 microseconds(68.671 milliseconds) Mind you, I could have sworn the other day the values were different and that the pre-converted was slightly faster but eh. These are just rough tests to give me a ballpark of what I'm looking at. I'm sure there is going to be a little more of a delay, this was just turning the pins on in a nested for loop for 480 and 800 to simulate writing 800x480 pixels. Did not include clocking the pulses to the LCD, I'll get those tests after I build the shield and start coding the interfacing to the screen then i can do actual tests to post better results.
Before anyone asks about the UART RX and TX status LEDs, I just incorporated a "hack" I read on the internet and tested using a scope on the RX and TX lines noticing them sinking current when the board is transmitting or receiving. In theory it should work but I won't be able to confirm that until I build the board. I say this because when looking up this topic it was difficult for me to find an exact answer as to wether this was possible or not. The Ethernet layout was based off some other Ethernet designs that used the ENC chip and the PoE passives came off it's datasheet.
As long as my feedback isn't terribly too bad, I'll post more updates as I work on this project. And if anybody has any idea what I should use the Flash Memory Chip for, please let me know The Screens graphics I intend to make use of the MicroSD to store it's data Another note on the Arduino libraries. I have a personal programming background. I have programmed since I was kid so it comes natural to me so quite often, if the libraries don't suite me for what I need, I'll end up writing the code to do what I want. I'm so excited, can't wait for my board to come back so I can build it and move to the next step. Wish me luck
PS thank you Ben Heck Show for inspiring alot of my ideas. It keeps me active
UPDATE: #1
Boards came in today.
Isn't she a beauty. Not sure if my luck is just that bad or I'm horrible at soldering. All the years I've wielded a soldering iron, 1 chip specifically proved to be a nightmare. The Ethernet chip had a fine pin pitch, which I was aware of, just wasn't prepared to attempt to hand solder it to the board. Good thing the Osh Park sends you three boards, cause it took three boards to get that little bugger soldered properly without painfully having to remove the bridges and destroying the board. Everything else went on like a treat though. Turns out I was in so much of a rush however to get the boards made, I ended up making 3 layout mistakes all being component clearances. The large cap intruded on the PoE but I was able to still solder it to the board, a little offset. and the 2 8 pin ZIFs. I should've added the outline to the footprint when I created the component in the library so I could've adjusted the clearance on the board. One of them I was able to solder and might be able to use, I'm going to have to be careful. The other, I couldn't even solder to the board as you will see below, due to the other connector and the MAC eeprom.
Anyhow, BEHOLD!
100% hand soldered, spent about 8 hours, taking breaks, curing a persistent migraine and eating in between ready to be plugged in and programmed. I'm so excited. I'll have to figure an alternative ZIF connector that will fit on the board of course, that one is for my microSD card reader that's mounted on the lcd. It's going to be on hold anyways.... Turns out the SD Association is very secretive and wants you to buy a license to use the 4 bit parallel SD protocol. Wish I'd have known that before I laid out my board... Hindsight, I'll figure something out.
After plugging her in, no smoke or explosions so far so good. Still got a long way to go on the firmware, but so far I know this much. The Power, TX and RX Status LEDs, the Piezo, the MAC chip, and the reset switch I know work. Just gotta program the rest of the components in and get them working, I'll be able to post some videos I hope. Until next time
Update: #2
Due to some unforeseen problems and me rushing to get the board made, I had to make some revisions to the board and am currently waiting for a new board. Such as life, I can still code the firmware carefully with this board until the new one comes in and I'll assemble it. I tell you the things you learn. You definitely can't beat it. Some of the changes include, adjusting the ribbon connectors so there is no conflict with other components, moved the capacitors over to give the PoE module the proper clearance, added reverse diode and transistor with resistor to the Piezo as the datasheet suggested, changed the routing layout for the microSD to use the SPI instead of the SD parallel as I originally planned to do because of the SD Association's "Illuminati" society they have going on and for the main reason I decided to redo the board, I flipped the pins around on the 24bit bus running to the LCD control ribbon. Originally, and as anal as I am about things have absolutely no idea why I done it this way, I had wired the bus 0:23 to the PIO C 32:0 (spreading the 24 bus to available pins on the DUE using a function in the firmware) basically in that order so the data bus was in reverse of the pins pushing the data out of the micro. Mind you this is still doable however it would mean that I would have to write the pins individually in software or completely reverse the data I sent to the PIO, not happenin, or re-save all commands, files, and any data I needed to pass in reverse in advance, dumb and cumbersome. needless to say, I have reversed the pin layout on the board to now reflect 23:0 on the lcd data bus to the 32:0 PIO C. Alot less processing overhead and headache.
Update: #3
Just a quick update so this topic doesn't seem stale. Also hope by just editing, those who follow are still seeing when I update this blog. Boards V2.0 came in last Thursday and I had a therapeutic Friday night soldering the components on to the new board. I'm still missing a few components but I manage to get my Ethernet working so I played with it a little this weekend. A tip for those who are walking the same path I am and are hard at work designing their first major board or any project for that matter. Always check, double check, triple check and after you go thru all of that check all steps again. Trust me, if you don't, just cause you think you got it right, I guarantee you goofed somewhere. Prime example. I'm waiting on new components right now, that being a new 40 pin connector and I have FFC cables coming for all 3. I already have the FFC cables for this, however when I wired up the pins for the connector, I followed the pinout on the screen side as reference. and the way the cables and connectors are laid out, I should have reverse them on my board side. Well I did not, so now I have cables that are inverted to compensate so I don't have to send off for a new board. Small things like that will be a major headache for you and can potentially be a greater cost if you damage the components involved. If anyone can get any helpful information from this blog, hopefully at the very least they get that. It can save you frustration in the end. Anyhow, now I'm on break until the new connector and the FFC cables come in before I can test the screen (and make sure I didn't fry it. It was plugged in for some time while I was pulling hair out trying to figure out why I couldn't get it to come on before something told me to double check my pinout on the screen and follow the ribbon down to my board and cross check the boards pinout.)
It does communicate with the network ok and even served up a webpage that messed with my nephew when I had him pull up it's IP on his phone. That was a great thing to see it working on this board, the first board, I could not get it to work. Once I get the new connector and solder it on the board, I'll provide and updated pic and hopefully some pics of the screen in action. So excited. To this point, my current Firmware code which should have a barebone class for the screen, pinouts, functions for the miscellaneous functions on my board, and the IP stack and library for the Ethernet just takes up 7% of the Due. I think I have more than enough program memory to add more advanced functions to the screen, code for the touch screen, the sd card interface, the font chip and the flash chip.
Another future goal on this project would be to design a 3d printed case to mount this thing in. Something else, I'm trying to figure out how to procure. Been wanting a 3D printer so bad, but can't afford one at the moment. Once I finally get one, I'll be working on an enclosure to encase this thing in.
Back on track so, it might be a few weeks before the parts I'm waiting on come in, so hopefully after they do, probably the following weekend, I'll provide another update and work on the framework for the screen then a UI to work with it and tie everything together so it fits the final outcome that is the title of this blog. The end goal of this of course is to work over a closed network with a Linux server at the heart that this screen will communicate with along with other sensors, relays, actuators and switches communicate with to become a home automation system of my liking, this part of course being responsible for displaying environmental sensor data from throughout the house, allowing user interaction and substituting the thermostat providing better environmental control around the house.
-------------------------------------------------------------------------
I've still got a long way to go, but I wanted to get some photos up real quick. my cables and the other connector came in, so I was able to finish the soldering portion of my board and now, it should be all firmware. So far, the full screen interfacing code works beautifully and I have a few basic screen functions, it can fill the screen in any 24 bit color and by proxy, any pixel for that matter, select any portion of the screen to manipulate, and can draw 32x32 sprites with scaling. Not % scaling but multiplied whole numbers. EG the smiley is x5 scale for a 160x160 sprite. By the way, this picture doesn't do it justice. It's actually bouncing off the corners of the screen moving back and forth. It has a little flickering due to this is just a micro but it still seems to move it fairly fast. the Screen fill is completed in under a second. Don't know how much can't measure it. But it is enough you can see the color quickly wipe down.The sprite I have to delay about 150 milliseconds to give it enough time to actually display the graphic to the human eye. A few animation tricks to give it a good speed without sacrificing quality due to flickering. Even though it may not look like much, but believe me it was a milestone for me. Of course I still have alot to do for the code for the screen. Need to add more graphic functions and such and make it more versatile. Hoping to be able to add some Alpha blending as well as I am also able to retrieve the data I would have at any given point on the screen.
Still to be done, I need to get the SD library loaded in and get the code up and working to access it. I have quite a few 800x480 photos I want to load into it. I need to work on the code for the Flash chip and the Font chip, work on the Touch panel code, and do some more work on the Ethernet. It works beautifully, but for what communication over the network I intend this device to do in the end, I still need to write the code for that. Right now, I have a simple web server loaded on it with a small HTML page that it gives the user when they access it's ip. This blog is getting to be long, so I don't know if I mentioned this already, but the Ethernet on this device does have it's own unique MAC address. No faking it, curteousy of the MAC address EEPROMs I got from Element14's store ( I promise I'm not trying to do a promotional deal , but they are awesome and have alot of the components that I need for my projects) Not to mention faster than ordering from China off eBay.
We'll see, when I get closer to being finished with this project, I might put everything in an archive and make it available if anyone would want to try this hardware configuration for yourself. Essentially what this Hardware is, is an Arduino Due with a Shield of my design which has Ethernet, PoE Support(not tested yet, don't have the PoE box yet) Buzzer sound, and this 7" Resistive touch display that has 3 interface connections, one for the screen, one for the micro SD mounted on the back of the screen and one for the flash and font chip. It is also not limited to what I have in mind for it. You can also use it for other projects as well. I'll give an example later on. I have a challenge for Ben Heck later down the road, should he accept. More on that later. I will post more as I progress this project
Got the screen to load an image from the SD card. Took quite a bit of tweaking with the code to figure it out. I tried to call the File.read function based on what I seen in the library with horrible results, ended up using it like the examples said and did a read byte by byte. However, I'm not too thrilled on the load speed. Took about 7 seconds. I will be going thru every nook and cranny of the SD library's monstrosity of code and minimize it to what I need and speed up the read times. No structure in that library I promise you. But she is definitely coming together nicely. The SD code rewrite will be a nice weekend project for me. On a plus note, thru my research, I learned I could adjust the SPI speed for each individual component I have hooked up. Which is sweet. Means I can temper it to each devices optimal speed for maximum efficiency. Considering I have 5 devices on the SPI bus, each with different max speeds.
Thus far everything I put on this latest board is working flawlessly and all other work left is software. I have this wonderful sense of accomplishment knowing how far I've come on this project. Especially considering that when I initially bought the screen back in November, I had no idea what I was getting into and I went from just the screen to upgrading the Mega to a Due, laying out and designed a board, maximized everything that I could think of that I could use with it and added it to it, went through 2 major board revisions 4 minor. and 57k of code so far coded onto the board and for to see it display this:
Now mind you even though I'm taking you all on a journey with me working on this project, I fully welcome feedback and any ideas anyone would like to see a demo of that I could code into the board. I am after all a programmer at heart.
Top Comments