Mad Scientist Hut Blog
The Forums The Blog Lyons Cam About us Contact Products
  • Product Pipeline
  • Daily Blog
    • MISC
      • Basic Circuits
  • Joule Thief
  • 3-Axis G Sensor
  • Geiger counter
  • Ion Chamber (Radiation Detector)
  • MSP430
 
  Older Entries »

Lessons in measurement error

By john, on March 24th, 2012%




I built a tachometer for the milling machine, as a step in giving the cnc controller full spindle control (auto-change with tool change, and sense when it’s stalling.)  The first version uses an arduino and this code: http://arduino.cc/playground/Learning/Tachometer

The sensor is a mouse encoder wheel LED/phototransistor pair, with a turned aluminum disc that has a hole drilled in it, as the encoder itself.

(You may ask why I’m not using an AS5040.  That’s the wrong tool for the job, since it senses position rather than just rotation, and the encoder wheel I just cut fits right on the hollow mill spindle, which provides no easy place to put a magnet.)

Anyway.  The arduino code works fine.  The schematic, however, has a problem: if you wire it up just as this says, the phototransistor output is always at about Vcc: the analog input to the arduino measures between 1017 and 1023 no matter how carefully you block the phototransistor.

But the moment you go to measure the voltage coming off the phototransistor with respect to ground, it works perfectly: any bit of anything blocks the lightbeam and the output goes to a fraction of a volt.

The meter’s input impedance drags down the output and makes it work.  It’s hard to troubleshoot something that works when you’re measuring it, and only doesn’t work when you’re not measuring it.

A 1 megohm resistor between the output and ground makes it work great.

optical tachometer schematic

optical tachometer schematic

 

Tomorrow I’ll add an LCD rather than having to keep a laptop in there to see the RPM, and a bit later I’ll turn the whole thing into a standalone board on the back of the LCD, but for the moment this will do.

 


Comments are closed   Daily Blog, MISC   Arduino tachometer  

usb sniffing using wireshark

By john, on March 24th, 2012%

A while back Kirk gave me a webcam that has pan and tilt control. It works well under Windows. But I’m a masochist — and I already have a weather station + insolation + multiple temperature measurement setup for an old linux laptop, and I thought it’d be nice to add a pan&tilt webcam to the mix.
The webcam is a Creative Live! Motion cam. It uses a standard ccd for which drivers are included in the mainline kernel so camorama et al can get video from it natively. But that doesn’t handle motion.
Soooo I fired up wireshark, preparing to copy these guys:

http://techblog.vsza.hu/posts/Reverse_engineering_chinese_scope_with_USB.html

who reverse-engineered the screendump program for an oscilloscope (and found that the scope actually dumps a nice full-color high-resolution screencap that the stock software degrades to a small monochrome picture.)

So I installed XP in virtualbox, installed the cam drivers in XP, and fired up the camera.
Problem 1: no USB. I solved this by running virtualbox as root.
Problem 2: XP crashed the moment I tried to do anything with the camera. I solved this by starting virtualbox as root, and doing the whole XP install from that — just copying over a VM made as a user didn’t do it.
At this point the camera is stable in XP.
Problem 3: wireshark crashed the camera connection. As soon as wireshark came up, the USB stream got broken.
My friend Brian pointed out that other people have had problems with old versions of libpcap, upon which wireshark relies. Turns out even recent versions of Ubuntu and Mint have wireshark packages from 2007.
Independent repositories to the rescue: ppa:jelmer/daily will provide you with (as of right now) wireshark 1.4.2 rather than the stock 0.9 and that has a libpcap that works beautifully.
So now I can drive the video camera around, taking pictures, and logging usb commands. I can look through the packets — ignoring the 64kbyte ones, that are just chatter between the computer and the camera and analyzing the packets that are larger than that — and start figuring out how I can copy them.

That’s as far as I’ve gotten so far, because now I’m learning how to use wireshark’s filters so I can have it show only the differences between sequential packets.

Comments are closed   Daily Blog, MISC   USB Sniffing, wireshark usb  

Expanded Scale Analog Meter Circuit

By Kirk, on February 25th, 2012%

I am putting in a small scale solar system with a 24VDC flooded lead acid battery bank for back up power. I want to make a low power consumption expanded scale analog meter circuit to monitor the battery bank voltage of my system. The expanded scale allows me see the voltage range that I am most concerned about between 21V to 30V and that gives me about three times the resolution on the meter face.

 

While searching for circuit ideas I found this website “The Back Shed” and I liked the simplicity of the circuit that they presented on their site (this is the circuit from their site). I tried to make the circuit but found that the response was not very linear.

 

 

 

 

 

The problem with this circuit is that the current going through the Zener diode changes as the voltage input to the circuit changes (I=V/R) because it uses a simple resistor current limit.

Zener diode voltages are specified at a set current in the datasheet. In this Zener diode curve, Izt is the current where the Zener voltage Vz is specified, if you change the current through the Zener diode the voltage changes.

Zener Diode Curve

Zener Diode Curve

 

 

 

 

 

 

 

 

 

 

 

I wanted an expanded meter with a fairly linear response. So after thinking about the linearity issue with the Back Shed circuit and how it was related to the current changing in the circuit, I decided to revisit our old friend the current limit circuit I blogged about previously.

I modified the current limit to pull about 1.5mA through the circuit and added Zener diodes in place of the LEDs.

Expanded Meter Circuit

Expanded Meter Circuit

(To get a larger image, click image, then click image on the following page) So here is how this circuit works: For voltages below 21V the Zener diodes are off and there is no current flowing in the meter path of the circuit. Somewhere around 21V the Zener diodes crack over their knee voltage then current starts flowing in the circuit. The current limit circuit turns on and starts to drop voltage across the 2N7000 NMOS FET. As the voltage going into the circuit rises the current limit circuit causes the NMOS to drop any voltage not going through the Zener and current sense resistor. The Zener diodes drop a fairly constant voltage in this circuit because the current limit circuit is holding the current at a fairly constant rate. Since the 10VDC panel meter is measuring the Voltage across the NMOS it displays any voltage over ~21VDC on the meter face. The battery bank voltage should not go over 30VDC , unless there is something wrong with the charge controller, so hopefully we never see the meter at 32V.

(Note: instead of the 400 Ohm resistor in the schematic I used a 1K trim pot in series with 200 Ohms) (Also for the meter I bought a cheap 10VDC panel meter from E-bay, $5.99 including shipping)

This circuit still has the drawback of the temperature coefficient (TC) of the Zener and also the temperature effect of the VBE on the transistor that will have an over all effect on the accuracy with temperature. The temperature error is a very small (around 0.08%/degree C, for a change in room temperature of 65F to 75F you would see an error of less than 0.1V) and that small of an error really does not matter to me. If you are concerned with having a more accurate meter over a large temperature range, you can use a combination of Zener diodes with a positive and negative TC. An example would be to use four 1N5222B (TC=-0.085%/C) and a 1N5242B (TC=+0.077%/C) .

I took the 10VDC panel meter apart and scanned the face in on a flat bed scanner at 600DPI then modified the the scan with GNU Image Manipulation Program (GIMP) and reprinted it at 600 DPI onto a shipping label sticker. Placed the sticker onto the meter face cut the edges of the sticker off then put the meter back together. The following picture was the first pass:

Expanded Meter Face Rev1

Expanded Meter Face Rev1

 

 

 

 

 

 

 

After I put the circuit to the meter I found it was a little off ( this is was really no surprise, since Zener diodes are +/-5%, but it was a lot closer than I expected) so I had to calibrate the meter with one more graphic spin in GIMP. To calibrate the meter face with the actual DC voltage reading. I put the expanded scale meter in parallel with a digital multimeter, made little tick marks on the meter face for the voltages.

Meter Face Calibration

Meter Face Calibration

 

 

 

 

 

 

 

 

I ended up with a graphic like this.  ( Note: I highlighted the 28.8V mark since this is where my charge controller will push the battery bank to at the bulk charge phase) ( the 30VDC mark is also important for when I equalize the battery bank)

Final Expanded Scale Meter Face

Final Expanded Scale Meter Face

 

 

 

 

 

 

 

 

And here is picture of the meter hooked up with a power supply and a DMM to verify operation.

Expanded Meter in Operation

Expanded Meter in Operation

Comments are closed   Basic Circuits, Daily Blog   24V solar meter, analog expanded scale meter, expanded scale meter, expanded scale panel meter, green energy, low power 24VDC solar meter, solar battery bank meter, solar system meter  

Product Road Test – TI eZ430-F2013 Development Tool

By Kirk, on July 6th, 2011%

I just received the MSP430 Ultra-Low Power MCUs eZ430-F2013 Development Tool made by Texas Instruments from Newark to Electronic Components for a product road test.

TI usb development tool

TI ez430-F2013 usb development tool









 

This is a complete USB based development tool for about $23.00, that includes all of the required hardware and software to start a MSP430F2013 low power micro-controller project. It features:

  • eZ430-F2013 development tool including a USB debugging interface and detachable MSP430F2013 target board
  • eZ430-F2013 target board
    • LED indicator
    • 14 user accessible pins
  • eZ430 debugging and programming interface
    • Supports development with some 2xx Spy Bi-Wire devices (refer to Table 1-1 in MSP430 Hardware Tools User’s Guide for complete compatibility list)
    • Supports eZ430-T2012 and eZ430-RF2500T target boards
  • Removable USB stick enclosure
  • Includes IAR Kickstart and Code Composer Studio which include an assembler, linker, source-level debugger and limited C-compiler
  • Full documentation on CD-ROM
eZ430 dev. board with removable daughter card

eZ430 dev. board with removable daughter card








 

The USB stick comes in an easy to remove case that you pry open at the corner. The MSP430F2013 is mounted on a removable daughter card. The daughter card has test points that allow access to all of the pins of the MSP430F2013.

The MSP430F2013 features:

  • Low Supply Voltage Range 1.8 V to 3.6 V
  • Ultra-Low Power Consumption
    • Active Mode: 220 µA at 1 MHz, 2.2 V
    • Standby Mode: 0.5 µA
    • Off Mode (RAM Retention): 0.1 µA
  • Five Power-Saving Modes
  • Ultra-Fast Wake-Up From Standby Mode in Less Than 1 µA
  • 16-Bit RISC Architecture, 62.5-ns Instruction Cycle Time
  • Basic Clock Module Configurations:
    • Internal Frequencies up to 16 MHz With Four Calibrated Frequencies to ±1%
    • Internal Very Low-Power Low-Frequency Oscillator
    • 32-kHz Crystal
    • External Digital Clock Source
  • 16-Bit Timer_A With Two Capture/Compare Registers
  • On-Chip Comparator for Analog Signal Compare Function or Slope A/D
    (MSP430F20x1)
  • 10-Bit 200-ksps A/D Converter With Internal Reference, Sample-and-Hold,
    and Autoscan (MSP430F20x2)
  • 16-Bit Sigma-Delta A/D Converter With Differential PGA Inputs and
    Internal Reference (MSP430F20x3)
  • Universal Serial Interface (USI) Supporting SPI and I2C
    (MSP430F20x2 and MSP430F20x3)
  • Brownout Detector
  • Serial Onboard Programming, No External Programming Voltage Needed,
    Programmable Code Protection by Security Fuse

In the coming weeks we will be testing the development system. We will post some sample code for our project also.

Comments are closed   MISC

Simple LED Constant Current Circuit Uses Four Discrete Components

By Kirk, on June 25th, 2011%

I need to add an active current limit to the LEDs from the previous post. The main reason for the current limit is so that the brightness of the LEDs remains uniform across the lead acid battery voltage range of 11.8 to 14.4V. The circuit I am using is a very simple and only uses 4 components to limit current.
See the schematic here:(to see a bigger version of any of these pictures click the image, then click the image on the following page, it is a weird wordpress issue)














The circuit functions as follows:
For this example we will set the current limit at 100mA so R2 is 6 Ohms.
The NMOS is turned on when the voltage from Vin through R1 exceeds the NMOS Gate threshold level. As voltage at Vin rises so does current through the circuit and so does the voltage drop across R2. The current limit kicks in when the R2 voltage drop exceeds the base voltage threshold (VBE) of approximately 600mV on Q1. So if the current limit is set for 100mA the voltage across R2 = 6 Ohms * 0.1A = 600mV. When Q1 turns on it starts to pull the voltage down at the gate of the NMOS causing the FET to go into its linear region, this limits the current through the circuit. The NPN transistor is so much faster than the NMOS that there is no problems with oscillation in the circuit ( this assumes that the circuit is built properly with the current limit components in a very tight group )

There is one more ‘benefit’ to this circuit. If you want some limited form of over heating protection for your load circuit you can place the transistor next to the hottest part of the load. The VBE of the transistor will drop as it heats up, effectively dropping the the current limit in the circuit, this will all depend on the current in the transistor and the temperature. The greatest analog guru of all time Bob Pease wrote an article that explains VBE in detail just click here to read What’s All This VBE Stuff, Anyhow? Of course if you want to keep your current limit circuit constant keep the transistor away from the heating of the load.

Here is a simulation run of the circuit: Red line is the current going through the LEDs and R2, Blue line is the Voltage into the circuit ramped from 0 to 14.4V in 20mS, Green is the gate voltage of the NMOS, Light blue is the Voltage across R2 and at the base of Q1.












This circuit can be used for a constant current source / sink for LEDs and laser diodes (the circuit can be used on the high or low side of a load). It can also be used anywhere a current limit function is needed.

The NMOS can be just about any N-Channel FET that is rated for 1.5X the voltage of the circuit, 2X the Wattage of the circuit and at least 2X the current of the circuit, and should have a reasonable RDSon. The FET may need to attached to a heat sink, if you plan on running more than a 1/4 Watt.

The current limit function comes into play only if the input voltage is high enough to meet the following:

Vin > Load Circuit Voltage Drop + ( NMOS RDSon * Ilim ) + ( R2 * Ilim)

Here is an example of the current limit setting a constant current for two different voltage levels:












For example A the current limit is set for 30mA and is barely on with just 0.7V dropping across M1. This is derived with : 11.8V Vin – (LED forward voltage 3.5V at 30mA * 3 LEDs) – 0.6V across R2
The power dropped on M1 = 0.7V * 0.03A = 21mW

In example B the lead acid battery is fully charged and the power drop is at it highest with the power dissipated on M1 = 4V * 0.03A = 102mW

Comments are closed   Basic Circuits, Daily Blog   constant current circuit, laser diode current limit circuit, LED Constant Current Source, LED current control, LED current limit control  

An LED Daylight Sensor with PWM Brightness Control

By Kirk, on June 19th, 2011%

This blog adds a PWM brightness control to the circuit from the previous post A Quick and Simple LED Daylight Sensor.

I have added a 555 timer circuit to give the LED daylight sensor circuit PWM brightness control. See the schematic here:
(to see a bigger version of any of these pictures click the image, then click the image on the following page, it is a weird wordpress issue)













Adding a variable PWM control to the previous circuit only uses eight more components.

Using the 500K potentiometer the PWM can be set for ~1% to ~99% duty cycle.

I have also increased the resistance going to the photo-transistor to further reduce the off state current draw and increase the dark sensitivity ( the circuit turns on later, when it is darker, and back off earlier in the morning ).

Since I am running my circuit with the PWM duty cycle set to 30% I have increased current to the LEDs to get more light out with less average current draw ( Note the 68 Ohm resistor that were 100 Ohms in the previous circuit ). The LEDS appear brighter because of persistence of vision from the human eye.

Comments are closed   Basic Circuits, Daily Blog   555 Timer PWM circuit, LED Light Sensor, photo sensor, photosensor, Phototransistor light sensor, PWM LED control, Solar Light  
 
  Older Entries »

Blog Search

Blogroll

  • EEweb Forum
  • Subscribe to the Mad Scientist Hut RSS feed

Archives

Copyright © 2013 Mad Scientist Hut Blog - All Rights Reserved
Powered by WordPress & the Atahualpa Theme by BytesForAll. Discuss on our WP Forum

27 queries. 0.249 seconds.