Show Posts
Pages: [1] 2
1  Using Arduino / General Electronics / Re: 1st read of DS18S20 temp sensor is wrong on: May 20, 2013, 03:13:47 pm
Code:
ds.write(0x44,1); // start conversion, with parasite power on at the end
The important word in the comment is start. You aren't giving the device time to finish the conversion so the first time through you get rubbish.
If you have the resolution set to 12 bits (I think that's the default), it takes 750 milliseconds to do the conversion. I give it 800 just to be sure:
Code:
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(800);

Pete
That makes sense, but I never would have thought of that.  Thanks.  I'll try it when I get home.
I just got my code updated, and it works great.  Thanks again.
2  Using Arduino / General Electronics / Re: 1st read of DS18S20 temp sensor is wrong on: May 19, 2013, 06:46:47 pm
Code:
ds.write(0x44,1); // start conversion, with parasite power on at the end
The important word in the comment is start. You aren't giving the device time to finish the conversion so the first time through you get rubbish.
If you have the resolution set to 12 bits (I think that's the default), it takes 750 milliseconds to do the conversion. I give it 800 just to be sure:
Code:
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(800);

Pete
That makes sense, but I never would have thought of that.  Thanks.  I'll try it when I get home.
3  Using Arduino / General Electronics / Re: 1st read of DS18S20 temp sensor is wrong on: May 19, 2013, 06:45:42 pm
Normally you should check the CRC == data[8] after reading

Check out the Dallas Temperature Control Library (google is your friend)
Thanks for the tip.  I'm so new, I don't even know what to Google.  This helps.
4  Using Arduino / General Electronics / 1st read of DS18S20 temp sensor is wrong on: May 19, 2013, 04:38:30 pm
My project includes a transmitter with 4 buttons.  When any one of these buttons is pressed, my code reads a temp sensor and then starts a generator.  I've posted just the temp reading portion of my code below.  The rest of the works fine once the temp is read correctly.

When I plug in my usb cable the first time and hit a Tx button, the temp is always read as 185.  When I press the button immediately after, the temp reads correctly.  This website is the source for the temp reader code I'm using.  I don't fully understand it, but I'm trying to.  How do I get rid of the errant first temp reading?

Code:
/*
reads the temp sensor when a button on the Tx is pressed
*/

// OneWire used to read DS18S20 temp sensor
#include <OneWire.h>

// inputs from Rx
int VtFromRx = 12;
int buttonAFromRx = 11;
int buttonBFromRx = 10;
int buttonCFromRx = 9;
int buttonDFromRx = 8;

// other devices
int tempSensor = 13;

//Temperature chip i/o
OneWire ds(tempSensor);
float tempGen = 60;

void setup() {
  Serial.begin(9600);
 
  pinMode(VtFromRx, INPUT);
  pinMode(buttonAFromRx, INPUT);
  pinMode(buttonBFromRx, INPUT);
  pinMode(buttonCFromRx, INPUT);
  pinMode(buttonDFromRx, INPUT);
 
  pinMode(tempSensor, INPUT);
 
  Serial.println("setup complete");
}

void loop() {
 
  // read the inputs from the key fob
  int readVtFromRx = digitalRead(VtFromRx);
  int readButtonAFromRx = digitalRead(buttonAFromRx);
  int readButtonBFromRx = digitalRead(buttonBFromRx);
  int readButtonCFromRx = digitalRead(buttonCFromRx);
  int readButtonDFromRx = digitalRead(buttonDFromRx);
     
  if (readVtFromRx == HIGH){     //this line checks to see if any button was pushed
    Serial.println("");
    Serial.print("---- Some button was pushed ---- ");
    tempGen = getTemp();
    Serial.println(tempGen);
   
    if (readButtonAFromRx == HIGH){
      tempGen = getTemp();
      Serial.println("-- A was pushed --");
      Serial.print("The temp is ");
      Serial.println(tempGen);
    }
   
    if (readButtonBFromRx == HIGH){
      Serial.println("-- B was pushed --");
    }
   
    if (readButtonCFromRx == HIGH){
      Serial.println("-- C was pushed --");
    }
   
    if (readButtonDFromRx == HIGH){
      Serial.println("-- D was pushed --");
    }
     
  }
  delay(200);
}

float getTemp(){
//returns the temperature from one DS18S20 in DEG Fahrenheit

byte data[12];
byte addr[8];

if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}

if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}

ds.reset_search();

byte MSB = data[1];
byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSumC = tempRead / 16;
float TemperatureSumF = TemperatureSumC * 9/5 + 32;

return TemperatureSumF;
}


Here's what the serial output looks like for a sequence of 5 button pushes:
5  Using Arduino / General Electronics / Re: SMA connector wiring on: April 21, 2013, 05:13:43 pm
Thanks.  They are both 433 MHz.
6  Using Arduino / General Electronics / SMA connector wiring on: April 21, 2013, 04:18:36 pm
I have a receiver board that reads inputs from a key fob like you use to unlock your car.  The Rx board has a single coiled wire which seems to be the antenna (first pic).  I would like to add a magnetic base antenna (second pic) to extend the range of the system.  My problem is that I don't know how to connect the Rx single wire to the SMA connector.  Does the center wire of the coax connect to the Rx coiled wire?  What about the outer jacket of the coax?  Do I connect it to system ground?

 
7  Using Arduino / Project Guidance / Re: 1st prototype fried, have questions (remote start system) on: March 31, 2013, 10:29:52 am
All I have now is my multimeter.  It gives a reading of 12.2V - 12.6V, depending on whether the generator is running or not.  Once I get a scope, I can do a better job of looking for spikes (I think, right?).

This is the UBEC I'm using to supply the servo.  It would be easy to change some wiring and drive both the Arduino and the servo from this.  My concern is that it's a switching regulator instead of linear.  Would this provide the same protection as the 5v linear regulator you recommended?
8  Using Arduino / Project Guidance / Re: 1st prototype fried, have questions (remote start system) on: March 31, 2013, 12:27:58 am
I'd put money on it the Voltage Regulator becoming fried (Voltage Flux?), and then that could lead to the processor getting a full 12v (Causing the heat you see and damage to the box)

Get a 5v linear regulator, and possibly a heatsink for it (12v+ out to the Regulator, 5v out to VIN on the board)

That's the step I couldn't see.  I couldn't connect the dots between voltage flux and overheating.  Thanks.  I'll do some reading about your theory and how to test it.  I really want to know what happened rather than have a really good idea of what happened.

The remote system was last working at night when I used it shut off the generator.  It didn't work the next morning.  There shouldn't be any voltage flux during the night when nothing is happening.  And the remote was working when it was used to shut off the generator.  So most likely, the failure happened during the generator shut down.  That makes sense.  I'm sure the voltage gets more "fluxy" during the shut down process.

So how does this make the Rx module die?  It has 7 wires between it and the Arduino: 5 digital inputs, 5V, and Gnd.  Could the Voltage Regulator on the Arduino fry in such a way that it would send the full 12V to the Rx module?
9  Using Arduino / Project Guidance / Re: 1st prototype fried, have questions (remote start system) on: March 30, 2013, 09:59:35 pm
My schematic is kinda funky and done in powerpoint.  I'm still learning how to use appropriate software.  I'll try to clean it up and get it posted, but for now, here are the basics:

12V power from generator ---- through switch ---- Arduino Vin
12V power from generator ---- UBEC to convert to 5V ---- through relay block ---- to servo

12V ground from generator ---- everything

Arduino 5V pin ---- Rx Vcc
                      ---- Relay block Vcc
                      ---- temp probe
                      ---- pull up resistor for temp probe

Digtal Arduino pins (input) ---- 5 from Rx module
                                       ---- 1 from switch on generator used to control idle speed
                          (output) ---- 4 to relay block
                                       ---- 1 to control servo position

I've found a decent oscilloscope on Craigslist.  I hope to pick it up tomorrow.  I haven't touched one in 15 years, so it might take me some time to get a reading on the 12V supply from the generator.

Is there anything I should inspect on the fried Nano that would give insight to how this failed?
10  Using Arduino / Project Guidance / 1st prototype fried, have questions (remote start system) on: March 29, 2013, 02:34:43 pm
I'm making a remote start system for my generator which I use to power my camper.  I built my development unit on my workbench using an Uno and a breadboard.  I got all the kinks worked out, and then I made my first prototype.  For space saving, the prototype replaced the Uno with a Nano.  I tried it out last weekend and had some issues.
- the DS18B20 temp sensor didn't work (i haven't had time to look into this, probably bad wiring by me)
- the generator battery was dead after sitting overnight (it's an 8 amp-hour battery)
- the nano and the receiver module are dead
- the plastic project box is slightly melted near the Nano

So everything worked from Fri night to Sat night.  When I woke up Sun and hit the start button on the remote, nothing happened.  I walked outside to the generator and tried the stock key and nothing happened.  The battery was dead.  I had to manually start it with the pull cord.  After the battery charged, the stock electric start system was working again, but my remote system never did.  I shut off the power to the remote to preserve the battery, and the battery never died again.  When I got home, I swapped in a new Nano and Rx module and everything worked again.  I'm trying to diagnose what happened before I progress with any more testing.

So it seems the dead battery, fried Nano and Rx module, and the melted box are all related.  The first picture below shows how the components were located in the box.  In the bottom middle right next to the relay block is the Rx module.  The second picture is a better view of how the box melted a little near the Nano.  The box wasn't near any heat source.

Onto the diagnosis.  Obviously, an 8 amp-hour battery draining in about 8 hours is a bad sign.  I didn't even think that was possible with this system.  I figured something would burn up and short out first.  My Nano is powered directly from the 12V battery on the generator, so there's a chance some ripples got to it.  If so, I can see it resetting itself, but I wouldn't think it would die.  I don't have a scope, so I'm not sure how bad the 12V supply is.  This is my first experience with Arduino, so I'm still learning.  I'm buying a scope now and reading about voltage regulators (Practical Electronics for Inventors is a big help).  Could ripples and spikes have done this much damage?  Either way, I will clean up the power supply but I'm not certain that was the cause this weekend.  How would that have drained the battery?  I'm not using any sleep modes for the Nano.  I haven't figured how to do that yet, but I plan to.

The generator 12V goes into the Vin pin on the Nano.  The 5V pin is used to supply the temp sensor, relay block, and the Rx module which all take very little power.  There is also a servo to actuate the choke, but it gets its power through a UBEC connected to the battery 12V.  The UBEC (first pic, to the right of the relay block) power is run through one of the relays.  I didn't want the servo to always have power.  I only supply power to it when the servo is needed during the starting sequence.

So how did the Nano presumably draw enough current to melt the plastic box and take out the Rx module?  Or what else happened?



11  Using Arduino / General Electronics / Re: need a 3PDT switch - on/on, not on/off/on - with label plate on: February 23, 2013, 08:47:23 pm
Found this plate.  Its just what I needed.  I don't know how I missed it the first time I went through digikey's catalog.
12  Using Arduino / General Electronics / Re: need a 3PDT switch - on/on, not on/off/on - with label plate on: February 23, 2013, 08:07:41 pm
Form Factor
I need this to be easily installed into an existing sheet metal control panel.  That limits me to switches with circular mounting holes.  I prefer solder lugs, but that's negotiable.

End Result
I'm making an electric start system for a generator.  Of the 3 circuits in the 3PDT switch, the first is being used to switch power on/off to the arduino.  The other 2 circuits are used to direct an existing switch on generator's control panel between the stock wiring harness and the arduino.  So here's how the circuit works:
switch ON - arduino is on, the stock switch on the generator is routed to the arduino
switch OFF - arduino is off, the stock switch on the generator is routed to the factory wiring harness

I could use a basic SPST switch and a 3PDT relay, but I'm finding that to be more expensive.

A little more searching has turned up these switch plates.  They're nice and also affordable.  The drawback is that they are for 12mm threads.  Swtiches with 12mm threads are pretty big for this application and much more expensive ($8.51) than the 6mm versions ($1.45).  I would really like to find the switch plates for the 6mm switches.

Thanks for looking.
13  Using Arduino / General Electronics / need a 3PDT switch - on/on, not on/off/on - with label plate on: February 23, 2013, 05:36:05 pm
I'm having trouble finding the switch I need for a project.  I need a 3PDT switch that is on/on (doesn't have a center off position).  I found one this one but it doesn't have a label plate like this SPST switch.  I've looked for an hour and can't find anything.  This is for a semi-commercial product so cost is somewhat of a concern.  If it was jut for me, I'd buy both of the linked switches and make what I need from them.

Alternatively, does anyone know where I can buy just the label plates?
14  Using Arduino / General Electronics / Re: Servo twitch on startup on: February 05, 2013, 11:42:05 am
I got a new servo yesterday, and it does the same thing.  It does twitch in the opposite direction though.

I'm adding a relay to delay the power to the servo.
15  Using Arduino / General Electronics / Re: Servo twitch on startup on: January 27, 2013, 04:12:56 pm
As noted, some servos, such as GWS, twitch much more than others on power application.
Other than finding servos that don't twitch, it may work to use a Mosfet to apply power to the
servo [p-chan Mosfet on high-side power], and start the incoming pulses before power is applied. 
Maybe.
This works with the servos I have.  After I power on the Arduino, I manually connect the servo to power and there's no twitch.  So I know the P-chan Mosfet circuit you describe will work.

I swapped my Uno boards and the twitch is still present.  When swapping servos on the new Uno, one thing that was interesting is that different brand servos twitch in different directions (ccw vs cw).  I'm ordering some other servos today.  If that doesn't do it, I'll do the Mosfet design.
Pages: [1] 2