Show Posts
Pages: [1]
1  Using Arduino / Motors, Mechanics, and Power / MOSFETs for PWM of high current/voltage - Does order in series matter? on: July 28, 2014, 02:52:27 pm
I am looking to PWM a 15W LED array with a 11V drop voltage.  I found a tutorial on building a constant current supply (specifically, Step 8 @ http://www.instructables.com/id/Circuits-for-using-High-Power-LED-s/) using the FQP50N06L, and I was wondering:

Is there any particular reason why I never see the MOSFET between the cathode of the LED and Vin?  Assuming a Vin of 12V, and a 5V logic signal, should I expect the MOSFET to not conduct from drain to source?  Is this why the switch is typically located between the anode and ground, after the load does its business?

Seems trivial, though I never thought the sequence of components in series mattered. 
2  Using Arduino / Networking, Protocols, and Devices / Re: Multiple I2C devices - Need guidance on irresponsive RTC on: July 03, 2014, 07:51:26 pm
Figured it out!

The VCC pin on the HIH6130 was hooked to a de-energized pin on the Arduino, and the 2.2k pull-up resistors were not being utilized in the LOW state.  When I attempted to hook the RTC in parallel and run the clock, I could never get it to actually send/receive data.  I experimented by switching the VCC pin to HIGH, and the RTC behaved!  I used my multimeter to test for conductance over the SDA and VCC pin while the program was running, and would get a small *bleep* every time the VCC pin was switched to high.

I'm still not sure it makes sense as to why it works... but the moral of the story is to make sure your VCC pin on your pull-up resistors is indeed HIGH. 
3  Using Arduino / Networking, Protocols, and Devices / Multiple I2C devices - Need guidance on irresponsive RTC on: July 02, 2014, 11:49:35 pm
Hello All,

I am learning about I2C communication on my Arduino Mega 2560.  I am trying to use two I2C devices, Sparkfun's HIH6130 temp/humidity breakout board, as well as Sparkfun's DS1307 RTC breakout board.  I've gotten each device to work fine individually, but I believe I'm having an issue with either working when wired in parallel.

Running the below code for the RTC and with the HIH6130 completely disconnected, I get a normal response.  As soon as I plug the HIH6130 in parallel to the RTC, however, the RTC hangs and the code fails to display any outputs. 

I see that the HIH6130 already has 2.2k pull-up resistors to VCC over the SCL and SDA lines.  Does this imply that I shouldn't need a pull-up resistor for the RTC if I hook it in parallel?  Any guidance on wiring these two breakout boards would be hugely appreciated.  I'm a mechanical guy, and circuits can be overwhelming at times.

HIH6130 homepage: https://www.sparkfun.com/products/11295
HIH6130 schematic: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Weather/HIH6130_Breakout_v10.pdf
DS1307 homepage: https://www.sparkfun.com/products/99
DS1307 schematic: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/RTC-Module-v13.pdf

Code:
#include <Wire.h>

#define DS1307_I2C_ADDRESS 0x68 //the i2C address for the RTC

//variables necessary for the RTC
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
byte zero;

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return ( (val/16*10) + (val%16) );
}

//code for getting time from the RTC
String getTimeDs1307()
{
  // Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.write(zero);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7, true);

  // A few of these need masks because certain bits are control bits
  second     = bcdToDec(Wire.read() & 0x7f);
  minute     = bcdToDec(Wire.read());
  hour       = bcdToDec(Wire.read() & 0x3f);  // Need to change this if 12 hour am/pm
  dayOfWeek  = bcdToDec(Wire.read());
  dayOfMonth = bcdToDec(Wire.read());
  month      = bcdToDec(Wire.read());
  year       = bcdToDec(Wire.read());

  String timeString="";
  timeString += hour, DEC;
  timeString += ":";
  timeString += minute, DEC;
  timeString += ":";
  if (second < 10)
    timeString += "0";
  timeString += second, DEC;
  //Serial.println(timeString);
  return timeString;
}

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("Code is started");
  zero=0x00;
}

void loop() {
  Serial.println(getTimeDs1307());
  delay(3000);
}
4  Using Arduino / Programming Questions / Re: Managing Arduino RAM - Is this an effective technique? on: December 03, 2013, 05:20:19 pm
Awesome resources, thank you.  I have some nighttime reading ahead of me  smiley

I don't fully understand the idea behind fragmentation - it seems like dynamic Strings tend leave behind "trash" bits which eventually hog all your SRAM. 

How would I know how much space to reserve for my strings?  If I overcompensate the size, will I have funky data?
5  Using Arduino / Programming Questions / Managing Arduino RAM - Is this an effective technique? on: December 03, 2013, 03:51:27 pm
Hi all,

I have an Arduino Mega that I intend to use for logging data of water and air quality.  Using an ethernet shield for writing to a SD, the intent is to log data in time intervals of 5 seconds or greater.  I have four sensors connected via RX/TX, a RTC, a digital moisture sensor, and a few analog devices. 

I'm trying to keep RAM usage at a minimum so I can expand this project in the future.

My general strategy was to use as few global variables as possible and rely on local variables within functions to do my heavy lifting.  My question is:  when I tell Arduino to execute a function (for example 'getTimeDs'), does it store the String that the function was declared as?  Is this a very RAM-intensive code?

Please refer to my paraphrased code:

Code:
void loop() {
  File dataFile = SD.open(fileName, FILE_WRITE);
  if(dataFile) {
    dataFile.print(getTimeDs1307());  //calls for the RTC to get the time
    dataFile.print(", ");
    dataFile.print(getDateDs1307()); //calls for the RTC to get the date
    dataFile.print(", ");
    dataFile.print(getTemperature1()); //calls for the digital thermometer
    dataFile.print(", ");
    dataFile.print(getHumidity1()); //calls for the digital moisture sensor
    dataFile.print(", ");
    dataFile.print(getSensorPH()); //calls for pH
    dataFile.print(", ");
    dataFile.print(getSensorORP()); //calls for ORP
    dataFile.print(", ");
    dataFile.print(getSensorCond()); //calls for Conductivity
    dataFile.print(", ");
    dataFile.print(getSensorDO()); //calls for DO
    dataFile.close();
  }
  else {
    Serial.println("Error 1");
  }
  delay(interval);  //the interval between data samples
}

String getTimeDs1307()
{
//code for the RTC
}

etc etc etc...

Thank you for the help.
6  Using Arduino / Storage / Re: SD and 16x2 LCD do not work together. on: November 07, 2012, 02:10:49 pm
ElCaron, I think I'm experiencing the same problem as you, though I'm not sure what you mean by two different SPI interfaces.  Could you elaborate a bit, perhaps posting your end-result pinout?

I'm using an ethernet shield, 20x4 LCD, and Arduino Mega.  The LCD utilizes pins (7,8,9,10,11,12) and the SDCS at pin 4.  I can run each component separately, though when combined together (specifically when I add the line 'lcd.setCursor(0,0)'), I fail to write anything to the SD.

7  Using Arduino / Sensors / Re: analog sensor questions (especially why use voltage dividers ?) on: July 16, 2012, 10:24:32 pm
So, going off of the information about sensitivity and the resistor, is there an "optimum" resistance where your sensor is most accurate?

I'm using a water level sensor, which is basically a linear resistor.  With no water, it is 1500 ohm resistance, filled 8 inches and it's down to 300 ohm.  I'm using it for a fish pond and am not expecting fluctuations more than a few inches.  If I want to get the most accurate possible results, could I anticipate better measurements if I pick a resistor based on my height meter's mean resistance?   
8  Using Arduino / Sensors / Re: Atlas Scientific pH Sensor Help on: July 12, 2012, 05:51:35 pm
You mean 9600 baud?  I'm still getting blank stares from my serial monitor.

Are you able to explain how the serial input works?  As I understand it with this particular code, I should be able to type out '\r' into my serial monitor and get a reading.  Would anyone agree to this being correct?
9  Using Arduino / Sensors / Atlas Scientific pH Sensor Help on: July 12, 2012, 01:25:05 am
I am sporting an Arduino Mega 2560 with an ethernet shield and Arduino 1.0 software.  I am trying to hook up an Atlas Scientific pH probe (https://www.atlas-scientific.com/product_pages/kits/ph-kit.html) which hooks to my Arduino through a BNC plug to a breakout board to the Serial3 ports. 

I'm new to serial communication and was hoping someone could help clarify what is going on and how I can manipulate this into useful information.  Right now, I am getting nothing on my computer's serial monitor, regardless of what I type in.  Any thoughts?

My wiring can be found through this link: https://www.atlas-scientific.com/_files/code/Arduino-sample-code-EZ-COM-MEGA.pdf

My coding is also found through that link, or you can refer to it below:

String inputstring = "";
String sensorstring = "";
boolean input_stringcomplete = false;
boolean sensor_stringcomplete = false;
//a string to hold incoming data from the PC
//a string to hold the data from the Atlas Scientific product
//have we received all the data from the PC
//have we received all the data from the Atlas Scientific
//product
void setup(){
Serial.begin(38400);
Serial3.begin(38400);
inputstring.reserve(5);
sensorstring.reserve(30);
}
//set up the hardware
//set baud rate for the hardware serial port_0 to 38400
//set baud rate for software serial port_3 to 38400
//set aside some bytes for receiving data from the PC
//set aside some bytes for receiving data from Atlas Scientific
//product
void serialEvent() {
char inchar = (char)Serial.read();
inputstring += inchar;
if(inchar == '\r') {input_stringcomplete = true;}
}
//if the hardware serial port_0 receives
//a char
//get the char we just received
//add it to the inputString
//if the incoming character is a <CR>,
//set the flag
void serialEvent3(){
char inchar = (char)Serial3.read();
sensorstring += inchar;
if(inchar == '\r') {sensor_stringcomplete = true;}
}
//if the hardware serial port_3 receives
//a char
//get the char we just received
//add it to the inputString
//if the incoming character is a <CR>,
//set the flag
void loop(){
if (input_stringcomplete){
Serial3.print(inputstring);
inputstring = "";
input_stringcomplete = false;
}
//here we go...
//if a string from the PC has been received in its entierty
//send that string to the Atlas Scientific product
//clear the string:
//reset the flag used to tell if we have received a completed
//string from the PC
if (sensor_stringcomplete){
Serial.println(sensorstring);
sensorstring = "";
sensor_stringcomplete = false;
}
}
//if a string from the Atlas Scientific product has been
//received in its entierty
//send that string to to the PC's serial monitor
//clear the string:
//reset the flag used to tell if we have received a
//completed string from the Atlas Scientific product
10  Using Arduino / Motors, Mechanics, and Power / Re: Servo and power supply question - turns in one direction on: December 05, 2011, 09:16:28 pm
The breadboard itself is powered by 8 AA batteries, though the (+) leads that run out of the breadboard are divided by 1.5 volt integers.  So, I can choose from 1.5 volts, 3.0 volts... up 9.0 volts.  I'm running power out of the 4.5 volt. 

My only defense against the code not being bad is because the very same code works flawlessly when it is my arduino providing the power. 

11  Using Arduino / Motors, Mechanics, and Power / Re: Servo and power supply question - turns in one direction on: December 04, 2011, 06:34:36 pm
Alright, so I think I've hooked up my external power source.  On my breadboard, I've grounded my power source to the ground on my breadboard, as well as the ground on my arduino.  It seems to work, but there's a lot of "chatter".  The motor is never quiet, like it was when my arduino was solely powering it.  The power source that I'm using is actually a all-in-one solderless breadboard kit, powered by 8 AA batteries.  Would the qualities of the batteries (in terms of charge) at all affect this "chatter" ? 
12  Using Arduino / Motors, Mechanics, and Power / Servo and power supply question - turns in one direction on: December 04, 2011, 01:52:10 pm
For awhile now, I've been doing small arduino projects to learn the coding structure associated with it.  Recently, I ordered some small, 5 volt servos to experiment with motor control.  Using the provided "sweep" and "knob" examples provided, my main goal was to simply establish control of the servo.  Regardless of how the code was structured, however, the servo always turned as far as it could clockwise.  A lot of troubleshooting went on, and I found that the code would work if the servo was powered by the arduino, that is, the power, ground, and communication wires were all wired into the board.  I found that the servo misbehaved because I was using an external 5 volt power supply attached to the power and ground wires, with the communication wire attached to my arduino. 

This leads me to my question: why does my servo only work if all three leads are plugged into the arduino?  Why can't I use an external power supply if my communication wire is attached to the arduino?  Ultimately, I'd like to operate a few servos simultaneously, and I'm concerned that it may result in damage to my arduino. 

Any input is appreciated.  Thank you all.
Pages: [1]