Go Down

Topic: Object counter « counting box » (Read 2189 times) previous topic - next topic

Nagaro

#30
Apr 15, 2019, 10:44 pm Last Edit: Apr 15, 2019, 10:48 pm by Nagaro
Hi,

Attached the Fritzing schematic from this project.
I've tried to make it as easy to read as possible.

Can somebody validate it, or tell me what to change/improve ?

Thank you,

dougp

#31
Apr 15, 2019, 11:48 pm Last Edit: Apr 15, 2019, 11:53 pm by dougp
It's a very nice looking drawing but, (sorry) for a circuit of more than a few connections it becomes very difficult for someone not familiar with the thing to decode what they're seeing.  This is because with all the components out there, some with tens of pin connections, it's nearly impossible to tell just by looking how something is wired up.  Most experienced people are used to looking at schematics where the parts' pins are named & numbered so you can see at a glance what's connected to what.  Here's an example from Maxim's site:



This emphasizes the Maxim part but it illustrates the principle.  A full schematic would include all  connections, with pin names/numbers, for all  components.  Unfortunately this would also mean expanding signals grouped into a single line for brevity like the digit and segment lines in the drawing.

Even a hand-drawn schematic including the pin names/numbers is better in this case than a pictorial and would, IMHO, get more responses and allow people to see more exactly how you've made all the connections and so give an informed response.

Yes, it's more work but it would be a useful experience.  Besides, you'll need a real drawing to work from and to have available for future reference.  There are choices of drawing software but I use the free ExpressSCH.
Everything we call real is made of things that cannot be regarded as real.  If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet. - Niels Bohr

No private consultations undertaken!

wvmarle

Agreed, totally unreadable. Especially as the MAX7219 and display pinouts are not given. So can't tell whether the connections are correct or not.

No decoupling cap at the MAX7219. That's an issue.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Nagaro

Ahah, i guessed you would answer that it's unreadable :-)

I'll try to make a more readable one, following your advices.

Also, i'll add the 10 uf electrolytic and 0.1uf(100n) ceramic capacitors, as it seems like it's mandatory to have them.

Would that be ok ?

Thanks,

wvmarle

The 100n one yes - all digital ICs need one. You can also see one in the reference circuits of the datasheet, p.12/13.

The 10u, where did you find this? I don't see an obvious need for it, but that doesn't mean it's not necessary.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Nagaro

Great, thank you. I can even see where to install it :-)

For the second capacitor, i found it there :
https://thecustomizewindows.com/2017/11/arduino-max-7219-cng-basic-circuit-led-7-segment-displays/
Honestly, i trust more what you say than any website. So if you say only the one for 100 nm is enough, then i'll only install this one :-) I need to order it too :-)

I'll update the Fritzing sketch, but that might take some days. In between, i'll start with the Arduino code, as now i know exactly which components i use, so i have all ly inputs/outputs.

wvmarle

Trust the manufacturer's data sheet; not what random people (including myself) tell you on the Internet.

Just checked the link - and found one major issue in the image where they have the two capacitors, and that's with the physical layout.

The 100nF should be placed physically as close as possible to the pin. That wire is a pretty bad thing here, it adds stray induction which in turn negates a lot of the effect of that cap. The 100 nF should go between the GND bus and the strip the Vcc pin is connected, when placing it on a breadboard (and even closer when you're using a proper PCB - there are chips that have the GND and Vcc power pins next to one another, soldering a 0805 package on top of those two leads is then the ideal placement).

Adding a 10µF electrolytic capacitor won't hurt, anyway. Just try it out.

If you order components you may consider adding a pack of 20 x 10 values of electrolytic, and 20 x 30 values of ceramics. Something like that. It's just very convenient to have those values on hand even if you end up not using half of them, they're really cheap so it's not much of a financial investment.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Nagaro

Awesome, thank you for the advise. I'll take care of it when i'll have all components to make the physical layout.

Nagaro

Hi,

I was writting the code, everything was going well until i got this error message : Exit status 1, Error compiling for board Arduino Nano.
Do you know what can be the problem ?

Below the code (not finished yet, as i'm still checking how to display the numbers with the Max7219+7segments) :

Code: [Select]

#include "LedControl.h"
LedControl lc = LedControl(4,5,6,4);

// ----- Code for Change State for FC-51
// this constant won't change:
const int  PinFC51 = 2;    // the pin that the pushbutton is attached to
const int  PinButtonPlus1 = 3;    // the pin that the pushbutton is attached to
const int  PinButtonMinus1 = 4;    // the pin that the pushbutton is attached to
const int  PinButtonReset = 5;    // the pin that the pushbutton is attached to
const int PinLED = 13;       // the pin that the LED is attached to

// Variables will change:
int buttonStateFC51 = 0;         // current state of the FC51
int lastButtonStateFC51 = 0;     // previous state of the FC51

int buttonStatePlus1 = 0;         // current state of the button
int lastButtonStatePlus1 = 0;     // previous state of the button

int buttonStateMinus1 = 0;         // current state of the button
int lastButtonStateMinus1 = 0;     // previous state of the button

int buttonStateReset = 0;         // current state of the button

int FC51 = 0;
int ButtonPlus1 = 0;
int ButtonMinus1 = 0;
int ButtonReset = 0;


// ----- Code for Max7219 + LEDs
int count = 1000;


void setup()
{

// ----- Code for Change State for FC-51
  // initialize the button pin as an input:
  pinMode(PinFC51, INPUT);
  pinMode(PinButtonPlus1, INPUT);
  pinMode(PinButtonMinus1, INPUT);
  pinMode(PinButtonReset, INPUT);
 
  // initialize the LED as an output:
  pinMode(PinLED, OUTPUT);
 
  // initialize serial communication:
  Serial.begin(9600);

// ----- Code for Max7219 + LEDs
    lc.shutdown(0,false);
    lc.setIntensity(0,5);
    lc.clearDisplay(0);
}

void loop() {

// if FC51 changes the state, it does +1
ChangeStateFC51();
if (FC51 == 1) {
  Plus1();
  Update7segment();
  FC51=0;
  }

// if PushButtonPlus1 is active, it does +1
PushButtonPlus1();
if (ButtonPlus1 == 1) {
  Plus1();
  Update7segment();
  ButtonPlus1=0;
  }

// if PushButtonMinus1 is active, it does -1
PushButtonMinus1();
if (ButtonMinus1 == 1) {
  Minus1();
  Update7segment();
  ButtonMinus1=0;
  }

// if PushButtonReset is active, it resets to 0
PushButtonReset();
if (ButtonReset == 1) {
  Reset();
  Update7segment();
  ButtonReset=0;
  }

}

void ChangeStateFC51() {

  // read the FC51 input pin:
  buttonStateFC51 = digitalRead(PinFC51);

  // compare the buttonState to its previous state
  if (buttonStateFC51 != lastButtonStateFC51) {
    // if the state has changed from low to high, increment the counter otherwise don't
    if (buttonStateFC51 == HIGH) {
      FC51=1;
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  lastButtonStateFC51 = buttonStateFC51;

}

void PushButtonPlus1() {
 
  // read the pushbutton input pin:
  buttonStatePlus1 = digitalRead(PinButtonPlus1);

  // compare the buttonState to its previous state
  if (buttonStatePlus1 != lastButtonStatePlus1) {
    // if the state has changed from low to high, increment the counter otherwise don't
    if (buttonStatePlus1 == HIGH) {
      ButtonPlus1=1;
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  lastButtonStatePlus1 = buttonStatePlus1;
 
}

void PushButtonMinus1() {
 
  // read the pushbutton input pin:
  buttonStateMinus1 = digitalRead(PinButtonMinus1);

  // compare the buttonState to its previous state
  if (buttonStateMinus1 != lastButtonStateMinus1) {
    // if the state has changed from low to high, increment the counter otherwise don't
    if (buttonStateMinus1 == HIGH) {
      ButtonMinus1=1;
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  lastButtonStateMinus1 = buttonStateMinus1;
 
}

void PushButtonReset() {
 
  // read the pushbutton input pin:
  buttonStateReset = digitalRead(PinButtonReset);

  // compare the buttonState to its previous state
  if (buttonStateReset = 1) {
      ButtonReset=1;
    }
    // Delay a little bit to avoid bouncing
    delay(50);

}

void Plus1()
{
 
}

void Minus1()
{
 
}

void Reset()
{
 
}

void Update7segment() {

// ----- Code for Max7219 + LEDs
    String t = String(count++);
    lc.setDigit(0,0,(int)(t[0]-'0'),true);
    lc.setDigit(0,1,(int)(t[1]-'0'),false);
    lc.setDigit(0,2,(int)(t[2]-'0'),false);
    lc.setDigit(0,3,(int)(t[3]-'0'),false);
    delay(100);
    lc.shutdown(0,true);
    lc.shutdown(0,false);

}



PS : If you find already something wrong in the code (not linked to this issue), you can already let me know :-)

wvmarle

Why don't you post the whole error message? The problem is in the part you didn't post... the part where the compiler tells you what happened.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Nagaro

#40
Apr 18, 2019, 07:25 am Last Edit: Apr 18, 2019, 07:26 am by Nagaro
Here is the full error message :


Code: [Select]

C:\Users\xxx\Documents\Arduino\libraries\LedControl\src\LedControl.cpp: In function 'setDigit.constprop':

C:\Users\xxx\Documents\Arduino\libraries\LedControl\src\LedControl.cpp:169:1: internal compiler error: Segmentation fault

 }

 ^

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://gcc.gnu.org/bugs.html> for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Erreur de compilation pour la carte Arduino Nano



Hope it will help more :-)

wvmarle

"internal compiler error"

That's about the last I expected to see! Exit status 1 is most commonly an undeclared variable, or closing } missing, something like that. Tbh no idea how to handle this one. Nasty. You just ran into a compiler bug.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

dougp

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://gcc.gnu.org/bugs.html> for instructions.
I would: not alter this code at all.  Save a copy of the code which produced this error and supply the information requested as above.
Everything we call real is made of things that cannot be regarded as real.  If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet. - Niels Bohr

No private consultations undertaken!

Nagaro

Hi,

I actually found on a forum on arduino a workaround for this bug (which is a compiler bug, you're right. I changed the Arduino AVR Boards from version 1.6.23 to 1.6.21 in the preferences, and the issue doesn't appear anymore.
I'll anyway submit the issue via the link as dougp proposed, and continue to write the code. And let's see if the support team will solve the issue, that i can come back to the newer version of the Arduino AVR Board.

wvmarle

The bug itself is in gcc, not Arduino, but it's a very specific interaction between your code, the Arduino IDE and the compiler itself that triggers it.

So when submitting the bug add as much detail of your system as possible, especially the IDE version, so they have a chance of reproducing it, and hopefully fixing the problem.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up