Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Programming Questions / Re: 2 diffrent analog value influenced eachother on: September 06, 2013, 02:01:01 pm
When the temperature will be changed this has effect on the PAvalue.

When the PAvalue has changed, this has effect on the temperature.
17  Using Arduino / Programming Questions / Re: 2 diffrent analog value influenced eachother on: September 06, 2013, 02:47:33 am
Hi PeterH,

Thanks for the good question.

Quote
Are you sure it's affecting the actual reading
Yes, Im sure.

U can test very easely, just Upload the sketch and put 2 potentiometers on the analog input.
When u adjust 1 of them it affect the other.

Im pretty sure that i have written the sketch well.


thanks for the help so far.

Ed.
18  Using Arduino / Programming Questions / Re: 2 diffrent analog value influenced eachother on: September 05, 2013, 03:41:02 pm
Hi,

For each analog input I use for example a 10K potentiometer.
From each potentiometer i receive a value from 0Vdc to 5Vdc

The problem is, when i adjust one of them, it affects the other value.

Ed.
19  Using Arduino / Programming Questions / 2 diffrent analog value influenced eachother on: September 05, 2013, 03:16:17 pm
Hi,

When I integrate the PAvalue it will influenced the Temp / Fan control.

Code:
#include <LiquidCrystal.h>
  
   float Voltage;
   float TempC;
  

   int FAN = 9;                            // FAN Optocoupler (CNY74-2) connected to digital PWM pin 9
   int Temperature;
   int PAvalue;
 // int PAvalue = 0;
 
  const int PA = 2;                       // analog channel 2 (PA signal Input).
  const int LM35 = 0;                     // analog channel 0 (LM35CZ).
  const int LowTemp = 30;                 // Setting LOW Temperature setpoint. The Fan reach full speed then temperature is more than 10°C above setpoint.

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);    // lcd naar Digital pin (4=2,6=3,11=4,12=5,13=6,14=7) (lcd header "gnd" = 1,(3),5,16) and (lcd header "+5 volt" = 2,15)

  
void setup()
{
    lcd.begin(16,2);
    pinMode(FAN, OUTPUT);                 // Set pin for output to control FAN Optocoupler.
}
void loop()
{
    Temperature = analogRead(LM35);                         // read the value from the LM35 sensor
    Voltage = Temperature * (5.0/1024);                     // convert reading to voltage (in V), for 5V input
    TempC = ( 5.0 * Temperature * 100.0) / 1024.0;          // convert voltage to temperature

    lcd.setCursor(0,1);
    lcd.print(TempC);                                       // Print Celsius temperature to LCD
    lcd.print((char)223);                                   // degree symbol
    lcd.print("C ");

    analogWrite(FAN, constrain( (TempC - LowTemp) * 25, 0, 255));   // If the temperature is highher than the set point, run the fans.
{
}
    PAvalue = analogRead(PA);                               // read the value from the PA output driver.
    float PAVin = PAvalue * (4.5 / 1024.0);

    if (PAVin>4)
{
    lcd.setCursor(8, 0);
    lcd.print("10");
}
   else
    if (PAVin>3 && PAVin<4)
{
    lcd.setCursor(8, 0);
    lcd.print(" 8");
}
   else
    if (PAVin>2 && PAVin<3)
{
    lcd.setCursor(8, 0);
    lcd.print(" 6");
}
   else
    if (PAVin>1 && PAVin<2)
{
    lcd.setCursor(8, 0);
    lcd.print(" 4");
}
   else
    if (PAVin>0.5 && PAVin<1)
{
    lcd.setCursor(8, 0);
    lcd.print(" 3");
}
   else
    if (PAVin>0 && PAVin<0.5)
{
    lcd.setCursor(8, 0);
    lcd.print(" 2");
}
{
    lcd.setCursor(0, 0);
    lcd.print("Output:");
    lcd.setCursor(11, 0);
    lcd.print("Watt");
    lcd.setCursor(10, 1);
    lcd.print(PAVin);
    lcd.setCursor(15, 1);
    lcd.print("V");
 }
}

Do i forget something?

Any help will appriciate.

Thanks
Ed.
20  Using Arduino / Programming Questions / Re: Temperature control fans on: September 02, 2013, 02:49:04 pm
Dit u finish this project with a final and good working sketch?

can u post the final sketch please?.

ty

regards,
ed
21  Using Arduino / Programming Questions / Re: decimal calculation correction problem on: August 13, 2013, 02:23:33 pm
hi,

thanks for getting the Info.

When i go 20 Mhz higher this is the result:

20.0000400543 = Freq
38.9000015258 = MF
16.0000000000 = Xtal
91 = Band
58.9000396728 = Na
942 = Nb
768 = Nc
AE = lsb DR2
3 = msb DR1

The result when i go to 30 MHz:

30.0000782012 = Freq
38.9000015258 = MF
16.0000000000 = Xtal
91 = Band
68.9000778198 = Na
1102 = Nb
1024 = Nc
4E = lsb DR2
4 = msb DR1

this is only an example when it count from 1 MHz to 30 Mhz.

At this moment the actual frequency's (when selected) must be:
Code:
#define LB 0xA1                   // Low frequency band 46.25 - 170 MHz = 0xA1
#define MB 0x91                   // Mid frequency band Mid 170 - 450 MHz = 0x91
#define HB 0x31                   // High frequency band High 450 - 860 MHz = 0x31

In my opinion it make much difference.

ed

22  Using Arduino / Programming Questions / Re: decimal calculation correction problem on: August 12, 2013, 02:22:42 pm
Hi all,

this is the actual plan:

To tune a TV-tuner with I2C i need to calculate HEX "lsb" and "msb".

When i adjust the frequency in steps (MHz or KHz) the following code i have made to calculate the HEX adress MSB and LSB.

Xtal: DEC 16.0 is used with Xtal_a = 4.0 MHz or DEC 20 is used with Xtal_b 3.2 MHz.
MF: Mid Freqency DEC 38,9 MHz


Code:
float Na;
float Freq;
 int Nb;
 int Nc;
 int msb;
 int lsb;

Na =Freq+MF;
Nb =Na*Xtal;
Nc =((INT)(Nb/256)) * 256;
lsb =Nb-Nc;
msb =(INT)(Nb/256);

-------------------------
this is the actual reading when the software is running.

the selected frequency = 1 MHz (also with a strange number at the end "1192")

1.0000001192 = Freq
38.9000015258 = MF
16.0000000000 = Xtal
91 = Band
39.9000015258 = Na
638 = Nb
512 = Nc
7E = lsb DR2
2 = msb DR1


hope u have some more information regarding the MF correction

ed
23  Using Arduino / Programming Questions / decimal calculation correction problem on: August 11, 2013, 01:04:50 pm
hi,

this is the code:
Code:
#define MF 38.9
Na = Freq + MF;

When i run the software in the Nano, I see that the decimal MF is 38.9000015258 and not 38.9.

how can i decrease this "15258" to 38.9

i have tried to:
Code:
MFcorr = MF - 15258

but not work well


i appreciate all the help
ed
24  Using Arduino / Programming Questions / 4 x I2C devices check not work propary on: June 18, 2013, 04:27:47 pm
what i am doing wrong.
i need at start-up a I2C check if the connection is made proparly.

Code:
  byte Respond1;                            // At startup, check if I2C Device responding
  byte Respond2;                            // At startup, check if I2C Device responding
  byte Respond3;                            // At startup, check if I2C Device responding
  byte Respond4;                            // At startup, check if I2C Device responding

Code:
void setup()
{
  Serial.begin(9600);
  lcd.begin(24, 2);                                 // Type LCD
  lcd.clear();
  Wire.begin();                                     // Wake up I2C Master. Connect pin 4 (the clock, or SCL, pin) and pin 5 (the data, or SDA, pin)
   
   lcd.setCursor(4,0);
   lcd.print("I2C Initializing");
   lcd.setCursor(0,1);
   
Wire.beginTransmission(Tuner_address_TX);
    Wire.requestFrom(Tuner_address_TX, 1);                      // request 1 bytes from Tuner_address_TX 0x60
    Respond1 = Wire.endTransmission();
  if (Respond1 == 0)
    lcd.print("");
    else
    lcd.setCursor(0,1);
    lcd.print("  I2C ERROR Tuner 0x60  ");
   
 delay(2500);
    lcd.setCursor(0,1);

Wire.beginTransmission(PCF1_BUTTON);
    Wire.requestFrom(PCF1_BUTTON, 1);                      // request 1 bytes from PCF1_BUTTON 0x3E
//    Respond2 = Wire.endTransmission();
  if (Respond2 == 1)
    lcd.print("");
    else
    lcd.setCursor(0,1);
    lcd.print(" I2C ERROR Buttons 0x3E ");

 delay(2500);
    lcd.setCursor(0,1);

Wire.beginTransmission(PCF2_LED);
    Wire.requestFrom(PCF2_LED, 1);                      // request 1 bytes from PCF2_LED 0x3D
    Respond3 = Wire.endTransmission();
  if (Respond3 == 0)
    lcd.print("");
    else
    lcd.setCursor(2,1);
    lcd.print("  I2C ERROR Led's 0x3D  ");

 delay(2500);
    lcd.setCursor(0,1);

Wire.beginTransmission(PCF3_RELAY);
    Wire.requestFrom(PCF3_RELAY, 1);                      // request 1 bytes from PCF3_RELAY 0x3B
    Respond4 = Wire.endTransmission();
  if (Respond4 == 0)
    lcd.print("");
    else
    lcd.setCursor(1,1);
    lcd.print(" I2C ERROR Relay's 0x3B ");

    delay(2500);
    lcd.setCursor(0,1);
   
    lcd.clear();
    lcd.setCursor(7,0);
    lcd.print("I2C Ready");
   
    delay(2000);
    lcd.clear();
25  Using Arduino / Programming Questions / How to change from standard to other digital input on: May 25, 2013, 11:42:41 am
I like to use Digital input 9 and 10
but dont know how to change in this code

Code:
static boolean rotating=false;
void rotEncoder()
{
  rotating=true; // If motion is detected in the rotary encoder,
                 // set the flag to true
}
//...

void setup() {

  // Attach Interrupts
  attachInterrupt(0, rotEncoder, CHANGE);  // ISR for rotary encoder
  //...
  //...
}

void loop() {
  //...

   while(rotating)
  {
    delay(2);  // debounce by waiting 2 milliseconds
               // (Just one line of code for debouncing)
    if (digitalRead(4) == digitalRead(2))  // CCW
    StepDR2--;
    else                          // If not CCW, then it is CW
    StepDR2++;

    rotating=false; // Reset the flag
  }
}

http://playground.arduino.cc/Main/PinChangeInt
Yes, i know.. but how ?...
26  Using Arduino / Programming Questions / How to check the external I2C devices if they are connected on: May 12, 2013, 03:11:08 pm
I have a Arduino Nano and 5 external I2C devices connected with I2C on pin 4 & 5.

When my sketch is starting up, it not detect if a external I2C device is connected. (i have to do this check only once at startup).

i want to create something like
Code:
Wire.requestFrom()

and when a external device is not connected, it return with a message
Code:
lcd.print("I2C Error Device 2");

I dont know if i am on the right way.
some help are appriciate.

thanks
27  Using Arduino / Programming Questions / <MenuBackend.h> Menu control with I2C pushbuttons on: March 16, 2013, 11:53:30 am
hi,

I need some help to remove the ARDUINO PINS and intergrade my I2C pushbuttons in the Menu.

this the the working Menu with ARDUINO PINS. get it from http://playground.arduino.cc/Code/Menu
Code:
#include <MenuBackend.h>
#include <LiquidCrystal.h>

const int buttonPinLeft = 8;
const int buttonPinRight = 9;
const int buttonPinEsc = 10;
const int buttonPinEnter = 11;

int lastButtonPushed = 0;

int lastButtonEnterState = LOW;   // the previous reading from the "Enter" input pin
int lastButtonEscState = LOW;
int lastButtonLeftState = LOW;
int lastButtonRightState = LOW;

long lastEnterDebounceTime = 0;  // the last time the output pin was toggled
long lastEscDebounceTime = 0;
long lastLeftDebounceTime = 0;
long lastRightDebounceTime = 0;
long debounceDelay = 500;    // the debounce time

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

//Menu variables
MenuBackend menu = MenuBackend(menuUsed,menuChanged);
//initialize menuitems
    MenuItem menu1Item1 = MenuItem("Item1");
      MenuItem menuItem1SubItem1 = MenuItem("Item1SubItem1");
      MenuItem menuItem1SubItem2 = MenuItem("Item1SubItem2");
    MenuItem menu1Item2 = MenuItem("Item2");
      MenuItem menuItem2SubItem1 = MenuItem("Item2SubItem1");
      MenuItem menuItem2SubItem2 = MenuItem("Item2SubItem2");
      MenuItem menuItem2SubItem3 = MenuItem("Item2SubItem3");
    MenuItem menu1Item3 = MenuItem("Item3");

void setup()
{
  pinMode(buttonPinLeft, INPUT);
  pinMode(buttonPinRight, INPUT);
  pinMode(buttonPinEnter, INPUT);
  pinMode(buttonPinEsc, INPUT);
  
  lcd.begin(16, 2);

  //configure menu
  menu.getRoot().add(menu1Item1);
  menu1Item1.addRight(menu1Item2).addRight(menu1Item3);
  menu1Item1.add(menuItem1SubItem1).addRight(menuItem1SubItem2);
  menu1Item2.add(menuItem2SubItem1).addRight(menuItem2SubItem2).addRight(menuItem2SubItem3);
  menu.toRoot();
  lcd.setCursor(0,0);  
  lcd.print("message");

}  // setup()...

void loop()
{

  readButtons();  //I splitted button reading and navigation in two procedures because
  navigateMenus();  //in some situations I want to use the button for other purpose (eg. to change some settings)
                  
} //loop()...

void menuChanged(MenuChangeEvent changed){
  
  MenuItem newMenuItem=changed.to; //get the destination menu
  
  lcd.setCursor(0,1); //set the start position for lcd printing to the second row
  
  if(newMenuItem.getName()==menu.getRoot()){
      lcd.print("Main Menu       ");
  }else if(newMenuItem.getName()=="Item1"){
      lcd.print("Scannen         ");
  }else if(newMenuItem.getName()=="Item1SubItem1"){
      lcd.print("Item1SubItem1");
  }else if(newMenuItem.getName()=="Item1SubItem2"){
      lcd.print("Item1SubItem2   ");
  }else if(newMenuItem.getName()=="Item2"){
      lcd.print("Freq band       ");
  }else if(newMenuItem.getName()=="Item2SubItem1"){
      lcd.print("Item2SubItem1   ");
  }else if(newMenuItem.getName()=="Item2SubItem2"){
      lcd.print("Item2SubItem2   ");
  }else if(newMenuItem.getName()=="Item2SubItem3"){
      lcd.print("Item2SubItem3   ");
  }else if(newMenuItem.getName()=="Item3"){
      lcd.print("Freq invoer      ");
  }
}

void menuUsed(MenuUseEvent used){
  lcd.setCursor(0,0);  
  lcd.print("message");
  lcd.setCursor(0,1);
  lcd.print(used.item.getName());
  delay(3000);  //delay to allow message reading
  lcd.setCursor(0,0);  
  lcd.print("message");
  menu.toRoot();  //back to Main
}

void  readButtons(){  //read buttons status
  int reading;
  int buttonEnterState=LOW;             // the current reading from the Enter input pin
  int buttonEscState=LOW;             // the current reading from the input pin
  int buttonLeftState=LOW;             // the current reading from the input pin
  int buttonRightState=LOW;             // the current reading from the input pin

  //Enter button
                  reading = digitalRead(buttonPinEnter);


                  if (reading != lastButtonEnterState) {

                    lastEnterDebounceTime = millis();
                  }
                  
                  if ((millis() - lastEnterDebounceTime) > debounceDelay) {

                    buttonEnterState=reading;
                    lastEnterDebounceTime=millis();
                  }

                  lastButtonEnterState = reading;
                  
                  reading = digitalRead(buttonPinEsc);

                  if (reading != lastButtonEscState) {

                    lastEscDebounceTime = millis();
                  }
                  
                  if ((millis() - lastEscDebounceTime) > debounceDelay) {

                    buttonEscState = reading;
                    lastEscDebounceTime=millis();
                  }
                  
                  lastButtonEscState = reading;                   

                  reading = digitalRead(buttonPinRight);

                  if (reading != lastButtonRightState) {
                    // reset the debouncing timer
                    lastRightDebounceTime = millis();
                  }
                  
                  if ((millis() - lastRightDebounceTime) > debounceDelay) {

                    buttonRightState = reading;
                   lastRightDebounceTime =millis();
                  }
                  
                  lastButtonRightState = reading;                  
                  
                  if (reading != lastButtonLeftState) {

                    lastLeftDebounceTime = millis();
                  }
                  
                  if ((millis() - lastLeftDebounceTime) > debounceDelay) {

                    buttonLeftState = reading;
                    lastLeftDebounceTime=millis();;
                  }
                  
                  lastButtonLeftState = reading;  

                  if (buttonEnterState==HIGH){
                    lastButtonPushed=buttonPinEnter;

                  }else if(buttonEscState==HIGH){
                    lastButtonPushed=buttonPinEsc;

                  }else if(buttonRightState==HIGH){
                    lastButtonPushed=buttonPinRight;

                  }else if(buttonLeftState==HIGH){
                    lastButtonPushed=buttonPinLeft;

                  }else{
                    lastButtonPushed=0;
                  }                  
}

void navigateMenus() {
  MenuItem currentMenu=menu.getCurrent();
  
  switch (lastButtonPushed){
    case buttonPinEnter:
      if(!(currentMenu.moveDown())){  //if the current menu has a child and has been pressed enter then menu navigate to item below
        menu.use();
      }else{  //otherwise, if menu has no child and has been pressed enter the current menu is used
        menu.moveDown();
       }
      break;
    case buttonPinEsc:
      menu.toRoot();  //back to main
      break;
    case buttonPinRight:
      menu.moveRight();
      break;      
    case buttonPinLeft:
      menu.moveLeft();
      break;      
  }
  
  lastButtonPushed=0; //reset the lastButtonPushed variable
}

This is the I2C pushbutton control i want to use in the menu, instead of the ARDUINO PINS.
Code:
{
  Wire.requestFrom(PCF1_BUTTON, 1);
  if(Wire.available())                              // If the request is available from the PCF1_BUTTON
{
    PCF_1=Wire.read();                              // Receive the data from the PCF1_BUTTON
}
    if(PCF_1<255)                                   // If the button data is less than 255
{
    if (PCF_1==254) { buttonLeft; };
    if (PCF_1==253) { buttonRight; };
    if (PCF_1==251) { buttonEsc; };
    if (PCF_1==247) { buttonEnter; };

}

I wil appreciatie any help
28  Using Arduino / Programming Questions / Re: PCF8574AN configured as output for relay on: February 16, 2013, 05:10:33 pm
thanks for posting Mike,

just with some help i almost finish the project.

it is only this past part with the PCF what makes it hard to find out.
29  Using Arduino / Programming Questions / Re: PCF8574AN configured as output for relay on: February 16, 2013, 03:52:36 pm
Quote
when you want to turn it off then use
Code:
setOutput(4);

Quote
when you want to turn it off then use
Code:
clearOutput(4);

also where to put those
30  Using Arduino / Programming Questions / Re: PCF8574AN configured as output for relay on: February 16, 2013, 02:42:08 pm
sorry, i dont get it working.
Pages: 1 [2] 3 4