Show Posts
Pages: 1 [2] 3 4 ... 6
16  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: December 23, 2006, 12:08:14 pm
Quote
Well, unfortunately it doesn't work for me either. But, at least I understand why my code didn't work.

I Keep getting the same line:
"AA 0 4B 46 FF FF C 10 87"
The only thing I changed in the code was adding a ds_reset() at the start of the loop(void). But it didn't make any difference. I tried a "read rom", (33h) command. Then the 64bit ROM code is read from the scratchpad. So, that works.
As you stated in the comment after the CONVERT (44h) command this probably doesn't work.

Yes, that's all I get too  :-/
All the digital operations work, but convert doesn't. I haven't had time to, but I'd like to read my ROM code and address the chip specifically when issuing the convert command. The datasheet isn't very clear and straightforward in describing when "Skip ROM" can be used.

Happy Holidays!
17  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: December 22, 2006, 07:40:26 pm
http://dmgaming.com/arduino/ds18x20-on-arduino-wiring/

Please let us know if you get it working! Here, or in my comments section.

Edit: My scope doesn't seem to trigger well & sharp unless I do one request at a time in the loop. It appears that the data line goes to around 3v when the conversion starts. I did use the required 4.7k pull-up resistor on the data line. And, I accidentally hooked it up backwards polarity once, oops!

/* DS18S20 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.
 *
 *
 */
// variable declaration
int onepinio = 7; // i/o
int pres; // just a temporary variable to store return data  

void ds_reset(void) {
  pinMode(onepinio, OUTPUT);  // Pull low for 500mcs
  digitalWrite(onepinio,0);
  delayMicroseconds(500);
  pinMode(onepinio, INPUT);   // Release for at least 500mcs
  pres=0;
  delayMicroseconds(500);
  while (pres = 0) {
    pres=digitalRead(onepinio);
  }
}
void ds_write1(void) {
  pinMode(onepinio, OUTPUT);
  digitalWrite(onepinio,0);
  delayMicroseconds(5);        // A "1" is when the line is pulled
  pinMode(onepinio, INPUT);    //     1mcs < t < 15mcs  
  delayMicroseconds(45);       // so the write slots are even
}

void ds_write0(void) {
  pinMode(onepinio, OUTPUT);
  digitalWrite(onepinio,0);
  delayMicroseconds(20);        // A "0" is when t > 15mcs (30 typical)
  pinMode(onepinio, INPUT);
  delayMicroseconds(30);        // evening up again...
}

int ds_readbit(void) {
  pinMode(onepinio, OUTPUT);
  digitalWrite(onepinio,0);
  delayMicroseconds(1);          // A "read slot" is when 1mcs > t > 2mcs
  pinMode(onepinio, INPUT);
  delayMicroseconds(2);          // Wait just a bit
  return(digitalRead(onepinio)); // return what we see on the line
}

void ds_writebyte(byte dsbyte) {
  byte mask;                            // How heavy is this bit?
  int cwt;
  cwt=0;
  for (mask = 0x01; mask; mask <<= 1) {  // Thanks to mellis - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1147888882
    if (mask & dsbyte) {                 // Or whoever they got it from...
      ds_write1();
    }
    else {
      ds_write0();
    }
  }
}

int ds_readbyte(void) {
  byte mask;
  int cwt;
  cwt=0;
  for (mask = 0x01; mask; mask <<= 1) {  // Thanks again.
    cwt = cwt + mask * ds_readbit();
  }
  return(cwt);
}

void setup(void) {
  // initialize inputs/outputs
  // start serial port
  pinMode(onepinio,INPUT);
  digitalWrite(onepinio,1);
  Serial.begin(9600);
}

void loop(void) {
  ds_writebyte(0xCC);         // Skip ROM
  ds_writebyte(0x44);         // Supposed to work, but doesn't for me.
  pres=0;
  //pinMode(onepinio, OUTPUT);  // Maybe I was going to try parasite power?
  //digitalWrite(onepinio, 1);
  //delay(100);
  //digitalWrite(onepinio, 0);  // In thst case, be sure to turn it back to 0
  //pinMode(onepinio, INPUT);   // to turn off the internal pull-up resistor.
  while (pres = 0) {          //   The chip's supposed to return a 0 until the
    pres=ds_readbit();        // conversion's done (can't do in parasite mode)
  }
  ds_reset();
  ds_writebyte(0xCC);         // Skip ROM
  ds_writebyte(0xBE);         // Read Scratchpad
  int cby;                    // Call me lazy, or creative: "current byte"
  cby=0;
  while (cby <=8) {           // we need 9 bytes
    Serial.print(ds_readbyte(), HEX);
    Serial.print(" ");
    cby=cby+1;
  }
  Serial.println();
  delay(100);                 // Lets not flood.
}
18  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: December 20, 2006, 02:10:42 pm
(BUMP)

I'm new to this whole Arduino thing but it is a great design and tool, and I'm very enthusiastic about what I may be able to do with it.

Recently I received my own Arduino USB development board to play around with, and I also happened to order one of Dallas semiconductor's 1-wire temperature sensors. Painfully going through the datasheet for the DS12S20, I hacked together code to try to interface with this unit. I am not working in parasite power mode.

After getting the timing is right and the subroutines in place in order to read and write to the one wire interface, I was able to come up with a working software. The current version simply sends a request to do a conversion, waits until it is done, and then requests the scratchpad from the unit.

I thought that this would take much longer than a few hours, however at this point I can communicate with the temperature sensor and read back data. At this point, I simply have the nine bytes set back over in their numeric value, via the serial port (USB interface in my case).

Interestingly enough, so far I am able to receive proper data. What is sent back is on par with what the data sheet says should be sent back, including reserved registers and CRC codes, and the data that I received corresponds to what this should be by default. Also, I was able to make the Arduino write to the temperature sensor's storage registers and read the data back properly, so everything is working in that department.

The problem is, when I send a request to do a conversion, that is fine and well, except that the data that is returned for bytes one and two (which should be the temperature reading), always are returned as the default power on value for the DS12S20. For some reason, I cannot get it to convert and return temperature readings.

So, at this point it is only a marginal success in that I can get these sensors to hold two bytes for me, however I cannot get it to do what it was designed to do, and convert temperatures.

If anyone at this point is still trying to interface these or other chips that use the one wire interface, to Arduinos, it is possible with not too much code, however I am stumped at this point as to why the sensor will not initiate a conversion and return sensible data. I've tried hooking up an oscilloscope to the one wire data pin, and the transaction seems to be taking place properly, yet the DS12S20 will not write the finished conversion value to the scratchpad. Perhaps I have a bad sensor, however at this point I only have one so I cannot confirm this to be the problem.

The other thing is that in the data sheet for this temperature sensor, all of their examples heavily rely on the "parasite power mode" and I do not see specific examples of using it with external power. Any suggestions?
19  Forum 2005-2010 (read only) / Interfacing / Re: DS1822 and getting sensible numbers on: January 26, 2007, 02:27:25 am
http://pdfserv.maxim-ic.com/en/ds/DS1820-DS1820S.pdf

According to the datasheet the MS Byte is the sign.

Make sure your timing is right, if you read the 1-wire thread you will see I ran into difficulties powering for conversion. This particular issue afflicts the ds12x20p, which only runs in "parasite power" mode.

How do you know that the resolution is 12 bits if you can't get it to convert?
20  Forum 2005-2010 (read only) / Interfacing / Re: Coding Question: Making a ShiftIn on: March 13, 2007, 02:05:06 pm
Sorry, the code there is for having the microcontroller do the clocking. I've never had the need to use an external clock.

I might check to see if i2c could be used, since the avr's support this. Or, perhaps you could attach an interrupt. What are you trying to interface to?
21  Forum 2005-2010 (read only) / Interfacing / Re: Coding Question: Making a ShiftIn on: March 12, 2007, 08:46:30 pm
Well, I didn't look around but heres one I wrote for a project of mine.

int shiftIn() {
  int cwt;
  cwt=0;
  bitmask=128;
  while (bitmask >= 1) {
    digitalWrite(shtClk, HIGH);
    cwt = cwt + bitmask * digitalRead(shtData);
    digitalWrite(shtClk, LOW);
    bitmask=bitmask/2;
  }
  return(cwt);
}

That is for MSB first, other end changes data on rising edge of the clock.
22  Forum 2005-2010 (read only) / Development / Do unused functions in a library use memory? on: March 27, 2008, 03:42:09 pm
Hello. I am working on a library for cheap RF links which need encoding to work. These typically come in pairs of two devices, a transmitter, and receiver.

In the event that a sketch is only using the transmit routines, and the receive code is not used, will having the receive code in the library consume sketch space?

I am trying to determine whether I should make one library for both, or two separate libraries. If a sketch is not using the receive code, I would like it not to take up room in the sketch.

P.S. This forum's search engine doesn't work very well  smiley-wink
23  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino BT serial communication problem on: May 29, 2007, 02:53:04 pm
I'm not sure, but this may work... try only transmitting once the PC has connected.
24  Forum 2005-2010 (read only) / Troubleshooting / Re: ARDUINO BT trouble on: May 29, 2007, 03:13:20 pm
Quote
hi
bootloader was corrupted somehow (only happened once or twice, not really sure how, may have been due to my reprogramming the bootloaders to give modules a new name)

I am experiencing the same problem with my arduino bt. I went to reprogram a name and key on the bluegiga module. A few minutes later I unplugged the power, then a few seconds later back in.

Now pin 7 seems to be strobing on/off. It sharply rises to high, then slowly drops to ground, and repeats a bunch of times a second. I cannot see the bluetooth module from my PC unless I tie down the MCU's reset line.

Edit:
Problem solved by uploading program right after plugging in. This had me freaked!
25  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino Mini + BlueSMiRF(BT) + Maxuino on: May 07, 2007, 11:30:24 am
Have you checked the baud rate? I'm not certain, but the bluesmirf may ship pre-set to 115200bps.
26  Forum 2005-2010 (read only) / Troubleshooting / Re: arduino BT newbie need help!!!! on: March 30, 2007, 10:52:21 am
Hello.

I initially had issues with timing, but now I release my mouse pointer (on the upload button) at the same time as the reset button. Actually, starting the upload process on the pc slightly before sometimes helps on slower PC's, IME. I'm not sure if the arduino program compiles the sketch each time after clicking "upload", so this could change the window for uploading.
27  Forum 2005-2010 (read only) / Development / Re: Alternatives to wiring and soldering PCB Board on: December 29, 2007, 06:29:39 pm
I noticed futurlec does PCB manufacture. I got a quote on an arduino-sized board (dual-sided), and it looks to be cheaper than batchpcb.

http://futurlec.com/PCBService.shtml

The numbers I got were -
2.7" x 2.1", double-sided with solder mask and silk screening, for 1 PCB US$54.66, for 10 its $87.60;
Same size without silk screen, 1 for 42.66, 10/ 75.60
Same size w/out silk screen or solder mask, 1/ 18.66, 10/ 51.60

So if you choose no silk screening (white text telling you which parts go where) and no solder mask (green overlay), your custom design that fits on an arduino-size board is ten for US$51.60, that is pretty cheap considering how much time is saved.

For comparison batchpcb is $10 to setup and $2.50 per square inch, so for a 2.7" x 2.1" its roughly $24 total for one (with solder mask, silkscreen, etc). But for 10 boards its ~$150. So, batchpcb may be worth the money for one or two boards with the silkscreen/soldermask options, but for quantities futurlec takes the cake. My understanding is a solder mask is not needed, and neither is silkscreen, but even if you do get those options, for 10 boards it's still cheaper than batchpcb, by a good $60.
28  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: I like adruno but in needs 2 things to sell it on: May 04, 2007, 12:12:14 pm
Nope...

Debugging can be tedious, especially if it's trial-and-error, moving a line of code around that dumps debug info.
29  Forum 2005-2010 (read only) / Interfacing / Re: SHT15 Humidity/Temperature Tutorial on: April 08, 2008, 01:53:04 pm
Actually I'm the person behind the framistats effort. I posted about the X10 awhile back, maybe 2 months ago when I actually took some action. The idea has been tossed around and even worked on somewhat in 2003 (see: X10 appliance timer, although this version interfaced directly to a wireless keyfob).

I've been toying with the idea of using X10 as I saw arduino has a page about it. I picked up two PL513 power-line interfaces at a cost of about $5 each. These devices have 4 wires and allow a microcontroller to put X10 commands on the power line. My main concern with this option is reliability, which can be affected by line noise and/or faulty house wiring, among other things.

As for the making money part, the lack of certifications as well as, no money for patents, keeps me from mass production. Well, also I'm pretty lazy and unmotivated lately, and neck-deep in medical problems. Still, there is a certain niche market which I've been targeting (albeit half-asses). It is actually the hobby which prompted me to make these devices. I'd love to produce such a thing but I hold myself back for being scared of the technicalities. This is partly why I've leaned towards open-source, and perhaps just selling my PC software. Plus I like to contribute to the open-source world, really.

Every once in awhile I'll see someone's project trying to accomplish the same task, and I have even collaborated with people trying to do this and make a commercial product from it. But more times than not, the whole thing either turns out to be more than they can handle, or they lose interest in it (as is the case with me, often).

In five years of tinkering with environmental monitoring and control, I have only seen one product tailored to the hobbyist, within the budget of a hobbyist. That is growtronix, however I tend not to like it because a) the high price, b) the fact that if the computer loses power or the software crashes, nothing works. And c) they're competition, naturally. I hear that growtronix is a one-man operation, and it works like this: You pay them, then they order the parts and build it, and send you your system when they're done in about 3-6 weeks.

The one innovative feature of theirs is the use of telephone cable as interconnects (RJ11). Their various sensors use some standard in automation (CAM?) so that could have its benefits over something completely proprietary; the interconnects allow expandability. But OTOH, using X10 in a device like this would offer up to 255 different devices to be switched.

Anyways, I wanted to put all that out there for anyone who stumbles upon this thread and would like more information. If you would like I can dig up more notes and links to other's similar projects for your reference - in five year's time I've amassed quite a collection and have considered environment automation from almost every angle conceivable  smiley-grin
30  Forum 2005-2010 (read only) / Interfacing / Re: SHT15 Humidity/Temperature Tutorial on: April 07, 2008, 06:26:55 pm
Glacial_Wanderer, to the best of my knowledge the framistats is a single arduino interfaced to a PC, and is meant for smallish environments. Also, I have seen in the past an open-source framistat which was stand-alone (no pc). Open-source everything was probably considered, but one needs to make a living somehow no? Still, I'd be willing to bet the framistats project is held back due to lack of money getting certifications (CE, UL), which would be necessary to sell the device as a consumer appliance and be protected from lawsuits should the device malfunction. A way to get around this, of course, is having people build their own.

One other thing I've thought of to tackle the problem mentioned above, is by using already-certified devices to switch the power. Such as, X10, which arduino has a how-to for, regarding controlling x10 devices using an arduino.

The biggest challenge is writing the PC software, especialy if one wants the arduino-controller to run independently of the PC. This is important as computers tend to fail.
Pages: 1 [2] 3 4 ... 6