MegaMatrix 1.0

18 Dec18

MegaMatrix 1.0

Back in April I designed two boards just for fun. One was a Persistence Of Vision (POV) board and the other was an educational board for my students to understand how a Matrix display works.

Read more...

Particle memory limitations and workarounds

18 Sep18

Particle memory limitations and workarounds

When coding in C/C++ it's crucial to do memory management correct. For a device that is expected to "just work" you simply cannot have any memory leaks. The simple way to solve this is to never allocate memory dynamically. By just instantiating all objects statically, you can be guaranteed that you always have enough memory. What do you do when you past this?

With the first Particle hardware platform called Spark Core, you had about 108Kb for your program and 35Kb of runtime memory available. With the Particle Photon, you have 128Kb program and about 60Kb runtime. This extra memory does however come with an undocumented limitation - for the Setup wifi feature (known as Listen Mode) to work, you have to leave at least 21.5Kb of the 60Kb free. You are free to use more, but if you do so the Listen Mode will not work correctly. Saving credentials will seem to work, but eventually fail.

If you've gotten to this, the trick is of course to start allocating memory dynamically instead of statically. That way you can utilise the same memory for multiple things. Jumping through some hoops and rethinking what needed to be in memory at what time, we found a fairly simple solution. We have a lot of debug features that take up valuable memory. Customers will normally not use these, so by making it all dynamic we suddenly had a lot of memory to spare. Here's how the memory usage looked before and after:

Memory use:
   text    data     bss     dec   note
  89884    2148   43360  135392   (before dynamic allocation)
  89868    2148   33128  125144   (after dynamic allocation of a large buffer)
  90012    2148   18468  110628   (Debug screens moved to RAM)

We basically halved the memory usage without sacrificing any features by just rethinking what we needed to load at what times in the program. I'm quite happy with how this turned out and I wanted to share in case others run into the same issue. Big shoutout the the great community and employees at Particle that helped solve this issue!

Level shifting NeoPixels for Particle Photon

14 Sep18

Level shifting NeoPixels for Particle Photon

I just miscounted how many GPIO pins I had for a project, so I had to find a way to save some pins. In this project we have a status LED that is either red, green or both (producing a somewhat orange color). I need 4 of these per Photon, so that's 8 pins. What about using programmable ws2812, sw2812b or SK6812 LED's?

Read more...

Odd Particle Photon error messages and what they can mean

23 May18

Odd Particle Photon error messages and what they can mean

This post will eventually become a serachable collection of info that I have not found any other place. I usually make my projects based on the P1 module that has an extra 1Mb of Flash built in, but it's the same device as the P0 used in the Photon. If you look inside a P0 and a P1, you'll quickly see the familiarity. It's basically just the extra Flash and the FCC approved PCB antenna that differs.

Errors

"Potentially unhandled rejection [3] Serial problems, please reconnect the device" usually means that you have another serial connection open so you can't get access to the port. Just close this and Particle Setup (and other things that require Serial access) This happens ever so often if you're using the super-neat --follow option that keeps a serial connection open even though the device is restarting.

If you read/write beyond the length of an array, you'll easily see the readed red blink. Another way to achive this is using Serial inside a constructor. It's really hard to flash your device when it keeps crashing, so what if there was a way to get the device online but without running your firmware? Of course there is! Hold down RESET and SETUP buttons. Release the RESET button and when you see the device blink purple, release that button also. The device will now blink green, but when it's connected it won't run the firmware. Instead it will fade purple to show that it's online, but not running your program.

Nice to know!

If you need to clear the wifi settings, just hold down the SETUP button for 10 seconds or more. Instead of slow blue blink, you'll then get a very fast blue blink. This means that wifi setup has been fully cleared.

When you're debugging, it's super annoying to have to restart the Serial monitor all the time. You don't have to! Just use this instead:

particle serial monitor --follow

This will try to find the serial port when the device reconnects (for OTA programming and other things)

Easter funtime with KiCad

06 Apr18

Easter funtime with KiCad

This Easter, my 17 year old son got sick for the last days of the holidays, so we left the mountains were we usually stay. All of a sudden had a couple days of spare time, so I sat down and made two PCB’s that I had been thinking about for a while!

Read more...

Embedding myself in devices

19 Nov17

Embedding myself in devices

This blog's been a litte dead the last year as I've been head deep in two big projects in addition to teaching more than before at Westerdals ACT. I'm not dead and I'm having a blast!

I'm doing exactly what I want at the moment and I feel that I'm creating really good stuff.

Read more...

Basic Blink example for dsPIC30F4013

20 Nov16

Basic Blink example for dsPIC30F4013

With an Arduino, I can teach someone to blink a LED in 15 minutes. It will always work. In the world of PIC microcontrollers, there's nothing "that just works". To help others trying to make a dsPIC30 family microcontroller do just the simplest thing, I'm posting this mini tutorial including what they expect you to know and what you actually need to know.

The Arduino community has always been a place where newcomers could feel welcome. Even the simplest questions are answered politely and nobody looks down on someone just learning the ropes. In general, it's a very welcoming platform. You just download the IDE, plug the Arduino in via USB and you're already moving. I've now tought microcontrollers to students for 4 years and they really love using Arduino as their first hardware tool. So what's different with the microcontrollers from Microchip you may ask? The answer is simple - everything!

Read more...

Makeblock mBot review

02 Sep16

Makeblock mBot review

One of my favorite tools is the Makeblock Robot contruction system. I've actually spent more than $7000 on parts, so you can certainly call me a fan! This weekend I'm hosting a robot workshop for kids and based on former experience, I suggested that we'd use the mBot robot kits. That suggestion has cost me quite a bit of time, so I'll take this oppourtunity to review of the kit to tell what's good & bad.

I sincerely hope that Jasen Wang (Makeblock CEO) and others will read this review and find it a useful tool to improve the product. At it's current state the mBot offering is unprofessional and not a good product.

Read more...

Playing with LoRa radio

30 Jul16

Playing with LoRa radio

I've played around with different radio technologies the last year. Some are cheap, some are expensive, but most of these have a fairly short range. LoRa is different and well worth checking out! Here I'll go through the dev-boards I used, power usage and what range you can expect from LoRa radios.

Read more...

Milling 2-sided PCB’s

08 Jan16

Milling 2-sided PCB’s

Before xmas I did a lot of PCB milling for a client. Compared to getting the PCB's commercially made somewhere, this is the equivalent of rapid prototyping for circuits. Getting a board produced in the UK, Germany or Asia will typically take at least 2 weeks (but often 3). If you can reliably produce 2-sided boards using a mill, you'll iterate and find errors faster.

Read more...