Alpenglow Industries
  • Store
    • Through-Hole Soldering Kits
    • SMT Soldering Kits
    • Tools and Accessories
    • Solderless Kits
    • Seasonal Blinkies
    • Programmable Kits for Makers
    • Textile and Yarn Tools
    • All Alpenglow Products
    • Bright Wearables
    • Makerbytes Soldering Kits
  • About
  • Blog
  • Instructions
    • How To Solder
    • Soldering Kits
    • Solderless Kits
    • Build A Blob
    • Tools
    • Coin Cell Power
    • SwitchTrick
    • SMT Garden
    • Foxy Pride
    • FUnicorn
    • Krampus
  • Contact

BigNums I2C

6/22/2022

0 Comments

 

TL;DR: how to use BigNums with I2C LCDs
  • Instead of installing BigNums2x2 via the Arduino Library Manager, download BigNums2x2.h and BigNums2x2.cpp locally and place them in your sketch folder alongside your .ino file
  • Add the library for your given LCD in the normal fashion, and analyze its source to ensure it conforms with the functions used by Arduino’s LiquidCrystal library
  • If any exceptions are found (for example, DFRobot’s customSymbol() vs. createChar()), update the local BigNums source to match the library’s nomenclature
  • Once you have conformed the BigNums2x2 code to your library’s interface, everything should “just work” – let us know if not, and we’ll be more than happy to help diagnose!
Picture
We recently had a comment on our original BigNums2x2 blog post about using the library, which is designed for parallel interface Hitachi HD44780-based 16x2 LCDs, with an I2C-equipped LCD. We immediately set to work adding I2C compatibility to our library, with the goal of enabling 16x2 LCDs of all kinds to have big numbers. But then things got complicated – complicated enough that we ultimately decided not to incorporate I2C support into our library. Here’s what we learned – hopefully it will help you implement BigNums with whatever I2C LCD you are using!
Picture
Rewinding for a moment, let’s talk about the different interfaces that you may encounter with 16x2 LCDs. The most common Hitachi HD44780-based displays use a dozen or more pins – greater still if it’s RGB – which can lead to a fairly messy breadboard, before you’ve even fleshed out other parts of your project. By using I2C, you can bring that pin count down to four: the same power and ground as before, plus SDA (data) and SCL (clock). And because the I2C bus allows up to 128 devices (or more with multiplexing), you’re actually kind of not using any pins, since a second, third, or … 128th device can in theory also be added with no additional I/O overhead. So, using an LCD that uses I2C, or obtaining an adapter for your existing display, can really simplify things. But what happens if you want to use BigNums?
Our BigNums2x2 library in turn uses Arduino’s LiquidCrystal library, which only supports 4 or 8-bit parallel Hitachi-compatible displays. But there are a number of I2C LCDs designed for use with Arduino, so, how do they work? It turns out each one of them tends to have its own library – usually not well maintained, and largely ripped off from one another in the ones that we looked at!
Picture
Photo: Seeed Studio
The first display that we tried, simply because it was on hand, was Seeed’s Grove 16X2 LCD RGB Backlight. This LCD presented its own special challenge in that its I2C implementation appears to be flawed. When used alone, the example code for this device completely failed to work. Further investigation, including diagnostics via i2c_scanner, revealed that the device was not found on address 0x3e as expected. But curiously, Seeed’s Grove Digital Light Sensor v1.1 seemed to work fine with all things equivalent hardware-wise – and curiouser still, the LCD worked too when the Digital Light Sensor was also present on the bus! Our best guess is that the LCD lacks the correct termination resistance and thus adding the Digital Light Sensor helps terminate the bus line.
Picture
After resolving these hardware issues, we started prototyping an updated BigNums2x2 library, using the Grove_LCD_RGB_Backlight library. The easiest way to do this was actually to duplicate our library files BigNums2x2.h and BigNums2x2.cpp locally alongside our sketch in place of the “real” library. By substituting the Grove library, which (mostly) supports the same interface, for the stock Arduino library in our code, we had BigNums2x2 up and running on the Grove LCD fairly painlessly. But, what about other I2C boards – it seemed imperative that we get a larger sample of representative devices in order to ensure that other devices could be added similarly.
Picture
Photo: DFRobot
Next up was the DFRobot Gravity: I2C LCD1602 Arduino LCD Display. As with the Seeed device, a custom library provided by the manufacturer is used via include as a substitute for the original Arduino library. After a quick confirmation that the library examples worked, it was time to see if it could be adapted as easily as the Seeed library. Unfortunately, the DFRobot library appeared to be missing a critical function, createChar(), which BigNums2x2 uses to create the custom characters that we use to make the Big Nums themselves. A closer look at the datasheet revealed mention of the requisite CGRAM functionality, so how come it wasn’t in the library? Analyzing that source revealed two very interesting facts: first, that the CGRAM function existed, but was called customSymbol(), and … that vast portions of the header file appeared identical to Seeed’s! Which wouldn’t inherently be an issue, since it’s open source – but DFRobot failed to preserve Seeed’s 2013 copyright, claiming authorship and replacing with their own 2016 copyright.
Picture
So…surely we couldn’t be the first library to encounter the issue of wanting to support multiple I2C LCDs? After a few false starts with other libraries, we noticed a lot of references online to fmalpartida’s new-liquidcrystal library – which seemed to no longer exist at the BitBucket repo which all the links pointed to. Further searching revealed a clone of the BitBucket library on GitHub, with a handful of commits over the past half decade or so. And! The documentation was retrievable via the Internet Archive’s Wayback Machine! Before adopting it as the basis for our LCD support though, we thought we should put it through its paces with the displays on hand.

We installed the library as usual, but received the error Multiple libraries were found for "LiquidCrystal.h" – weird that this new library would collide with Arduino’s default; but a closer look at those old docs clarified how the library was intended to be used:

The library has been developed to replace the current Arduino library, therefore you will need to remove/backup the LiquidCrystal folder from the Arduino library folder the original LiquidCrystal library and replace it for this one. You will also potentially need to remove other LCD libraries like LiquidCrystal_I2C as that will also conflict with this library.

Instead of just including the library, we had to use it to physically replace the stock library files in C:\Program Files (x86)\Arduino\libraries\LiquidCrystal – highly unusual! And a hassle we wouldn’t want to force on our users … but perhaps we could just rename it to prevent the conflict and include in the normal fashion if it turned out to be good – so let’s see how it goes…

With the standard HD44780 display, everything worked great once the pins were updated to match our breadboarded example. The DFRobot I2C module, however, presented further challenges. Unlike using the device’s own library, we had to specify the I2C address ourselves; actually, let’s take a moment to unpack what that means: remember the earlier discussion about i2cscanning? Different I2C devices have different addresses – typically a good thing, since it means you can combine them on a single bus. But what this also means is that LCDs from different manufacturers often have different addresses, so you can’t just have a hard-coded value like the individual libraries that were provided by each OEM (and even those typically require hacking if you cut the trace or bridge the pads that allow you to use their alternate address in order to eliminate a conflict with another device) and expect it to work for all. So either the library needs a way to “know” the address of each commonly-used device, in order to provide a seamless experience for users, or, as is the case with new-liquidcrystal, users are required to specify the address during initialization. But, manufacturers don’t always do a good job of making the address clear – in fact, as mentioned, they typically abstract it in the library so that users don’t have to “worry” about it. And in the case of the DFRobot display there was nothing in their wiki or examples, so we had to go digging. Diving into their library source code (again) suggested it was 0x7c, so we updated the example sketch to use this, and:

HelloWorld_i2c_DFR:8:27: error: no matching function for call to 'LiquidCrystal_I2C::LiquidCrystal_I2C(int)'

Weird, why would changing the address cause that? The answer was that it wouldn’t: the example didn’t compile even with the default value. There were multiple signatures for the lcd() function, and one finally built without error when we #DEFINE’d the missing POSITIVE macro, but … nothing happened with the LCD. Double-checking the device using the i2c_scanner revealed a device on 0x3e (same as the Grove!) – but … didn’t the code say 0x7c? Closer inspection revealed that the value is right shifted (0x7c>>1 = 0x3e) – because I2C addresses are 7-bit plus one more bit for read/write – but even the corrected value failed to produce any result.
Picture
Photo: Adafruit

Running out of development boards to test with while trying to avoid continually rewiring between testing, we tried the Grove LCD on Adafruit’s Metro M0, a SAMD21-based board. The original lcd() signature worked on this different architecture, but provided no output, and the other, even after manual #DEFINE of POSITIVE resulted in the error:

HelloWorld_i2c_Grove:11:18: error: invalid conversion from 'int' to 't_backlightPol' [-fpermissive]
11 | #define POSITIVE 1

At this point it felt like time to accept defeat.

What did we learn in our failed attempt to add I2C support to our library? First of all, be skeptical of your hardware: it might not be you – it might be a flawed I2C implementation! Second, pay close attention to library source code and its providence. And finally: sometimes it’s best to just do the thing, instead of creating a universal factory to do all the things. If we would have just demonstrated how to hack the library by making a local copy and adjusting it to the specific board/library that the commenter was working with, we would have been done much sooner. But at the same time, we wouldn’t have this lovely blog post full of lessons, so … maybe it was worth it in the end!
0 Comments

Solder Sesh #29 Transcript: David Ray of Cyber City Circuits

6/15/2022

0 Comments

 
Check out the transcripts for the all the highlight clips from this past soldersesh with David Ray! Carrie spoke with David Ray of Cyber City Circuits (based in Georgia) and had some great conversations! David talked about running a subscription service and the fast-pace nature of monthly delivery cycle, fulfilling childhood dreams and growing a business just as the pandemic started (early 2020, here!). David also answers the chat's burning questions about PCB assembly and manufacturing and talks about his ideas for a traveling roadshow!
Cyber City Circuits is on Twitter and Instagram, and you can find more information about the company on their website!
Full Stream:
(2:21 – 7:33) Subscription Kits

Carrie: I'm going to start soldering and I would love to chat with you, David, about the whole subscription club and how it got started. And if you don't mind sharing with us some of the challenges of it. I like to do small business talk at times and let people know some of the behind the scenes struggles, right?

David: Oh my God. Yeah, it's important that if someone can learn from my lessons, they don't have to make the same mistakes. They could choose to make the same mistakes, but they don't have to. At least give them the opportunity to see where I didn't. So, in late 2019, I cashed in my retirement account, I started a business, I bought a pick and place machine, and then we got a pandemic three months later.

David: So, Chris and I decided at that point, because we didn't know what to do, to make face shields. We started doing face shields for the local hospitals for the pandemic. We got the plastic from Coca-Cola. We had to pay for the shipping, but they literally gave us a ton of plastic, like bottle plastic. It came on a spool; it was like 2,200lbs of plastic. We got it all laser cut and we made a bunch of face shields, and we were sitting there. We had a lot of time just sitting there, making face shields, just looking at each other. First of all, if you can get a subscription product off the ground and make it really successful it will pay all your bills.

Carrie: It's nice because you know, you have some prediction of what kind of money is coming in every month. So, it makes cashflow and finances a lot smoother.

David: Right! So, we thought, we'll give it a try with a subscription box. So, we spun up the store so that we could do the subscription box. Then we also had the other stuff – we came out with the cyber digit, which is a really cool, neo-pixel kind of seven segment display. We came up with a lot of products and we're going to do subscription boxes. So, the first few were easy. Everyone has an idea for a decent soldering kit, right?
Carrie: Yeah, you started off with them once a month. Which is quite a lot.

David: Imagine walking into a month and having a deadline that's 28 days away that you have to ship a product and you don't even know what the product is yet. And you have 28 days to ship it. And you know, with China and you got to ship all the stuff from overseas, you got to get the boards made. And yeah, we did it monthly for like a year and it was rough! Man, you talk about getting really quick with development time.

Carrie: Yeah. I feel like it's super easy to have it sort of planned in your head. It's easy to have the best intentions at the beginning. You think, I'm going to spend one month just prepping all of these kits and doing all this work ahead of time, and then we'll just slow roll it month by month. Right? And then life happens. Other business stuff happens, and it turns out that you get the first thing done, then you need to take a break because you have a whole bunch of other stuff that needs immediate attention. Then you start getting in this cycle of always lagging and you're just a little bit later than you want to be and then it gets to be super stressful.

David: And it compounds. That’s another thing, if you think something's going to take you a couple days, it's really going to take you six days. Whatever you think it's going to take, it's going to take three times longer without exception.
  
(23:44 – 26:55) Growing Business

Carrie: So, the good part about deciding not to do the soldering kit anymore is that part of the reason that you were having so much trouble keeping up with it is also because you were busy with other stuff, right?
​
David: Yeah, we started it when we didn't have any business when we just started out and then we finally got business where we became successful at what we wanted to do, and there's just no more room for it, unfortunately. I really wanted to keep it going.

Carrie: So, tell us, for people who might not know, what that other side of the business is.

David: Oh my God. I'm the largest electronics manufacturer in August! We’ve got pick and place machines, we've got a reflow oven and we've got this big, fancy stencil printing machine that's had to meet a crane twice just to get into our building. We do a lot of design work; we also do a lot of fabrication and box builds. For example, right now we have like 50 waterproof enclosures that we're building these things into that go places. And so, we're going to be QC-ing them all, putting batteries in them, doing a 72 hour burn in over a weekend, and all that. So, we offer all these services and we're really good at it for the most part. And we're new, we really got going in 2020, and we're on fire. We're doing really, really, really good. And I'm happy that for people like Bob and Jason and Carrie, that really helped us along this journey, thank you.

Carrie: Yeah, no problem. It's been awesome getting to know you through Twitter and the internet and meetups and stuff like that. That's what it's all about.

David: [Question from Tom: “What is your main business that needs SMD line?”] Well, I do PCB assembly, Tom. I can do it for you, too! We do a lot of PCB work for Jason; we've done work for Carrie, and yeah. We’re looking to get a new line; well new to me – it's used, but a Manncorp line hopefully by the end of this quarter.

Carrie: What is that, is that like a pick and place and reflow, or is that inspection?

David: Oh, it’s fancy stuff, Carrie!

Carrie: Oh, tell me, I want to hear about fancy machines.

David: We're going to take the little garbage stuff we got and go put it in a dumpster and put in all the new stuff!

Carrie: Before you put it in the dumpster, give a girl a ring, haha.

David: I’m just kidding, we'll end up taking those machines and dedicating them to customers, but maybe at some point I can give a little tour.

 (30:15 – 36:37) Stealing a Book/ Fulfilling Childhood Dreams

David: So, when I was 12 years old, I stole a book from the Lexington County public library.

Carrie: Wait, you weren't charged a million dollars in late fees.

David: I don't think they ever knew how to find me. This is the book that I stole when I was a kid. [Giant Handbook of 222 Weekend Electronics Projects] That's the same book, Giant Handbook of  222 Weekend Electronics Projects. And as a kid I never built any of these, but I read this book over and over and over and I wanted so hard to understand what the hell this meant. You know, please explain this to me. And I found some more books, I didn't steal those. I got some other books and I started learning and I started fooling around with it. Then I went to the Marine Corps, and I did radio repair for the Marines, and they trained me some. And now, here I am. This is like childhood dream kind of stuff. It's so cool and I'm sure Carrie’s in the same boat.

Carrie: Yeah, I am trying to also live my best 12-year-old life, although when I was 12, I didn't know anything about electronics. I didn't even know what I wanted to do when I was 12. I would have been in seventh grade. I think paleontologist was still what I wanted to be at that point in time. Maybe it was either that or astronaut. I'm not sure which.

David: What year was it? Do you know? Do you remember?

Carrie: I was 12 in 1989.

David: So, did you ever own a pair of parachute pants?

Carrie: I did not! However, some of my friends did and they looked super fly in them because they had the Hammer moves, too. So, I grew up in the Caribbean.

David: Where in the Caribbean? I didn't know that. Where are you from?

Carrie: So, I grew up on the island of St. John and the US Virgin Islands and I went to school on St. Thomas for most of my life from when I was 7 on through high school. I was taking a boat to a different island every day and back for school. I lived with my mom in the Caribbean and my dad was living in New Jersey; I would see him for summers. He was the engineer electronics person. Although, when I was little, he wasn't working in electronics, he was working at a family restaurant business, but he had a big love for it, and he also worked on the Apollo program. He was always into space stuff, and he was really into computers even before PCs were a thing that everybody had. So, I learned about computers early from him. I had some electronic toys early, but I also got a lot from my mom, and I've always loved reading and literature and writing and things like that. So, I kind of got different stuff from each of them, but there wasn't a lot of opportunity to tinker with electronics. We didn't have an electronics lab at all. It wasn't actually until, well, we didn't even have an electronics lab in college. I hated electronics in college because the intro class was terrible.

Carrie: It wasn't until my first job after college that I started getting into electronics because suddenly there were cool projects that we were trying to build. We were trying to build this small little 6.0” airplane in pre-2000. So that was a really hard task at that point in time, not a hard task today, but you know, back in the last century it was a tough, tough thing. Electronics were bigger and more power hungry. So, I have come by a love of electronics from doing it for jobs and working with them and just learning for the last 25 years. But that means that I have a lot of making up for lost time when I was a kid. So, now we're all about all of the toys and the lights and the blinkies and the baby Yodas and the unicorn plushies. Space stuff, everything, just bring it, all the fun stuff we want it. 

(44:55 – 48:17) Traveling Roadshow

Carrie: Traveling Roadshow.

David: Oh my God. Traveling Roadshow.

Carrie: You should talk about that.

David: So, I got this idea for a travel show. I got a new truck and it's nice, it’s a 2022 4Runner, but I got it so I can go on the road with it. I'm going to hop in the truck with somebody and a bunch of cameras and a whole bunch of microphones, and we're going to go to a town near you. We're going to meet local small businesses that do electronics hardware like me, like Carrie, like everybody else that we know, and hang out with them for the day! Eat dinner with them, get to know what their family's like, and ask them all of the burning questions. If you could send a message back to yourself five years ago, what would you say?

Carrie: Five years ago, was 2017. It would be injection mold SkeinTwister knobs because we' will sell enough of them that injection molding makes sense.

David: I was going to say keep it because I'll show everybody on the show when we come and visit you.

Carrie: I'll come up with another one. It'll be all good.

David: All right. And I'm going to come and see Jason. Jason doesn’t know it yet. You still here Jason?

Carrie: Yeah, he usually hangs out while he does some of his Fibonacci assembling things.

David: The idea with the show is to not to promote products that they people sell, right? Say, I go see Jason; let's show off the Fibonacci boards. That's not what we're here for. Instead, it would be more about learning more about you and the person behind the product and what drives you and what makes you want to come to do this for a living. Maybe you're not in it for a living. Maybe you moonlight and you still have a day job. Well, why is that? What would make you want to quit your day job and do it full-time? All these different things. The idea is I would do it for an entire month. I go see 20 people and then I bring all the footage back and hire somebody to edit it all. Then we got a YouTube series and I sell it to the travel channel and make money.

Carrie: Yeah!

(55:04 – 59:36) Assembly Questions

David: Does anybody have any burning PCBA questions they like to ask? It's a Cyber City after dark. We can get all your burning DFM questions out of the way!

Carrie: Oh, did you see responses about the favorite Cyber City Circuits kits?

David: Yeah, Bob said that he really liked the Theremin and what was the other one?

Carrie: Jason's Fibonacci got a mention and the alarm clock kit.

David: Yeah, Jason’s Fibonacci was great, and the alarm clock kit, man. That one was fun; it has a built-in MP3 player. The song it played on the alarm clock kit is a song that I played on guitar. It's a recording I made when I was in high school, and it was called “The Digital Alarm Clock Song” because it just seemed like the kind of song that would play to wake you up in the morning.

David: Tommy Marshall asks, “Is there an SMD size you recommend and why?” That's a good question, it’s application dependent. If you're going to be hand soldering stuff, I'd recommend 1206 and 0805. If you're going to be using tweezers for manufacturability, I'd recommend 0603 and 0805. We do 0402. We just did a whole bunch of 0201 yesterday. [Groans from the audience.] So, Chris is really good at that kind of stuff. I'm not, I'm just good looking, we can do 0402 and we can do 0201, but we charge more for that. Everyone does, it's not just us. Any PCB assembler worth their money is going to charge you through the nose for 0201 and 0402, so avoid those when you can. 0603 is the most common size and 0805 is really nice. When you're doing KiCad, there's an option for hand solder pads. There's R0603, and then there's R0603 hand solder. Use the hand solder stuff; you're just going to make your life a lot easier for rework, if you can get away with it. Now if it's a really tight constrained design, maybe not, but they're not that much bigger, they don't take up that much more space, and it makes everybody's life easier.

David: Bob asks, “Do we need to provide parts for assembly, or do you provide those for an additional fee?” So, we do whatever you want! We can do turnkey; when we buy parts, we just do markup – that's an industry standard. Everyone charges you markup. So, we just charge markup when we buy parts. Otherwise, we do consignment fees which is $5 per piece of cut tape. Now, the reason we charge a consignment fee per piece of cut tape is because we had a joker that sent us 10 pieces of cut tape for the same part. For each of those pieces you have to have a special machine to splice cut tape together and that machine takes time. That machine can be very frustrating to work with, but you have to splice the cut tape together. So, we charged $5 per. Then it has to be loaded into the machine; the fastest we can do is 3 to 5 minutes per line, that's the fastest we can do, and that's if nothing goes wrong. So, we charge a consignment fee per line, and we charge markup if we buy stuff, but we're happy to do whatever. If you want a quote, send an email to sales@cybercitycircuits.com and I would love to talk to you!

Carrie: Nice.
​
David: Always a salesman.
0 Comments

    Archives

    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    September 2021
    August 2021
    July 2021
    June 2021
    February 2021
    January 2021
    October 2020
    June 2020
    February 2020
    August 2018

    Categories

    All
    Arduino Libraries
    Badges!
    Beginning-electronics
    Binary
    Feminism
    FUnicorns
    Irreverent
    LCD Fonts
    PCBs
    Racism
    Vote!

    RSS Feed

How to Buy Our Things:
​Our Storefront
Tindie Storefront
Digi-Key Marketplace
Alpenglow Yarn (our yarn tools)


© 
2018-2022 Alpenglow Industries
Stay in Touch:
About Us
Blog
Contact Us
Newsletter
  • Store
    • Through-Hole Soldering Kits
    • SMT Soldering Kits
    • Tools and Accessories
    • Solderless Kits
    • Seasonal Blinkies
    • Programmable Kits for Makers
    • Textile and Yarn Tools
    • All Alpenglow Products
    • Bright Wearables
    • Makerbytes Soldering Kits
  • About
  • Blog
  • Instructions
    • How To Solder
    • Soldering Kits
    • Solderless Kits
    • Build A Blob
    • Tools
    • Coin Cell Power
    • SwitchTrick
    • SMT Garden
    • Foxy Pride
    • FUnicorn
    • Krampus
  • Contact