Skip to main content

Messages

This section allows you to view all Messages made by this member. Note that you can only see Messages made in areas you currently have access to.

Messages - jbeale

62
General discussion / Re: Teensy 3.0 arrived
Explanation of terms used in descriptions of ADCs (analog to digital converters)

LSB = least significant bit. "1 LSB" is one count from an ADC. The 10-bit Arduino (ATmega328p) ADC has 2[sup:]10[/sup:] = 1024 levels, so the size of 1 LSB is 1/1024 of full scale or about 0.1 %.  Normally full scale is the power supply of 5 V, so 1 LSB is about 5 mV.  On the '328p you can also select the internal 1.2V reference, with the function [font=Courier:]analogReference(INTERNAL);[/font:]  ...in which case 1 LSB is just over 1 mV, or select the external reference input pin, so 1 LSB is about 0.1% of whatever voltage that is.

On the Teensy 3, in full-resolution mode you get 2[sup:]16[/sup:] or 65536 levels, so 1 LSB is 1/65536 of full scale, which is about 15 ppm (parts per million). So the Teensy 3's ARM chip has 64 times more levels on its ADC than the '328p gives you, but you may not get that much actual resolution if there is a lot of noise (difference between the actual voltage and the reading you get). Noise can come (for example) by capacitive pickup of digital signals elsewhere in the CPU chip, or thermal noise in resistors, etc. 

P-P noise = Peak to Peak noise. This is the difference between the maximum and the minimum reading, for a fixed input value. It should be specified with a sample size, as it does not converge to a fixed value with larger numbers of samples, like root-mean-square noise does.  As you keep sampling for longer times, you pick up increasingly rare, ever larger noise peaks.

Standard Deviation is a statistical value describing how widely a set of values varies from the average.  If you put a fixed, noise-free voltage into an ADC and take some large number of readings, and then take the standard deviation of those readings, that is the RMS (root mean squared) noise of the ADC itself.  The Teensy 3 ADC has about 1 LSB of RMS noise in the circuit I tested. With a 3.3V supply as the reference, that means I have Vrms = 50 uV.  With the "white noise" assumption (usually correct), about 68% of all readings I take will be within +/- 1 standard deviation = 50 uV of the true value. See also: Wiki: Standard Deviation.

Relatively low resolution ADCs (8 or 10 bits) often have much less than 1 LSB of noise, so with a fixed voltage input, a set of 100 readings might all be the same value. In that case, averaging readings will not improve your resolution. With 1 LSB of noise, averaging together n=100 readings will (in theory) improve the resolution of your measurement by a factor of sqrt(n) = 10.  Note that resolution is not the same thing as accuracy.

For an ADC to be accurate, the voltage offset (counts with 0 input), the gain (counts per volt), and the integral and differential nonlinearity (hopefully negligible) must be known and unchanging so that a calibration remains valid.  I have not tested those parameters on the Teensy 3 yet, although I did note the offset depends on input capacitance, and system clock frequency. The ADC resolution as a fraction of full scale is described by the bit depth and the noise, and is independent of gain and voltage offset.
63
General discussion / Teensy 3.0 arrived
Yesterday's mail had my Teensy 3.0 (ARM Cortex-M4 with Arduino-style programming). This is from Paul's kickstarter (US Mail takes 2 days from OR to CA, it seems). Some pics: Teensy3, and on breadboard

My first test was to see how good the on-board ADC is. It is 16 bits, but Paul had said due to noise, it is effectively only 13 bits. You can see my experimental setup in this photo.  ADC0 is driven by a 499/1.0k resistive divider from Vdd to AGND (analog ground pin), and a 0.1 uF cap from ADC0 to AGND.  In this case Vref = Vdd = 3.266 V and ADC0 input is 2.171 V (per Fluke 179). This gives an expected reading of 65535*(2.171/3.266) = 43563 counts, where 1 LSB = 49.84 uV.  Running the below code, with a sample size of 10000 readings, I get a standard deviation of just about 1 LSB (so RMS noise = 50 uV) and peak-peak noise of 7 counts, and a DC offset from the expected reading of 10-20 LSBs (= 0.5 to 1 mV).

 The noise and offset from the expected reading depends somewhat on the clock rate set.  Without that 0.1 uF cap from ADC0 to AGND, both p-p and std.dev noise increase about 3.5 times.  The board is being powered by (no doubt noisy) +5.18V from a USB hub on a PC monitor, the 3.266 V is from the on-board regulator.  The AGND pin is sensitive with this simple unshielded setup: even just connecting the ground lead of my battery-powered Fluke 179 multimeter and nothing else (and with the meter powered off) increases RMS noise from 0.9 to 1.6 LSB.

By the way, compiling and downloading code to T3 is a lot faster than with a standard Arduino. The attached code compiles, downloads, and is running in about 2.5 seconds!  Also, the USB ACM interface is remarkably faster than the 115.2k Arduino if you want to send a lot of data via serial.print() output.

Sample Output from ADC test program:
Code: [Select]
# Teensy 3.0 @ 96 MHz
# Samples/sec: 2246.69 Avg: 43582.86 Offset: 19.94 P-P noise: 7 St.Dev: 0.944
# Samples/sec: 2245.68 Avg: 43583.17 Offset: 20.25 P-P noise: 8 St.Dev: 0.938
# Samples/sec: 2245.68 Avg: 43583.22 Offset: 20.31 P-P noise: 7 St.Dev: 0.931
# Samples/sec: 2245.68 Avg: 43583.40 Offset: 20.48 P-P noise: 8 St.Dev: 0.940
# Samples/sec: 2246.18 Avg: 43583.25 Offset: 20.33 P-P noise: 8 St.Dev: 0.921

# Teensy 3.0 @ 48 MHz
# Samples/sec: 2236.64 Avg: 43583.83 Offset: 20.92 P-P noise: 9 St.Dev: 1.116
# Samples/sec: 2236.64 Avg: 43583.67 Offset: 20.76 P-P noise: 8 St.Dev: 1.123
# Samples/sec: 2236.14 Avg: 43583.81 Offset: 20.89 P-P noise: 8 St.Dev: 1.117
# Samples/sec: 2236.64 Avg: 43583.73 Offset: 20.81 P-P noise: 10 St.Dev: 1.107

# Teensy 3.0 @ 24 MHz
# Teensy 3.0 ADC test start:
# Samples/sec: 2156.10 Avg: 43573.35 Offset: 10.44 P-P noise: 7 St.Dev: 0.913
# Samples/sec: 2156.10 Avg: 43573.42 Offset: 10.50 P-P noise: 8 St.Dev: 0.928
# Samples/sec: 2156.10 Avg: 43573.55 Offset: 10.64 P-P noise: 7 St.Dev: 0.927
# Samples/sec: 2156.10 Avg: 43573.44 Offset: 10.52 P-P noise: 7 St.Dev: 0.907
# Samples/sec: 2156.10 Avg: 43573.33 Offset: 10.42 P-P noise: 7 St.Dev: 0.923

Code for ADC test program
Code: [Select]
// Analog input test for Teensy 3.0    Oct 4 2012 J.Beale
// Setup: https://picasaweb.google.com/109928236040342205185/Electronics#5795546092126071650

    #define VREF (3.266)        // ADC reference voltage (= power supply)
    #define VINPUT (2.171)      // ADC input voltage from resistive divider to VREF
    #define ADCMAX (65535)      // maximum possible reading from ADC
    #define EXPECTED (ADCMAX*(VINPUT/VREF))    // expected ADC reading
    #define SAMPLES (10000)      // how many samples to combine for pp, std.dev statistics

    const int analogInPin = A0;  // Analog input is AIN0 (Teensy3 pin 14, next to LED)
    const int LED1 = 13;        // output LED connected on Arduino digital pin 13

    int sensorValue = 0;        // value read from the ADC input
    long oldT;

    void setup() {    // ==============================================================
      pinMode(LED1,OUTPUT);      // enable digital output for turning on LED indicator
      analogReference(INTERNAL);  // set analog reference to internal ref
      analogReadRes(16);          // Teensy 3.0: set ADC resolution to this many bits
   
      Serial.begin(115200);      // baud rate is ignored with Teensy USB ACM i/o
      digitalWrite(LED1,HIGH);  delay(1000);  // LED on for 1 second
      digitalWrite(LED1,LOW);    delay(3000);  // wait for slow human to get serial capture running
   
      Serial.println("# Teensy 3.0 ADC test start: ");
    } // ==== end setup() ===========

    void loop() {  // ================================================================
   
      long datSum = 0;  // reset our accumulated sum of input values to zero
      int sMax = 0;
      int sMin = 65535;
      long n;            // count of how many readings so far
      double x,mean,delta,sumsq,m2,variance,stdev;  // to calculate standard deviation
   
      oldT = millis();  // record start time in milliseconds

      sumsq = 0; // initialize running squared sum of differences
      n = 0;    // have not made any ADC readings yet
      mean = 0; // start off with running mean at zero
      m2 = 0;
   
      for (int i=0;i<SAMPLES;i++) {
        x = analogRead(analogInPin);
//        Serial.println(x,0);
        datSum += x;
        if (x > sMax) sMax = x;
        if (x < sMin) sMin = x;
              // from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
        n++;
        delta = x - mean;
        mean += delta/n;
        m2 += (delta * (x - mean));
      }
      variance = m2/(n-1);  // (n-1):Sample Variance  (n): Population Variance
      stdev = sqrt(variance);  // Calculate standard deviation

      Serial.print("# Samples/sec: ");
      long durT = millis() - oldT;
      float datAvg = (1.0*datSum)/n;
      Serial.print((1000.0*n/durT),2);

      Serial.print(" Avg: ");    Serial.print(datAvg,2);
      Serial.print(" Offset: ");  Serial.print(datAvg - EXPECTED,2);
      Serial.print(" P-P noise: ");  Serial.print(sMax-sMin);
      Serial.print(" St.Dev: ");  Serial.println(stdev,3);
   
//    while (true) {}
    } // end main()  =====================================================
65
General discussion / board-to-board connections without a connector
I recently got a $30 USB microscope (close-focus webcam) from Amazon, specifically this one.

lsusb reports  05e3:0511 Genesys Logic, Inc. 
and Windows says BRIGHTWELL BEAUTI-CAM

Video is 640x480 and picture quality is about what you expect from a cheap webcam (sample photo).

Looking inside, I thought the construction was interesting. There is a small square PCB holding the camera module, and another square board in front of that holding 8 white 0603 LEDs. The camera PCB is connected at right angles to the main PCB without using a connector. The boards are just butted together. The camera board has small notches on two opposite edges, which receive matching tabs on the main board for alignment.  Solder is flowed between each pair of pads which almost touch each other, forming an L shape. The joints are somewhat visible in this photo (not visible are the similar pads on the bottom side, a total of 19 connections)

I haven't seen this before. Is this type of construction considered "manufacturable"?  I guess so if a cheap webcam uses it (?)
66
Project logs / Re: Latest PCB batch of 11 designs just arrived from Seeedst
[quote author="matseng"]Maybe some specialized filter can do 6 mil whites but also ensure that single blacks are at least 10 or 12 mils to make the image look even better.[/quote]

Impressive results! I think the ink dot spreading (making image too dark with black ink, or too light with white ink) is known as "dot gain" in the offset-printing business. You can compensate for it with the right dithering software. See for example: http://en.wikipedia.org/wiki/Dot_gain

I guess the first step would be to submit a grey-scale step pattern or wedge to calibrate the process, to find out what correction to apply. Of course the silkscreen process parameters are likely to change over time...
67
General discussion / Re: current draw from small USB WiFi adapters
Just FYI, I got my 2nd R-Pi on Friday, and discovered a nice change. This issue is now less critical if you get one of the latest R-Pi boards (shipping as of last week) because of the change you see here:
https://picasaweb.google.com/1099282360 ... 0375008498
As you can see, USB fuses F1,F2 are now 0-ohm jumpers. Your total current draw including CPU & Ethernet is still limited by the 750 mA input fuse though. And heating of the board traces, if you bypass that fuse eg. by powering through the +5V on the GPIO pins.
69
General discussion / shorter soldering iron tip?
I've been soldering for about 35 years and I think the answer to my question is "no", but maybe someone here knows of something:

I recently realized that one reason it's easier to solder at work than at home (apart from the nice binocular microscope) is that we have Metcal MX-500P-11 soldering irons. Apart from the fast warmup time, the Metcal is easy to use because the tip is only 4 cm away from the hand grip, enabling precision work.  I cannot afford my own Metcal, so at home I have a cheap Radio Shack iron with a tip about 8 cm away from the grip.  Since it is 2x as long as the Metcal, any deviation in the angle of my hand is multiplied by 2x at the tip, and that makes a real difference with accuracy.

My question: is there any affordable iron with a very short grip to tip distance? Or is that not practical with a simple, conventional iron?  The Metcal uses RF power from the remote base going right to the tip, so there is no separate heating cartridge in the handpiece to design around.
70
Project development, ideas, and suggestions / Re: CPiLD
It is interesting. Whether I want one myself would depend on the price. The schematic shows a generic oscillator, would that be stuffed and if so what frequency? Could I get just the PCB, without parts?
71
General discussion / Re: current draw from small USB WiFi adapters
Just got one more, which I tested this evening in the same way. It draws more current both in standby and when active, although it is not any faster. It does see several more local APs via inSSIDer than the other two, smaller adapters, which may mean it is better at very-weak-signal work. In counting APs I do not count as separate a few groups of APs showing sequential MAC IDs, which I presume are the same physical device presenting different interfaces. One neighbor has a TRENDnet device listing eight different MAC addresses, which seems excessive (4 on ch.11, 4 on ch.8+4).
-----------------------
http://www.amazon.com/gp/product/B002WBX9C6
TP-Link TL-WN722N USB-WiFi N adapter  (external 4 dBi antenna)
standby: 123 mA
DSL provider speed test, transmitting: 140 mA (max)  0.91 Mbps
DSL provider speed test, receiving: 159 mA (max) 12.23 Mbps
iperf speed test to local WinXP box: 260 mA (max) 31.3 Mbps

ping to local WinXP: min/max/avg: 1/7/2 msec
24 different APs visible with provided 4 dBi antenna
29 different APs visible with TP-Link 8 dBi antenna
works OK with 6' USB cable
never goes higher than 65 Mbps indicated link speed, even at -24 dBm signal and about 5 feet from my AP
72
General discussion / current draw from small USB WiFi adapters
In case of interest, I'm posting the below comment I just put in the Raspberry Pi forums. The R-Pi has polyfuses that limit the built-in USB ports to devices using less than about 140 mA of current.  It turns out that you can use some USB WiFi adaptors directly without a powered hub, BUT only if you don't go too fast.
==============

Just compared two small USB-WiFi N adapters from ebay.  Both devices connected easily from my WinXP laptop to my Linksys WRT160Nv2 router, reporting excellent signal and 72 Mbps link speed. It is interesting to see that both devices keep under the 100 mA limit while working the internet at my DSL speed. But going to a machine on the LAN, the speed goes up and the current draw goes up with it, above 150 mA which is more than the unmodified RPi USB port can reliably provide.  So I'd expect either of these devices would be perfectly reliable for internet browsing used direct in the RPi without a supply, but UNreliable for heavy LAN use (eg. high-bitrate video streaming).  ...Unless you have faster internet than I do, in which case, web use might hit overcurrent also.

By the way, the RTL8188CU device worked fine at the end of a six foot USB extension cable. The RT5370 device was not reliable on that cable, although it was fine with a 1-foot extender cable.
---
http://www.ebay.com/itm/260976202890
Ralink RT5370 USB-WiFi N adapter (small external 2 dBi antenna)
standby: 66 mA 
DSL provider speed test, transmitting: 75 mA (max)  12 Mbps
DSL provider speed test, receiving: 82 mA (max) 0.91 Mbps
iperf speed test to local WinXP box: 173 mA (max) 34.3 Mbps
---
http://www.ebay.com/itm/330646461862
Ralink RTL8188CU USB-WiFi N adapter  (internal antenna)    <-EDIT: actually Realtek brand, not Ralink
standby: 84 mA
DSL provider speed test, transmitting: 96 mA (max)  11 Mbps
DSL provider speed test, receiving: 94 mA (max) 0.91 Mbps
iperf speed test to local WinXP box: 157 mA (max) 18.7 Mbps
---
I compared the RT5370 with the included 4-inch long 2 dBi antenna and also a (claimed) 8 dBi TP-Link antenna about 11 inches long.  I did not see much difference in the RSSI figures from inSSIDer. A directional antenna works better in open space than indoors with confused beam patterns from all the reflections.

Last item, the first RT5370 I got stopped working after a few days (the ebay guy sent a replacement; thanks!) so I took it apart to have a look, if you're interested:
https://picasaweb.google.com/lh/photo/_ ... directlink
https://picasaweb.google.com/lh/photo/_ ... directlink
73
General discussion / Re: sample code for LTC2440 24-bit ADC
Hey, I just opened an old box, and what do you know, the circuit is still there.  As I said, not very pretty. I had series resistors on the digital lines to the Arduino on the theory it might reduce edge rates and hence digital noise coupling. Not sure there was much benefit though.  You can also see a LTC1052 "zero-drift" chopper-stabilized amplifier on the right, not connected. I was using a LT1021B as a 5V reference (not shown).


https://picasaweb.google.com/1099282360 ... 3269182194
74
General discussion / Re: sample code for LTC2440 24-bit ADC
I don't have any photos (it was a rather crude setup anyway) and I don't have it set up right now... as you'll note from the code, this was from back in 2010.  I only just posted the code now since a user here doing a LTC2440 sensor project sent me a PM to request it.
75
General discussion / Re: good storage box for PCBs (Arduino-sized) ?
For what it's worth- I came across a Plano #5305 box at a garage sale. These are made for baseball playing cards. The divisions are large enough for Arduino-sized boards with enough room for extra attached wires, small accessory boards, etc.  You can see here a Seeduino Mega, and a DP CPLD board among others:

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01912487744session_write_close ( )...(null):0
20.01942619360ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01942620136Database_MySQL->query( ).../DatabaseHandler.php:119
40.06412758896Database_MySQL->error( ).../Db-mysql.class.php:273