Recent Posts

Pages: [1] 2 3 ... 10
1
Español / Re: Problema Con Modulo Rele
Last post by daviten - Today at 03:34 am
Acabo de desconectar el arduino uno que estaba con Wire pasando datos al Mega, y solo deje funcionando el Mega sin ningun sensor solo con los reles, con este codigo limpio...

Code: [Select]
#include <SPI.h>
#include <Ethernet.h>
char mess[15];
int estadopin3 = 0;
int estadopin4 = 0;
int estadopin5 = 0;
int estadopin6 = 0;
int estadopin7 = 0;
int alarma = 0;
int estadoalarma = 0;
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 1, 200);
IPAddress myDns(192,168, 1, 1);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
EthernetServer server(28);
EthernetClient client;
void setup() {
  pinMode(8, INPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  Ethernet.begin(mac, ip, myDns, gateway, subnet);
  server.begin();
}
void loop() {   
 
EthernetClient client = server.available();       
  if (client) {
    if (client.available() > 0) {
      char c = client.read();
      //Mandar estados al iniciar app
      if(c == '*'){
      sprintf(mess,"pin%i%i%i%i%i%i",digitalRead(3),digitalRead(4),digitalRead(5),digitalRead(7),digitalRead(6),alarma);       
      server.print(mess);
      }
      //PIN3
      if(c == '1')
      digitalWrite(3, HIGH);
      if(c == '2')
      digitalWrite(3, LOW);
      //PIN4
      if(c == '3')
      digitalWrite(4, HIGH);
      if(c == '4')
      digitalWrite(4, LOW);
      //PIN5
      if(c == '5')
      digitalWrite(6, HIGH);
      if(c == '6')
      digitalWrite(6, LOW);
      //PIN31
      if(c == '9')
      digitalWrite(5, HIGH);
      if(c == 'm')
      digitalWrite(5, LOW);
      //PIN33
      if(c == 'n')
      digitalWrite(7, HIGH);
      if(c == 'b')
      digitalWrite(7, LOW);
      if(c == 'q')
      alarma = 1;
      if(c == 'w')
      alarma = 0;
    }
 
  }     
      if(estadopin3 != digitalRead(3) || estadopin4 != digitalRead(4) || estadopin5 != digitalRead(5) || estadopin6 != digitalRead(6) || estadopin7 != digitalRead(7) || alarma != estadoalarma)
      {
      sprintf(mess,"pin%i%i%i%i%i%i",digitalRead(3),digitalRead(4),digitalRead(5),digitalRead(7),digitalRead(6),alarma);       
      server.print(mess);
      estadopin3 = digitalRead(3);
      estadopin4 = digitalRead(4);
      estadopin5 = digitalRead(5);
      estadopin6 = digitalRead(6);
      estadopin7 = digitalRead(7);
      estadoalarma = alarma;
      }
     
  if(digitalRead(8) == HIGH && alarma == 1)
  {
      server.print("ala");
      alarma = 0;   
  }       
}


Y por ahora funciona todo sin delay, no se cuelga... los prendo y apago todos rapido y va barbaro...
2
Project Guidance / Re: Voltage "Switch"
Last post by TomGeorge - Today at 03:34 am
Hi,
Quote
  • Drive Voltage:9-12V;Chip Power:10W;Cool White.Color Tempreture:6000-6300K
  • Forward Current(IF):900-1050mA ;Lumen:700-850lm;Size:29 x 20mm/1.1 x 0.8 Inch(L*W)

It should be okay with out a limit resistor on 9V

Does the LED light up correctly directy to the 9V supply?
What is the 9V supply?

Don't connect the output of the Arduino directy to the transistor base.

Check your connections, protoboard does not like high continuous currents through it

Tom... :)
3
Français / Re: J'aimerais utiliser un att...
Last post by Alain46 - Today at 03:33 am
Il y a plusieurs problèmes dans ton code

Tu utilises les bornes 6 et 7 pour le contrôle du sens de rotation de ton moteur
et les bornes 2 et 3 pour le capteur incremental

Ensuite tu associe une interruption avec changement d'état aux bornes 6 et 7 (qui sont les bornes de contrôle du moteur)

Code: [Select]
attachInterrupt(sensA, gestioninterruption2, CHANGE);
 attachInterrupt(sensB, gestioninterruption3, CHANGE);


Si tu utilise une carte Uno ou Mega, ces broches ne fonctionnent pas pour générer une interruption sur changement d'état

voir Arduino attachInterrupt

D'autre part serial.print utilise les interruptions pour transférer les données.
Pendant le déroulement d'une ISR, les autres interruptions sont bloquées
Autrement dit, tu ne peu pas appeler serial.print à l'intérieur d'une ISR

4
Sensors / MPU6050 I2CDevlib Information
Last post by ddesousa - Today at 03:32 am
Hi there,

I have recently started using I2Cdevlib with my MPU6050 and would like some more information on how the library works without using it blindly.

1. How does the Digital Motion Processing (DPM) within the chip work? What does it do?
2. How does the interrupt work? What is it caused by? I have a heavy sketch going on in the meantime (SD card, display, heart rate sensor.etc) in the background. Can it still be used with all these modules without delaying other functions?
3. How does the library incorporate quaternions?

I tried looking for all these answers but could not find relevant info.

Thanks!
5
Deutsch / Hardware Serial statt Software...
Last post by Cali_X - Today at 03:32 am
Hallo zusammen,

ich bin noch absoluter Einsteiger und versuche jetzt schon seid einiger Zeit mir Wissen anzueignen, wie ich ein Sketch was Sowohl Hardware als auch Software Serial verwendet, so umzuschreiben, das auf dem Arduino Mega 2560 nur Hardware Serial 0 und 2 verwendet wird.

Ganz ehrlich ich verstehe es nicht...

Es geht um ein GSM/GPS Modul mit SIM808, ich habe schon SMS versendet, aber über die fertigen beispiele die Softwareserial nutzen.

Was mich als Anfänger dabei verwirrt sind die vielen Dateien die genutzt werden um die Funktionen unterzubringen.


Code: [Select]

#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
int messageIndex = 0;
char MESSAGE[300];
char lat[12];
char lon[12];
char wspeed[12];

char phone[16];
char datetime[24];

#define PIN_TX 10
#define PIN_RX 11
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

void sendSMS();
void getGPS();
void readSMS();

void setup()
{
  mySerial.begin(9600);
  Serial.begin(9600);

  //******** Initialize sim808 module *************
  while(!sim808.init())
  {
      Serial.print("Sim808 init error\r\n");
      delay(1000);
  }
  delay(3000);

  Serial.println("SIM Init success");
     
  Serial.println("Init Success, please send SMS message to me!");
}

void loop()
{
  //*********** Detecting unread SMS ************************
   messageIndex = sim808.isSMSunread();

   //*********** At least, there is one UNREAD SMS ***********
   if (messageIndex > 0)
   {

      readSMS();
      getGPS();
      sendSMS();
 
      //************* Turn off the GPS power ************
      sim808.detachGPS();

      Serial.println("Please send SMS message to me!");
   }
}

void readSMS()
{
  Serial.print("messageIndex: ");
  Serial.println(messageIndex);
 
  sim808.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
             
  //***********In order not to full SIM Memory, is better to delete it**********
  sim808.deleteSMS(messageIndex);
  Serial.print("From number: ");
  Serial.println(phone); 
  Serial.print("Datetime: ");
  Serial.println(datetime);       
  Serial.print("Recieved Message: ");
  Serial.println(message);
}

void getGPS()
{
  while(!sim808.attachGPS())
  {
    Serial.println("Open the GPS power failure");
    delay(1000);
  }
  delay(3000);

  Serial.println("Open the GPS power success");
   
  while(!sim808.getGPS())
  {
   
  }

  Serial.print(sim808.GPSdata.year);
  Serial.print("/");
  Serial.print(sim808.GPSdata.month);
  Serial.print("/");
  Serial.print(sim808.GPSdata.day);
  Serial.print(" ");
  Serial.print(sim808.GPSdata.hour);
  Serial.print(":");
  Serial.print(sim808.GPSdata.minute);
  Serial.print(":");
  Serial.print(sim808.GPSdata.second);
  Serial.print(":");
  Serial.println(sim808.GPSdata.centisecond);
  Serial.print("latitude :");
  Serial.println(sim808.GPSdata.lat);
  Serial.print("longitude :");
  Serial.println(sim808.GPSdata.lon);
  Serial.print("speed_kph :");
  Serial.println(sim808.GPSdata.speed_kph);
  Serial.print("heading :");
  Serial.println(sim808.GPSdata.heading);
  Serial.println();

  float la = sim808.GPSdata.lat;
  float lo = sim808.GPSdata.lon;
  float ws = sim808.GPSdata.speed_kph;

  dtostrf(la, 4, 6, lat); //put float value of la into char array of lat. 4 = number of digits before decimal sign. 6 = number of digits after the decimal sign.
  dtostrf(lo, 4, 6, lon); //put float value of lo into char array of lon
  dtostrf(ws, 6, 2, wspeed);  //put float value of ws into char array of wspeed

  sprintf(MESSAGE, "Latitude : %s\nLongitude : %s\nWind Speed : %s kph\nMy Module Is Working. Mewan Indula Pathirage. Try With This Link.\nhttp://www.latlong.net/Show-Latitude-Longitude.html\nhttp://maps.google.com/maps?q=%s,%s\n", lat, lon, wspeed, lat, lon);
}

void sendSMS()
{
  Serial.println("Start to send message ...");
 
  Serial.println(MESSAGE);
  Serial.println(phone);
 
  sim808.sendSMS(phone,MESSAGE);
}



Das oben ist das eigendliche Programm und ich bin jetzt an der folgenden Stelle hängen geblieben in der sim808.cpp wo ich denke das man da irgendwie übergeben muss welche Serial genutzt wird:

Code: [Select]
#include "sim808.h"

//SoftwareSerial *serialSIM808 = NULL;

Stream *serialSIM808 = NULL;

/*
void  sim808_init(void * uart_device, uint32_t baud)
{
    serialSIM808 = (SoftwareSerial*)uart_device;
  serialSIM808->begin(baud);
}

*/

void  sim808_init(void * uart_device, char num)
{
    if(num)
serialSIM808 = (HardwareSerial*)uart_device;
else
serialSIM808 = (SoftwareSerial*)uart_device;
}


Ich habe bisher noch nirgendwo raus finden können, was die Sterne bedeuten in dem Code, bis auf den stern bei */ natürlich.

Was ich einfach nicht verstehe, wie und an welcher Stelle wird das ganze umgesetzt, das die Software Serial genutzt wird und wie kann ich das ganze SoftwareSerial rausnehmen um z.b. HardwareSerial 2 zu verwenden?


Code: [Select]
#define PIN_TX 10
#define PIN_RX 11
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,


meine Vermutung ist, das genau an der stelle ich etwas verändern muss und ich probierte es mit:

Code: [Select]
//#define PIN_TX 10
//#define PIN_RX 11
//SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&Serial2);//Connect RX,TX,PWR,


jedoch ohne Erfolg und mit einem Fragezeichen über dem Kopf, was das & Symbol wohl für eine Wirkung haben könnte...

Ok, ich weiß jetzt mittlereile das * und & Zeigeroperatoren sind, also werde ich in die Richtung mich weiter einlesen, aber ich würde mich bitte sehr über etwas Hilfe freuen, schneller mit meinem Problem zu einer Lösung zu kommen, denn es übersteigt eindeutig leider noch meinen Horizont und müsste meiner meinung nach so einfach zu lösen zu sein, das ich es einfach nicht sehe...

Ich habe wirklich viele Artikel und Tutorials gelesen, aber was bei dem SIM808 Code gemacht wird, das habe ich so in der form noch nicht gefunden...

Vielen Dank für euer Verständniss

Mit freundlichen Grüßen

Cali
6
Sensors / Re: Using Arduino and GPS modu...
Last post by bazzlance - Today at 03:28 am
I have now made a slight modification to the Speed formula to capture decimal amounts > 0.5; it is:
    Speed = ((uint32_t)(fix.spd.whole + .27) * 1852UL)/1000UL; // avoids floating-point
7
I'm newbie. No experience of soldering. Zero. Never touch it before. I'm using low cost rosin core solder.  how to I make it stick as I touch between pin and gap holes.
8
Microcontrollers / Re: Still having issues using ...
Last post by Xnke - Today at 03:27 am
This is a ATmega128/1281/2561, the 64 pin TQFP package. These specifically use different programming pins, and that catches people up sometimes.

I'll get the schematic posted up shortly.
10
There is a way to capture the encoder outside of the loop portion of your code using interrupts that can make your code much simpler. we need free up pin 2 for the clock input and activate an interrupt for pin 2. you would need to move the pin 2 to pin 13 on the LCD display but that shouldn't be a problem.

Code: [Select]
int PinCLK = 2; // to use the attachInterrupt() funnction we need to use pin 2 or 3
int PinDT = 12;
volatile long count = 0;
long lastcount;

void Encoder() {
  //PINB is an BYTE of 8 Bits and is linked directly to pins 8 through 13
  //Pin 8 is linked to bit 0 and Pin 13 is linked to bit5
  //so we can read bit 4 to find out what pin 12 is.
  // We are doing this because it is fast
  (bitRead(PINB, 4) == true)  ? count++ : count--;
  /*
    // Slower Code that does the same thing
    if(digitalRead(PinDT) == HIGH){
       count++;
    } else {
       count--;
    }
  */
}
long GetCount() {
  long C;
  noInterrupts ();
  C = count;
  interrupts ();
  return C;
}
void setup() {
  Serial.begin(115200);
  attachInterrupt(digitalPinToInterrupt(PinCLK), Encoder, RISING); // We trigger the Encoder function each time the clock pin goes HIGH
}

void loop() {
  // put your main code here, to run repeatedly:
  long Counter;
  Counter = GetCount();
  if ((lastcount != Counter)) {
    Serial.println(Counter);
  }
  lastcount = Counter;
}


also you will want to add a capacitor on the data and clock pins to suppress the switch bounce.

I conveniently soldered some surface mount .1uf capacitors to fix debounce here.
Z
Pages: [1] 2 3 ... 10