Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Software Serial Parity Question - help please... on: April 26, 2014, 07:01:58 pm
UKHeliBob - thanks for the pointer. am not sure how I missed that. I have spent a couple of hours trying to modify the lib as suggested by pylon in that thread.

I am not sure what I am doing wrong, but I cannot get it to work. I have added the code to the lib files and that causes a compile error, and I have tried just straight up modifying/adding the lines of code he wrote pertaining to parity... but still i get no result. at least this way it still compiles fine.

can someone please give me some suggestions or guidance. Thanks
2  Using Arduino / Networking, Protocols, and Devices / Re: How to set SoftwareSerial 8E1---HELP!!! on: April 26, 2014, 08:00:19 am
Guys,
someone just pointed me towards this thread... I am very grateful.

I am also in need of a SoftwareSerial port 9600,8e1. I read the posts and have tried to modify the software serial lib (after making a copy and renaming of course smiley ) but cannot get it to compile, i get various errors.

I am sorry if this is a really basic question but can someone walk me through the process of adding the SoftwareSerial8e1 functionality....

Thanks
3  Using Arduino / Programming Questions / Software Serial Parity Question - help please... on: April 25, 2014, 10:55:32 pm
Hi,
I am in the middle of a project and have everything just about ready to roll but just realized I have one small issue.... parity.

I have been testing with the Serial port on my nano and setting it up with the command:
Code:
Serial.begin(9600,SERIAL_8E1)
My problem is that I need to be able to do this using pins 11 and 12 with software serial. Is there any way to switch the parity bit on the software serial begin command (or even in the lib?)

Thanks for the help smiley
D
4  Using Arduino / Project Guidance / Serial.event question with software serial on: December 06, 2013, 10:40:46 pm
Quick question guys... I have a attiny85 project that I am using software serial with. My question is if I am sending a message via software serial, but waiting for a specific message back from the device before I send the next message etc, etc, etc....

I have not coded anything yet, and this is my second attiny85 project (I mean not having a hardware UART lines)... but was just trying to get some pointers on how to proceed.... from a general concept I wish I could use a serial.event type of command to pull each character out of buffer into a string and check it against my "known reply" that I am looking for. the thing is that I don't think serial.event does not apply to Software Serial.... My concern is I will slow/stop the main loop if i try and check for messages repeatedly...

Soooooo, ideas smiley

Thanks
5  Using Arduino / Project Guidance / Re: Software Serial Question on: December 01, 2013, 07:58:59 pm
Peter,
Thanks for the suggestion - that makes much more sense. The one caveat I would mention is I am 100% certain that once the original transmitter sends the trigger, it will be silent until the event is over. there is no change that two drivers will fight each other in that sense. My other issue is that I was hoping to do this with a attiny85.... so hardware uart lines are out. I understand the limitations of software serial, so if its not possible - that's the deal smiley I will have to go back to the drawing board.... but if you can see any other way please let me know your thoughts...
6  Using Arduino / Project Guidance / Re: Software Serial Question on: December 01, 2013, 07:45:27 pm
sorry for delay in reply - thanks for the help.

Quote
Is the Arduino intercepting the message (i.e. it receives it on one interface and transmits it on another - there is no direct path past it), or just listening to the message (i.e. the original message is also received at the ultimate destination)?

yes, the arduino is intercepting/ aka listening to the "transmit" line of one of the uart modules. when it hears something that it is listening for, it then connects "its" transmit line to the uart bus and sends its message to the same uart device that was being talked to. after it is done it "releases" the line by turning the pin into an input so as to allow normal non-arduino communication to occur.

Quote
Why have you two separate instances of softwareSerial with the same name and different pins?
again, this is so that I can listen on one pin without having the tx pin hold the line "mute". when I acutally want to send something after an event is triggered, that is when I change the pin assignments...

Quote
I wondered about that, but more about why use software serial at all.
using this on an attiny, no hardware uart lines....

thansk for all the help guys - and sorry for all the """""" uses smiley smiley
7  Using Arduino / Project Guidance / Re: Software Serial Question on: December 01, 2013, 12:22:34 am
That is 100% right. ... The software serial example uses 11 and 12. Changing them did not alter the issue though. ....any other ideas? ????
8  Using Arduino / Project Guidance / Software Serial Question on: November 30, 2013, 10:53:37 pm
Hi all,

I am trying to listen into a uart line between two devices. When a particular set of characters is sent, I want my Arduino to transmit a specific message. My issue is that it seams some characters that should be sent are getting lost... and also once I trigger one event, the remaining events do not send any characters, just line feed.... not sure why. I have attached my code, not sure if this was adequate explanation but please feel free to comment and suggest any solution. Thanks,
 
Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(11, 12); // RX, TX

const unsigned int MAX_INPUT = 50;
static unsigned int input_pos = 0;

void setup() 
{
  mySerial.begin(38400);
  pinMode(13, OUTPUT);
}

void(* resetFunc) (void) = 0;//declare reset function at address 0

void SendMessage(const char * data)
{
  digitalWrite(13, HIGH);
  boolean fourZero = false;



      SoftwareSerial mySerial(11, 10);     
      mySerial.begin(38400);
      mySerial.println();
      delay(1500);
 
      if(strcmp(data,"!01")==0) {mySerial.print("%50155%"); }
      if(strcmp(data,"!02")==0) {mySerial.print("%50154%"); }
      if(strcmp(data,"!03")==0) {mySerial.print("%50153%"); }   

 //     input_pos = 0; 

    mySerial.println(" ");
 
    mySerial.println("");
    pinMode(10, INPUT);



}

void loop()
{
  if (mySerial.available () > 0)
  {
    processIncomingByte (mySerial.read ());
  }   
}

void processIncomingByte (const byte inByte)
  {
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;

 
   if (inByte == 35)                    // # is the key
       {
         SendMessage(input_line);

          SoftwareSerial mySerial(11, 12); // RX, TX
          mySerial.begin(38400);
 
 
//       input_pos = 0;     

        resetFunc(); //call reset
           }
           else
           {

            if (input_pos < (MAX_INPUT - 1))
            input_line [input_pos++] = inByte;
            }
  }
9  Using Arduino / Project Guidance / Re: String help please on: October 08, 2013, 05:53:58 pm
I am sorry - I did not mean to seam like I was ignoring the advice - I very much appreciate and value all the input. The problem I have is that my knowledge is limited and the only way I know how to "print" something is as a string. I also am not sure how to pull and join only two characters stored in an array. I did the below and it does work, but I am sure there is a better/correct way to do this. Thanks again for all the help  smiley

Code:
if(strncmp(&inData[2],"A6",2)==0) {mySerial1.print("part1- "); mySerial1.print(String(inData[4]));mySerial1.println(String(inData[5]));}
10  Using Arduino / Project Guidance / Re: String help please on: October 07, 2013, 07:39:24 pm
Guys - that worked perfect! Thanks. My only issue is this:
Code:
            if(strncmp(&inData[2],"A6",2)==0) {mySerial1.print("part1-"); mySerial1.println((String(inData)).substring(4,7));}   

If i send a message for example like "!5A620" I would expect the output via the myserial1 to be "part1-20". The issue is that all I get is "part1-". what am I missing?

Thanks,
11  Using Arduino / Project Guidance / String help please on: October 07, 2013, 12:00:01 am
Guys - this is killing me. the amount of time I have spent of this is insane!!! please tell me what I am missing. I want to send commands via serial in the format "!541gg" and be able to trigger a software serial event based on it being a "!5" message, option "41" and now send software serial "test" and "gg"....

I cannot attach all my code right now as I am still working on it, but what I am attaching has the same issue. The "!5" filter does not work, and as soon as index = 6 all the options/if statements in the networkmessage1 & 2 get run???

Please let me know what I am doing wrong...

Thanks
Code:
/*
#include <SoftwareSerial.h>

SoftwareSerial mySerial1(10, 11); // RX, TX

String stringOne;
char inData[6];
char inChar;
byte index =0;

void setup() 
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }




  // set the data rate for the SoftwareSerial port
  mySerial1.begin(9600);

}

void loop() // run over and over
{
   if (Serial.available() > 0)
   {

     checkApplicationMessage();

 }
}

void checkApplicationMessage()
{

       if (index < 6)
       {
         inChar = Serial.read();
         if (inChar == '!'){
           index = 0;
         }
         
         inData[index] = inChar;
         index++;
         inData[index] = '\0';
       }
       else
       {
         index = 0;
       }

    ProcessApplicationMessage();       

  }   
 
void ProcessApplicationMessage()
{

    if (index == 6)
     {


              if((String(inData)).substring(0,2) == "!4")
              {   
              NetworkMessage1();
              }

       
              if((String(inData)).substring(0,2) == "!5")
              {   
              NetworkMessage2();
              }
          index = 0;
         

}
}

void NetworkMessage1()
{


           
            if((String(inData)).substring(2,4) == "01") {mySerial1.print("test1_1"); mySerial1.print((String(inData)).substring(4,6));}
            if((String(inData)).substring(2,4) == "02") {mySerial1.print("test2_1"); mySerial1.print((String(inData)).substring(4,6));}
            if((String(inData)).substring(2,4) == "03") {mySerial1.print("test3_1"); mySerial1.print((String(inData)).substring(4,6));}
         

}

void NetworkMessage2()
{


           
            if((String(inData)).substring(2,4) == "01") {mySerial1.print("test1_2"); mySerial1.print((String(inData)).substring(4,6));}
            if((String(inData)).substring(2,4) == "02") {mySerial1.print("test2_2"); mySerial1.print((String(inData)).substring(4,6));}
            if((String(inData)).substring(2,4) == "03") {mySerial1.print("test3_2"); mySerial1.print((String(inData)).substring(4,6));}
         

}
12  Using Arduino / Project Guidance / Re: using gsm module for access control on: August 22, 2013, 11:26:57 am
full code

Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial2(7, 8);
SoftwareSerial mySerial1(10, 11);

int SER_Pin = 6; 
int RCLK_Pin = 3; 
int SRCLK_Pin = 4;


#define number_of_74hc595s 1


#define numOfRegisterPins number_of_74hc595s * 8

String stringOne;


boolean registers[numOfRegisterPins];
char inData[6];
char inChar;
byte index =0;

char inDataModem[6];
char inCharModem;
byte indexModem =0;


void setup(void) {
  Serial.begin(9600);
  mySerial2.begin(19200);
  mySerial1.begin(9600); 

  pinMode(SER_Pin, OUTPUT);
  pinMode(RCLK_Pin, OUTPUT);
  pinMode(SRCLK_Pin, OUTPUT);
 
 
  pinMode(5, OUTPUT);
  pinMode(2, OUTPUT);   
  pinMode(13, OUTPUT);
  pinMode(9, OUTPUT);

  //reset all register pins
  clearRegisters();
  writeRegisters(); 

}

//set all register pins to LOW
void clearRegisters(){
  for(int i = numOfRegisterPins - 1; i >=  0; i--){
     registers[i] = LOW;
  }
  digitalWrite(5, HIGH);
  digitalWrite(2, LOW); 
}

void writeRegisters(){

  digitalWrite(RCLK_Pin, LOW);

  for(int i = numOfRegisterPins - 1; i >=  0; i--){
    digitalWrite(SRCLK_Pin, LOW);

    int val = registers[i];

    digitalWrite(SER_Pin, val);
    digitalWrite(SRCLK_Pin, HIGH);

  }
  digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
  registers[index] = value;
}

 
void loop(){
 
   while (Serial.available() > 0) {
     {
       if (index <5)
       {
         inChar = Serial.read();
         if (inChar == '!'){
           index = 0;
         }
         
         inData[index] = inChar;
         index++;
         inData[index] = '\0';
       }
       else
       {
         index = 0;
       }
     }
     if (index == 5){
              if(strcmp(inData,"!0000")==0) {Serial.println("OK");}
              if(strcmp(inData,"!0100")==0) {mySerial2.println("AT");}


    if (indexModem <5)
       {
         inCharModem = mySerial2.read();
         if (inChar == '+'){   
           indexModem = 0;
         }
         
         inDataModem[indexModem] = inCharModem;
         indexModem++;
         inDataModem[indexModem] = '\0';
       }
       else
       {
         indexModem = 0;
       }
       if(strcmp(inDataModem,"+CMTI")==0) { indexModem = 0; mySerial2.println("AT+CMGR=6"); }

 
}
   }
}
13  Using Arduino / Project Guidance / Re: using gsm module for access control on: August 21, 2013, 11:16:42 pm
ok guys... working though and need some help. I have this code running in my loop, and my goal is to
1. when the gsm receives a text on myserial2 the code checks for the index, opens the message with cmgr  and then checks the body for a "yes" or "no" as message body.
2. based on that it runs 2 possible processes.
3. it ends by deleting all messages with at+cmdl 1,4

I know I only have the very beginning, but am hoping there may be a better way. right now this is in my main loop....

Code:
   while(mySerial2.available() > 0){
     inCharModem = mySerial2.read();
      if (indexModem < 5){
         if (inCharModem == '+'){   
           indexModem = 0;
         }
         
         inDataModem[indexModem] = inCharModem;
         indexModem++;
         inDataModem[indexModem] = '\0';
       }
     
     else
       {
         indexModem = 0;
         Serial.write(mySerial2.read());
       }
   }
       if(strcmp(inDataModem,"+CMTI")==0) { indexModem = 0; mySerial2.println("AT+CMGR=7"); }
}
14  Using Arduino / Project Guidance / Re: using gsm module for access control on: August 21, 2013, 01:38:56 pm
its a seeed studio sim900 board - could not find that much info on it from their site...

on the first topic - do you have any examples I could use as a foundation - code that continually checks for new txt messages, and then reads them and based on what it reads creates an output?
15  Using Arduino / Project Guidance / using gsm module for access control on: August 21, 2013, 01:21:54 pm
Hi all,

I have a project using a arduino micro to control some shift registers as well as communicate with a uart serial device with a software serial port. A pc based software application I developed send commands to the atmega which in turn either affects the state of a relay or sends a pre-packaged message to the serial device. currently there is no bi-directional communication between the application and arduino. adding this is not a issue and is in the near future.

I would like to use a gsm shield that I have, connected to the arduino via another software serial port to enable and disable the hardware. I would also be the same mechanism for re-enabling the hardware. my concerns and what I am looking for help on is...

how would I check the gsm modem all the time for any new messages and how to parse them for the "code" sent
how would I retain a memory even with a power cycle that the current state of the arduino is "diabled" or "enabled"
how would I trigger something in the code so that the serial port reports to the software application the hardware is "on" or "off"

any suggestions would be great! thanks
Pages: [1] 2 3