Show Posts
Pages: 1 2 [3] 4 5 ... 12
31  Forum 2005-2010 (read only) / Interfacing / Re: ArduinoBt searching for other BT devices on: June 24, 2007, 01:28:16 am
I am still struggling with the SET CONTROL BIND. Your code was helpfull but I still haven't figured out why the BIND doesn't work.
I changed your code a bit because I had the feeling that the output is not always complete. I store the output in the eeprom and read it back afterwards.

Code:
#include <TextString.h>  
#include <EEPROM.h>

int ledPin = 13;                // LED connected to digital pin 13
int resetPin = 7;                  // BT module uses pin 7 for reset
char inByte = 0;                // incoming serial byte
int  infoSize = 0 ;
void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  pinMode(resetPin, OUTPUT);  
  Serial.begin(115200);        // start serial at 115200 kbs
}

void loop()
{
  // if we get a valid byte, read analog ins:
  if (Serial.available() > 0) {    
    inByte = getbyte();  // get incoming byte
    if (inByte == '&' ) { // look for a &
      infoSize = getInfo();
    }
    else if (inByte == '@' ) { // look for a 0
      digitalWrite(ledPin, LOW); // set led LOW
      Serial.print("Get string:  ");  
      for(int i=0;i<infoSize;i++) //eeprom print lus
      {
        Serial.print(EEPROM.read(i));
      }
      Serial.println();
      Serial.print("Cleared string  size: ");
      Serial.println(infoSize);
    }        
  }
}

int getInfo()
{
  int j=0;
  digitalWrite(ledPin, HIGH); // set led HIGH
  delay(2000);  
  Serial.print("+++");
  delay(2000);

  Serial.println("SET");
  //Serial.println("SET CONTROL BIND 0 8 FALL INFO");  
  //Serial.println("SET BT PAGEMODE");
  //Serial.println("SET BT ROLE");
  //Serial.println("INFO");
  for (int i=0; i <= 10; i++){
    delay(1000);
    while (Serial.available() > 0 && j <512) {    
      inByte = getbyte();  // get incoming byte    
      EEPROM.write(j, inByte);
      j++;
    }
    delay(1000);
  }  
  delay(2000);
  Serial.print("+++");
  delay(2000);
  digitalWrite(ledPin, LOW); // set led low
  return j;
}


char getbyte()
{
  while (Serial.available() == 0) { //look for aviable data
    // do nothing, wait for incoming data
  }
  return Serial.read(); //return data if aviable
}
32  Forum 2005-2010 (read only) / Interfacing / Re: ArduinoBt searching for other BT devices on: June 21, 2007, 05:56:49 pm
Very nice. I changed the inquiry to SET so I could see the parameters of the module. I tried to get the interruts on the pio's working but did not succeed. Thanks to your program I could see that I didn't have these bind commands. I already got the parameters from the WT11 before but I couldn't believe that there were so little settings. Your programs shows the same, so, for some reason my set control bind commands don't stick.
33  Forum 2005-2010 (read only) / Interfacing / Re: ArduinoBt searching for other BT devices on: June 21, 2007, 07:53:38 am
Quote
Could somebody help me with example code for switching from data to command mode.
Preforming a command like the call or inquiry command and then switching back to the data mode?

Yeah, I would to see a piece of code for that.

But sondag, you already had the escape sequence working you said. Did you try an inquiry with little output, store it in a string and then switch back to datamode with the escape sequence? Let's say LIST, with only 1 connection there will be a "LIST 1" line and a "LIST 0 xxxxx" from your currenct connection.
34  Forum 2005-2010 (read only) / Interfacing / Re: ArduinoBt searching for other BT devices on: June 21, 2007, 06:33:33 am
Quote
So multiplexing will not work.
Can somebody help me with the right settings for the control echo.
I think that I don't do it on the right way.

NO NO NO NO don't touch the control echo!

If you do that then the WT11 will mess up programming the arduino. Not only are sending the program but there will also be events from the WT11 on the TX line to the atmega.
NO NO NO NO don't touch the control echo!
NO NO NO NO don't touch the control echo!
NO NO NO NO don't touch the control echo!

(I learned from experience  >smiley-sad )
35  Forum 2005-2010 (read only) / Interfacing / Re: ArduinoBt searching for other BT devices on: June 21, 2007, 05:38:46 am
One of the problems with saving your data in an array is memory usage. You have only 1k of memory available so you can't make a huge array. I tried increasing the serial buffer but it didn't work either. I don't get the complete response from the WT11 and after the initial output of the WT11 it always sends 14 characters at a time. I don't have a clue what is going on.

Multiplexing would be interesting. BUT, if you set the WT11 to multiplexing and you want to change something of the WT11 parameters you have a problem, unless multiplexing is working flawless right away. Because in multiplexing the ASCII commands don't work anymore. You might try to escape this with the SET CONTROL BIND for a command issued by a signal on a pin of the WT11. But, I have had no luck yet with the hardware control on the WT11 pio's.
36  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: September 26, 2007, 02:36:02 am
But does you program work without "OneWire ds(10)"? I don't think so.
37  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 19, 2007, 09:27:39 am
Quote
You can check out the keywords.txt of the existing libraries (in lib/targets/libraries).  It looks good, except that OneWire should be in the datatypes section and a KEYWORD1.  Now we just need to zip it all and upload it somewhere (the playground?).

I made this after looking at an example. Only the OneWire wasn't clear to me. I have changed the file, so you can just copy/paste it.
38  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 18, 2007, 11:43:41 am
So, the easiest jobis done too, although I am not sure if I got it right. I thought I read something about the keywords.txt file, but I can't find it anymore.
Code:
#######################################
# Syntax Coloring Map For OneWire
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

OneWire    KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

reset      KEYWORD2
write_bit      KEYWORD2
read_bit      KEYWORD2
write      KEYWORD2
read      KEYWORD2
select      KEYWORD2
depower      KEYWORD2
reset_search      KEYWORD2
search      KEYWORD2
crc8      KEYWORD2
crc16      KEYWORD2

#######################################
# Instances (KEYWORD2)
#######################################


#######################################
# Constants (LITERAL1)
#######################################

[edit]changed the keywords.txt[/edit]
39  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 17, 2007, 06:45:18 am
I will make the keywords.txt then. That seems to be the easiest part.  smiley
40  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 14, 2007, 11:23:54 am
I have a (simple) working example, that could be added. What is still missing from the library is readout in degrees celsius, I have that too. Also missing is more precise readout. The Application note in which it is explained seems to have disappeared. Except for the keywords.txt I think the library is pretty much done.


It is all jims work, so I guess he will want to pack it up too. Otherwise I will give it a shot. But I need someone to have look at it afterwards.
41  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 06, 2007, 11:06:31 am
Well jims, your code is working! I don't understand why I needed an extra pin to get my code working but your code works with just pin 7 and GND connected.


At the moment I have 3 sensors connected and all 3 give a temperature reading. Your library should become a standard library.
42  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 06, 2007, 02:46:19 am
Quote
Physically, I have all the DQ lines connected to my IO pin, all the grounds connected to a ground, and 4.7k ohm resistor from a Vcc to the DQ lines. It would be best to connect all the remaining pins of the DS18S20s to either Vcc or GND, then a regular DS18S20 (not a -P) would still work in either normal or parasite mode depending how you connected it.


Strange, my code started working when I used another pin to supply current to Dq during the temperature conversion.

I am very glad that you have the device enumeration already working, that saves me a lot of time!

I will try it and report back.
43  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 05, 2007, 11:35:37 am
This program is specifically for the DS18S20P. But it is probably easier to get a non P(arasite) version working. To avoid misunderstandings let's start with the DS18S20P  connections.

GND and Vdd to GND, Dq to pin 6 AND  to pin 7 AND via a 4k7 resistor to +5V on arduino board.


Thanks to yerg2k to get me started and jims to get me thinking.
Comments are welcome.

Code:
/* DS18S20P Temperature chip i/o
 * ---------------
 *
 * See http://pdfserv.maxim-ic.com/en/ds/DS1820-DS1820S.pdf for the datasheet.
 *
 * (copyleft) 2006 by Derek Yerger - Free to distribute freely.
 * (sorry Derek, great inspiration but I rewrote it completely)
 *  heavily modified by bigengineer
 * inspired by: http://microsyl.com/
 * and Dallas 1-wire datasheets
 *
 */
#define DQ 7  //data pin
#define PU 6  //separate pin for pull up
#define pin13 13
#define VERSION 01

void setup(void)
{
  // initialize inputs/outputs
  // start serial port
  pinMode(DQ,INPUT);
  pinMode(PU,INPUT);
  pinHigh();
  Serial.begin(9600);
}
byte reset()
{
  pinLow();
  delayMicroseconds(500);
  pinIn();
  delayMicroseconds(70);
  if (digitalRead(DQ) == LOW)
  {
    delayMicroseconds(500);
    return(1);
  }
  return(0);
}
void WriteByte(byte data)
{
  byte i;
  for(i=0;i<=7;i++)
  {
    pinLow();
    if (data & 0x01) //write 1
    {
      delayMicroseconds(7);
      pinIn();
      delayMicroseconds(70);      
    }
    else //write 0
    {
      delayMicroseconds(70);
      pinIn();
      delayMicroseconds(7);
    }
    data>>=1;
  }
}
void convertTemp()
{
  byte i;
  byte data = 0x44;
 
  for(i=0;i<=7;i++)
  {
    pinLow();
    if (data & 0x01) //write 1
    {
      delayMicroseconds(7);
      pinIn();
      delayMicroseconds(70);      
    }
    else //write 0
    {
      delayMicroseconds(70);
      pinIn();
      delayMicroseconds(7);
    }
    data>>=1;
  }
  pullupHigh(); //pull pin 6 high for the conversion
  delay(750); //conversion time is 750 milliseconds
  pullupIn(); //switch off pin 6
  pinIn();
}
byte readByte()
{
  /* timing is critical here. But timing values are different
   * from the datasheets. These values are found by trial & error.
   * The delay's should be somewhere around 15 uS.
   */
  byte data=0;
  byte i;
  byte bit;
  for(i=0;i<8;i++)
  {
    pinLow();
    delayMicroseconds(1); // > 2 doesn't work
    pinIn();
    delayMicroseconds(1); // >5 doesn't work
    bit = digitalRead(DQ) & 0x01;
    data >>= 1;
    if (bit) data |= 0x80;
    delayMicroseconds(50); //doesn't seem to be necessary
  }
  return(data);
}

void pinHigh()
{
  pinMode(DQ,OUTPUT);
  digitalWrite(DQ,HIGH);
}
void pinLow()
{
  pinMode(DQ,OUTPUT);
  digitalWrite(DQ,LOW);
}
void pinIn()
{
  pinMode(DQ,INPUT);
  //pullupIn(); //om de resistor pull-up te laten werken
}

void pullupHigh()
{
  pinMode(PU,OUTPUT);
  digitalWrite(PU,HIGH);
  digitalWrite(pin13, HIGH);
}
void pullupLow()
{
  pinMode(PU,OUTPUT);
  digitalWrite(PU,LOW);
  digitalWrite(pin13, LOW);
}
void pullupIn()
{
  pinMode(PU,INPUT); //necessary for resistor pull-up
  digitalWrite(pin13, LOW);
}

void readRom()
{
  byte j;
  byte pad[9];

  reset();
  WriteByte(0x33);
  for(j=0;j<8;j++)
  {
    pad[j] = readByte();
  }
  for(j=0;j<8;j++)
  {
    Serial.print(pad[j], HEX);
    Serial.print(" ");
  }
  Serial.println("read rom");
}
void readScratchpad()
{
  byte j;
  byte pad[9];
  int msb,lsb;

  WriteByte(0xBE);
  for(j=0;j<9;j++)
  {
    pad[j] = readByte();
  }
  for(j=0;j<9;j++)
  {
    Serial.print(pad[j], HEX);
    Serial.print(" ");
  }
  Serial.print("read scratchpad  ");
  msb = pad[1];
  lsb = pad[0];
  if (msb <= 0x80)lsb = lsb/2;
  msb = msb & 0x80;
  if (msb >=0x80) lsb = (~lsb)+1;
  if (msb >=0x80) lsb = lsb/2;
  if (msb >=0x80) lsb = ((-1)*lsb);
  Serial.print("T =  ");
  Serial.print(lsb);
  Serial.print(" ");
    
}
void loop(void)
{
  readRom();
  reset();
  WriteByte(0xCC);
  convertTemp();
  reset();
  WriteByte(0xCC);
  readScratchpad();
  Serial.print("version: ");
  Serial.println(VERSION);
   delay(1000);                 // Lets not flood.
}

[edit]changed typo that cosinekitty discovered[/edit]
44  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 05, 2007, 11:00:47 am
 smiley YES YES
Finally, it works. I'll do a quick clean up of the code and post it. Though I rewrote almost everything it was a hardware  >smiley-sad problem after all. I don't really understand it, maybe someone can explain it to me. There are some other issues that I found out by trial and error. So, I am not there yet, but there is a start to get 1-wire working.
45  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 04, 2007, 01:55:34 pm
This http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=41771&highlight=ds18s20 thread explains something about connecting the DS18S20. To it seems it is about the powered sensor. Unfortunately, because I have the DS18S20P I can't connect to it like "kartman" explains.

Pages: 1 2 [3] 4 5 ... 12