Showing posts with label PIC. Show all posts
Showing posts with label PIC. Show all posts

Tuesday, June 10, 2025

Driving a WS2812B with a PIC

One of my projects needed a small footprint μC. For a while, PIC chips had disappeared from the market post COVID and I opted for the ESP8266. But now, they are not only back but newer chips are available. I was using the PIC 12F1840 but I had outgrown the program memory of 7K. The PIC 16F18115 has twice the program memory of 14K. Besides some enhanced features that are not of interest, it is actually cheaper. While it has an internal oscillator of 32 MHz, it is a lot slower than the ESP8266. This will make driving the WS2812B a bit of a challenge.

There may be many ways to drive a WS2812B from a PIC using some peripherals imaginatively. This is yet another way. This drives a single WS2812B using a bit-banging approach.

The SK6812 is a good substitute for the WS2812B. The datasheet timings are a bit different from the WS2812B, though in practice, they may still interoperate. I have tried to generate timings that are valid for both chips as per their datasheets.

Friday, March 6, 2020

Oxeye - A daisy chain servo controller

I finally decided to try out a robot arm. I have been looking at getting one (either that or one of those biped robots) for a while. I was also looking forward to building a controller for it from scratch.

One interesting problem is how to control several servos. Most solutions end up with this octopus like controller where wires from all the servo motors snake to a single controller board. This board has multiple servo outputs. But never enough. A much better way would be to use a bus structure.

Each servo will have its own little controller. Each controller will have an input and output port. Or the other way around – it is just a bus. Each controller is connected to the next one in a daisy chain. The first one is connected to the controller and the last one has one port unused. Depending on ease of wiring, in some cases a Y cable can connect multiple controllers to a single one. This should make the wiring a lot simpler – no tangle of connections to a single controller. It also simplifies the controller - there is only one port. This is roughly how smart servos work as well.

Monday, July 8, 2013

An Interrupt based DCC Decoder

In the early days of DIY DCC decoders, the preferred method of DCC decoding logic was to write precisely metered sections of hand-written assembly code that sampled the DCC input. These were based on the venerable 16C84 running at 4MHz.

But with modern PICs running at 32 MHz and over, it is possible to write an interrupt driven DCC decoder. This means no more intricately hand-coded assembly. You could write it in C without worrying too much about the code generated - within reason. So what is a good interrupt period to sample the DCC input? OK, 22us. But how accurate does this period have to be? Can we use the internal oscillator in a PIC? Yes, we can!

Sunday, June 9, 2013

IR Interface for an Ethernet SBC

In a previous blog, we looked at a range of ethernet based SBCs. We have also been looking at various IR Remote Control signals. The next step is to bring the two together - to build a circuit to send and receive IR signals using an ethernet based SBC. This blog describes a small bit of hardware added to the SBC to do this.

IR Firmware for the PIC 18F

Almost every one of my designs involves a periodic timer interrupt. This is used for all timing. For the IR receive, the input may have to be sampled every 25 us. This is a very short interrupt period. For an IR send, the input has to be toggled every 12.5 us. This is just not practical.

It was time to explore some of the features of the PIC 18F that I had long ignored. One was the PWM feature which was used to do the IR send. The other was CCP that was used to do the IR Receive. The hardware used has been described in a previous blog.

Using the Microchip TCP/IP stack on Olimex SBCs

To build a web server application on an Olimex Ethernet SBC, you have to download the Olimex version of the Microchip TCP/IP stack and modify it. To get started with it, as a first step, I got rid of files that I don't need for implementing a web server. The Microchip stack uses a ~ variable embedded in HTML pages to serve your custom information on a web page.

Wednesday, May 15, 2013

Web front-end for an ethernet PIC SBC

I now have a basic web interface with a PIC SBC. It uses ajax to get simple text based information back and forth between the SBC and the browser. This blog looks at building the web front-end to interact with the SBC in a more user-friendly way.
With the limited resources of a PIC, it makes sense to move all the user interface logic to the browser. This will leave just the bare functions within the PIC while still having a reasonably rich UI. Nothing beats understanding a UI by trying it out. Use a dummy version of it to see how it works and study the associated HTML and javascript to explore its inner workings.

Sunday, May 12, 2013

Web Interface for an ethernet based IR Interface

In the past few blogs, we looked at implementing an IR remote control interface on an ethernet SBC. We also looked at how records can be stored on the EEPROM on the SBC. Now we look at the web interface required to use the SBC as an IR remote control.

Implementing EEPROM Storage

In a previous blog, we looked at how you can store a bunch of records of varying types but all of fixed length in an EEPROM on an Olimex ethernet SBC. Now let us take a real world example, well, my world anyway, and store that in an EEPROM. As it is on an ethernet SBC, we will also write code to allow the records to be stored and received using a browser. The data to be stored is the IR signals required to control one or more audio or video components like TVs, DVD Players, etc.

Saturday, May 4, 2013

Storing records on a PIC web server

In a previous blog, I looked at using the TCP/IP stack on an Olimex PIC SBC to implement a web server. In this blog, I look at storing and retrieving data on the EEPROM on the SBC. My data is a collection of records of different types. The SBC in use, the Olimex PIC-WEB SBC, uses an Atmel AT45DB011. This chip has its idiosyncrasies that the storage process takes advantage of.

Monday, October 22, 2012

Ethernet based PIC SBCs

Almost every PIC project has to deal with implementing some kind of a user interface. Buttons, LEDs, LCD display – the hardware is not trivial to add and the result is far from user friendly. What’s more, you have to walk up to the unit to interact with it. This is far from ideal – a rolling potato gathers no couch.

An Ethernet based SBC (Single Board Computer) is one solution. Such an SBC will at the very least have an Ethernet connection. It should have the ability to host a web server. The code for this should be available. Writing one from scratch is way beyond my abilities. With the web server must come a large amount of flash storage, not a few KB but hundreds of KB.