Show Posts
|
|
Pages: [1] 2 3 ... 5
|
|
1
|
Using Arduino / Audio / Re: Audio Filtering
|
on: May 15, 2013, 05:02:21 am
|
Thanks all!  Now I'm going to try it. Although I have some knowledge about DST this is going to be hard for me. I have to understand fine how to store the right values after doing FFT, and then how to compare it with the new samples (programming issue). Regards.
|
|
|
|
|
2
|
Using Arduino / Audio / Re: Audio Filtering
|
on: May 14, 2013, 02:19:18 am
|
First of all, thanks everyone! - Grumpy_Mike: I could compare with a template, but for example, I don't know if it will work when volume doesn't be the same.
- Magician: I need to go up to 22 KHz, I'm going to take a look to your link. It could be helpful for me.
- DVDdoug: My idea is compare one sound a time, and in one specific case. So if it is a truck, it will be a specific truck in one determined moment. If it is a trumpet, it will be the same trumpet playing the same music notes.
I had thought about make a first reading amplitude attempt (in dB) for three different frequencies, then save them, and after that listen sound compare with them for detect if is positive/false detection. Regards.
|
|
|
|
|
3
|
Using Arduino / Audio / Audio Filtering
|
on: May 13, 2013, 02:38:43 am
|
Hi, I have some doubts about how to implement a solution for the app that I explain below: - I want to filter specific audio sounds (truck, trumpet...) with an arduino and a microphone (amplifier + microphone).
- The main idea is taking samples for a short time (a few seconds), analyze the sound in frequency, and know if it is from an audio source or another.
- I have characterized my target sounds in three frequencial components (Hz), with their amplitude (dB). And I only want to compare the sound measured with these components but I can't split them from audio samples I have taken.
I read about doing it with 'ffft' library, but for the moment I don't know how to implement it. Could someone tell me how to do it? Is there another solution for this app? Regards.
|
|
|
|
|
4
|
Using Arduino / Networking, Protocols, and Devices / Read parameters in cyclic sleep pin-wake
|
on: May 06, 2013, 03:29:28 am
|
Hi, I'm working with several S2 xbee device in cyclic sleep pin-wake mode (SM5) to minimize the power consumption of my net. My configuration is: SM = 5 SN = A (10) SO = 4 SP = 3E8 (1000) ST = 64 (100) Also I have the CTS enabled (DIO7 = 1). SP = 3E8 (1000) SN = A (10) But I have problems reading XBee parameters, I can't read any of them in a short ST. The main issue is when xbee is awake for a long time only for reading AT parameters, the power consumption reduces the battery life. Also I have read about to add a Commissioning button to 20pin, and even if this is managed by a digital pin from the MCU, can't be the right solution because 30 seconds is too much time for being awake. How can I read any data by AT commands from XBee before it goes to sleep (ST is only 100ms).Regards.
|
|
|
|
|
5
|
Using Arduino / Project Guidance / Re: Sensor Network for an irrigation system
|
on: March 18, 2013, 03:39:03 pm
|
Hi all, this topic is really interesting. I have some questions too. - Nfds talked in his second post about doing a 5-8 network nodes, isn't it too expensive for working with gprs for such network?
- You talked about pumps and solenoids, what kind of them do you have selected for this project?
- Related with previous question, what kind and maximum charge of batteries have you choosen?
- And one last question, could you tell us what type of sprinkler will you use?
And a little help. - This network seems to be enough for a home garden, so I think it would be better a wifi wireless system, with enough range for transmitting data, also bidirectional communication. Moreover you can send all data to cloud from your gateway with only one interface.
- Gboard seems to be a complete system to work as you want, but if you only want to send data messages there are more cheaper devices, or even arduino shields to this function.
I hope these last tips could help you.
|
|
|
|
|
6
|
Using Arduino / Networking, Protocols, and Devices / Re: AT Command Mode. Maximun Payload
|
on: February 14, 2013, 04:40:38 am
|
|
Hi,
thanks!!
The problem was in the receiver code, so for the moment is solved!
I was modifying some MCU register after copying code here, and that was the problem. When I avoid these instructions it began to work fine.
* The AT command haven't been still tested by myself, so in a few days I hope to can test them.
Regards.
|
|
|
|
|
7
|
Using Arduino / Sensors / Re: Wire issue with ADXL345
|
on: February 13, 2013, 07:15:50 am
|
|
Hi,
thanks to all!!
With an external pull-up, it works!!
I have to verify it better, but for the first time (with a 4k7 resistor) it is working.
Regards!
|
|
|
|
|
8
|
Using Arduino / Networking, Protocols, and Devices / Re: AT Command Mode. Maximun Payload
|
on: February 13, 2013, 06:11:30 am
|
|
Hi,
first of all, thanks for every one!
I'm trying to answer your questions at the best way.
- Serial.flush(). It's used to clean the Serial port. It's possible that I used it more than neccesary, but sometimes I get some garbage in Serial port (it could be for using '\t' or '\n').
- IDE 1.0 Linux.
- How long...? I don't have too much knowledge reading AT commands from MCU yet. So I can't read AT commands faster if I don't wait one second (also I have troubles with, if I set CTS FLOW CONTROL bit (DIO7). [I'll try to avoid Serial.flush in these functions also the 'delay', could you give any tip about?].
- Serial port. It's used to talk with XBee but at my test, it's the way I can assure the communication is working fine.
* For receiving data: an Arduino Mega with a Xbee Shield and the code post below (it switches on/off a led for a time). It shows Serial port data by Cutecom app. ** For transmitting data: an explorer usb and the X-CTU app, so I can send the message I want.
Regards!
|
|
|
|
|
9
|
Using Arduino / Networking, Protocols, and Devices / Re: AT Command Mode. Maximun Payload
|
on: February 08, 2013, 03:17:01 am
|
Hi, the two question marks are a trick. The code in the receiver is like this: #define INI_MSG 0 #define FIN_MSG 4 #define INI_MAC 12 #define FIN_MAC 28 #define INI_IDMSG 29 #define FIN_IDMSG 43 #define INI_ACT 44 #define FIN_ACT 51 #define INI_TACT 52 #define FIN_TACT 61 #define INI_PRACT 62 #define FIN_PRACT 71
unsigned long init_int_time = 0; unsigned long last_int_time = 0;
String MacAlta = "", MacBaja = "";
int tProbe = 0; String inputString = ""; // a string to hold incoming data boolean stringComplete = false; // whether the string is complete
int aCt = 0; int tAct = 0; int prAct = 0; int vAct = 0; int vTAct = 0; int vPrAct = 0; String strACK = ""; String strSMS = ""; String strError = ""; String cmp = "sms:"; String strAct = "AC"; String strTi = "TI"; String strPr = "PR";
int tSend = 0; int tError = 0;
/* * */
void setup(void) {
Serial.begin(38400); Serial.println("\t XBEE AT \n"); readXBee(); }
/* * */
void loop(void) { if (stringComplete) {
if ((inputString.substring(INI_MSG,FIN_MSG) == cmp) && (inputString.substring(INI_MAC,FIN_MAC) == (MacAlta + MacBaja))) { tSend = 1; } else { tError = 1; tSend = 0; } strSMS = inputString.substring(INI_IDMSG,FIN_IDMSG); Send();
inputString = ""; stringComplete = false; } while (Serial.available() > 0) { char inChar = (char)Serial.read(); inputString += inChar;
if (inChar == '\n') { stringComplete = true; Serial.flush(); } } }
/* * */ void Send() { switch (tSend) { case 0: ERROR(); break; case 1: ACK(); Read_Message(); break; } // clean serial buffer Serial.flush(); tSend = 0; strSMS = ""; }
/* * */ void ERROR() {
// print message Serial.print(cmp);
// @MAC // 32 bit MSB Serial.print(MacAlta);
// 32 bit LSB Serial.print(MacBaja); Serial.print(" ");
// ID_MSJ Serial.print(strSMS); Serial.print(" "); // ERROR switch (tError) { // Mensaje incorrecto case 1: strError = "ERROR 404 - Not Found"; break; // Parametros erroneos case 2: strError = "ERROR 406 - Wrong Parameters"; break; //default: // si nada coincide, ejecuta el "default" // el "default" es opcional } Serial.print(strError); Serial.println(" ");
// clean serial buffer Serial.flush(); tError = NULL; strError = ""; }
/* * */ void ACK() {
// print message Serial.print(cmp);
// @MAC // 32 bit MSB Serial.print(MacAlta);
// 32 bit LSB Serial.print(MacBaja); Serial.print(" ");
// ID_MSJ Serial.print(strSMS); Serial.print(" "); // ACK strACK = "OK"; Serial.print(strACK); Serial.println(" ");
// clean serial buffer Serial.flush(); strACK = ""; }
/* * */
void Read_Message() {
if ((inputString.substring(INI_ACT,INI_ACT+2) == strAct) && (inputString.substring(INI_TACT,INI_TACT+2) == strTi) && (inputString.substring(INI_PRACT,INI_PRACT+2) == strPr)) { aCt = inputString.substring(INI_ACT+2,INI_ACT+4).toInt(); tAct = inputString.substring(FIN_TACT+2,FIN_TACT+4).toInt(); prAct = inputString.substring(INI_PRACT+2,FIN_PRACT+4).toInt(); vAct = inputString.substring(FIN_ACT-2,FIN_ACT).toInt(); vTAct = inputString.substring(FIN_TACT-4,FIN_TACT).toInt(); vPrAct = inputString.substring(FIN_PRACT-4,FIN_PRACT).toInt(); Serial.println(aCt); Serial.println(tAct); Serial.println(prAct); Serial.println(vAct); Serial.println(vTAct); Serial.println(vPrAct); Do_It(); } // ERROR EN MSG DE ACTUACION else { tError = 2; tSend = 0; Send(); } }
/* * */
void Do_It() { tProbe = millis();
// DIGITAL PIN OUTPUT pinMode(aCt, OUTPUT); while ((millis() - tProbe) < vPrAct) { init_int_time = millis(); if (init_int_time - last_int_time > vTAct) { digitalWrite(aCt, HIGH); } if (init_int_time - last_int_time > vTAct) { digitalWrite(aCt, LOW); } last_int_time = millis(); } digitalWrite(aCt, LOW);
aCt = NULL; tAct = NULL; prAct = NULL; vAct = NULL; vTAct = NULL; vPrAct = NULL; }
/* * */
void readXBee() { int i = 0; MacAlta = "00"; MacBaja = "";
delay(100); while(i < 15) { char inChar; Serial.flush(); Serial.print("+++"); delay(1000); while (Serial.available() > 0) { // Get the 'OK' msg inChar = (char)Serial.read(); } delay(1000);
Serial.flush(); Serial.println("atsh"); delay(1000); while (Serial.available() > 0) { inChar = (char)Serial.read(); MacAlta += inChar; i++; } delay(1000); Serial.flush(); Serial.println("atsl"); delay(1000); while (Serial.available() > 0) { inChar = (char)Serial.read(); MacBaja += inChar; i++; } delay(5000); } }
|
|
|
|
|
10
|
Using Arduino / Networking, Protocols, and Devices / AT Command Mode. Maximun Payload
|
on: February 07, 2013, 09:53:28 am
|
|
Hi,
I'm trying to send a RF data payload of 73 bytes between 2 Zigbee-Pro modules in AT Command Mode.
The two modules are equal configured:
ROUTER AT. Fmw 22A7 ID: 5555 DH: 0 DL: FFFF BD: 5
And they shows, NP: 54 (this is 84 bytes in decimal). So, it must be read perfectly, but instead of this the data frame is wrapped, and this makes me have errors at reading time of serial buffer.
How can I configure my modules to avoid this behaviour??
Where is the error (receiver or transmitter side)??
|
|
|
|
|
11
|
Using Arduino / Sensors / Re: Wire issue with ADXL345
|
on: February 07, 2013, 07:56:50 am
|
|
Hi,
and thanks all!
@afremont: - If I force the interrupt by a wire, it works perfectly. - With MCU always awake, ADXL's interrupt works fine.
@pylon: - 'Doesn't jump', I mean ATmega doesn't react on it. - I'm using internal pull-ups. Could this be the problem?
I'm still trying to discover why is this happening, although I'm going to some of these things.
|
|
|
|
|
13
|
Using Arduino / Networking, Protocols, and Devices / Re: ZB-Pro Router issue in large network
|
on: February 05, 2013, 07:18:38 am
|
|
Hi,
thanks Jack!
I have repeated your test and it worked (with default parameters).
Now, I'm going to try a nonsense. I change the 'sleep mode' to 'pin hibernate' in one router (I know it must be always awake), and let it falls asleep for an hour, then I wake it up, and try again the communication.
I think this last test will be worst case, and the router has to join the network again, so if it doesn't find coordinator first, it won't work.
Regards!
|
|
|
|
|
14
|
Using Arduino / Sensors / Re: Wire issue with ADXL345
|
on: February 05, 2013, 03:04:25 am
|
|
That's right.
ADXL's INT1 pin is connected to digital pin of the Arduino board, so I can use an internal interrupt and wake up the MCU when a tap occurs.
I wrote down that interruptions occurs when MCU is awake, and when WDT finishes each cycle, but when is completely asleep, interruption doesn't 'jump'.
|
|
|
|
|
15
|
Using Arduino / Sensors / Re: Wire issue with ADXL345
|
on: February 04, 2013, 03:01:01 am
|
Hi, the ADXL's INT1 pin is connected to pin 11 in the Arduino UNO, to wake up it with a PCINT (internal interruption). But instead of wake up the Arduino, it remains sleep until it wakes up by the watchdog. //sda.-a4 //scl.-a5 #include <ADXL345.h> #include <Enerlib.h> #include <Wire.h> #include <PinChangeInt.h> #include <PinChangeIntConfig.h>
#define PIN_ADXL_ 11 #define pin 13 #define MAX_VALUE 1023.0 #define Vcc 5 #define TiempoVibracion 900 #define NumeroVibraciones 5 #define TiempoEnvioDatos 5
boolean firstTime = true; // If 'True' is the first time, then change to 'False' volatile unsigned long firstSend; unsigned long init_int_time = 0; unsigned long last_int_time = 0;
ADXL345 adxl; //variable adxl is an instance of the ADXL345 library int contAdx = 0; unsigned long tiempoAdxActual = 0; unsigned long tiempoAdxAnterior = 0; unsigned long tiempoAdxResta = 0;
Energy energy;
byte interrupts; unsigned long Tiempo = (TiempoEnvioDatos * 60) / 8; unsigned long NumeroDesbordamientos = 0; volatile int activo = LOW;
//___________________________________________________________________________________________ // WATCHDOG
ISR(WDT_vect) { NumeroDesbordamientos++; if(NumeroDesbordamientos > Tiempo) { activo = HIGH; } }
//___________________________________________________________________________________________ void setup(void) { pinMode(pin, OUTPUT);
pinMode(PIN_ADXL_, INPUT); digitalWrite(PIN_ADXL_, HIGH); ConfigurarAdx(); PCintPort::attachInterrupt(PIN_ADXL_, Adx, RISING); NumeroDesbordamientos = 0; // reseteo contador activo = LOW; // reseteo estado. Iniciar dormido. // Reference to 5V analogReference(DEFAULT); Serial.begin(38400);
WDTCSR = 0x00; // Deactivate Watchdog delay(1000); watchdog(); // configuracion del wacthdog activo = HIGH; } //___________________________________________________________________________________________ void loop(void) {
interrupts= adxl.getInterruptSource(); if(activo) { WDTCSR = 0x00; // Deactivate Watchdog NumeroDesbordamientos = 0; // reseteo contador Envio(); activo = LOW; WDTCSR = 0x71; // Reactivate Watchdog }
energy.PowerDown(); //maximo ahorro de energia } //___________________________________________________________________________________________ void watchdog() { MCUSR &= ~(1 << WDRF); WDTCSR |= (1 << WDCE) | (1 << WDE); WDTCSR = 0x71; } //___________________________________________________________________________________________ void Envio() { Serial.print("\tAdxl345_Accel: "); Serial.println(contAdx); } //___________________________________________________________________________________________ void Adx() { init_int_time = millis(); if (init_int_time - last_int_time > 200) { tiempoAdxActual = millis(); tiempoAdxResta = tiempoAdxActual - tiempoAdxAnterior; // REVISAR tiempoAdxAnterior = tiempoAdxActual; if(tiempoAdxResta <= TiempoVibracion) { contAdx++; if(contAdx >= NumeroVibraciones) { activo = HIGH; } } else { contAdx = 0; } last_int_time = init_int_time; } } //___________________________________________________________________________________________ void ConfigurarAdx() { adxl.powerOn(); //set activity/ inactivity thresholds (0-255) adxl.setActivityThreshold(75); //62.5mg per increment adxl.setInactivityThreshold(75); //62.5mg per increment adxl.setTimeInactivity(10); // how many seconds of no activity is inactive? //look of activity movement on this axes - 1 == on; 0 == off adxl.setActivityX(1); adxl.setActivityY(1); adxl.setActivityZ(1); //look of inactivity movement on this axes - 1 == on; 0 == off adxl.setInactivityX(1); adxl.setInactivityY(1); adxl.setInactivityZ(1); //look of tap movement on this axes - 1 == on; 0 == off adxl.setTapDetectionOnX(1); adxl.setTapDetectionOnY(1); adxl.setTapDetectionOnZ(1); //set values for what is a tap, and what is a double tap (0-255) adxl.setTapThreshold(10); //62.5mg per increment adxl.setTapDuration(15); //625μs per increment adxl.setDoubleTapLatency(10); //1.25ms per increment adxl.setDoubleTapWindow(80); //1.25ms per increment //set values for what is considered freefall (0-255) adxl.setFreeFallThreshold(7); //(5 - 9) recommended - 62.5mg per increment adxl.setFreeFallDuration(45); //(20 - 70) recommended - 5ms per increment //setting all interupts to take place on int pin 1 //I had issues with int pin 2, was unable to reset it adxl.setInterruptMapping( ADXL345_INT_SINGLE_TAP_BIT, ADXL345_INT1_PIN ); adxl.setInterruptMapping( ADXL345_INT_DOUBLE_TAP_BIT, ADXL345_INT1_PIN ); adxl.setInterruptMapping( ADXL345_INT_FREE_FALL_BIT, ADXL345_INT1_PIN ); adxl.setInterruptMapping( ADXL345_INT_ACTIVITY_BIT, ADXL345_INT1_PIN ); adxl.setInterruptMapping( ADXL345_INT_INACTIVITY_BIT, ADXL345_INT1_PIN ); //register interupt actions - 1 == on; 0 == off adxl.setInterrupt( ADXL345_INT_SINGLE_TAP_BIT, 1); adxl.setInterrupt( ADXL345_INT_DOUBLE_TAP_BIT, 1); adxl.setInterrupt( ADXL345_INT_FREE_FALL_BIT, 0); adxl.setInterrupt( ADXL345_INT_ACTIVITY_BIT, 0); adxl.setInterrupt( ADXL345_INT_INACTIVITY_BIT, 0); }
|
|
|
|
|