Show Posts
Pages: 1 ... 23 24 [25] 26 27
361  Forum 2005-2010 (read only) / Interfacing / Re: detecting obstructions on the sea on: December 08, 2010, 09:13:17 am
I started out using an LM386 @12V, then went to 2 LM380's in bridge configuration.
The receivers have 2 TL081 JFET op-amps, each with a gain of 10.

Originally I was using my SYM-1 (that's a 6502 single board computer with 32K of RAM, running @ 1Mhz) to process the data, using 3 ADC0804's.
That was kinda "iffy", so I gave each A/D converter it's own 2K static CMOS RAM, with a counter stepping @ 10khz, which is the max sampling rate of the ADC0804.
That only gives you a minimum of 1 foot/sample, as sound travels @1ms/foot.
I then went to TL0831 ADC's, those are 8 bit serial converters that let you clock data @600K, I divided the 6502's 1Mhz clock by 2, to give me a 500khz clock, which gives 62.5ksample/sec.
Thats a minimum range of around 5mm! Which was too tall an ask for a 1Mhz processor.
So I started using the same 40khz clock I was using to drive the ultrasonic transducer, which gives you a minimum resolution of 6cm, which was still pushing the envelope for a single 6502.
I started using the SYM simply to control the sonar, then passed the data on to an Apple II, that was kinda slow as well, but a friend gave me my first Linux system, a DX-4/100 and I transferred all my Pascal code over to the Linux box.
That's as far as I got until a couple of months ago when I got my first Mega.
As I said first thing I did was put a Mega on a $20 radio controlled car, with a Pololu H-Bridge module and an XBee module.
I'm using the first 3 analog inputs on the car's Mega for the 3 ultrasonic receivers.

My second Mega is receiving the data and I'm displaying it either on my eee or my desktop machine, just as simple vertical bar graphs.

It's all pretty crude right now, but when work calms down a bit I'll refine the circuit and code.

I'll draw up the circuit if you want and post it.

There is not much to it, just the LM380's driving the transmitter, I got the circuit straight from the National Semiconductor application note.
The receivers are just 2 JFET op amps each with a gain of 10.

Even if you want to use normal ranging you can still use the same setup.

I should mention I really like building big, complex circuits out of 7400 series chips, normal 74LS series can clock at a maximum of 25Mhz, which was pretty darn fast when I only had access to 1Mhz processors.
The craziest/most complex thing I ever built was a "Life" engine, that could do 25 generations/second.

So if this idea for "sonar illumination" sounds complex that's why.
Using a modern microcontroller will make it a lot simpler, even if you need to add external RAM as a buffer.
Besides if bats can do it, so can we!
362  Forum 2005-2010 (read only) / Interfacing / Re: detecting obstructions on the sea on: December 08, 2010, 01:48:06 am
If you use one of the waterproof ultrasonic receiver/transmitter pairs and really drive the transmitter, by that I mean don't mess around with 5V, use an amplifier chip, 2 LM380's in a bridge configuration or an STK module.
Those sealed ultrasonic transmitters will produce a >105dB and take a maximum input voltage of 140V!
That is enough to hurt, so don't put your ears anywhere near it when it's operating, you wont hear it, but believe me you will feel it, like somebody sticking a knitting needle in your ear.
Here in Australia you can buy a kangaroo scaring device that mounts on your front car bumper, I've seen 'roo's react to them at distances of over 100M! Again it's not something you can safely stick your ear in front of, it really hurts!
Same goes for ultrasonic "intruder" detectors, some of those have a VERY high output.

Bat's, rat's dolphin's and whales have been "imaging" like this for ever!
Dolphin's can stun fish with a concentrated pulse of sound.

I've been experimenting with a continuous output ultrasonic system.
Rather than a pulse I've been trying to "illuminate" the area in front of a small rover, then using multiple receivers to "watch" the reflected sound.
With 3 receivers I "fill" in the gaps between them by summing the outputs of the outer receivers with the centre one, sort of like synthetic aperture radar.
I started out just watching the output on my CRO, as soon as I got my Mega and XBee modules I started visualising the A/D converters output as simple vertical bar graphs.
You can drive around quite well without running into stuff.

Another thing I've tried is a few different shaped "reflectors" for the transmitter and receivers.
A simple plate at 45 degrees above a horizontally mounted transmitter widens the field of the beam produced, as well as flattening it out.
Building small horns for the receivers also is something to try.

You can definitely tell the difference between various materials and textures, grass has a different texture to gravel, bark and wood return a different sound texture to concrete, which is different to bricks.

363  Forum 2005-2010 (read only) / Interfacing / Re: Temperature, Humidity, and Pressure Data logger on: December 08, 2010, 09:12:21 pm
For a temperature, humidity and water flow logging and warning system I'm putting together for the turkey farm I work on, I'm going to use the Seeedstudio Mega clone, it's like half the price and brings all the 1280's I/O pins.
364  Forum 2005-2010 (read only) / Interfacing / Re: Temperature, Humidity, and Pressure Data logger on: December 08, 2010, 12:51:30 am
I have yet to get an SD card to work with a simple voltage divider to shift levels.

But, on the GPS/Navigator/environmental monitor thing I'm building I have -
On I2C
- An HMC6352 digital compass
- A DS1307 RTC
- 8 24LC256 EEPROMS

- An MPL115A Digital barometer.
- A uM-FPU v3 floating point unit

On the Mega's UARTS

- Serial "0" is for programming and uploading collected data
- Serial 1 is connected to an EM-406 GPS
- Serial 2 is connected to an XBee module
- Serial 3 is connected to one of the "huge" LCD displays with serial backpack that Sparkfun sell

Everything is working fine, except the "keypad" library seems a bit sluggish, I'm going to solve that by adding a separate ATmega328 for the keypad, beeper/key "click", status LEDs.

I've tried all 10 I2C devices on my Duemilenove and it worked fine.
Then I added the 2 SPI devices and it still worked.
I just ran out of I/O pins for everything else!
I2C is a fairly fast serial protocol and SPI is way faster.

If it were me, I'd use a Mega, just for the extra UART's and I/O.
365  Forum 2005-2010 (read only) / Interfacing / Re: Driving a speaker, where's the volume? on: December 07, 2010, 07:21:01 pm
Great! That's exactly what I meant, even if I didn't articulate it very well.
Your speaker will last longer this way.
366  Forum 2005-2010 (read only) / Interfacing / Re: Driving a speaker, where's the volume? on: November 28, 2010, 03:40:15 am
I would use an LM386, if you look at the circuit in application note, there is a capacitor in series with the speaker.

The "cap" is NOT just for filtering, not only does it stop DC bias from destroying your speaker, but stores a bit of energy.

You'll need to put a 10k pot in series between the Arduino pin and the input of the LM386.
If you build the basic '386 circuit, it'll have a gain of 20, with a digital out put into an 8 ohm speaker it'll be pretty loud!

The reason you are getting less volume than you are expecting is that electromechanical speakers do not have the same characteristics as a piezio-electric speaker.
Because it has a coil AND a magnet there is inductance and reluctance to take into account.
The transistor circuit will work a whole lot better if you put an electrolytic cap in series with the speaker, say 250 uf, with the positive side of the cap going to your transistor amp, the negative side to the speaker, the other side of the speaker should go to ground.

Driving it the way you are will burn out the voice coil.
367  Forum 2005-2010 (read only) / Interfacing / Re: i2c crash with 10k [ch937] pullups.. ok with 2.2K [ch937]. ??? on: December 06, 2010, 06:39:05 pm
You should have a 100nf ceramic or greencap on both the input and out put, as well as the 10uf tantalum or electrolytic cap on the output, other wise the regulator will oscillate like a bitch!

Also remember with linear regulators like the LD1117S33CTR, you need to give it enough voltage to "work" with or it will oscillate like a bitch!
368  Forum 2005-2010 (read only) / Interfacing / Re: Melexis SMBus IR Thermometer - NFI on: December 01, 2010, 09:46:20 am
I tried the 4.7K pull up resistors, but that didn't work.
There is another document on the Melexis site, I'll post the address later, it has "preliminary" stamped all over it, but it does look hopeful.
I'm going to have another go at it when I get my Tektronics storage CRO home, I think I'll have more luck.

On thing to bare in mind is SparkFun has an evaluation board for the MLX90614

If you have a look at the schematic

They have just hooked the sensor up to the I2C port, no pull ups!

Unfortunately the link on github is broken, so I've not been able to download their source.

Has anyone found out why using the i2cmaster library prevents the UART working?
As a few people have pointed out, even a simple "Hello World" no longer works on the serial monitor!

The PWM output is going to be a "chicken and egg" problem, you'll have to make it work over I2C to set it up!

As I'm going to use this sensor in my "tricorder" thing, I was going to mount it in a "wand", along with some gas sensors.
My idea is to use a separate ATMEGA in the wand and communicate back to the main unit via serial link.

I already have 10 devices on my I2C bus, an HMC6352 digital compass, a DS1307 RTC and 8 24LC256 EEPROMS, I'll also have a temperature and humidity sensor when it arrives, that'll make 11, 12 if I put my uM-FPU V3 on the I2C bus, but I think I'll keep that on the SPI bus along with my MPL115A.

From what I've read SMB and I2C devices are going to be "difficult" to have on the same bus.
So a dedicated controller in the "wand" seems like a good idea.
I've already ordered a few ATmega328's pre-programmed with the Arduino bootloader, I've found the keypad library a bit "twitchy" when you have a lot of stuff going on.
So I was going give my keypad it's own controller to scan the keys, make the key press "beep" and do some other stuff.

This project is taking on a life of it's own!
I'll have to start documenting it now it has the beginnings of a case.
And before you ask, yes, my Mega still has a few port pins I'm not using, yet.
369  Forum 2005-2010 (read only) / Interfacing / Re: Melexis SMBus IR Thermometer - NFI on: November 30, 2010, 11:23:22 pm
I've tried EVERY bit of code I can find and I can't get squeak out of this sensor!
When I try the i2cmaster library, I can't get any output on the serial monitor.
I'm now trying the code sensorJunky posted and still no output on the serial monitor.
I'm going to have to get the CRO home!
I think I've been spoilt by the other I2C devices I've tried, HMC6352, eeproms, my uM FPU!
370  Forum 2005-2010 (read only) / Interfacing / Re: turn laser on and off using PWM on: November 28, 2010, 06:14:01 am
The pictured 300mW unit probably is real and these days that is relatively "low" powered.
There are plenty of 100mW+ laser articles on Hack A Day.

The guy on Hack A Day that posted video of his Star Trek "Phasor" bursting balloons across the room states his 350mW blue laser diode only draws 450-500mW.

Some of the blue laser diodes from Blue Ray Burners push upwards of 1W!
But I'm not about to take my BDROM burner to bits to complete my RGB laser scanner!
(Yes, I stupidly bought a Blue Ray burner and I'm still the only person I know with one! BUT I can back up 25G or 50G, @ AUS$1/G, sigh)

That idiot Kip Kay from Make had a stupidly dangerous tutorial about putting blue laser diodes in Bic lighter casings AND lighting cigarettes right in front of his face, with no eye protection, but that's Kip Kay for ya!

I just bought a 10mW red laser diode and a 10mW green laser pointer, but I won't be operating that version of my laser "wobbler/scanner" indoors without a low power setting!

So far the most powerful laser diode I have is a 250mW and an older 100mW Infra-red module from laser printers.

The higher resolution the laser printer or bromide/film printer is, the higher the laser diode output is, probably because the scanning mirror is spinning faster.

The Linotronic 4000 dpi film printer I used to work with had a HUGE laser diode module, that one was rated at 500mW and it got really hot, especially when you printed out full A0 film or bromide.

I've used the infra red diodes behind diffusers, turned right down as "night shot" illumination for my Sony camcorder.

The upshot of all this is, they might not be safe or legal, but there a plenty of ridiculously high powered laser diodes and pointers for sale!
371  Forum 2005-2010 (read only) / Interfacing / Re: turn laser on and off using PWM on: November 28, 2010, 03:22:41 am
I have had a laser pointer running @5V for the last 5-6 years , I bridged the switch with solder, that's after I ran it continuously for months with a cloths peg holding the switch "on".
From your photo it looks like mine, I ripped it out of the case and just hooked it up to a 5V supply, switched with the first transistor I found in my junk box.
If it ran on 3 "button" cells you might not have enough current and voltage to get the laser control circuit to "come up".

It's only REALLY cheap laser pointers that don't have the whole feedback circuit from the actual laser diode.

Don't feed current straight into the laser package, if it's got 3 pins it WILL need the feedback circuit, or the device will not last very long.

3V probably isn't enough to power the laser AND it's control circuit, if it had 3 "button" cells that's at least 4.5V, a bit more if they are fresh cells.
372  Forum 2005-2010 (read only) / Interfacing / Re: Driving a mosfet directly - questions on: November 28, 2010, 03:52:36 am
One important thing to remember is that FET's of any kind are voltage controlled devices, Bi-Polar transistors are current controlled devices.

A silicon bi-polar transistor when it comes "on" has a .6V voltage drop across the emitter/collector junction, that's why they get hot, whatever current you draw through the transistor has to dissipate that 0.6V @ whatever current you are pulling through it.
ALL silicone devices have this 0.6V voltage drop.

It's a bummer big germanium power transistors are no longer available.
Germanium devices have a 0.3V drop across them, it's why "crystal" radios usually have an OA-91, it makes them more sensitive.

a FET turns into a piece of wire! :-)
And has a minuscule voltage drop across it.
That's IF you turn it "hard" on.

With a Bipolar transistor like a 2N2222, you can get away with just a resistor on the base, but it will only switch when the voltage hits 0.6V, a better way is to put a voltage divider on the base, calculate the 2 resistor values so you have the base sitting just under 0.6V, then feed the output from your Arduino pin through a resistor into the voltage divider, it will switch much quicker that way.

Remember you can use a transistor for much more than a switch! (I hear told  smiley )
373  Forum 2005-2010 (read only) / Interfacing / Re: DS1307 and LCD on: November 28, 2010, 02:59:41 am
Can you output anything to your LCD?
If you have the Time library, even without setting the CURRENT time you should get something.
This is the sketch I based my code on.

 * RTC Control v.01
 * by <> John Vaughters
 * Credit to:
 * Maurice Ribble - for RTC DS1307 code
 * With this code you can set the date/time, retreive the date/time and use the extra memory of an RTC DS1307 chip.  
 * The program also sets all the extra memory space to 0xff.
 * Serial Communication method with the Arduino that utilizes a leading CHAR for each command described below.
 * Commands:
 * T(00-59)(00-59)(00-23)(1-7)(01-31)(01-12)(00-99) - T(sec)(min)(hour)(dayOfWeek)(dayOfMonth)(month)(year) - T Sets the date of the RTC DS1307 Chip.
 * Example to set the time for 02-Feb-09 @ 19:57:11 for the 3 day of the week, use this command - T1157193020209
 * Q(1-2) - (Q1) Memory initialization  (Q2) RTC - Memory Dump

#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68  // This is the I2C address

// Global Variables

int command = 0;       // This is the command char, in ascii form, sent from the serial port    
int i;
long previousMillis = 0;        // will store last time Temp was updated
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
byte test;
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
  return ( (val/10*16) + (val%10) );

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
  return ( (val/16*10) + (val%16) );

// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers, Probably need to put in checks for valid numbers.
void setDateDs1307()                

   second = (byte) (( - 48) * 10 + ( - 48)); // Use of (byte) type casting and ascii math to achieve result.  
   minute = (byte) (( - 48) *10 +  ( - 48));
   hour  = (byte) (( - 48) *10 +  ( - 48));
   dayOfWeek = (byte) ( - 48);
   dayOfMonth = (byte) (( - 48) *10 +  ( - 48));
   month = (byte) (( - 48) *10 +  ( - 48));
   year= (byte) (( - 48) *10 +  ( - 48));
   Wire.send(decToBcd(second));    // 0 to bit 7 starts the clock
   Wire.send(decToBcd(hour));      // If you want 12 hour am/pm you need to set
                                   // bit 6 (also need to change readDateDs1307)

// Gets the date and time from the ds1307 and prints result
void getDateDs1307()
  // Reset the register pointer

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

  // A few of these need masks because certain bits are control bits
  second     = bcdToDec(Wire.receive() & 0x7f);
  minute     = bcdToDec(Wire.receive());
  hour       = bcdToDec(Wire.receive() & 0x3f);  // Need to change this if 12 hour am/pm
  dayOfWeek  = bcdToDec(Wire.receive());
  dayOfMonth = bcdToDec(Wire.receive());
  month      = bcdToDec(Wire.receive());
  year       = bcdToDec(Wire.receive());
  Serial.print(hour, DEC);
  Serial.print(minute, DEC);
  Serial.print(second, DEC);
  Serial.print("  ");
  Serial.print(month, DEC);
  Serial.print(dayOfMonth, DEC);
  Serial.print(year, DEC);


void setup() {

void loop() {
     if (Serial.available()) {      // Look for char in serial que and process if found
      command =;
      if (command == 84) {      //If command = "T" Set Date
       Serial.println(" ");
      else if (command == 81) {      //If command = "Q" RTC1307 Memory Functions
        if (Serial.available()) {
         command =;
         if (command == 49) {      //If command = "1" RTC1307 Initialize Memory - All Data will be set to 255 (0xff).  Therefore 255 or 0 will be an invalid value.  
          Wire.beginTransmission(DS1307_I2C_ADDRESS); // 255 will be the init value and 0 will be considered an error that occurs when the RTC is in Battery mode.
          Wire.send(0x08); // Set the register pointer to be just past the date/time registers.
         for (i = 1; i <= 27; i++) {
         Serial.println(": RTC1307 Initialized Memory");
         else if (command == 50) {      //If command = "2" RTC1307 Memory Dump
          Serial.println(": RTC 1307 Dump Begin");
          Wire.requestFrom(DS1307_I2C_ADDRESS, 64);
          for (i = 1; i <= 64; i++) {
             test = Wire.receive();
             Serial.println(test, DEC);
          Serial.println(" RTC1307 Dump end");
      Serial.print("Command: ");
      Serial.println(command);     // Echo command CHAR in ascii that was sent
      command = 0;                 // reset command
//*****************************************************The End***********************

After I set the current local time I was able to use this bit of code.
 * TimeRTC.pde
 * example code illustrating Time library with Real Time Clock.

#include <Time.h>  
#include <Wire.h>  
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t

void setup()  {
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  if(timeStatus()!= timeSet)
     Serial.println("Unable to sync with the RTC");
     Serial.println("RTC has set the system time");      

void loop()

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  if(digits < 10)

Are you sure your Arduino can "see" the RTC?
374  Forum 2005-2010 (read only) / Exhibition / Re: FORTH environment for Arduino on: January 11, 2011, 08:02:52 am
Freak me Lefty!
I have this Mars/Lunar lander obsession, my first attempt, age 12, was all relay logic and bulbs!
Then I went to DTL, after the start of the 70's I built a 6800 system, with front panel LED's and switches, you might know the one, from that issue of "Practical Electronics".
Still at it, always will, till I plant that Australian flag on the Moon/Mars, arduino or not.
375  Forum 2005-2010 (read only) / Exhibition / Re: FORTH environment for Arduino on: January 10, 2011, 10:11:39 am
Lot's of observatories use Forth.
The Arecibo radio telescope and the VLA radio telescope in New Mexico, this is not surprising, Charles Moore worked at the National Radio Astronomy Observatory (NRAO), he was a freelance programmer working mainly on control and data acquisition, which is where Forth really shines.
The contempt that C programmers show Forth (and just about any other language) is amazing!
Pages: 1 ... 23 24 [25] 26 27