Show Posts
Pages: [1] 2 3 ... 5
1  Using Arduino / Project Guidance / Animatronic with audio triggering on: September 18, 2014, 05:56:28 pm
I am working on an Animatronic that talks moves his head side to side and shakes forwards and backwards.

I have the talking working just fine, i need to add the turning of the head and shaking.

The mouth is triggered with audio that i have fed into the Shifty VU sheild.

The head and shaking are pistons that have relays to turn them on and off.

My issue is that what would be a good solution to monitoring for the audio signals, as well as turning on and off the head and shakes to a timer so it is synced with the talking.

Would using delays to just run a program for shaking and head turning. and use an interrupt when an audio signal is detected for the mouth?

Or would it be better to have the mouth always detected then use timer interrupts to run the head and shakes?

Any suggestions would be great

Thanks in Advance
2  Using Arduino / Project Guidance / Maximum Sampling Rate of PID Library on: March 10, 2014, 07:44:56 pm
I wish to use the PID Arduino library to create a PI controller with a sampling frequency of 100Khz. for a power factor correction boost converter.

Is this possible? Because i believe that maximum sampling time of arduino UNO is 10Khz? i heard somewhere it can reach to 100Khz.

in the code the sampling time is divided by 1000 so if sampling time is 1000, then it 1 sec.

So in this method, the sampling time would need to be set to .001 to get the 100Khz needed.

I feel having a decimal tho wouldn't work.

any help would be much appreciated.

Code:
void SetTunings(double Kp, double Ki, double Kd)
{
  double SampleTimeInSec = ((double)SampleTime)/1000;
   kp = Kp;
   ki = Ki * SampleTimeInSec;
   kd = Kd / SampleTimeInSec;
}
 
void SetSampleTime(int NewSampleTime)
{
   if (NewSampleTime > 0)
   {
      double ratio  = (double)NewSampleTime
                      / (double)SampleTime;
      ki *= ratio;
      kd /= ratio;
      SampleTime = (unsigned long)NewSampleTime;
   }
}
3  Using Arduino / Project Guidance / Re: Audio input to control pnematic relays. on: September 09, 2012, 01:42:34 pm
i have speech on a audio track i want to make the mouths of these animatronics sync withe the speech.
there is one realy to control the mouth.

4  Using Arduino / Project Guidance / Audio input to control pnematic relays. on: September 08, 2012, 11:54:25 am
Halloween is a coming and i am working on updating some animatronics.
They run on cassette tapes at the moment and the boars are marked '87 so thought id update them.

I wish to run an arduino with either a SMD card on it with the audio files on there, and output the audio files.
The audio files will just be voice and the audio signal will go into the arduino which then out puts 5 volt signals to some transistors to gate to switch the 24V to the pneumatic relays to activate.

Should i use the wave shield to accomplish this?
or a simpler way you think? Possibly split the audio to the speakers and to the arduino input. using voltage references to trigger output to the transistor switches.

Any help would be great
5  Using Arduino / Programming Questions / Re: Arduino Mega, freezezs when connecting to server on: August 24, 2011, 01:44:57 pm
sorry for the delay,

Here is how i am sending the emails with attachments. The code it actually in is alot bigger but the email sending is the same principal.

Code:
#include <Ethernet.h>
#include <SPI.h>
#include <SD.h>

char Sfile[]= {"S00DATA.csv"};

char filetype[] = {"csv"};
byte slave_address = 2;
byte SLAVE_END = 3;

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x6D, 0xD6 }; // Arduino's artificial mac address
byte ip[] = { 0, 0, 0, 0 }; // my ip
byte server[] = { 0, 0, 0, 0 }; // my smtp server ip
int time = 5000;
int wait = 2000;

File datatxt;
Client client(server, 25);

static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const int chipSelect = 4;

char Sender_email[] ={"blah@gmx.com"};

void setup()
{
 delay(time);
 Ethernet.begin(mac, ip);
 Serial.begin(9600);
 delay(1000);
 pinMode(10,OUTPUT);

 Serial.print("Initializing SD card...");
 
 if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");

 

}

void loop()
{
   Serial.println("connecting...");
 
 if (client.connect()) {
                        
                          
                        Serial.println("connected");
  
                        client.println("HELO itismeletschat"); /* say hello (statement after helo is needed but irrelevant)*/
                          delay(wait); /* wait for a response */

                        client.println("MAIL From: blah@gmx.com"); /* identify sender, this should be the same as the smtp server you are using */
                          delay(wait); /* wait for a response */

                        client.println("RCPT To:blahe@virelec.com"); /* identify recipient */
                          delay(wait); /* wait for a response */

                        client.println("DATA");
                          delay(wait); /* wait for a response */
                        
                        client.println("Subject: text file attached");
                        
                        client.print("Content-type: multipart/mixed; boundary=\"$boundary\" \r\n");
                        
                        while(slave_address <= SLAVE_END){
                                add_attachment(slave_address);
                                slave_address++;
                        }
                                              
                        client.println("."); /* end email */
                        client.println("QUIT"); /* terminate connection */
                        delay(wait); /* wait for a response */
                        
 
  
  
 } else {
   Serial.println("connection failed");
 }
  
  
  
 while (client.available()) {
   char c = client.read();
   Serial.print(c);
 }
 
 if (!client.connected()) {
   Serial.println();
   Serial.println("disconnecting.");
   client.stop();
   slave_address = 0;
   delay(300000);
  
 }
}




void encodeblock(unsigned char in[3],unsigned char out[4],int len) {
  out[0]=cb64[in[0]>>2];
  out[1]=cb64[((in[0]&0x03)<<4)|((in[1]&0xF0)>>4)];
  out[2]=(unsigned char) (len>1 ? cb64[((in[1]&0x0F)<<2)|((in[2]&0xC0)>>6)] : '=');
  out[3]=(unsigned char) (len>2 ? cb64[in[2]&0x3F] : '=');
}

void encode() {
  unsigned char in[3],out[4];
  int i,len,blocksout=0;
  
  while (datatxt.available()!=0) {
    len=0;
      for (i=0;i<3;i++){
            in[i]=(unsigned char) datatxt.read();
                if (datatxt.available()!=0) len++;
                      else in[i]=0;
      }
      if (len){
          encodeblock(in,out,len);
           for(i=0;i<4;i++) client.write(out[i]);
                blocksout++; }
      if (blocksout>=19||datatxt.available()==0){
          if (blocksout) client.print("\r\n");  blocksout=0;
      }
   }
}



void add_attachment(byte slave){
                                              
            client.print("--$boundary\r\n");                    
            Sfile[1] =(slave/10 + 48);
            Sfile[2] =(slave%10 + 48);
            datatxt =SD.open(Sfile,FILE_READ);
            client.print("Content-Type: ");
            client.print(filetype);
            client.print("; ");
            client.print("name=");
            client.println(Sfile);
            client.print("Content-Disposition: attachment; ");
            client.print("filename=");
            client.println(Sfile);
            client.println("Content-Transfer-Encoding: base64");  
            client.println("");        
            
            encode();
            datatxt.close();
            delay(wait);                        
}


it sends an email a few times then halfway through it seems to be cutting out and starting again.
SERIAL MONITOR:
Code:
disconnecting.
connecting...
connected
220 to5email2.gprs.rogers.com ESMTP server (InterMail vM.7.09.00.04 201-2219-102-106-20090410) ready Wed, 24 Aug 2011 14:33:47 -0400
250 to5email2.gprs.rogers.com
250 Sender <blah@gmx.com> Ok
250 Recipient <bla@virelec.com> Ok
354 Ok Send data ending with <CRLF>.<CRLF>
250 Message received: 20110824183353.IFDQ13635.to5email2.gprs.rogers.com@itismeletschat
221 to5email2.gprs.rogers.com ESMTP server closing connection

disconnecting.
connecting...
connected
220 to5email2.gprs.rogers.com ESMTP server (InterMail vM.7.09.00.04 201-2219-102-106-20090410) ready Wed, 24 Aug 2011 14:39:00 -0400
250 to5email2.gprs.rogers.com
250 Sender <blao@gmx.com> Ok
250 Recipient <bla@virelec.com> Ok
354 Ok Send data ending with <CRLF>.<CRLF>
connecting...
connection failed
connecting...
connection failed
connecting...
connection failed
6  Using Arduino / Programming Questions / Arduino Mega, freezezs when connecting to server on: August 23, 2011, 04:14:12 pm
I am using an Arduino Mega with a Ethernet Shield.

I have a program that datalogs and sends emails out every minute.
I can collect data and send out email once then on second loop through it freezes at connecting and just hangs there.

Any ideas?
7  Using Arduino / Programming Questions / enough space? on: August 22, 2011, 03:59:15 pm
Binary sketch size: 22274 bytes (of a 32256 byte maximum)

my program seems to not run with this memory used in sketch.

would this be the problem?

I can run other sketches on the same arduino with less mem used
8  Using Arduino / Programming Questions / Re: User input turned to HEX on: August 22, 2011, 01:08:30 pm
perfect thanks
9  Using Arduino / Programming Questions / SOLVED:User input turned to HEX on: August 22, 2011, 12:35:07 pm
Idea:

User inputs in serial monitor "A3"
when read in hex it will be 0x41 and 0x33

I would like when read in HEX it will be 0xA3

how can i achieve this?

i know how to read the values and such and I'm reading one value at a time, so "A" then the "3"

10  Using Arduino / Programming Questions / Re: Checking variable for while loop, updated from Interrupt on: August 18, 2011, 12:18:55 pm
thanks the volatile byte worked.

yes i know putting a delay in there is bad, in my actual program there is nothing like that.

thanks again
11  Using Arduino / Programming Questions / SOLVED:Checking variable for while loop, updated from Interrupt on: August 18, 2011, 11:44:55 am
I am using a TIMER1 overflow interrupt,
I have written a quick code to test to see if i can update a variable with the interrupt as its being checked by a while statement.

Code:
   
    #include "TimerOne.h"
    
    byte FLAG = 0;
    void setup()
    {
      Serial.begin(9600);
      pinMode(6, OUTPUT);
      Timer1.initialize(1000000);        
      Timer1.attachInterrupt(callback);  
      Timer1.stop();
      
    }
    
    void callback()
    {
      digitalWrite(6, HIGH);
      delay(10);
      digitalWrite(6, LOW);
      FLAG = 1;
      Timer1.stop();
     }
    
    void loop()
    {
      Serial.println("SEND MESSAGE");
      Timer1.start();
      Serial.println("RECEIVING");
      while(FLAG == 0);
      FLAG = 0;
      delay(10000);      
    }
    

It doesn't notice the interrupt change in the FLAG status with :   while(FLAG == 0);

It does notice the flag change however if i put something in the while loop to check eg:

while(FLAG ==0){
Serial.println(FLAG, DEC);
}

Does anyone know why this is happening?
Doesn't  " while(FLAG == 0);" continuously check the state of FLAG anyways?

12  Using Arduino / Programming Questions / Re: Email attachments from arduino as an SMTP client on: August 15, 2011, 02:53:32 pm
okay i figured that out too, here's a post Incase someone is wondering.
Sending Multiple Attachments

Code:
    Serial.println("connected");
  
                        client.println("HELO itismeletschat"); /* say hello (statement after helo is needed but irrelevant)*/
                          delay(wait); /* wait for a response */

                        client.println("MAIL From: blank@gmx.com"); /* identify sender, this should be the same as the smtp server you are using */
                          delay(wait); /* wait for a response */

                        client.println("RCPT To: blank@virelec.com"); /* identify recipient */
                          delay(wait); /* wait for a response */

                        client.println("DATA");
                          delay(wait); /* wait for a response */
                        
                        client.println("Subject: text file attached");
                        
                        [b]client.print("Content-type: multipart/mixed; boundary=\"$boundary\" \r\n");[/b]
                        
                        [b]client.print("--$boundary\r\n");[/b]
                        
                        datatxt =SD.open("HEAD2.csv",FILE_READ);                
                        client.print("Content-Type: csv; name=\"HEAD2.csv\"\r\nContent-Disposition: attachment; filename=\"HEAD2.csv\"\r\nContent-Transfer-Encoding: base64\r\n\r\n");
                        encode();
                        datatxt.close();
                        delay(wait);
                        
                        datatxt =SD.open("meow.txt",FILE_READ);
                        [b]client.print("--$boundary\r\n");[/b]
                        client.print("Content-Type: txt; name=\"meow.txt\"\r\nContent-Disposition: attachment; filename=\"meow.txt\"\r\nContent-Transfer-Encoding: base64\r\n\r\n");
                        encode();
                        datatxt.close();
                        
                        client.println("."); /* end email */
                        client.println("QUIT"); /* terminate connection */
                        delay(wait); /* wait for a response */
            
           
13  Using Arduino / Programming Questions / Re: Email attachments from arduino as an SMTP client on: August 15, 2011, 01:48:09 pm
If i want to send multiple attachments, do i have to use boundaries?
which i guess the next question is, what are boundaries and how do i use them?
14  Using Arduino / Programming Questions / Re: Email attachments from arduino as an SMTP client on: August 15, 2011, 01:01:21 pm
oh! nevermind, i missed calling the function "encode();"

Everything is good. Thanks
15  Using Arduino / Programming Questions / Re: Email attachments from arduino as an SMTP client on: August 15, 2011, 12:50:59 pm
Well i just tried that code again,
it decided to work this time, now i just need to send the contents of the txt file, it didn't have any contents.
but i can send a txt file.
Pages: [1] 2 3 ... 5