Show Posts
Pages: [1] 2
1  Forum 2005-2010 (read only) / Development / Re: NewSoftSerial Library: An AFSoftSerial update on: February 12, 2009, 10:03:07 am
Hi Mikal,

I have compiled NSS on a windows machine and this has resolved the hangups - so it does seem to be the OSX compiler that is/was causing the problems.

Thanks for all the hard and good work.
Roger  
2  Forum 2005-2010 (read only) / Development / Re: NewSoftSerial Library: An AFSoftSerial update on: February 10, 2009, 08:46:23 am
Thanks mikal  smiley

I have checked both functions - checkBattery & checkReader - and each  runs fine when it is the only function called in the loop when using SoftwareSerial.  It is the combination of the two in the main loop using  NewSoftSerial which causes the lockup (the code posted earlier today).  I have also tried calling just a single function - either checkBattery or checkReader - using NSS and this also causes lockup.  So for me the problem definitely originates from the NSS library.

I am using Diecimila.

roger
3  Forum 2005-2010 (read only) / Development / Re: NewSoftSerial Library: An AFSoftSerial update on: February 09, 2009, 06:15:02 pm
Hi Mikal

my code is for a wireless RFID reader.  I would like to check battery levels and look for tags in my main loop.  As has been reported in other threads - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1201703850/9#9 - SoftwareSerial's read function blocks until there is a tag available to read, making it 'impossible' to perform both checks.  The available function in NewSoftSerial would hopefully resolve this.

Much thanks for the support.
Roger  smiley

Code:
#include <NewSoftSerial.h>
#include <avr/sleep.h>
#include <string.h>

#define BATTERY_CHECK_INTERVAL 60000
#define SIX_HOUR 952
#define FIVE_HOUR 945
#define FOUR_HOUR 936
#define THREE_HOUR 926
#define TWO_HOUR 910
#define ONE_HOUR 881
#define ZERO_HOUR 836


// RFID reader for Arduino
// Wiring version by BARRAGAN <http://people.interaction-ivrea.it/h.barragan>
// Modified for Arudino by djmatic
// Modified to use SoftwareSerial by Erik Sjodin <http://www.eriksjodin.net>
// Modified for use in TagMat by Roger Meintjes <http://www.doc.gold.ac.uk/~ma701rm/>
 
/*
 * RFID_Scratch03 (Arduino)
 *
 * Tests communication between RFID, ArduinoXbee, Processing & Scratch.
 * Reads in RFID tag code from reader and writes it out through Xbee.
 * Code is written out as the String start_byte<10 char code>stop_byte.
 *
 * Battery is checked once every minute.
 * Battery charge written out as String start_byte<10 char charge in hours>stop_byte.
 *
 * Connect:
 * Arduino pin 3 to RFID SOUT
 * Arduino GND to RFID GND
 * Arduino Digital pin 2 to RFID /ENABLE
 * Arduino 5v to RFID VCC
 */

 
char code[13] = "";  
char charge[13] = "";
char baseString[11] = {72, 82, 95, 67, 72, 65, 82, 71, 69, 13, 0};  

unsigned long timeNow = 0;
int batteryLevel = 0;
int val = 0;
int bytesRead = 0;

int rx = 3;
int tx = 4;
int batteryPin = 5;
int rfidEnable = 2;

//set up software serial port
NewSoftSerial softSerial = NewSoftSerial(rx, tx);

void setup()
{
  timeNow = millis();
  pinMode(rx, INPUT);
  pinMode(tx, OUTPUT);
  pinMode(batteryPin, INPUT);
  pinMode(rfidEnable, OUTPUT);
  
  softSerial.begin(2400);     //set software serial port to reader baud rate
  Serial.begin(9600);         //set hardware serial port to xbee baud rate
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);   //set sleep_mode to most power saving  
  
  //initialize reader with reset cycle
  digitalWrite(rfidEnable, LOW);      
  delay(100);
  digitalWrite(rfidEnable, HIGH);
  delay(100);
  digitalWrite(rfidEnable, LOW);
  delay(100);
}

void loop() {
  if((millis() - timeNow) > BATTERY_CHECK_INTERVAL) {
    checkBattery();
    timeNow = millis();
  }
  else {
    checkReader();
  }
}

void checkReader() {
  digitalWrite(rfidEnable, LOW);
  if(softSerial.available() > 0) {
    //check for start byte
    if((val = softSerial.read()) == 10) {
      bytesRead = 0;
      code[bytesRead] = val;
      bytesRead++;
      //do nothing until all twelve bytes have arrived
      while(softSerial.available() < 12);
      //read in code and stop byte
      while(bytesRead < 12) {
        val = softSerial.read();
        code[bytesRead] = val;
        bytesRead++;
      }
      digitalWrite(rfidEnable, HIGH);
      //check for the stop byte
      if(val == 13) {
        Serial.print(code);
      }
      delay(250);      
    }
  }
}

void checkBattery() {
  batteryLevel = analogRead(batteryPin);
  charge[0] = 10;  //start byte
  charge[2] = 0;   //termination byte
  if(batteryLevel > SIX_HOUR) {
    charge[1] = 54;   //ASCII 6
  }
  else if(batteryLevel > FIVE_HOUR) {
    charge[1] = 53;   //ASCII 5
  }
  else if(batteryLevel > FOUR_HOUR) {
    charge[1] = 52;   //ASCII 4
  }
  else if(batteryLevel > THREE_HOUR) {
    charge[1] = 51;   //ASCII 3
  }
  else if(batteryLevel > TWO_HOUR) {
    charge[1] = 50;   //ASCII 2
  }
  else if(batteryLevel > ONE_HOUR) {
    charge[1] = 49;   //ASCII 1
  }
  else if(batteryLevel > ZERO_HOUR) {
    charge[1] = 48;   //ASCII 0
  }
  else {
    sleep_mode();
  }
  Serial.print(strcat(charge, baseString));  //create and write charge string
}
4  Forum 2005-2010 (read only) / Development / Re: NewSoftSerial Library: An AFSoftSerial update on: February 05, 2009, 04:07:59 am
Quote
Could this be because pins 2 and 3 (used very often in the soft serial examples I've seen) share an interrupt with the UART on pins 0 and 1? Unfortunately, my device requires a specially designed shield so I can't move pin assignments around easily, but if someone who is having interrupt problems could try using, say, pins 8 and 9 for the soft serial and see if they continue to have problems, that would be an interesting experiment.

I was using pins 2 and 3 and have changed them to 8 and 9 as suggested - unfortunately there is no noticeable change in the lockup.

Really hope this can be resolved..  smiley
5  Forum 2005-2010 (read only) / Development / Re: NewSoftSerial Library: An AFSoftSerial update on: February 04, 2009, 07:16:08 am
Quote
Questions for the Arduino world at large:

1. Has anyone experienced the kind of lockup in AFSoftSerial that etracer describes?
2. Please let me know if you
   a. notice any difference in behavior between AFSoftSerial and NewSoftSerial.
   b. have successfully tested multiple instances of NewSoftSerial.
   c. have any observations about baud rates that don't seem to work reliably with either AFSoftSerial or NewSoftSerial.

Mikal

I have tested both AFSoftSerial.h and NewSoftSerial.h with 2400 baud rate for a Parallax RFID reader.  Both produce lockups - although they seem to lock at slightly different points in the code.  The exact same code works perfectly with SoftwareSerial.h

I am using OSX 10.4.11 with Arduino 0012.

rogermm
6  Forum 2005-2010 (read only) / Interfacing / Re: monitoring solar power module's li-ion battery on: November 09, 2009, 09:33:08 am
Thanks for the advice Grumpy Mike.  I'll give it a go and report any issues.
7  Forum 2005-2010 (read only) / Interfacing / monitoring solar power module's li-ion battery on: November 09, 2009, 07:45:29 am
Hi

I am testing out Libelium's solar power module for Arduino:
http://www.sensor-networks.org/index.php?page=0828028040

I need to monitor the li-ion battery and take action when it reaches the low-voltage threshold.  Two problems + associated questions:

a.) the battery manufacturer does not state what the low-voltage threshold is on their data sheet.  Is there a standard way for calculating this?

b.) the board converts the battery's 3.7V to 5V, meaning that what is coming off the board is not a true reflection of the battery's current voltage.  Is the best approach monitor the battery voltage before it enters the board to get a 'true' reading, or is there some way to use what is coming off the board?

thanks in advance
8  Forum 2005-2010 (read only) / Interfacing / Re: Deicimila on polymer lithium ion batteries on: January 12, 2009, 07:06:26 am
You might consider using an external fuse. R/C batteries have pretty high short circuit current ratings (low impedenace) and the 'standard' Arduino type boards usually don't fuse the external Vin power.

Thanks, that makes a lot of sense.  Would any fuse below the maximum suppliable current do the job?

Also, are there any issues with connecting large diameter wire from the NiMH pack - 16AWG - to the standard gauge wire which fits the Arduinos pins?
9  Forum 2005-2010 (read only) / Interfacing / Re: Deicimila on polymer lithium ion batteries on: January 11, 2009, 05:25:56 pm
Thanks.  Are their any other precautions I should take when connecting an RC-type battery like the NiMH to the arduino?  
10  Forum 2005-2010 (read only) / Interfacing / Re: Deicimila on polymer lithium ion batteries on: January 11, 2009, 03:14:47 pm
mem, thanks very much for the code!  what a help.  would definitely not have got there on my own.  

a follow up question:  if we are setting the LOW_VOLTS_WARNING constant to 7.2 (in analog), what voltage should I expect from the fully charged 6 cell pack?
11  Forum 2005-2010 (read only) / Interfacing / Re: Deicimila on polymer lithium ion batteries on: January 11, 2009, 07:06:07 am
knuckles904, I am not familiar with cell balancing.  Can you provide a little more info on this please?

sunbox, thanks for the links.  5V is insufficient for the project - I have tried Libelium's solar power module (just the board & battery) which uses a 3.7V lithium-ion battery pushed up to 5V.  I require the full 5V from the Arduino 5V pin and the Diecimila specs say you need to provide 7-12V (when running from non-usb power) in order to get this.  Also the sparkfun USB Lipo charger only charges one 3.7V cell at a time.  You cannot use it to charge two cells connected in series - they must be disconnected and charged separately.  Not a very functional option. :-/

For the short term, given that this project will be used by people other than myself, I have decided to test out a 7.2V NiMH battery used in RC  & robotics.  (I have read too much about the instability of lipos.)   Anyone with experience monitoring a NiMH battery for end-of-discharge voltage with an Arduino?

The Lipo project will continue as a long-term goal. Thanks for all the help.
12  Forum 2005-2010 (read only) / Interfacing / Re: Deicimila on polymer lithium ion batteries on: January 08, 2009, 02:10:50 pm
Thanks.  I will look into that.  

Just to confirm, if one is powering the arduino from an external power source which is more than 5V - Deicimila specs recommend 7-12V - one should ONLY use the Vin pin?   Is the power jack not an option?
13  Forum 2005-2010 (read only) / Interfacing / Re: Deicimila on polymer lithium ion batteries on: January 08, 2009, 12:51:02 pm
That's is indeed the cut off voltage. But you sheet mail sparkfun if it has a built-in cuff off circuit. Most LiPo batteries have those but it's not clear if this one has it too.

I have mailed them and the reply is no.  They suggest monitoring the discharge with an ADC.  Anyone with experience in this area??

thanks
14  Forum 2005-2010 (read only) / Interfacing / Re: Deicimila on polymer lithium ion batteries on: January 07, 2009, 05:36:44 am
Thanks for your suggestions thefatmoop.  My code is all sorted (that is the area where I have the least problems. smiley)  I am however interested in your idea of hooking the reader directly up to the xbee.  How would you pull the enable pin on the reader low (to start reading) without the microcontroller?
15  Forum 2005-2010 (read only) / Interfacing / Re: Deicimila on polymer lithium ion batteries on: January 07, 2009, 05:14:05 am
Thanks knuckles904 for your thoughts.  Any suggestions on how I can monitor the voltage and cut it off when it reaches 3V?

(I am thinking of using these http://www.sparkfun.com/commerce/product_info.php?products_id=8483 batteries.  The spec sheet says 2.75V is the 'Discharge cut-off Voltage".  Is this what you are referring to?)
Pages: [1] 2