Show Posts
Pages: [1] 2
1  Using Arduino / Installation & Troubleshooting / Re: Problem installing Arduino driver on Windows 8 on: April 04, 2013, 05:03:46 pm
Arduino 1.0.4 and higher now have signed drivers for Windows 8.
2  Using Arduino / Sensors / Re: IRRemote library, timers and PWM on: August 11, 2012, 10:43:18 am
I have an ir romote lib that will work on any port that supports interupts.  You can get it from here:
   http://zbotic.com/index.php/download/ 

Note it only supports remotes that use nec protocol but that seems pretty popular.
3  Using Arduino / Sensors / Re: Massive sensor noise/problems? on: August 11, 2012, 10:31:11 am
That's exactly what you should do.  On the other end you'll need to recombine those two bytes into an int.  you should be able to find easilly find some sample code that does the lowbyte/write and then on the read recombines.
4  Using Arduino / Sensors / Re: IR Remote Controller Library - Interrupt based rather than polled on: July 20, 2012, 06:02:23 pm
I have fixed the problem you reported.  You can get the fix with v1.3 at http://www.zbotic.com/index.php/download/
5  Development / Suggestions for the Arduino Project / Re: How about standard Error Codes? on: May 18, 2012, 10:26:20 pm
I like that you live by your motto.  :-) 

I think with feedback from the Arduino forum, you could have a consolidated error list that would cover 80% of the standard error conditions.  It would make it a lot easier to figure out how to use a new library - and it might remind library writers to check for common error conditions.
6  Development / Suggestions for the Arduino Project / How about standard Error Codes? on: May 17, 2012, 07:42:12 pm
How about having Arduino IDE ship with an include file with standard error codes that could be used by libraries and sketches:

Code:
#ifndef ERRORCODES_H
#define ERRORCODES_H

//! \version 1.2
enum ErrorCode {
    SUCCESS=        0,
    ERROR_CHECKSUM=         -9999,
    ERROR_TIMEOUT=          -9998,
    ERROR_DISABLED=         -9997,
    ERROR_UNSUPPORTED=      -9996,
    ERROR_UNKNOWN_RSP=      -9995,
    ERROR_BAD_COMMAND=      -9994,
    ERROR_DIRECTORY=        -9993,
    ERROR_FILENAME=         -9992,
    ERROR_NOT_ANALOG_PIN=   -9991,
    ERROR_NOT_DIGITAL_PIN=  -9990,
    ERROR_NOT_INTERRUPT_PIN= -9989,
    ERROR_NOT_PWM_PIN=      -9988,
    ERROR_NOT_SERIAL_PIN=   -9987,
    ERROR_READ=             -9986,
    ERROR_WRITE=            -9985,
    ERROR_BAD_PARAM=        -9984,
    ERROR_INIT1=            -9983,
    ERROR_INIT2=            -9982,
    ERROR_INIT3=            -9981,
    ERROR_NO_DATA=          -9980,
    ERROR_NO_MEMORY=        -9979,
};

#endif // ERRORCODES_H
7  Using Arduino / Sensors / Re: Problem commanding sensors please help on: May 12, 2012, 01:06:05 pm
If three relays work and it fails on the fourth it sounds like you may not have enough current.  What model are the relays (how many amps)?  Are they all connected to the WaterIsOn pin?
8  Using Arduino / Sensors / Re: Interface Arduino with GPS, accelerometer, gyro, magnetometer, barometer on: May 11, 2012, 07:03:02 pm
I've connected GPS, accelerometer, magnetometer, and temperature sensor  to Arduino.  See http://www.zbotic.com/index.php/download/ for links to the devices and a library.  The Arduino can easily connect those devices and read from them.  You could then send their output to Arduino USB/Serial monitor on a PC, or save the data to an SD card on the Arduino. 

Unfortunately there are a bunch of different types of connectors for sensors and they have Ground, Signal, and +V  on different pins.  I'm pretty careful but I've managed to melt (literally) three sensors by connecting the wrong polarity - by some miracle my Arduino and all the ports are still working.  You should consider www.seeedstudio.com and use their "Grove" devices.  Grove is a standard set of connectors for sensors and Seeedstudio is pretty cheap (although if you're not in Asia, shipping is slow).  Grove is also available from some sites in North Am (and probably Europe).  Personnally I'm not a fan of tinkerkit - they have a smaller number of sensors and their pinout seems the least popular.

You' may want to get an I/O shield (gives you a bunch of connectors for the sensors).  I2C is good for the more complicated sensors since it's a bus and allows complex communications and multiple devices.  For I2C you might want http://www.seeedstudio.com/depot/grove-i2c-hub-p-851.html?cPath=178_191 since it let's you connect multiple I2C devices (using grove connectors). 
9  Using Arduino / Sensors / Re: IR Remote Controller Library - Interrupt based rather than polled on: May 10, 2012, 09:38:29 pm
It supports NEC protocol remotes.  If you need other protocols, let me know.
10  Using Arduino / Sensors / Re: IR Remote Controller Library - Interrupt based rather than polled on: May 10, 2012, 03:34:42 pm
This is the one I used (no idea what type it is) http://www.dfrobot.com/wiki/index.php?title=IR_Kit%28SKU:DFR0107%29

I think/hope that it's just a matter of changing the key mapping section  for other remotes (shown below).

Code:
//! Decode specific remote-control keys - override this with routine for your Remote
int IRController::decode(int rawCmd)
{
    switch (rawCmd)
    {
    case 32640:  // turns on/off power
        return(POWER_BUTTON);
        break;
    case 32385:  // FUNC/STOP
        return(FUNC_BUTTON);
        break;
    case 32130:  // |<<
        return(BACK_BUTTON);
        break;
    case 32002:  // >||
        return(PLAY_BUTTON);
        break;
    case 31875:  // >>|
        return(FORWARD_BUTTON);
        break;
    case 32512:  // VOL+
        return(VLMUP_BUTTON);
        break;
    case 31492:  // VOL-
        return(VLMDOWN_BUTTON);
        break;
    case 31620:  // v scroll down
        return(DOWN_BUTTON);
        break;
    case 31365:  // ^ scroll up
        return(UP_BUTTON);
        break;
    case 30982:  // EQ
        return(EQ_BUTTON);
        break;
    case 30855:  // ST/REPT
        return(REP_BUTTON);
        break;
    case 31110:  // 0
        return(0);
        break;
    case 30600:  // 1
        return(1);
        break;
    case 30472:  // 2
        return(2);
        break;
    case 30345:  // 3
        return(3);
        break;
    case 30090:  // 4
        return(4);
        break;
    case 29962:  // 5
        return(5);
        break;
    case 29835:  // 6
        return(6);
        break;
    case 29580:  // 7
        return(7);
        break;
    case 29452:  // 8
        return(8);
        break;
    case 29325:  // 9
        return(9);
        break;
    default:
        errorCode = ERROR_UNKNOWN_RSP;
        return(key);  // Set errorCode code but return unrecognized raw key
        break;
    }
}

11  Using Arduino / Sensors / IR Remote Controller Library - Interrupt based rather than polled on: May 09, 2012, 11:07:52 pm
IR Remote controllers for Arduino are super cheap and quite useful.  Unfortunately all the libraries I've seen used polling, which makes them tough to use in a project.  So, I wrote an interrupt driven IR remote library.  This makes it really easy to have your project doing all sorts of activities and still be able to receive IR remote controls.  It uses PCINT, so the IR controller can be on any interrupt handling pin (including support for PCINT on Mega 2560).  You can download the lib from here: http://www.zbotic.com/index.php/download/

Note that zipfile includes other libraries - for just the remote control, only unzip IRController, Device, and PCInterrupt.  Also, this has codes for one type of remote - you will likely have to replace the codes with your remote's codes.

Sample usage
Code:
#include "PCInterrupt.h"
#include "Device.h"
#include "irController.h"

IRController irController;

// Note: modify myHardware.h in libraries\device and add change IR_PIN to the value of the pin you have your IR controller on.
void setup()
{
  Serial.begin(9600);
  Serial.println("Started");

   int res = irController.begin(IR_PIN, OTHER_DEVICE);
   if (res != SUCCESS) {Serial.println("error="); Serial.println(res);}
}

void loop(){
  int val = irController.read(); // Returns negative value if no new command rcvd
  if (val >0) Serial.println(val);
  delay(500);
}
12  Using Arduino / Sensors / Re: PING sensor giving incorrect values on Pin A0! on: April 26, 2012, 03:12:50 pm
I have tested the code posted by AWOL with a Ping Sensor on A0 on a MEGA 2560 and the setup works perfectly.

There is no difference in the header pins for the Mega 2560, so there is no reason to use Analog pins vs Digital for this, but it will work on A0.

Using standard jumper cables you should get quite a snug fit.

Run a wire from the pin marked GND into Arduino pin marked GND
Run a wire from  the pin marked 5V into Arduiono pin marked 5V
Run a wire from  the pin marked SIG into Arduino pin marked A0

Run AWOL's code or the standard ping lib code modified to use A0.

You should see a bright green LED on the Ping blink like mad and the serial monitor will show correct distance.
13  Using Arduino / Sensors / Re: A new Generic Library for Sensors and Devices on: April 17, 2012, 12:29:33 pm
That would be great if you could provide more sensor libs.  I can then "genericize" them.
14  Using Arduino / Sensors / Re: A new Generic Library for Sensors and Devices on: April 16, 2012, 10:26:41 pm
That is definitely what I had in mind.  The first part would be the generic sensor type, followed by specific HW.  It's actually a bit hard to find the hardware specifics for some of these devices, but I'll try to clean that up.   After your post, I was thinking about the GPS and I actually think the code will work for any GPS since they all seem to be Serial and use the same standard NMEA command set.  So I think the libraries will be:

Compass_LSM303

GPS

IRController

LiquidCrystal_LCD03

Distance_??? - need to research the chipset, but all the online ones seem to work the same as the Parallax Ping sensor

Temperature_DHT11_DHT22 - changing this to work with either DHT11 or DHT22 chipset
15  Using Arduino / Sensors / A new Generic Library for Sensors and Devices on: April 15, 2012, 01:48:36 pm
I've tried to create a generic library for Sensors and Devices:

http://zbotic.com/index.php/about/

I'd like feedback on whether people think the design makes sense or suggestions for changes. Obviously feel free to use if you find it useful.  Most of the libraries are based on refactoring code on Arduino sites (with original authors in place) to make them more generic.

Device Library – v1.0
This is a set of Device libraries that all use the same standard interfaces such as begin() and read().  This makes it really easy to incorporate new devices into your sketches since they all work the same way.  This  currently has standard libraries for: distance sensor, proximity sensor, compass, color sensor, ambient volume sensor, IRRemote, GPS, and generic Analog sensor and generic Digital Sensor, and an LCD shield.  Note that the IRRemote Library is interrupt based rather than using a polling loop.

The Device Libraries all use the following standard interfaces

Constructor takes no parameters – simply Xyz();

Xyz.begin(int pin, DeviceType deviceType) – This is used for all initialization.  PIN is the first parameter for digital, analog, serial and interrupt sensor libraries.  This performs all initialization and returns an errorCode or ERROR_SUCCESS if successful.  Note that the “begin” function always uses a PIN  even for serial devices (use TX pin), likewise it uses the PIN for Interrupt functions, not the Interrupt number. 
The Device type is the second parameter and can be DIGITAL_SENSOR, ANALOG_ SENSOR, I2C_DEVICE, SERIAL_DEVICE, INTERRUPT_DEVICE, DIGITAL_OUT_DEVICE, PWM_DEVICE or OTHER_DEVICE. Additional initialization parameters are passed after Sensor Type for some of the sensors.

Xyz.read() – If the sensor has only one function, then Xyz.read() performs all work necessary to return the device’s currrent value.  For example, read is used for the distance sensor and simply returns the distance.  No other calls are needed to do a read.

Xyz.readAbc()  –If the sensor has multiple functions, then Xyz.readAbc() returns the device’s currrent value for one of it’s multiple functions, for example GPS.readLatitude();
All libraries use the base library, Device.h

General rules for the libraries
Loops or delays are avoided in the libraries (only LCD and Temperature have delays)
They support UNO/compatible and Mega2560/compatible systems. 
They can use any supported hardware pins (UNO/compatible and Mega2560/compatible).
Consistent error codes are used (from ErrorCodes.h)
They use JavaDoc formatted comments

Library Names
All the interface names are generic and hide the specifics of the underlying hardware, however the actual library name to be included may have a suffix for the specific hardware type.  For example, the temperature sensor library is named TemperatureSensor_DH11.h since it supports the DH11 chip, but the classes and interfaces are generic: Temperature,temperature.begin(), temperature.readTemperature(), temperature.readHumidity(), etc.  This makes it easy to switch specific hardware types without needing to change any code.

Pin Assigments
The only time a pin (or any hardware specific item) is specified is in the Xyz.begin interface. 
All example code uses pin assignments from MyHardware.h and it is recommended that your code place all pin assignments in this file. This file contains all the pin assignments and hardware specific items you use and allows easier management of pin assignments.  This allows you to easilly move a project to a different hardware setup without any code changes, just changes to MyHardware.h.  By placing all the pin assignments in one file, it’s easy to see if there are any conflicts and also easy to wire up your Arduino.
Pin names are formed as <Library>_<Instance>_PIN.  For example, DISTANCE_LEFT_PIN.  Instance is optional if only one sensor for that type is present
.
Error Codes
ErrorCodes.h contains all errorCodes
All interfaces set the errorCode variable in the object

Metric / Imperial
All libraries use Metric by default.  You can call Xyz.SetImperial() to have a device use Imperial units instead.

Here is a sample routine using the library (error handling removed):

Code:
#include "myhardware.h"
#include "Wire.h"
#include "Device.h"
#include "Servo.h"
#include "Ping.h"
#include "LiquidCrystalI2C.h"
#include "Compass_LSM303.h"
#include "Proximity.h"
#include "Sonar.h"
#include "irController.h"
#include "Temperature_DHT11.h"
#include "TinyGPS.h"
#include "GPS_MTK3329.h"

// CONSTRUCTORS
LiquidCrystal lcd;          // LCD Display
Compass      compass;       // Compass
Proximity    obstacleLeft;  // Proximity sensor
Device       sound;         // Ambient Sound sensor
Device       motion;        // Motion Detector
Sonar        sonar;         // Distance Sensor
IRController irController;  // IR Remote Control reader - Interrupt Based
Temperature  temperature;   // Temperature Sensor
GPS          gps;           // GPS

// INITIALIZE
void initializeDevices() {
int result;

  result = lcd.begin(LCD_I2C_ADDR, 20, 4);
  result = compass.begin( -549, -364, -250, 335, 547, 817 );   // You MUST run calibrate to get calibration values for minx, miny, minz, maxx, maxy, maxz
  result = gps.begin(1, SERIAL_DEVICE);
  result = sound.begin(SOUND_PIN, ANALOG_SENSOR);
  result = motion.begin(MOTION_PIN, DIGITAL_SENSOR);
  result = temperature.begin(TEMPERATURE_PIN, OTHER_DEVICE);
  result = irController.begin(IR_PIN, OTHER_DEVICE);
  result = sonar.begin(SONAR_PIN, OTHER_DEVICE,SONAR_SERVO_PIN, 3, 90);
  result = obstacleLeft.begin(SONAR_LEFT_PIN, DIGITAL_SENSOR);
}

// SETUP
void setup()
{
  Serial.begin(9600);
  Wire.begin();
  initializeDevices();
}

// LOOP
void loop(){
  readsensorValue();    // Get Sensor Readings
  displaysensorValue(); // Display them
  delay(500);
}

// READ SENSORS
void readsensorValue(){
  int val;
 
  sensorValue[DAT_COMPASS] = compass.read();
  sensorValue[DAT_LAT]     = gps.readLatitude();
  sensorValue[DAT_LON]     = gps.readLongitude();
  sensorValue[DAT_VLM]     = sound.read();
  sensorValue[DAT_FRONT]   = sonar.read();
  sensorValue[DAT_LEFT]    = obstacleLeft.read();
  sensorValue[DAT_TEMP]    = temperature.readTemperature();
  sensorValue[DAT_HUM]     = temperature.readHumidity();
  sensorValue[DAT_MOVE]    = motion.read();
  val               = irController.read();
  if (val >0) sensorValue[DAT_IR] = val;
}
Pages: [1] 2