Archive | Freescale RSS for this section

Weather Hardware

The weather hardware starts with FRDM-K22 makes up the processor.

The operating system is FreeRTOS. Both Kinetis SDK and Kinetis Design Studio were used to create the project.
The sensors used are:

  •  DHT11 – Temperature and Relative Humidity
  • BMP180 – Pressure and Temperature
  • CdS light sensor
  • Bluetooth SPP – bluetooth serial peer to peer
  • Windspeed – pulse input
  • Rain Fall – pulse input

 

14955773_1715250465462966_1674935137746592502_n

You can access the code for this project at github.

You can see some of the data using the rest call below.

screenshot-from-2016-11-01-19-13-01

 

 

Advertisements

Frequency Counter (Update)

Spend some time this weekend and now have the display timer update callback working. I originally set it up to read from a queue, but that did work like I expected. To clarify, the callback worked well, since it was only pulling the data out of the queue. The issue came from putting the data in the queue.
Capturing frequency is really the counts per time period. To do this we tie a counter to an external pin and we see how many counts is has after a time period has expired. The software architecture would typically be to use a timer peripheral setup to fire an interrupt service routine (ISR) when the timer expires.

The process typically looks like this:

  1. Setup the timer so that the expiration period is the gate time.
  2. Clear the counter value.
  3. Enable the timer.

When the gate timer expires the ISR gets called and does the following:

  1. Stop the counter.
  2. Clear the interrupt flag.
  3. Calculate the frequency. (This may be done later)

So everything was going fine, until I tried to put a new entry in the queue.

Seems FreeRTOS compares the priority of the interrupt that is called to the ISR that is used for the system tick of the RTOS.

Now to figure out whether to continue down the path of using the queue, or to switch to just using a global variable.

I put the code on GitHub here.

Frequency Counter

So my Radio Shack frequency counter died. I decided that since I had a few 7-segment LED’s I would just make a bench top frequency counter.

Architecture

I started with the frequency counter designed by Wolf Buscher, DL4YHF.
He used a Microchip PIC, which I no longer have debugging tools for. A while ago I got rid of all my debuggers except for my J-Link ARM debugger. Having worked with ST, Microchip, Motorola processors, I decided that I would commonize on the ARM architectures. Specifically, on the Cortex-M series.
In my frequency counter I am using seven 7-segment displays, I also wanted a display that was MCU independent. So I used a 74LS47 BCD to 7-Segment driver and a 74HCT239 3 to 8 addressable bus. This means that I need 3 bits to select a segment and 4 bits to select the character to display. The 7-segment displays have their segment lines all tied together and their supply lines are controlled via the 74HCT239.
This works by turning power off to all 7-segment displays, writing the segment values to the 74LS47 chip, then enabling power to the segment using the 74HCT239. This is done for each digit in sequence at a rate faster than 60Hz. To the human eye this gives the impression that all digits are on simultaneously.
This is very similar to the construction method shown here

Front End Circuit

Because I wanted a fast input that converted low voltage sine waves into a square wave at the voltage of the mcu, I am using the following circuit.

Processor

For the processor I chose to you a NXP Kinetix Freedom K22F. This processor has a ARM Cortex-M4 processor with an internal floating point unit, DMA, USB, and standard MCU peripherals. The FRDM-K22F costs $30USD and includes an onboard debugger.

Code

I used Kinetis Design Studio (KDS) and the Kinetis Software Development Kit (KSDK) to write the software for the frequency counter. The KSDK provides drivers for the onboard peripherals. For the Real-Time Operating System, I used FreeRTOS. It is my favorite embedded RTOS due to its ease of use and because it is very light weight. Giving it a very small memory footprint.