Pages: [1] 2   Go Down
Author Topic: Looking for a HW/Software solution to a problem  (Read 2012 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Greetings all I am using a Macintosh Mini (snow leopard) and I am building a Doorbell / camera interface and need help.

I would like when the doorbell is pressed, it activates a relay that runs a Applescript (I already wrote) program to
start a sequence of events.

I am looking for a hardware / software solution that will see the relay, and then run the applescript or application.

I will pay for all hardware and your time.

please email me at  Jon (at) macgeek.com

Thanks!

Jonathan
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12482
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Hi MacGeek,

Where are you located?  looking at your name I think Scotland smiley-wink

There are several solutions possible but:
- Can your AppleScript monitor the hardware lines of a serial port ?  e.g. relay switches RTS from low-> HIGH 
- Can your AppleScript monitor the serial port ? e.g. commands "B"  and  "O" from the Arduino. B = Bell O = Off

Rob






Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

LOL no I am in Brooklyn, NY NOT Scotland!

I am actually looking for someone to write the program, and set it up for me.

Jonathan

PS: some more thoughts on it's function

1) once its triggered it should ignore all  trigger commands for 2 mins
(if someone keeps hitting the button to activate it)

2) it triggers other external events (contact closure)
(if I want to record the video on a dvr, for instance)

 



Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12482
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


OK Jonathan, Brooklyn it is,

Do you allready own an Arduino?

The additional requirements are quite clear, in pseudocode your application looks something like

Code:

define IO & libs

void setup()
{
   .. initialize things
}

void loop()
{
  If (doorbell pressed and last press was more than 2 minutes ago)
  {
    make a log entry on SDcard;
    set timer for two minutes;
    send signal to AppleScript (retry 3 times);
    if (DVR switch ON)
    {
      set DVR ON;
    }
 
  if (timer has passed 2 minutes)
  {
    set DVR OFF;
  }
}

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the code, I actually don't have ANY of the components yet.
I was looking for a HW/SW person to 'put it all together for me'

smiley-wink

Jonathan
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am still looking for a person, but I may end up doing the project myself (Cost constraints)

Here is the sequence I am trying to accomplish

1) person rings my doorbell (which triggers a relay)
2) relay activates doorbell and arduino - which sends a USB/Serial command to Macintosh monitoring and executes a APPLESCRIPT
3) arduino deactivates / ignores any more attempts to re-activate for 4 mins (doorbell push)
4) arduino activates a closed contact (so start a DVR, or other triggered function)
5) after 4 mins, arduino resets, returning all contacts to 'open'

Thanks

Jonathan
Logged

Miers 46500 France
Offline Offline
Full Member
***
Karma: 2
Posts: 174
EmbeddedAT .. From Concept to Prototype to Production
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Jonathan,

I guess my final offer was also too much for your budget.

I will keep an eye on this thread and chirp in from time to time if you are having problems.

Cheers Pete
Logged

EmbeddedAT .. From Concept to Prototype to Production

Electronics and firmware design and project mentoring

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am seeing just what this will cost me   smiley-money

I have tracked down the Applescript proxy server, and purchased the Arduino board
it is down now to seeing if I can figure out the code to do the simple

Sense button push
ignore all other button pushes
send command to Macintosh to start applescript


how hard can THAT be?

(we will see) LOL

Jonathan
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What you are trying to do it fairly easy to accomplish. I would suggest you either use Processing or Perl (my favorite) on your mini to monitor the serial port where the Arduino is plugged in. Then just come up with a scheme such as send the letter "A" when the doorbell is rung. From the Processing or Perl side it is simple to then read that "A" and trigger your applescript.

Check out:
http://arduino.cc/playground/Interfacing/Processing
http://arduino.cc/playground/Interfacing/PERL

To trigger an AppleScript from the command line, use osascript: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/osascript.1.html

The reason I mentioned Processing is that if you are a little familiar with Arduino, then Processing is pretty simple to pick up.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I have been paying, and making some good progress, I am having some MINOR ISSUES,

int ledPin = 13;   // LED connected to digital pin 13
int potPin = 0;    // white doorbell wire to analog pin 0
int val = 0;

long time = 0;
long debounce = 5000;

void setup() {
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  Serial.begin(9600);           // open serial port at 9600 baud
  digitalWrite(14 + potPin, HIGH); // set pullup on the analog pin
                                // (analog 0 = digital 14, a1 = d15, etc)
}

void loop() {
  val = analogRead(potPin);
  if (val < 50) {              // if the circuit is completed
  // (for me, it generally drops from 1023 to ~ 15 when 'ringing')
    if (millis()-time > debounce) {
      Serial.println("A");
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(5000);                   // ... 240000 = 4 mins
      digitalWrite(ledPin, LOW);    // and turns the LED off
      time = millis();
    }
  }
}

What seems to be happening, is that I have to push the button 3 times to get it to send the "A" to the serial Port,

I played with the delay(5000) to have it ignore the input, but It doesnt seem to be working...


Any ideas?

Thanks

Jonathan

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
int ledPin = 13;   // LED connected to digital pin 13
int potPin = 0;    // white doorbell wire to analog pin 0
int val = 0;

long time = 0;
long debounce = 5000;

void setup() {
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  Serial.begin(9600);           // open serial port at 9600 baud
  digitalWrite(14 + potPin, HIGH); // set pullup on the analog pin
                                // (analog 0 = digital 14, a1 = d15, etc)
}

void loop() {
  val = analogRead(potPin);
  if (val < 50) {              // if the circuit is completed
  // (for me, it generally drops from 1023 to ~ 15 when 'ringing')
    if (millis()-time > debounce) {
      Serial.println("A");
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(5000);                   // ... 240000 = 4 mins
      digitalWrite(ledPin, LOW);    // and turns the LED off
      time = millis();
    }
  }
}

What seems to be happening, is that I have to push the button 3 times to get it to send the "A" to the serial Port,

I played with the delay(5000) to have it ignore the input, but It doesnt seem to be working...

Any ideas?

Change "long time" to "unsigned long time".

On the first pass through your loop, you are trying this
Code:
if (millis()-time > debounce)
millis() starts at 0 and counts up, and time starts at 0. So you are waiting until millis() is greater than debounce(5000) before you actually set the fact that the button has been pressed for the first time.

With the current logic, when you first start up, wait 5 seconds after it starts before you try hitting the button and test. You can rearrange your logic to fix this, but this would be generally fine after the first 5 seconds.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a Cheat, BUT IT WORKS...

int ledPin = 13;   // LED connected to digital pin 13
int potPin = 0;    // white doorbell wire to analog pin 0
int val = 0;

long time = 0;

long debounce = 1000;

void setup() {
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  Serial.begin(9600);           // open serial port at 9600 baud
  digitalWrite(14 + potPin, HIGH); // set pullup on the analog pin
                                // (analog 0 = digital 14, a1 = d15, etc)
}

void loop() {
  val = analogRead(potPin);
  if (val < 100) {              // if the circuit is completed
  // (for me, it generally drops from 1023 to ~ 15 when 'ringing')
    if (millis()-time > debounce) {
      Serial.println("A");
      delay(500);
      Serial.println("A");
      delay(500);
      Serial.println("A");
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(120000);                   // ... 240000 = 4 mins
      digitalWrite(ledPin, LOW);    // and turns the LED off
      time = millis();
    }
  }
}

What I found what was happening, was the Arduino was sending the "A" to the serial port, But the Applescript Proxy was only reading every third "A" so I just had the program, send out THREE.. and by adding the Delay, the unit is ignoring any button pushes for "X"

Jonathan
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46222
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What I found what was happening, was the Arduino was sending the "A" to the serial port, But the Applescript Proxy was only reading every third "A" so I just had the program, send out THREE
You really need to figure out why this is happening, and fix it properly.

Have you told the proxy server to read 3 characters at a time?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The proxy server is a fixed program, written by someone years ago, who has (and his company too) disappeared

Jonathan
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
All of the frustration of programming, PLUS the dangers of electricity!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, that AppleScript proxy server sounds screwy. What's it called? Doing a simple Google search I came up with several AppleScript proxy servers. You may want to check out one of them, one that is less of a black box to you.
Logged

Chris Spurgeon
TWITTER: @chrisspurgeon

Pages: [1] 2   Go Up
Jump to: