Recent Posts

Pages: [1] 2 3 ... 10
1
@koepel, thanks for the feedback.

That 'while' was straight from the Arduino example, but I've updated with your suggestions.
2
Thanks for the feedback.
3
General Electronics / Re: logic level shifter
Last post by MorganS - Today at 11:18 pm
Optoisolator first.

Two transistors would be the next choice but you need to do calculations on base resistors and so on. Then two MOSFETs, but you need both P- and N-types.

The Opamp can be wired as a non-inverting comparator. This will be about as simple as the two transistors, in terms of component count.
4
Software / Re: 8 Switcher controlador de ...
Last post by surbyte - Today at 11:18 pm
Yo te pedí algo y no respondiste
5
Project Guidance / Re: Volume Control for Separat...
Last post by dougp - Today at 11:17 pm
If possible I'd like to use an Arduino to achieve this.

There would be a button that would start a bird song playing. This bird has two vocal cords that work simultaneously.
The visitor could control the volume from two knobs (one for each part of the bird song) to hear the differences.
What part does the Arduino play in this?
6
Sorry it didn't upload my pics last time
7
General Electronics / Re: LT3580 boost 5v to 12v
Last post by MorganS - Today at 11:13 pm
I am not an expert on switching power supplies but I've read a few guides and tried to lay down a couple on a PCB design recently. (Not back from manufacturing yet.)

The datasheet says the ground connection is the exposed pad on the bottom of the chip. Your layout doesn't seem to connect to that. Your pencil sketch also doesn't show a GND connection.


Further enhancements for the PCB layout...

Minimise the area of the SW node. Push the diode closer to the inductor.

Minimise the area of the high-current loops. The big trace that arches around the top could be run much closer to the chip. Remember when the switch is 'closed' there is a lot of current going through the inductor and into the ground pad on the chip. This current goes from zero to maximum at high frequency so try to make this loop smallest of all, to reduce EMI radiation.

8
Programming Questions / Re: iteration 647 invokes unde...
Last post by Tune - Today at 11:12 pm
Ray, thanks for replying. I understand the loop() function runs forever.

My problem is that the embedded for loop

Code: [Select]

for (counter=1;counter < 1000;counter++)
  {
 
 
  }


which I coded also runs forever. The Serial.print statements just keep coming and include values of counter way past 1000.
Also
Code: [Select]

 Serial.println("ERROR 10");


Which exists outside my for loop is NEVER executed.

I would expect it to be executed each time the counter reaches 1000 and the for loop terminates. but the for loop never terminates, counter just keeps increasing forever.
9
Hi, I'm developing an application with the W5500 ethernet shield.
In a few words, a maximum of two different clients can connect to arduino (acting as a server). When the shield detects the first incoming server connection, it have to estabilish a connection with an external server and acts as a data gateway.

When arduino is connected on BOTH sides (server+client), it stops receiving data from the client. Additionally, if I have no servers listening, the arduino itself stops receiving data from the client after 7 connection attempts.

Thanks a lot
Marco

10
I somehow cannot see the problem...Any help would be appreciated.
Below I added the suspected code (i can't paste teh complete code because I exceed the 9000 characters  :o ).
Its not finished but allready problems start to occur.
There is probably a lot code that can be improved, but which part is causing my problems?
If needed i can upload the complete program.

Code: [Select]
void menuLoop() {
  static byte mainScrIndex = 0, prevMainScrIndex = -1;
  static byte paramIndex = 0, prevParamIndex = -1;
  static byte menuLevel = 0;
  static bool paramEdit = false;
  static bool mainScrIndexSel;
  byte menuItems;
  boolean editableParam;
  static byte aciveLineNr, passiveLineOffset;

  //rotary encoder
  rotate();

  //Level 0 = Scrolling/editing main screen items
  if (menuLevel == 0) {

    //Scrolling main menu items
    if (!paramEdit) {
      scrollingMainMenu(&aciveLineNr, &mainScrIndex, &editableParam );
      if (buttonShortPress() && editableParam == true) {
        paramEdit = 1;
      }
    }

    //Editing main menu item
    if (paramEdit) {
      editMainSCreenItem(mainScreen, mainScrIndex, aciveLineNr, &paramEdit);
      if (!paramEdit) {
        showMainSCreenItem(mainScreen, mainScrIndex, aciveLineNr); //Update screen
      }
    }

    //Go to parameter list
    if (buttonLongPress()) {
      menuLevel = 1;
      paramIndex = 0; //Reser parameter index
      showParameterItem(ParamsTest, paramIndex); //Show parameter
    }
  }


  //Scroll parameter list of selected parameter item
  if (menuLevel == 1) {   
    //Serial.println("Menu level 1");
    if (!paramEdit) {
      menuItems = (sizeof(ParamsTest) / sizeof(paramType));
      paramIndex = getScaledEncValue(paramIndex, 0, menuItems, 1, false);
      if (paramIndex != prevParamIndex) {
        if (paramIndex < menuItems) {
          showParameterItem(ParamsTest, paramIndex );
        }
        else { //Show go back
          printGoBack();
        }
      }
    }

    //'Go back' is selected
    if (paramIndex == menuItems) {
      if (buttonShortPress()) {
        menuLevel = 0;
        paramEdit = false;
        showMainSCreenItem(mainScreen, prevMainScrIndex, 0 );
      }
    }

    //if parameter selected go to edit mode
    if (!paramEdit && (paramIndex != menuItems)) {
      paramEdit = buttonShortPress();
    }

    //Edit selected parameter
    if (paramEdit == true) {
      editParameterItem(ParamsTest, paramIndex, &paramEdit);
    }
 }

  prevMainScrIndex = mainScrIndex;
  prevParamIndex = paramIndex;
}

void scrollingMainMenu(byte *aciveLineNr, byte *mainScrIndex, boolean *editableParam){
  byte menuItems; 
  //static byte mainScrIndex = 0, prevMainScrIndex = -1;
  static byte prevMainScrIndex = -1;
  //static byte aciveLineNr, passiveLineOffset;
  static byte passiveLineOffset;
  static bool paramEdit = false;
  static bool mainScrIndexSel;
 
    //Scrolling main menu items
    menuItems = (sizeof(mainScreen) / sizeof(mainScreenType));
    *mainScrIndex = getScaledEncValue(*mainScrIndex, 0, menuItems - 1, 1, false);
    if (*mainScrIndex != prevMainScrIndex) {
      lcd.clear();
      if (*mainScrIndex > prevMainScrIndex) { //Scrolling down
        *aciveLineNr = 1;
        passiveLineOffset = -1;
      }
      else { //Scrolling up
        *aciveLineNr = 0;
        passiveLineOffset = 1;
      }
      showMainSCreenItem(mainScreen, *mainScrIndex, *aciveLineNr); //Show selected main screen item
      showMainSCreenItem(mainScreen, *mainScrIndex + passiveLineOffset, *aciveLineNr + passiveLineOffset); //Show other line
      lcd.setCursor(15, *aciveLineNr);
      lcd.print('*');
    }

    prevMainScrIndex = *mainScrIndex;
   
    //Edit selected main menu item if there is one
    if (checkMenuSpPresent(mainScreen, *mainScrIndex)) {     
      *editableParam = true;     
    }
    else{
      *editableParam = false;
    }
   
}

void showMainSCreenItem(mainScreenType *PmainScreenType, byte index, byte lineNumber) {
  mainScreenType LmainScreenType; //Create a temporary parameter item
  byte titleLength, argLength;
  //Copy parameter struct to local data
  memcpy_P (&LmainScreenType, PmainScreenType + index, sizeof LmainScreenType); //Copy parameter info from progmem

  titleLength = strlen (LmainScreenType.title);
  argLength = findn(*LmainScreenType.setpoint);

  lcd.setCursor(0, lineNumber);
  lcd.print(LmainScreenType.title);
  lcd.print(' ');

  printMainScreenParam(LmainScreenType.procesValue, LmainScreenType.decimals, false, lineNumber, titleLength + 1, argLength);
  lcd.print(LmainScreenType.unit);
}

void editMainSCreenItem(mainScreenType *PmainScreenType, byte index, byte lineNumber, boolean *paramEdit) {
  mainScreenType LmainScreenType; //Create a temporary parameter item
  static int prevValue;
  static bool prevBlink;
  byte titleLength, argLength;
  int setpoint;
  //Copy parameter struct to local data
  memcpy_P (&LmainScreenType, PmainScreenType + index, sizeof LmainScreenType); //Copy parameter info from progmem
  //change setpont value 
  *LmainScreenType.setpoint = getScaledEncValue(*LmainScreenType.setpoint, LmainScreenType.minValue, LmainScreenType.maxValue, 1, false);

  //Update screen when value changes
  if ((prevValue != *LmainScreenType.setpoint) || (prevBlink != blink_500ms)) {
    titleLength = strlen (LmainScreenType.title);
    argLength = findn(*LmainScreenType.setpoint);
    printMainScreenParam(LmainScreenType.setpoint, LmainScreenType.decimals, true, lineNumber, titleLength + 1, argLength);
    lcd.print(LmainScreenType.unit);
  }
 
  //Stop editing
  if (buttonShortPress()) {
    *paramEdit = 0;
    Serial.println("SAVE SP HERE!");
  }

  prevValue = *LmainScreenType.setpoint;
  prevBlink = blink_500ms;
}

void showParameterItem(paramType *PparamType, byte index) {
  static paramType LparamType; //Create a temporary parameter item
  //Copy parameter struct to local data
  memcpy_P (&LparamType, PparamType + index, sizeof LparamType); //Copy parameter info from progmem
  //Print title and paramter values
  printParamTitle(LparamType.title);
  printParamValues(LparamType.parameter1, LparamType.parameter2, LparamType.unit);
}

void editParameterItem(paramType *PparamType, byte index, bool *paramEdit) {
  //editParameterItem(paramType *PparamType, byte index) {
  paramType LparamType; //Create a temporary parameter item
  static int value = 0, prevValue = 0;
  byte nrOffParams;
  static byte paramIndex = 1;

  //Copy parameter struct to local data
  memcpy_P (&LparamType, PparamType + index, sizeof LparamType); //Copy parameter info from progmem

  //If two parameters to edit (time parameter)
  if (LparamType.parameter2 != NULL) {
    nrOffParams = 2; //two parameter to edit
  }
  else {
    nrOffParams = 1; //One parameter to edit
  }
 
  switch (paramIndex) {
    case 1:
      *LparamType.parameter1 = getScaledEncValue(*LparamType.parameter1, LparamType.minValue, LparamType.maxValue, 1, false);
      value = *LparamType.parameter1;
      if (value != prevValue) {
        printParamValues(LparamType.parameter1, LparamType.parameter2, LparamType.unit);
      }
      break;
    case 2:
      *LparamType.parameter2 = getScaledEncValue(value = *LparamType.parameter2, LparamType.minValue, LparamType.maxValue, 1, false);
      value = *LparamType.parameter2;
      if (value != prevValue) {
        printParamValues(LparamType.parameter1, LparamType.parameter2, LparamType.unit);
      }
      break;
  }

  //If not editing the last parameter go to next parameter
  if (paramIndex < nrOffParams ) {
    //Finished editting
    if (buttonShortPress()) {
      paramIndex++;
      Serial.println(F("Next param"));
    }
  }
  else { //Finished editting
    if (buttonShortPress()) {
      *paramEdit = false;
      paramIndex = 1; //Reset
      Serial.println(F("Finished editing")); //Removing F and the code works with no noticeable problems!!!!
      return true;
    }
  }

  prevValue = value;
  return false;
}

void printGoBack() {
  lcd.clear();
  lcd.setCursor(0, 0); // top left
  lcd.print(F("<- Go back"));
}

boolean checkMenuSpPresent(mainScreenType *PmainScreenType, byte index) {
  mainScreenType LmainScreenType; //Create a temporary parameter item

  //Copy parameter struct to local data
  memcpy_P (&LmainScreenType, PmainScreenType + index, sizeof LmainScreenType); //Copy parameter info from progmem
  if (LmainScreenType.setpoint != NULL) {
    return true;
  }
  else {
    return false;
  }
}
Pages: [1] 2 3 ... 10