Show Posts
Pages: 1 2 [3] 4 5 ... 22
31  Using Arduino / Programming Questions / Re: Pulse train comparrison/matching on: April 16, 2014, 10:11:48 am
Quote
Are you saying that when there is no smoke detection there is no signal, and when there is smoke detection there is the signal you displayed above?

Yes.

Quote
Does the device also put put any other signals that you need to identify as NOT being a smoke detection signal?

No.
32  Using Arduino / Programming Questions / Re: Pulse train comparrison/matching on: April 16, 2014, 07:19:24 am
Thanks for responding, Gentlemen. Perhaps I've not been clear enough. My post is concerning only one event, a smoke detector going off, sounding an alarm.  The smoke detector is a type that, when it goes off, transmits an RF signal to other smoke detectors and they will also sound an alarm. The data shown represents the output of an RF receiver that has captured the RF signal when the smoke detector goes off. The RF signal, as viewed on a scope, looks like this:

The Pulsein function sees the low, short pulses as approximately 390usec and the longer low pulses as approximately 800usec.

The output of the receiver is fed to an input pin (7) of an Arduino. The code is below. One line of the data shown in the original post is what is seen, over and over, in the serial monitor.
Code:
/*
  PulseIn sketch

 */


const int inputPin = 7;   // analog output pin to monitor
unsigned long val;  // this will hold the value from pulseIn

void setup()

  Serial.begin(115200);
}

void loop()
{
  val = pulseIn(inputPin, LOW);
  Serial.println(val);


Does this clear things up? - Scotty

33  Using Arduino / Programming Questions / Pulse train comparrison/matching on: April 15, 2014, 03:48:11 pm
Hello Guys.I'm working on a home security project, having a text sent to me if certain events occur. One of those events is the  detection of smoke. I purchased a Kidde wireless (433Mhz) smoke alarm and am currently able to receive it's signal via a cheap receiver and was successful is using the Arduino's Pulsein(negative transition) to collect pulse data from the alarm. Below are 3 groups. Each group shows pulse width data for different user switch settings on the alarm.

I'm seeking advice on how to compare the incoming data to fixed data in a constant variable. The first number in each row below is the pause between signals sent by the alarm. I suppose that detecting the length of that first number would be the start of collecting data. I'm imagining that any pulse width between a range of say, 360-420 could be assigned a 0 and any pulse width of a range of 780-820 be considered a 1. When determined to be 0 or 1, could those bits somehow be arranged into a binary number? How would that be done? Afterward I could compare it to a binary number stored in the previously mentioned variable. I'm seeking a direction to go with the programming. Please suggest a good way to go about this. Thanks - Scotty

Code:
30147 380 392 388 1573 402 402 393 394 401 401 401 800 402 802 810 804 802 402 405 398 397 405
48734 373 389 389 1587 403 390 393 400 400 400 393 806 401 801 802 801 808 402 394 397 405 402
37169 382 394 382 1572 397 396 400 394 396 402 401 800 397 801 802 802 804 397 400 403 405 396

41406 373 400 397 1572 398 397 402 397 401 809 801 397 810 802 812 804 400 398 405 804
39944 367 396 397 1568 405 396 396 401 402 804 799 405 802 805 805 800 407 401 400 804
35690 376 398 390 1579 407 392 400 403 402 801 804 402 809 802 801 805 406 396 406 806

31026 384 397 397 1579 398 397 401 385 402 398 394 401 410 792 802 802 801 410 405 405 394 397
35777 376 398 398 1578 402 398 402 402 400 397 398 405 402 795 804 804 812 406 403 403 398 394
40726 368 397 397 1565 400 397 401 401 401 397 402 403 410 796 804 806 805 410 405 403 398 394
34  Using Arduino / Motors, Mechanics, and Power / Re: Motorized Valve on: April 13, 2014, 06:17:39 am
Does the rate of flow need to be controlled or will simple on-off suffice? - Scotty
35  Using Arduino / Project Guidance / Re: Guitar Pickup Winder on: April 04, 2014, 02:02:48 pm
Quote
How fast was the winding being done?
It wasn't very fast; perhaps 75RPM.

Quote
Perhaps the design should have a stepper that moves the entire winding assembly (pickup bobbin and DC motor) back and forth rather than the copper wire?
What would be the difference?

At the time I was thinking that having a piece to guide the wire onto the spool, located very close to the spool might eliminate the lag in changing direction but that would require having that position change relative to the ever increasing diameter of the spool winding. That was more work than I was willing to put into it.

- Scotty
36  Using Arduino / Project Guidance / Re: Guitar Pickup Winder on: April 04, 2014, 08:47:54 am
This project appealed to me a couple of years ago. I put quite a bit of effort into it but it was not an essential project so I decided to move on after not eventually getting it to work correctly. The problem I encountered, and did not resolve, was in changing the left/right direction of the wind. When the end of a layer of wind would come about and a direction change was initiated, the winding wire would want to linger at the end and build up additional layers there. After enough pull in direction change, it would move in the opposite direction but by that time the device pulling the wire would be significantly away from the end. When the wire finally 'obeyed' and did move, it would move way over to it's intended position, skipping over most of the wind from the previous 'end' to it's new position. After only a few iterations of layers, it was a mess of hills and valleys. I used these motors. - Scotty
37  Using Arduino / General Electronics / Re: IR sensor for arduino on: April 04, 2014, 07:56:24 am
I completed this project. To avoid false triggering, I pulsed the transmitter at 38kHz since the receiver is designed to 'see' that frequency. For the IR receiver I used this. For the transmitter I used this. The emitter is driven through a transistor who's 38kHz base signal is derived from a 555 timer. I had problems with getting an accurate frequency with the 555; it was very fussy about the external timing capacitor used. I was able to get a stable frequency using a high precision, low value capacitor. If I were to do it again I would use an Attiny85. No external components (except for decoupling) are needed, very stable, and it costs only about $.40 more than a 555. You would need to learn how to load code to it but that's no big deal. - Scotty
38  Using Arduino / Project Guidance / Smoke alarm detection on: April 02, 2014, 09:12:57 am
Smoke alarm detection is part of a home security project I'm working on. I'm seeking advice on using a 'local' microcontroller to  detect smoke alarm activation and sending a 'smoke alarm activated' signal to a 'master' Arduino. My initial thinking is to make use of the smoke alarms battery as a power source. Doing so, power conservation is a must. Although I've not investigated much, I'm pretty sure I can make use of 'sleep mode' of an Atmel AVR device on a DIY board using perhaps an Attiny85 or like device or using a smaller Arduino such as a mini or micro. Any thoughts on that?

There are most likely several ways to have the smoke detector wake up the micro controller. One that comes to mind is tapping off the alarm's escape light. Any other ideas?

What are your thoughts on what low power, wireless means of transmitting that detection to a 'master' Arduino is most practical? Line of sight is not practical.

All that aside, would it be possible to make use of Kiddie wireless (RF) smoke detectors?

Thanks - Scotty
39  Using Arduino / Project Guidance / Re: Arduino caliper on: March 31, 2014, 07:04:13 am
Rather than build a digital caliper with an Arduino, it may be easier to hack one of the cheap digital calipers and use an Arduino to read the calipers. This has been done by a member of these forums. Simply google "interfacing arduino with a digital caliper". How do they work? Google "how do digital calipers work?". - Scotty
40  Using Arduino / Programming Questions / Re: Arduino > USB Host > RAZR Phone on: March 30, 2014, 07:47:12 pm
Thanks alot Paul. That helped a whole bunch.

Here's the code:
Code:
#include <cdcacm.h>
#include <usbhub.h>

#include "pgmstrings.h"

// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif



class ACMAsyncOper :
public CDCAsyncOper
{
public:
  virtual uint8_t OnInit(ACM *pacm);
};

uint8_t ACMAsyncOper::OnInit(ACM *pacm)
{
  uint8_t rcode;
  // Set DTR = 1 RTS=1
  rcode = pacm->SetControlLineState(3);

  if (rcode)
  {
    ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
    return rcode;
  }

  LINE_CODING lc;
  lc.dwDTERate = 115200;
  lc.bCharFormat = 0;
  lc.bParityType = 0;
  lc.bDataBits = 8;


  rcode = pacm->SetLineCoding(&lc);

  if (rcode)
    ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);

  return rcode;
}

USB     Usb;
//USBHub     Hub(&Usb);
ACMAsyncOper  AsyncOper;
ACM           Acm(&Usb, &AsyncOper);

boolean done = false;
uint8_t rcode;
char mode[] = "AT+CMGF=1\r"; //used to put phone into text mode
int modelen = strlen(mode);
char phone[] = "AT+CMGW=16105551212\n>FROM RAZR\z";
int phonelen = strlen(phone);
char message[] = "From Razr!\r";
int messagelen = strlen(message);

void setup()
{
  Serial.begin( 115200 );
  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
  Serial.println("Start");

  if (Usb.Init() == -1)
    Serial.println("OSCOKIRQ failed to assert");
  delay( 200 );
}

void loop()
{
  Usb.Task();

  if( Acm.isReady()) {
    //uint8_t rcode;

    /* sending to the phone */
    if (done==false){//if true, prevents multiple messages from being sent

      Mode_Setup();
      delay(500);
      Read_Function();
      delay(500);
      Enter_Number();
      delay(1000);
      //Read_Function();
      //delay(500);
      //Send_Message();
      //delay(500);
      //Read_Function();
      //delay(500); 
    }
    if (rcode)
      ErrorMessage<uint8_t>(PSTR("SndData"), rcode);

    //Serial.println("            DATA SENT");
    done = true;
  }
  delay(50);

}//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..

int Mode_Setup(){
  for (int i = 0; i < modelen; i++){
    uint8_t data = mode[i];
    rcode = Acm.SndData(1, &data);
  }
  Serial.println("                         Mode Setup Complete");
}

int Enter_Number(){
  for (int i = 0; i < phonelen; i++){
    uint8_t data = phone[i];
    rcode = Acm.SndData(1, &data);
    delay(50);
  }
  Serial.println("                         Enter Number Complete");
}

int Send_Message(){
  for (int i = 0; i < messagelen; i++){
    uint8_t data = message[i];
    rcode = Acm.SndData(1, &data);
  }
  Serial.println("                         Send Message Complete");
}

int Read_Function(){
  /* reading the phone */
  /* buffer size must be greater or equal to max.packet size */
  /* it it set to 64 (largest possible max.packet size) here, can be tuned down
   for particular endpoint */
  Serial.println ("In Read Function");
  uint8_t  buf[64];
  uint16_t rcvd = 64;
  rcode = Acm.RcvData(&rcvd, buf);
  if (rcode && rcode != hrNAK)
    ErrorMessage<uint8_t>(PSTR("Ret"), rcode);

  if( rcvd ) { //more than zero bytes received
    for(uint16_t i=0; i < rcvd; i++ ) {
      Serial.print((char)buf[i]); //printing on the screen
    }
  }
  delay(10);
}

I can now send commands to the phone. However, I've run into a little snag. The command I need to use is:
AT+CMGW="phonenumber"\n
 > Type your message here.\z
Which sends a single SMS message.

(The message being embedded in char phone[] in the sketch. Now that I think of it, it makes sense that a number shouldn't be dialed and then the message typed in. The number should be dialed after the message is typed.)

It won't compile because of the \z. The error message is 'unknown escape sequence \z. I've tried adding the decimal value of 26, i.e. char phone[] = "AT+CMGW=16105551212\n>message"+26; in lieu of \z but I get a different error message about the size of 'phone'.

I have been successful in calling another phone using ATD+12125551212; just to ensure I can dial out from the RAZR.

The following is displayed in the serial monitor when the sketch is executed:

Start
0705890300100A0705010200200007058202002000                         Mode Setup Complete
In Read Function
AT+CMGF=1

OK
                         Enter Number Complete


Can anyone suggest a remedy?
Thanks - Scotty
41  Using Arduino / Programming Questions / Re: Arduino > USB Host > RAZR Phone on: March 30, 2014, 07:06:01 pm
Thanks alot Paul. That helped
42  Using Arduino / Programming Questions / Arduino > USB Host > RAZR Phone on: March 28, 2014, 02:09:05 pm
Hello Guys. I'm working on  a project to notify me, via text, of certain conditions at my home. I have been able to send text to the RAZR via the Aduino IDE Serial Monitor, using the sketch below. Of course, I would like the Arduino to send the messages autonomously. Another fellow has been working on the same project and has asked the same question to the author of the sketch. His response was to 'Just replace strings that I send with strings you need to send.' I assume this in reference to the line of code: rcode = Acm.SndData(1, &data);. I've tried different approaches such as filling the variable 'data' with characters, a sting, numeric values, etc. to no avail. Most of the time, the error references some code in the cdcacm library. The error is as follows:

acm_terminal.ino: In function 'void loop()':
acm_terminal:71: error: invalid conversion from 'const char*' to 'uint8_t*'
acm_terminal:71: error: initializing argument 2 of 'uint8_t ACM::SndData(uint16_t, uint8_t*)'

It seems to me it should be relatively easy to have the Arduino send text as is done via the serial monitor. Within an Arduino sketch, is it possible to emulate sending text entered via the serial monitor?

Thanks - Scotty


Code:
#include <cdcacm.h>
#include <usbhub.h>

#include "pgmstrings.h"

// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif

class ACMAsyncOper : public CDCAsyncOper
{
public:
    virtual uint8_t OnInit(ACM *pacm);
};

uint8_t ACMAsyncOper::OnInit(ACM *pacm)
{
    uint8_t rcode;
    // Set DTR = 1 RTS=1
    rcode = pacm->SetControlLineState(3);

    if (rcode)
    {
        ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
        return rcode;
    }

    LINE_CODING lc;
    lc.dwDTERate = 115200;
    lc.bCharFormat = 0;
    lc.bParityType = 0;
    lc.bDataBits = 8;

    rcode = pacm->SetLineCoding(&lc);

    if (rcode)
        ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);

    return rcode;
}

USB     Usb;
//USBHub     Hub(&Usb);
ACMAsyncOper  AsyncOper;
ACM           Acm(&Usb, &AsyncOper);

void setup()
{
  Serial.begin( 115200 );
  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
  Serial.println("Start");

  if (Usb.Init() == -1)
      Serial.println("OSCOKIRQ failed to assert");

  delay( 200 );
}

void loop()
{
    Usb.Task();

    if( Acm.isReady()) {
       uint8_t rcode;

       /* reading the keyboard */
       if(Serial.available()) {
         uint8_t data= Serial.read();
         /* sending to the phone */
         rcode = Acm.SndData(1, &data);
         if (rcode)
            ErrorMessage<uint8_t>(PSTR("SndData"), rcode);
       }//if(Serial.available()...

       delay(50);

        /* reading the phone */
        /* buffer size must be greater or equal to max.packet size */
        /* it it set to 64 (largest possible max.packet size) here, can be tuned down
        for particular endpoint */
        uint8_t  buf[64];
        uint16_t rcvd = 64;
        rcode = Acm.RcvData(&rcvd, buf);
         if (rcode && rcode != hrNAK)
            ErrorMessage<uint8_t>(PSTR("Ret"), rcode);

            if( rcvd ) { //more than zero bytes received
              for(uint16_t i=0; i < rcvd; i++ ) {
                Serial.print((char)buf[i]); //printing on the screen
              }
            }
        delay(10);
    }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..
}
43  Using Arduino / Project Guidance / Re: Automated Chicken Feeder - Noob needs help on: March 26, 2014, 07:02:32 am
Quote
turning the motor on for a set time and reversing it the same amount of time to open close the valve?

That method might work sometime but I doubt it would work correctly consistently. The problem with the method is, depending on the load, that there is no way to determine the length of time it will take for the door to open or close. Besides that, the time it will take for the door to open or close will also greatly depend of the charge state of the battery. You cannot recharge a "just those ones you buy from the supermarket" battery.

I think you need to rethink this design. Your current one is just too flawed.

- Scotty
44  Using Arduino / Project Guidance / Re: Automated Chicken Feeder - Noob needs help on: March 25, 2014, 06:56:10 am
Welcome to the forums.
At 12v, under no load, that motor would make 1.2 revolutions in 2 seconds. Rather than controlling the length of time to the open or closed positions, I think a better approach would be to sense the open and closed positions and operate the motor until the desired position is reached. What power supply is used for powering the motor? - Scotty
45  Using Arduino / Programming Questions / Re: HC SR-04 and servo problem. on: March 24, 2014, 06:44:40 am
Welcome to these forums. Please read and follow the instructions contained in the sticky post, the first post on this forum's opening page. - Scotty
Pages: 1 2 [3] 4 5 ... 22