Sunday, April 8, 2018

Arduino Self Levelling Drone (Part 2)

Step 1: Construct the Power Distribution Board


The F450 airframe includes a power distribution board. The first thing that we need to do is to tin the connections for the Electronic Speed Controllers (ESC's) and the LiPo battery.




Pre-tin the ESC power leads (red and black) as well. This will make soldering them together much easier.



Unless you have asbestos fingers you will need a pair of long nose pliers to hold the wires in place. Make sure that you wire the ESC's the right way round, the red wires go to the positive (+) pad and the black to ground (-).

In a later part of this tutorial you will read about why I burnt out and needed to replace a couple of the ESC's. If you have bought the cheap versions like I did, you may want to install bullet plugs on the power connections as well as the motor connections. This may save some re-soldering.



Wire up the Deans T style plug, this will allow you to easily disconnect/replace the LiPo battery when required. I found the T plug/sockets on eBay. Have a look at the photos below.




I am also taking the power for the top platform (for the Arduino) from the battery plug. Solder the plug connections first, then solder the short wires to the two pads on the distribution board. Double check the polarity before soldering. Make sure you put the heat-shrink on the plug wires before you solder the other end!

If I did this again, I would add a power switch on the positive lead to the battery. It can be tricky pulling apart the T plug when the props are spinning.



Once you have soldered all of the connections to the Power Distribution Board you can check continuity using a multimeter. Check that all the grounds are connected and that all the positive terminals are connected.




Step 2: Flysky FS T6 Transmitter and FS R6B Receiver Binding Procedure


The binding procedure between the FlySky Transmitter and Receiver is fairly straight forward. It is easiest to do this before you connect any more wires. You need the Power Distribution Board complete so that you can power the ESC from the LiPo. Make sure you charge your LiPo before starting.

You will need the transmitter, the receiver, the link cable / binding plug (comes with the receiver), and one ESC.

Your ESC control cables may come in various colours. You can use the table below to decode which is which. The ESC may or may not come with a battery eliminator circuit (BEC). If yours does, there should be 5VDC on the positive (red) lead, relative to ground, when the LiPo is connected. We wont be using the BEC, all control power will come from the Arduino 5V bus.



Binding Procedure

  1. Put the bind plug (which is just a jumper wire) into the battery connector at the top of the R6B receiver.









  1. Plug the ESC servo/control cable into channel 3 (CH3 - throttle channel) of the receiver. The signal cable (orange on my ESC) should be next to the CH3 writing on the receiver. Ground (brown or black) should be to the far right (refer to photo). You can actually plug into any of the channels, but 3 is traditional!


  1. Make sure that none of the cables are touching each other, then connect the LiPo to the Power Distribution Board via the Dean T plug.

  1. The LED on the side of the receiver should start blinking. This indicates that it is ready to bind to a transmitter.

  1. Press and HOLD the bind key on the back of the transmitter. Turn on the transmitter, wait 3 seconds or so and then release the bind key when the LED on the receiver stops blinking. The LED on the receiver should now be solid on.



  1. Disconnect the battery from the Power Distribution Board. Remove the bind plug from the receiver, and turn off the transmitter.

  1. To check that binding is in place, turn on the transmitter, reconnect the LiPo to the Power Distribution Board and the receiver LED should be solid on indicating a connection. Turn off the Transmitter and the receiver LED will go out. Done! Disconnect the battery, and we can resume construction.




Step 3: MPU 6050 Gyros / Accelerometer


Next we need to connect some wires to the MPU-6050. Use the light duty hook up wire and solder to the Vcc (red), GND (black), SCL (white) and SDA (blue) pads on the MPU-6050. You can use whatever colour wire you want but keep track of what is what.


We now come to the first challenge. The clone version of the F450 airframe has a large hole in the top platform, right where we want to mount the MPU-6050! To provide accurate roll, yaw and pitch information, the MPU-6050 needs to be mounted as close to the centre of the Drone as possible.

The F450 Top Platform - with large hole in the middle!


In the original F450, the battery is mounted on the top platform and the flight controller is mounted on the Power Distribution Board. We are going to do it the other way around, with the battery at the bottom (lower centre of gravity) and the electronics on top (better access).


We will also mount the FS R6B receiver on this platform. It is about 45mm long and sticks out over the original top platform.



To solve both of these issues, we designed and 3D printed a light mounting bracket to cover up the top platform holes and make the MPU-6050 and R6B easy to mount using double sided tape. We used SketchUp to design the bracket. It is 125 mm long, 32 mm wide, and the rectangular portion is 1 mm deep. You can download a copy of the F450 Bracket STL File from Thingiverse.



The cylinder diameter is 28 mm and another 1.5 mm deep on top of the rectangle. This fills the hole in the top platform. It is a firm fit so you may need to adjust this based on your 3D printer tolerance.

Once you have created the part (or downloaded mine), you will need a slicer like Cura to produce the gcode file for your 3D printer.

The orientation of the gyro is not important as long as the Z-axis is vertical (perpendicular to the surface) and the edges of the gyro are aligned with the edges of the quadcopter. The setup software will detect the gyro's orientation and invert the gyro and accelerometer axis if necessary.



Mount the gyro with thin double side tape as close to the centre of the top platform as possible. Don't use foam tape or other dampening material as this could decrease accuracy. I found that tweezers made removal of the tape backing paper easier. While the software doesn't care which way the gyro is mounted, from a construction point of view, I had the wires closest to the back of the platform.



You can then mount the receiver behind the MPU-6050, also using double sided tape. I also located the receiver channel connections at the back of the platform for ease of access.

Step 4: Mount the Arduino


The next challenge is mounting the Arduino. You could drill some holes in the top platform and use spacers to mount, but we like using our 3D printer so we designed a purpose built mounting bracket.



The four mounting holes in the centre of the bracket match the holes in the centre of the F450 top bracket. You can download a copy of the Arduino bracket from Thingiverse.



The 4 x 15mm nylon tapped spacers used to attach the Arduino mounting bracket have the added benefit of holding the gyro and receiver bracket in place.



The bracket can be mounted in any orientation, but we located it so that the Arduino digital inputs were towards the back of the drone. The receiver channel connections, MPU-6050 SDA and SCL connections are all wired to that side of the Arduino. This also places the wired status LED at the back of the drone where it should be most visible, assuming the drone spends most of its time flying away from you!




In part 3 we will complete the hardware build.




Saturday, April 7, 2018

Arduino Self Levelling Drone (Part 1)

The Plan


F450 Airframe Kit


My latest project is an Arduino based self levelling drone. Being a rubbish pilot, I want the drone to be easy to handle and have the capability to carry a small video camera. There are a number of different designs available and I want to use a combination of the best available. One of my frustrations while building the drone was that none of the designs were complete, I would get a certain way into construction only to discover that I am missing a part. Where this happened to me I have made sure that I added the part to the list below (including connectors and specific cables).

Arduino Uno - used for the Flight Controller


I wanted to use an Arduino as the flight controller so that I have control over the drone firmware and can modify it as required. There is no better way to learn about drones / quadcopters than to build one! The base drone firmware is based on the YMFC-AL code from Joop Brokking. An electronic schematic of the drone is available from the Brokking.net site. Download a copy of this and print it out, you will refer to it frequently. It is in the zip file that contains the firmware (more on this later).




The drone platform I will utilise is the F450 Airframe kit. This airframe has an integrated PCB board built into the lower platform for connecting ESC's. This makes wiring the electronics much easier.


FlySky (FS-T6) 6 Channel Transmitter


The original versions of the DJI F450 airframe are still very expensive (over $1K), but you can get very cheap copies from China. My aim is to build the drone for under $250. You will be able to do it cheaper than this if you already have some of the parts and consumables. The motor and ESC kit comes with 1045 props but I have replaced these with 8045 props to reduce the ESC/motor load and make the drone more responsive (as suggested by Mr Brokking).

The end result.

Parts List


You will need to purchase the following parts. I have indicated part numbers, price and a link to where I bought them.


Qty Description Price (AUD)
1 F450 Air Frame $17.96
4 1000kV motor / 10 x 4.5 props / ESC $12.77
1 2S/3S lipo battery charger $10.93
1 3S / 2200mAh / 40C LiPo Battery $29.95
1 Flysky FS-T6 6-CH TX Transmitter & Receiver $62.79
1 8045 8X4.5 Carbon Fiber Propellers (2 pairs) $8.43
1 Arduino Uno $29.95
1 MPU-6050 gyro / accelerometer $2.99
1 1k Ohm 0.5 Watt Metal Film Resistors - 8 Pack $0.55
1 1.5k Ohm 0.5 Watt Metal Film Resistors - 8 Pack $0.55
1 330 Ohm 0.5 Watt Metal Film Resistors - 8 Pack $0.55
1 1N4004 1A 400V Diode - 4 Pack $0.70
1 200mm Black Cable Ties - 100 $10.95
1 5mm Green LED $4.25
4 Right Angle, 2.54 mm, 4 Contacts, Header $1.19
1 M3 15mm nylon spacer (25 pack) $11.95
1 M3 Bolts x 10mm -25 pack $3.00
1 5 PAIR Deans T Plug (5 x Female 5 x Male) $5.25
1 Heatshrink $14.50
1 Loctite 243 10ml Adhesive Threadlocker $14.55
5 Light Duty Hook up wire (4 colours) $2.75
5 Extra Heavy Duty Hook up wire (Red & Black) $1.25
1 5 x 15cm Servo Cables (Rx to Arduino) $7.30
1 12 Pairs 3.5mm Bullet Banana Plug Connector $7.00
1 Falcon 25mm x 2.5m Double Sided Tape $12.00
1 2.1mm DC Power Line Female Connector $1.95
$276.01


3S, 2200 mAh, 40C LiPo Battery


Feel free to replace with compatible models. Make sure they are compatible, for example we are using a 3S version of the LiPo batteries because this is at the upper voltage limit of the Arduino regulator.

3S LiPo Balanced Battery Charger



Tools


You will require the following tools to put the drone together.

  • 2.0mm Hex Wrench For frame and motor installation.
  • Scissors to open up all the packaging!
  • Diagonal Cutters
  • Long nosed pliers
  • Wire Strippers
  • Small phillips head screw driver
  • Hot glue to insulate solder
  • Soldering-iron and solder
  • Multimeter
  • 3D Printer (optional)

FlySky 6 Channel Receiver (comes with Transmitter)


Specifications


1000kV motor / 10 x 4.5 props / ESC Kit


A2212 motor:

KV: 1000
Max Efficiency: 80%
Max Efficiency Current: 4-10A (>75%)
Current Capacity: 12A/ 60s
No Load Current @ 10V: 0.5A
No. Of Cells: 2-3 Li-Poly
Motor Dimensions: Φ27.5* 30mm
Shaft Diameter: Φ3.17mm

30A brushless ESC:

Output: Continuous 30A, Burst 40A up to 10 Secs.
Input Voltage: 2-4 cells lithium battery or 5-12 cells NiCd/NIMh battery.
BEC: 2A / 5V (Linear mode).
Max Speed: 210,000rpm for 2 Poles BLM, 70,000rpm for 6 poles BLM, 35,000rpm for 12 poles BLM. (BLM: BrushLess Motor)

1045 Propellers (original):

Diameter of Shaft: 6.0mm
Adjustable by hole adapter (3mm, 3.2mm, 4mm, 5mm, 6mm, 6.35mm, 7.95mm)
Thickness of center: 9.7mm
Recommended wheelbase: 550mm - 700mm


8045 8 X 4.5 Carbon Fiber Propellers (replacements):

8045 Carbon Fibre Propellers


- Material: carbon fiber
- Size: 8 x 4.5"
- Shaft diameter: 5mm
- Total length: 20cm
- Weight: 5.2g for each prop

MPU 6050

MPU-6050 gyro / accelerometer


- Power supply: 3~5V
- Communication mode: standard IIC communication protocol
- Chip built-in 16bit AD converter, 16bit data output
- Gyroscopes range: +/- 250 500 1000 2000 degree/sec
- Acceleration range: +/- 2g, +/- 4g, +/- 8g, +/- 16g

Next up we will start construction...



Tuesday, November 7, 2017

Salae Logic & Protocol Analyzer 8 - Review and Tutorial

Overview




My latest acquisition is the Salae Logic Analyzer. I was very tempted to get the top of the line model, the Logic Pro 16, but decided I might as well see how useful it was before splashing out that much more cash. A reasonable compromise seemed to be the Logic 8 model.

What is a Logic / Protocol Analyzer?


A logic analyzer is an instrument that captures and displays multiple signals from a digital system or digital circuit. They are used for testing or debugging digital or logic circuits. The device
connects to a PC over USB and uses the Saleae Logic Software to record and view digital and
analog signals.  It operates by sampling a digital input connected to a device under test
(DUT) at a high sample rate. These samples are recorded to a sample buffer, and at the end of the
capture, the buffer is displayed in the software for review.

The following from the Logic 8 data sheet, explains where you would mostly use the device.

Logic analyzers are great for debugging embedded applications. In the most common case, a developer working on firmware for a microcontroller will write code to communicate with another component, possibly using protocols like serial, I2C, or SPI. To verify the functionality or
to diagnose errors in the firmware, a logic analyzer is connected to the digital IO used for
communication and records the activity during testing. The recording is then shown on the display
so the user can view the actual behavior of the firmware, and compare that with the expected
behavior to narrow down and identity the source of the issue – or verify that the operation is
correct.

Many oscilloscopes can perform a similar function, the advantage of the logic analyzer is that it can simultaneously display multiple signals (8 in my case) and relative timing information. The following from Radio Electronics, provides a good summary of the difference between a Logic Analyzer and an Oscilloscope.

  • Provide a time display of logic states:   Logic analysers possess a horizontal time axis and a vertical axis to indicate a logic high or low states. In this way a picture of the digital lines can be easily displayed.
  • Multiple channels:   Logic analyzers are designed to monitor a large number of digital lines. As logic analyzers are optimised for monitoring a large number of digital circuits, typically they may have anywhere between about 32 and 200+ channels they can monitor, each channel monitoring one digital line. However some specialised logic analyzers are suitably scaled to be able to handle many more lines, and in this way enable tracking and fault finding on much more complex systems.
  • Displays logic states:   The vertical display on the analyser displays the logic state as a high of low state. The signals enter the various channels and are converted into a high or low state for further processing within the analyser. It provides a logic timing diagram of the various lines being monitored.

Most Logic Analyzers don't allow you to analyse analogue data. The Logic 8 allows any of the 8 channels to be used for either analogue or digital analysis. The device expects an input voltage range of 0 to 5V but can handle a maximum of -25 to +25V. This is perfect for the Arduino and Raspberry Pi.

Note however  that although the device wont blow up if you connect 25V, the analog input on Logic 4 and Logic 8 is limited to +0V to +5V, and will saturate (take on minimum or maximum value) outside of this range. Logic Pro 8 and Logic Pro 16 have an analog input limited to -10V to +10V, and will saturate outside of that range. So probably not so good for working with RS 232.

Protocol Analyzers decode data that has been encoded according to a particular protocol, such as SPI or I2C. The Logic software currently offers 23 different protocol analyzers. Each protocol analyzer needs to be set up to tell it what channels to use for what (e.g. SDA = channel 0, SDC = channel 1 for I2C).

Setting Up


Getting the unit working is pretty straight forward. Start by downloading the software from Salae. Then connect the unit via the USB port. One minor irritation is that you have to connect the test clips to the wire harness yourself.


This is just a matter of pushing the lead into the test clip but it requires quite a bit of pressure or it will just fall off again. I used long nose pliers to ensure that the leads stayed put.

Bandwidth vs Sample Rate


In order to accurately record a signal, the sample rate must be sufficiently higher in order to preserve
the information in the signal, as detailed in the Nyquist–Shannon sampling theorem. Digital signals must be sampled at least four times faster than the highest frequency component in the signal.

Analog signals need to be sampled ten times faster than the fastest frequency component in the signal.

Active Channels vs Maximum Sample Rate


The maximum sample rates for digital and analog recordings is limited by the available USB bandwidth.

Because of this, sampling at the maximum rate is not possible on all channels at once. Some example sample rate combinations:

  • 3 channels, digital only, 100 MSPS
  • 2 channels, analog only, 10 MSPS
  • 8 channels, digital only, 25 MSPS
  • 8 channels, analog only, 2.5 MSPS

Using the Logic Analyzer


The big question is what can I do with this kit and is it useful? To answer this question, I will use the Logic Analyzer in a few typical scenarios and see how it goes.

Test 1 - PWM

As a first test I will look at Pulse Width Modulation (PWM) on the Arduino. Actually I will use the STEMTera breadboard for this test, it is an Arduino built into a breadboard and is handy for prototyping and testing.



I've connected an LED across pin 9 and GND, with an appropriate current limiting resistor. The simple sketch below should produce a square wave on pin 9 with a frequency of 500Hz and a 50% duty cycle.

// PWM demo to test Salae Logic 8
// 
// Arduino's PWM frequency is about 500Hz.
// A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) 
// requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle 
// (on half the time).

#define LED9    9

void setup() 
{
  pinMode(LED9, OUTPUT);
  analogWrite(LED9, 127);
}

void loop() 
{
  
}
Using channel 0 on the Logic 8 produces the following when I connect the probes across the LED.


As expected, we get a square wave with a period of 2 ms (1 / 500 Hz = 2 ms) and a 50% duty cycle. As a further check, I changed analogWrite(LED9, 64) to get a 25% duty cycle, and captured:


So for checking PWM duty cycle, this is a handy tool. The other thing that actually measuring the waveforms is good for is to test your assumptions. Initially, I was expecting the square wave to go from 0 - 5V, and if you disconnect the LED and measure from pin 9 to ground that is exactly what you get. However, with the LED in place and with our probes across the LED, the square wave goes from zero to approximately 2V. This is of course the characteristic forward voltage drop across the LED. To check this, I stuck the LED in the LCR tester which measured a Vf = 1.69V.



Test 2 - SPI

Next I will try out an application which uses the SPI protocol. This will test out the functionality of the protocol analyser and is something that you couldn't do as easily on a 2 channel DSO (since we are looking at 3 channels - DIN, CS and CLK).

We will use the Duinotech 8x8 LED Dot Matrix module described in a previous post. This communicates with an Arduino using SPI via the MAX7219 chip.

The Serial Peripheral Interface bus (SPI) is a synchronous serial communication interface specification used for short distance communication, primarily in embedded systems. The interface was developed by Motorola in the late 1980s and has become a de facto standard. Typical applications include Secure Digital cards and liquid crystal displays [Wikipedia].

The SPI bus specifies the following logic signals:

CLK: Serial Clock (output from master).
DIN: Master Output Slave Input, or Master Out Slave In (data output from master).
CS: Slave Select (often active low, output from master).
MISO: Master Input Slave Output, or Master In Slave Out (data output from slave) - not used in our application.

In our example, the Arduino is the Master and the LED Module is the Slave. As we are only connecting using 3 wires, communication is one way, from the Master to the Slave.

To begin communication, the master selects the slave device with a logic level 0 on the select line (CS). During each SPI clock cycle, a full duplex data transmission occurs. The master sends a bit on the DIN line and the slave reads it. For a 4 wire application the slave sends a bit on the MISO line at the same time and the master reads it. This sequence is maintained even when only one-directional data transfer is intended.

As described in our post on the 8x8 Led Matrix Module, we are controlling the module using the LedControl Arduino library. The first thing that we noticed when hooking up the Logic / Protocol Analyzer was that the clock speed appeared to be too slow. As expected, the CS line went low to kick things off.

The hardware SPI CLK on the Arduino is usually running at between 25kHz to 8MHz with a default of 4MHz. As shown in the screen capture below, we are measuring a clock frequency of about 64kHz.


This made me investigate the LedControl library in more detail. It turns out that the Library doesn't use the hardware SPI but emulates the SPI protocol using bit banging. In retrospect this is obvious since you can assign any digital input to the DIN, CS and CLK functions. Using hardware SPI these pins are set (see table 1).

A quick look at the LedControl source code shows that it is using the Arduino shiftOut() function to do most of the control of the logic lines. The syntax of the command is:

shiftOut(dataPin, clockPin, bitOrder, value)

It shifts out a byte of data one bit at a time. Starts from either the most (i.e. the leftmost) or least (rightmost) significant bit - MSB first for LedControl. Each bit is written in turn to a data pin, after which a clock pin is pulsed (taken high, then low) to indicate that the bit is available. So the clock speed will not necessarily be consistent, the pin transition happens when the data is ready - also not what I was expecting.

If you want to, you could trace every byte being transmitted to the LED module. For example the first byte of the "smile" image is 0x3C, you can see this being sent on the MOSI line in the screen shot below. The logic analyzer software allows you to search the decoded protocols which makes it easier to find a particular byte.



Arduino / Genuino BoardMOSIMISOSCKSS (slave)SS (master)
Uno or Duemilanove11 or ICSP-412 or ICSP-113 or ICSP-310-
Mega1280 Mega256051 or ICSP-450 or ICSP-152 or ICSP-353-
LeonardoICSP-4ICSP-1ICSP-3--
DueICSP-4ICSP-1ICSP-3-4, 10, 52
ZeroICSP-4ICSP-1ICSP-3--
10111 or ICSP-412 or ICSP-113 or ICSP-31010
MKR10008109--
Table 1. Arduino H/W SPI Pins

Conclusion


The question at the start was what can we do with a Logic / Protocol Analyser and is it useful? I have tested a couple of examples and based on this I think it will be very useful. If something is not working as expected, it may be because your assumptions were wrong. This was demonstrated very clearly above and I will be measuring my designs a lot more to ensure that the designs are doing what they should be.

Of course it also demonstrates that you don't need to understand how SPI works, to get an Arduino to talk with an 8x8 LED Module.

APPENDIX - Key Specifications - Salae Logic 8


  • Eight Digital Channels
  • 100 MSPS Digital Sampling (max)
  • 25 MHz Max Digital Bandwidth
  • Eight Analog Channels
  • 10 MSPS Analog Sampling (max)
  • 1 MHz Analog Bandwidth
  • Recording Length Limited by Available RAM and Density of Recorded Data
  • RGB LED, Customizable 24 bit Color


APPENDIX - Electrical Characteristics








Sunday, November 5, 2017

Duinotech 8 x 8 LED Dot Matrix Module Red

Introduction



Jaycar in Australia have a range of Arduino compatible kit, one such piece is the Duinotech 8 x 8 LED Dot Matrix Module Red. They provide the following specifications:

A 64 Red LED matrix, this module is easily controlled with the Led Control library. Display your own custom characters, or use multiple modules together to make a scrolling display.

•    Operating Voltage: 5VDC
•    Protocol: SPI (Shift-Register)
•    Chipset: MAX7219
•    LED Colour: RED
•    Dimensions: 62(W) x 32(H) x 14(D)mm

This is fine but doesn't really demonstrate how to use it. So I don't have figure this out again and to hopefully assist someone else who might want to use the module, I have summarised the key information below.

Hardware


Connection is very straight forward. From the dot matrix module:

VCC - connects to 5V on the Arduino
GND - connects to GND
CLK - connects to Arduino D10
CS - connects to Arduino D11
DIN - connects to Arduino D12

You can change the CLK, CS and DIN pin assignments in the software (see below).

Software


To drive this module you need the LedControl library. LedControl is an Arduino library for MAX7219 and MAX7221 Led display drivers. The code also works with the Teensy. Download this library and unzip it into your Arduino libraries folder. You can then try out the library using the sample code provided.

#include <LedControl.h>

int DIN = 12;
int CS =  11;
int CLK = 10;

LedControl lc=LedControl(DIN,CLK,CS,0);

void setup(){
 lc.shutdown(0,false); // The MAX72XX is in power-saving mode on startup
 lc.setIntensity(0,7); // Set the brightness, 15 = maximum value
 lc.clearDisplay(0);   // and clear the display
}

void loop(){ 

    byte smile[8]=   {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C};
    byte neutral[8]= {0x3C,0x42,0xA5,0x81,0xBD,0x81,0x42,0x3C};
    byte frown[8]=   {0x3C,0x42,0xA5,0x81,0x99,0xA5,0x42,0x3C};
    
    printByte(smile);
    delay(1000);
    printByte(neutral);
    delay(1000);
    printByte(frown);    
    delay(1000);
    lc.clearDisplay(0);
    delay(1000);
}

void printByte(byte character [])
{
  int i = 0;
  for(i=0;i<8;i++)
  {
    lc.setRow(0,i,character[i]);
  }
}
The initialization code for the lc variable through which we talk to the MAX72XX devices takes 4 arguments. The first 3 arguments are the pin-numbers on the Arduino that are connected to the MAX72XX. These can be any of the digital IO-pins on an Arduino. In the example, pins 12,11 and 10 were chosen.

The fourth argument to LedControl(dataPin,clockPin,csPin,numDevices) declaration is the number of cascaded MAX72XX devices that you're using with this LedControl. The library can address up to 8 devices from a single LedControl variable. There is a small performance penalty with each device you add to the chain, but the amount of memory used by the library code will stay the same, no matter how many devices you set. Since one LedControl cannot address more than 8 devices, only values between 1-8 are allowed.

LED Byte Generator




If you want to design your own images to display on the Dot Matrix module, the easiest way is to download the LED Byte Generator written by Bernhard Hofmann. This Javascript app generates byte codes for sending to an LED matrix.

It works for for 8x8 LED matrices driven by the MAX7219/MAX7221 to use in code such as C/C++ or Energia and run on an Arduino, Raspberry Pi or micro controller such as the MSP430.

To run the app, just File - Open the index.html file in your browser.




Wednesday, October 4, 2017

LCR-T4 Mega328 Component Tester



LCR-T4 Component Tester


I recently picked up an LCR-T4 Component Tester from E-Bay. I've had my eye on these for a while and for AUD12 (including the acrylic case), I thought it was worth giving one a try. There are LOTS of different versions out there.



So what does it do?

Well it measures components, including resistors (and potentiometers), inductors, capacitors, diodes, dual diodes , transistors (including MOS), SCR's, regulators, LED's, and even ESR.

Photo Credit: EEVBlog


The claimed accuracy is:

Resistance: 0.1 ohm resolution, maximum 50M ohm
Capacitor: 25pf -100,000 uf
Inductors: 0.01mh-20H

These are probably a touch optimistic but for picking out components, the accuracy is adequate.

Photo Credit: EEVBlog

This unit apparently comes with the 2013 M328 version of the software and includes a 128*64 backlit LCD display, which uses about 2mA in stand by. As you can see in the image above, the unit will automatically identify and tell you which pin is the BCE for a transistor, not to mention the gain and forward voltage - nice! One of the features is automated detection of pin assignment, which means the device can be connected to the tester in any order. You can only use pins 1,2,3 of the DIL socket.

The open source firmware and hardware design is based on the work of a couple of German dudes. If you were brave you could flash the firmware to the latest version.

Case Construction





Building the case is fairly simple. What takes the longest is peeling the paper from the laser cut acrylic sheets! Proceed as follows:

  1. Peel the paper from the acrylic (both sides).
  2. Mount the PCB on the base plate using the four smaller bolts and the spacers (see photos below). You may want to pass the battery cable under the PCB, but it isn't compulsory.
  3. Insert the side panels into the base, starting with the top one as it has the tightest fit against the screen ribbon cable.
  4. Snap the top plate in place, it will only fit one way. This should hold things in place while inserting the 4 long bolts and nuts which hold everything together. Done!






What Manual?


The first trick is to make sure that you use a fresh 9V battery, if you don't then the display will be unreadable.

Operation is pretty straight forward. Just plug the component that you want to test into pins 1, 2 or 3 on either side of the DIL socket, then press the blue test button. The unit turns itself off after displaying the results for 10 seconds. If you have surface mount components, you can use the pads on the PCB labelled 1, 2 and 3 instead of the DIL socket.

The unit will automatically detect NPN & PNP transistors, N- and P-channel MOSFETs, JFETs, diodes, small thyristors, and TRIACs. It will measure hFE and base-emitter-voltage for bipolar junction transistors (e.g. Darlingtons).

Up to two resistors can be measured with a resolution down to 0.1 ohm. The measurement range is up to 50 Mohm (Megaohm). Resistors below 10 ohms will be measured with the ESR and a resolution of 0.01 ohm. Note that resolution is not equivalent to accuracy.

Capacitors in the range 35pF (picofarad) to 100mF (millifarad) can be measured with a resolution down to 1 pF. Inductances of 0.01 mH to 20 H can be detected and measured.

The short video below shows an LED being tested.