Show Posts
Pages: [1] 2 3 ... 11
1  Using Arduino / General Electronics / Re: I think I let the magic smoke out...Can someone confirm? on: August 17, 2014, 08:45:00 pm
Ok...  Progress!


The following code works:

Code:
  float voltage_involt = (float) involt / 1023.0 * 1.1;
  float sensor_in = voltage_involt/.0648;
  float voltage_inamp = (float) inamp / 1023.0 * 1.1;
  String refVal = dtostrf(sensor_in,5,4,"stuff");
  menus.refval(refVal);

  split(sensor_in);
  menus.setvolts(inte, dec);

voltage_involt measures the voltage going into arduino
Sensor_in is the voltage that is calculated to reflect the voltage being fed to the sensor.  The supply outputs 12.5v.  The sensor is sending .81v.  So I divided 12.5 by .81 and then divided 1 by the answer to get .0648.

Peter, was this what you meant or were you suggesting to accomplish this another way?  My thought was to work on getting the voltage readings sorted out and then using the same sort of procedure to measure the current.

Thoughts?
2  Using Arduino / General Electronics / Re: I think I let the magic smoke out...Can someone confirm? on: August 17, 2014, 09:02:28 am
This morning I did simplify the code a little I took out the .0584 to try and read the raw voltage.  The .0584 previously showed me the voltage at the being fed into the sensor.

I'll try the code you posted above when I get home later today.
3  Using Arduino / General Electronics / Re: I think I let the magic smoke out...Can someone confirm? on: August 17, 2014, 06:05:13 am
No, a voltage divider is just two resistors.
Got it.

I did a little more reading on the atto pilot sensor last night.

You can still try to make that sketch working. Even with readVcc(). I'm afraid that with the 2 resistors, you run into new troubles.
At this moment I prefer to get something working, and accuracy is something for later.
Agreed
First of all, what kind of voltage do you want to read with the 'voltagepin' ?

From the product sheet:
Quote
Voltage sense is accomplished by scaling to 3.3V ADC range by a precision resistor divider.
  at 50v the sensor will output 3.3v I don't think I'll ever supply it more than 24v and for testing purposes I'm feeding the sensor 12v which yeilds .8v at the output.  I would guess that switching the reference to 2.56V might not be a bad idea.

Are there peaks that could damage the Arduino ?
  Not that I have seen.

When you select the internal 1.1V, don't do the calculation with the 5V of readVcc. That is of no use.

Where do you see this happening?  This is where I'm confused about where I've inadvertently started to use 5v instead of 1.1.


At the end of readVcc(), try to repair the analog settings.
Code:
long readVcc() {
   ...

  // Try to set the mux normal
  analogReference(...);       // set the the reference voltage that you choose
  analogRead(0);             // set mux and dummy read
  delay(20);                 // wait for voltages to become stable
  analogRead(0);        // another dummy read.

  return result; // Vcc in millivolts
}

I've added this to my sketch in the readVcc function.
4  Using Arduino / General Electronics / Re: I think I let the magic smoke out...Can someone confirm? on: August 16, 2014, 07:26:25 pm
Peter,

Thanks for the reply.  I'm actually trying to read this:  https://www.sparkfun.com/products/9028   This is a voltage divider, right?

Do you have any recommendations about how to read the sensor?

Thanks
5  Using Arduino / General Electronics / I think I let the magic smoke out...Can someone confirm? on: August 16, 2014, 01:57:34 pm
I had been working on a project using a 12v supply through the Vin Pin.  There were a few times (less than 5 that I can recall) that I plugged my USB in while powering the mega with the Vin.  Now when I power up the mega the sketch I'm running tells me that its reading over 3 volts.  When in reality there is only .8v at the analog input.  Prior to using the USB and the 12v at the same time that the analog read and calculations everything seemed to be working well.


Have I permanently damaged my mega?  Is there anything that I can do to double check for damage?

Thanks,

Loren
below is the sketch I had been running:



Code:
#include<UTFT.h>
#include<UTouch.h>
#include "Menus.h"


extern uint8_t SmallFont[];
//UTFT myGLCD(ITDB32S, 38,39,40,41);   // Remember to change the model parameter to suit your display module!
//UTouch myTouch(6,5,4,3,2);


//Sketch Variables

int mnu;
int x,y;
int voltagepin = 0;
int involt = 0;
int currpin = 1;
int inamp = 0;
int dec, inte;

//average


//millis

unsigned long time;
unsigned long currTime=0;

Menus menus;


//pulse in

/*int pulsepin = 8;
 unsigned long duration;*/



//fan stuff:

//Varibles used for calculations
int NbTopsFan =0;
int Calc;

//The pin location of the sensor
int hallsensor = 8;


typedef struct{                  //Defines the structure for multiple fans and their dividers
  char fantype;
  unsigned int fandiv;
}
fanspec;

//Definitions of the fans
fanspec fanspace[3]={
  {
    0,1            }
  ,{
    1,2            }
  ,{
    2,8            }
};

char fan = 1;   //This is the varible used to select the fan and it's divider, set 1 for unipole hall effect sensor
//and 2 for bipole hall effect sensor







void setup(){

  Serial.begin(9600);
  analogReference(INTERNAL1V1);

  menus.initScrn();
  menus.homeScrn();

  //average





  pinMode(hallsensor, INPUT);
  attachInterrupt(0, rpm, RISING);
  sei(); //Enables interrupts

  //pinMode(pulsepin, INPUT);



}


void loop(){
  menus.touched();


  involt=analogRead(voltagepin);
  delay(10);
  involt=analogRead(voltagepin);
  delay(10);
  inamp =analogRead(currpin);
  delay(10);
  inamp =analogRead(currpin);


  float Vcc = readVcc()/1000.0;
  float Voltage = ((involt / 1023.0)*Vcc)/.0584;
  float Ref = (involt /1023.0)*Vcc;
  String refVal = dtostrf(Ref,5,4,"stuff");
  //String refVal = String(Ref);
  menus.refval(refVal);

  split(Voltage);
  menus.setvolts(inte, dec);

  float Amperage = ((inamp / 1023.0) * Vcc);
  split(Amperage);
  menus.setamps(inte, dec);

  // delay one second without delaying
  time = millis();
  unsigned long diff;
  diff = time - currTime;
  if (diff>1000){
    cli(); //Disable interrupts
    Calc = ((NbTopsFan * 60)/fanspace[fan].fandiv); //Times NbTopsFan (which is apprioxiamately the fequency the fan is spinning at) by 60 seconds before dividing by the fan's divider

    NbTopsFan = 0; //Set NbTops to 0 ready for calculations
    sei(); //Enables interrupts


    //duration = pulseIn(pulsepin, HIGH);
    String fanspeed = String(Calc);
    fanspeed+=" rpm";
    Serial.println("Speed:  " + fanspeed);
    menus.rptfan(fanspeed);
    currTime = time;
  }










}

long readVcc() {
  // Read 1.1V reference against AVcc
  // set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
  ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
  ADMUX = _BV(MUX3) | _BV(MUX2);
#else
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif 

  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA,ADSC)); // measuring

  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH 
  uint8_t high = ADCH; // unlocks both

  long result = (high<<8) | low;

  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
  return result; // Vcc in millivolts
}


void split(float volts){
  //Serial.println(volts);
  int IntegerPart = (int)(volts);
  inte =IntegerPart;
  //Serial.println(IntegerPart);
  int DecimalPart = 100 * (volts - IntegerPart);
  dec = DecimalPart;
  //Serial.println( DecimalPart);

}



///fan:

void rpm ()      //This is the function that the interupt calls
{
  NbTopsFan++;
}







6  Using Arduino / Sensors / Re: My quest for analogRead accuracy failing miserably on: August 10, 2014, 08:02:20 pm
The OP seems to be using a special version of google which directs him or her to the most complicated version of their problem in preference to straightforward explanations.

Anyway,  you now have code that will work on any kind of processor.

Does anyone have a simpler way that would be just as accurate?
7  Using Arduino / Displays / UTFT SevenSegNumFont and decimals? on: August 03, 2014, 08:31:14 am
I've got a TFT using Henning karlsen's Library.  Should a decimal look like the attached picture?  I'm guessing that a decimal is probably not included in that font.  Is that right?

Thanks,

Loren

8  Using Arduino / Sensors / Re: My quest for analogRead accuracy failing miserably on: August 03, 2014, 07:42:42 am
I think I've got it....

Yesterday I found this code segment:

Code:
long readVcc() {
  // Read 1.1V reference against AVcc
  // set the reference to Vcc and the measurement to the internal 1.1V reference
  #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
    ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
    ADMUX = _BV(MUX5) | _BV(MUX0);
  #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
    ADMUX = _BV(MUX3) | _BV(MUX2);
  #else
    ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  #endif 
 
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA,ADSC)); // measuring
 
  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH 
  uint8_t high = ADCH; // unlocks both
 
  long result = (high<<8) | low;
 
  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
  return result; // Vcc in millivolts
}

It does the same thing as the examples in the OP but pertains to a mega.  Then I decided to take a step back and think for a minute.  There were too many unknowns and I was guessing too much.  So I simplified my sketch to show exactly what voltages were coming off of the sensor.  When I was able to verify with a meter that the voltages the display were stable and matched I figured out the offset that I needed to calculate the voltage being read by the sensor.  So for now I think that I have what I need.

Here is what my sketch looks like now:

Code:

#include<UTFT.h>
#include<UTouch.h>
#include "Menus.h"


extern uint8_t SmallFont[];
//UTFT myGLCD(ITDB32S, 38,39,40,41);   // Remember to change the model parameter to suit your display module!
//UTouch myTouch(6,5,4,3,2);


//Sketch Variables

int mnu;
int x,y;
int voltagepin = 0;
int involt = 0;
int currpin = 1;
int inamp = 0;

Menus menus;

void setup(){

  Serial.begin(9600);
  analogReference(INTERNAL1V1);

  menus.initScrn();
  menus.homeScrn();
 
}


void loop(){
  menus.touched();


  //if(mnu==0){

    //involt = analogRead(voltagepin);
    //delay(10);
    involt = analogRead(voltagepin);
    Serial.println(involt);
    //delay(10);
    //inamp = analogRead(currpin);
    //delay(10);
    inamp = analogRead(currpin);
   
   
 
    //int temp2 = analogRead(voltagepin);
    String rawVal = "Read voltage on A0:  ";
    rawVal += String(involt,DEC);
    myGLCD.print(rawVal, LEFT, 28);

 

    float calcV = (involt/69.35);
     String decimal = dtostrf(calcV,5,2,"stuff");
    String voltdisp = "Calculated Voltage:  ";
    voltdisp += decimal;
    myGLCD.print(voltdisp, LEFT, 42);
   
   
    float Vcc = readVcc()/1000.0;
    float Voltage = ((involt / 1023.0) * Vcc)/.0584;
   
    String refString = "Reference voltage is:  ";
    String decifloat = dtostrf(Vcc,5,2,"stuff");
    refString += decifloat;
    myGLCD.print(refString, LEFT, 56);
   
    String calcedIn ="Calculated A0 in is:  ";
    String temp3 = dtostrf(Voltage,5,4,"stuff");
    calcedIn += temp3;
    myGLCD.print(calcedIn, LEFT, 70);
   
  //}


}

long readVcc() {
  // Read 1.1V reference against AVcc
  // set the reference to Vcc and the measurement to the internal 1.1V reference
  #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
    ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
    ADMUX = _BV(MUX5) | _BV(MUX0);
  #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
    ADMUX = _BV(MUX3) | _BV(MUX2);
  #else
    ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  #endif 
 
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA,ADSC)); // measuring
 
  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH 
  uint8_t high = ADCH; // unlocks both
 
  long result = (high<<8) | low;
 
  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
  return result; // Vcc in millivolts
}



9  Using Arduino / Sensors / Re: My quest for analogRead accuracy failing miserably on: August 02, 2014, 04:20:42 pm
I added  analogReference(INTERNAL1V1); this morning but I don't think that helped a whole lot.  The voltage is still varying by 2 or 3 volts.

Here is the code that I've been using:

Code:

#include<UTFT.h>
#include<UTouch.h>
#include "Menus.h"


extern uint8_t SmallFont[];
//UTFT myGLCD(ITDB32S, 38,39,40,41);   // Remember to change the model parameter to suit your display module!
//UTouch myTouch(6,5,4,3,2);


//Sketch Variables

int mnu;
int x,y;
int voltagepin = 1;
int involt = 0;
int currpin = 0;
int inamp = 0;

Menus menus;

void setup(){

  Serial.begin(9600);
  analogReference(INTERNAL1V1);

  menus.initScrn();
  menus.homeScrn();
 
}


void loop(){
  menus.touched();


  //if(mnu==0){

    //involt = analogRead(voltagepin);
    //delay(10);
    involt = analogRead(voltagepin);
    Serial.println(involt);
    //delay(10);
    //inamp = analogRead(currpin);
    //delay(10);
    inamp = analogRead(currpin);
   
   
 
    //int temp2 = analogRead(voltagepin);
    String rawVal = "Read voltage on A0:  ";
    rawVal += String(involt,DEC);
    myGLCD.print(rawVal, LEFT, 28);

 

    float calcV = (involt/69.35);
     String decimal = dtostrf(calcV,5,2,"stuff");
    String voltdisp = "Calculated Voltage:  ";
    voltdisp += decimal;
    myGLCD.print(voltdisp, LEFT, 42);
   
  //}


}

Would achieving accuracy to .1v be achieved by hardware, code, or both?

Loren
10  Using Arduino / Sensors / Re: My quest for analogRead accuracy failing miserably on: August 02, 2014, 08:48:19 am
Got it....

I guess for my purposes of this project being accurate to a tenth of a volt would be good. 
11  Using Arduino / Sensors / My quest for analogRead accuracy failing miserably on: August 02, 2014, 08:25:43 am
I would like to use a one of these: https://www.sparkfun.com/products/9028 in a Power supply read the voltage and current sensors with an arduino mega and display the voltages on a 3.2 tft touch display.  I was getting inconsistent results so I googled and eventually came across these two pages:

http://hacking.majenko.co.uk/making-accurate-adc-readings-on-arduino
https://code.google.com/p/tinkerit/wiki/SecretVoltmeter

Then realized that neither pertain to the arduino mega.... 

I'm powering the mega using a server power supply.  Would it be worthwhile to run the 5v line into the AREF pin to try and stabilize the readings?

Any other input or suggestions are welcome as well.

Thanks,

Loren
12  Using Arduino / Project Guidance / Re: Referencing grounds and a RC power supply on: July 28, 2014, 05:09:56 pm
Your post seems to be missing the images, or I'm having and issue and can't see them...

I've attached the images to the post.  Hopefully that will help to illustrate my questions

If the "ground" is not really grounded, you can connect power supplies in series.   You need to check the specs or test it with an Ohmmeter (multimeter).   There should be no connection (infinite resistance) between the power supply's common/black/negative connector and the chassis, or between it and the common/black/common on the other power supply.
 

That's the idea here.  The tutorials that I've read will completely isolate the ground on the output (DC) side from the AC side.
13  Using Arduino / Project Guidance / Referencing grounds and a RC power supply on: July 28, 2014, 12:26:33 pm
I have recently converted a Server power supply to use as a "bench" supply to charge my RC Multicopter batteries.  Here is the tutorial that I've followed to make the my current 12v version  http://www.daddyhobby.com/forum/showthread.php?t=77204. I've been working on a circuit board (labeled "supply interface" below) to replace the one that is removed in the tutorial.  I'm hoping that the supply interface would enable me to use a Arduino Mega with a TFT shield to operate a few of the controls and monitor temperature.  The mega would communicate with a arduino mini located on the supply interface.  

My goal is to control two supplies running in series as outlined in the tutorial for a 24v supply.  Once I started to think about how the two supplies and all of the control stuff would be connected I really started to wonder about grounds.  Here is a block diagram that got me thinking:

 

On the left is the mega, in the middle is the supply interface, and on the right is the power supply.  Starting simple, if I maintain two grounds on the interface for the second power supply like this:



Would that keep the two grounds isolated without causing any problems while maintaining the ability to run the supplies in series?

Then as a follow on question is it possible to add a digital pot (controlled by the mini) between +5 from the power supply and the VOLT_ADJ pin, as well as read the speed of the power supply's fan without complicating things too much?

Thanks a ton,

Loren
14  Using Arduino / Project Guidance / GPS Follow me module... Is it possible on: April 01, 2014, 01:52:09 pm
I've got a hexicopter that I am beginning to shoot video with.  I'd like to build a small module that I could attach to a RC plane to have my hexicopter follow.

The system would most likely be comprised of two components:
  • A transmitter module to attach to whatever moving object I'd like to film consisting of the following:
    • GPS Module
    • Arduino Fio
    • Xbee to send the info to the receiver
  • A receiver of some sort to send the GPS information to my laptop (via usb????)

On my laptop I use a program called mission planner that has a "follow me" mode.  This mode uses the onboard GPS (on a tablet or phone) or incoming GPS data to tell the drone (Via wireless telemetry link) where to go to follow the location of mission planner. 

I think that I've got a basic understanding about how to transmit the GPS info from one xBee to another.  Does this seem feasible?  If so where could I find information of how to format and parse the location data to something that Mission Planner could use?

Thanks,

Loren 
15  Using Arduino / Networking, Protocols, and Devices / Re: Trying to get RSSI Value... How do I troubleshoot this on: March 20, 2014, 10:27:09 am
Would there be a way to include an if statement to check for High if there isn't an RSSI signal?

Edit:  

What about this:

Code:
int rssi1= pulseIn(rssiPin, HIGH, 300)/2;  //Read a HIGH pulse on a pin
      if (rssi1 == 0){
        if (digitalRead(rssiPin) == HIGH) rssi1 = 100;
      }
if (rssi1 != 0){
        //use rssi value
      }


Pages: [1] 2 3 ... 11