Pages: 1 [2]   Go Down
Author Topic: Psuedo Random 4 LED twinkler  (Read 3070 times)
0 Members and 1 Guest are viewing this topic.
Peoria AZ
Offline Offline
Newbie
*
Karma: 2
Posts: 44
Professional Hobbyist with Minor Experience
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In other words, floating inputs are most certainly not a problem for AVR processors.  That's how they are initialized after a reset or power-up.

If this i the case then this would solve that problem. I have a bunch of these so I will test it out over a period of time to see if there are any issues.

Moderator edit: changed the strikeout to underscore
« Last Edit: December 28, 2013, 06:25:38 pm by Coding Badly » Logged

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. smiley-lol

Peoria AZ
Offline Offline
Newbie
*
Karma: 2
Posts: 44
Professional Hobbyist with Minor Experience
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, it's on the internet so it must be true.   smiley-wink

more like "the guy brought up a valid point so it must need some consideration."

looking over that article you posted in the first introductory paragraph I can see where he got that idea from.

"both CMOS and BiCMOS families have a CMOS input structure. This structure is an inverter consisting of a p-channel to V
CC and an n-channel to GND. With low-level input, the p-channel transistor is on and the n-channel is off,
causing current to flow from VCC and pulling the node to a high state. With high-level input, the n-channel transistor is on,
the p-channel is off, and the current flows to GND, pulling the node low. In both cases, no current flows from VCC
to GND.
However, when switching from one state to another,
" (or in my case, floating between states) "the input crosses the threshold region, causing the n-channel and the
p-channel to turn on simultaneously, generating a current path between VCC
and GND. This current surge can be damaging,
depending on the length of time that the input is in the threshold region (0.8 to 2 V). The supply current can rise to several
milliamperes per input...
"

but then it also states below

"...This is not a problem when switching states within
the data-sheet-specified input transition time limit specified in the recommended operating conditions table for the specific
devices
."

So I'm assuming that you would not consider the floating pin on the AVR to be in the threshold region of the gates? does it matter if its switching or not during that time?
this is all kind of just above my experience level, the internet is my only source as well. misinformation needs to be corrected.
« Last Edit: December 28, 2013, 06:38:25 pm by SargentSeven » Logged

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. smiley-lol

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, it's on the internet so it must be true.   smiley-wink
more like "the guy brought up a valid point so it must need some consideration."

It is not a valid point.  The guy is an idiot.  A little basic logic proves my point: Hundreds of millions of AVR processors have been sold (billions of similar products).  For all AVR processors (and the vast majority of other products) the inputs are set to high impedance / floating after a reset / power-up.  If floating inputs for microcontrollers were a problem a large percent would have cooked when first powered and Atmel, Microchip, Intel, and a long list of other companies would be out of business.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

this is all kind of just above my experience level, the internet is my only source as well. misinformation needs to be corrected.

Incorrect.  The internet-at-large is not your only source of information.  Atmel's website is a far better place to look for answers...
https://www.google.com/search?q=atmega328+datasheet
http://www.atmel.com/Images/doc8161.pdf
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So I'm assuming that you would not consider the floating pin on the AVR to be in the threshold region of the gates? does it matter if its switching or not during that time?

Makes no difference.  The processor is perfectly stable with floating inputs.
Logged

Peoria AZ
Offline Offline
Newbie
*
Karma: 2
Posts: 44
Professional Hobbyist with Minor Experience
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the atmel website is on the internet isn't it?

I understand your a moderator but why do so many of you on here have such an attitude?

And as far as I'm concerned on the subject, yes it is fine when the pin ISN'T CONNECTED TO ANYTHING and in a floating state. but in this circuit that is not the case, there is a full circuit. so your point is invalid. and calling someone else an idiot is no way to behave as a moderator.
How about you take yourself somewhere else and let someone who can prove their point without being a d-bag get a chance to talk.
I've lost any and all respect for you.
Logged

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. smiley-lol

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

the atmel website is on the internet isn't it?

Which is why I included the phrase "at large".

Quote
I understand your a moderator but why do so many of you on here have such an attitude?

It's just me.  The others are better behaved.

Quote
And as far as I'm concerned on the subject, yes it is fine when the pin ISN'T CONNECTED TO ANYTHING and in a floating state. but in this circuit that is not the case, there is a full circuit. so your point is invalid.

If you say so.

Quote
and calling someone else an idiot is no way to behave as a moderator.

I am an honest person.  A duck is a duck.  I'm not going to lie about it.  (I hope you understand that I was not calling you an idiot.)

Quote
How about you take yourself somewhere else...

No.  I like it here.

Quote
...and let someone who can prove their point without being a d-bag get a chance to talk.

I'm a douchbag for calling someone an idiot but you are not a douchbag for calling me one.  Got it.

Quote
I've lost any and all respect for you.

Is there an actual loss involved?  Based on the fact that you just called me (someone you just met) a douchbag I assume you never had any respect for me.

In any case, I like your project.  Thank you for taking the time to post about it.  (In case you believe I am being sarcastic I refer you to the "duck" paragraph above.)
« Last Edit: December 28, 2013, 08:39:15 pm by Coding Badly » Logged

Peoria AZ
Offline Offline
Newbie
*
Karma: 2
Posts: 44
Professional Hobbyist with Minor Experience
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Which is why I included the phrase "at large".
 
Believe me, the internet in general includes the datasheets and articles from manufacturers.
Quote
It's just me.  The others are better behaved.
not as far as I've seen the last 2 years I've been lurking this site for information
Quote
If you say so.
I will be sure to post a topic about it in the forums to see what everyone else says, just to be clear. Let me clarify that I'm not presuming to know for sure, but based on evidence given i feel that you may be mistaken because you did not include the involved circuit.
Quote
I am an honest person.  A duck is a duck.  I'm not going to lie about it.  (I hope you understand that I was not calling you an idiot.)
I didn't feel you did, but regardless, I still feel that a person in your position on this forum should have a little more tact.
Quote
No.  I like it here.
Ok, but then I'll go ahead and prove my points if you really want to stay and listen.
Quote
I'm a douchbag for calling someone an idiot but you are not a douchbag for calling me one.  Got it.
Even though I feel there is a difference between being called out and name calling, Yes.
Quote
Is there an actual loss involved?  Based on the fact that you just called me (someone you just met) a douchbag I assume you never had any respect for me.
Initially yes, because you are a Moderator and I have seen your screen name numerous times here, some times you have good information and other times you just kind of troll on people. in any case I always give people the benefit of the doubt.
Quote
In any case, I like your project.  Thank you for taking the time to post about it.
I do believe your sincerity here, its unfortunate that the whole thread turned into a debate, however I feel that anyone coming here to learn may benefit from this, like i said I will delve into this further and post my results here for others to see. I have another project on the breadboard at the moment but I will probe around later to find out whats going on. I have a feeling that there is a difference between an open pin being left floating as an input and a pin floating while connected to a couple diodes in this configuration. like i had said before, the main idea here is in the code. The use of the random function and a Switch case is the biggest thing.
TL;DR     Moderators should have more tact, the initial problem will be resolved with more research.
« Last Edit: December 28, 2013, 09:02:08 pm by SargentSeven » Logged

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. smiley-lol

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5754
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Quote
and calling someone else an idiot is no way to behave as a moderator.

I am an honest person.  A duck is a duck.  I'm not going to lie about it.  (I hope you understand that I was not calling you an idiot.)
 

If somebody's being an idiot then you're not doing them any favors by being polite to them.

Call them an idiot, let them feel bad for a while, job done.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

NSW Australia
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3718
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The reason I used the internal pullup resistors is because I had read that with any CMOS chip, if you leave an input pin floating in this circuit, you could damage the chip. is this not true for the AVR chips?

here is my source for this information, .... neufeld.newton.ks.us/electronics

Well, the responder "mazzoo" is talking through his hat but I'm not sure the article author is all that alert either.  The circuit he cites as "Boosting the Drive Current" not only does not work when the input is tri-stated, it never works under any conditions!

This appears to be a good description of the problem...

I'm too lazy to read it thoroughly but ...

The gist of it is, it might be a problem if you have several dozen gates floating.  It cites maybe 4 mA per floating gate, so 36 gates together could pull 150 mA and cause heating.

The thing is - the ATmega328 has eight analog inputs, two of which are always floating in the DIP on the UNO as I gather - but have no digital input infrastructure.  The others however, as has been stated elsewhere, always have a digital input identical to all other ports and are intended to have any voltage within the supply range applied for indefinite periods.

It would be an interesting experiment to observe what these various inputs are doing - so I decided to do just that.

Code:
/* Input scanner demo
Code for max 7219 from maxim, reduced and optimised for using multiple 7219 cascaded,
______________________________________   */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define lcdAddr 0x20 // set the address of the I2C device the LCD is connected to

// create an lcd instance with correct constructor for how the lcd is wired to the I2C chip
       // addr, EN, RW, RS, D4, D5, D6, D7, Backlight, POLARITY
LiquidCrystal_I2C lcd(lcdAddr, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE);

int dataIn = 2;            // "DIN" on module
int load = 3;              // "CS" on module
int clock = 4;             // "CLK" on module
const int ledPin =  13;    // LED pin number

int maxInUse = 3;          // set how many MAX7219's used
int ledState = LOW;        // initialise the LED

int e = 0;                 // just a varialble

// define max7219 registers
byte max7219_reg_noop        = 0x00;
byte max7219_reg_digit0      = 0x01;
byte max7219_reg_digit1      = 0x02;
byte max7219_reg_digit2      = 0x03;
byte max7219_reg_digit3      = 0x04;
byte max7219_reg_digit4      = 0x05;
byte max7219_reg_digit5      = 0x06;
byte max7219_reg_digit6      = 0x07;
byte max7219_reg_digit7      = 0x08;
byte max7219_reg_decodeMode  = 0x09;
byte max7219_reg_intensity   = 0x0a;
byte max7219_reg_scanLimit   = 0x0b;
byte max7219_reg_shutdown    = 0x0c;
byte max7219_reg_displayTest = 0x0f;


void putByte(byte data) {
  byte i = 8;
  byte mask;
  while(i > 0) {
    mask = 0x01 << (i - 1);      // get bitmask
    digitalWrite( clock, LOW);   // tick
    if (data & mask) {           // choose bit
      digitalWrite(dataIn, HIGH);// send 1
    } else {
      digitalWrite(dataIn, LOW); // send 0
    }
    digitalWrite(clock, HIGH);   // tock
    --i;                         // move to lesser bit
  }
}

// maxSingle is the "easy" function to use for a single max7219
void maxSingle( byte reg, byte col) {    
  digitalWrite(load, LOW);  // begin    
  putByte(reg);             // specify register
  putByte(col);             //((data & 0x01) * 256) + data >> 1); // put data  
  digitalWrite(load,HIGH);
}

// initialize all MAX7219's
void maxAll( byte reg, byte col) {
  int c = 0;
  digitalWrite(load, LOW);
  for ( c =1; c<= maxInUse; c++) {
  putByte(reg);             // specify register
  putByte(col);             //((data & 0x01) * 256) + data >> 1); // put data
    }
  digitalWrite(load,HIGH);
}

// for adressing different MAX7219's while cascaded
void maxOne(byte maxNr, byte reg, byte col) {    
  int c = 0;
  digitalWrite(load, LOW);  // begin    
  for ( c = maxInUse; c > maxNr; c--) {
    putByte(0);             // no operation
    putByte(0);             // no operation
  }

  putByte(reg);             // specify register
  putByte(col);             //((data & 0x01) * 256) + data >> 1); // put data

  for ( c = maxNr-1; c >= 1; c--) {
    putByte(0);             // no operation
    putByte(0);             // no operation
  }
  digitalWrite(load,HIGH);
}

void putCol( byte colno, byte coldat) {
// Interprets colno as (zero ref) index in combined array
    byte t;
    t = colno >> 3;
    byte u;
    u = colno & 0x07;
    maxOne(t+1, u+1, coldat);
}

void dispon () {
 maxAll(max7219_reg_shutdown, 0x01);               // Display on
}  

void dispoff () {
 maxAll(max7219_reg_shutdown, 0x00);              // Display off
}  

byte icol = 0;          // Column index
byte pattern = 0;       // bit mask

// the follow variable is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 40;           // interval at which to blink (milliseconds)
long previousMillis = 0;      // will store last time LED was updated


// Samples digital 5, 6, 11, 12; analog 0, 1, 6, 7.
void readport () {
  for (e = 5; e <= 6; e++) {  
    pattern = pattern << 1;
    if (digitalRead(e) == HIGH) pattern++;
  }
  for (e = 11; e <= 12; e++) {  
    pattern = pattern << 1;
    if (digitalRead(e) == HIGH) pattern++;
  }
  pattern = pattern << 1;
  if (digitalRead(A0) == HIGH) pattern++;
  pattern = pattern << 1;
  if (digitalRead(A1) == HIGH) pattern++;
  pattern = pattern << 1;
  if (digitalRead(A6) == HIGH) pattern++;
  pattern = pattern << 1;
  if (digitalRead(A7) == HIGH) pattern++;

}

void worker () {
  lcd.setCursor(0,1);     // line 1 LHS
  lcd.print("   >");
  readport();
  putCol(icol,pattern);       // write the data.
  icol++;                     // moving right
  if (icol == maxInUse*8) {   // hit the side
    icol = 0;
  }
  for (e = 7; e >= 0; e--) {  
    if (pattern & (1 << e)) lcd.print(char(255));
    else lcd.print (" ");
  }
  lcd.print ("< ");
}
  

void setup () {

  lcd.begin(16,2);  // initialize the lcd as 20x4 (16,2 for 16x2)
  lcd.setBacklight(1); // switch on the backlight
  lcd.home ();  // go home to character 0 on line 0 (1st line)
  lcd.print(" Input  Scanner");  
  lcd.setCursor(0,1);  // character 0 on line 1 (2nd line)
  lcd.print ("   Version 02 ");

  pinMode(dataIn, OUTPUT);
  pinMode(clock,  OUTPUT);
  pinMode(load,   OUTPUT);
  pinMode(ledPin, OUTPUT);      

  digitalWrite(13, HIGH);  

/*  // option to declare inputs
  for (e=5; e<=12; e++) {   // ready the "data" inputs
    pinMode(e, INPUT);
    }

    pinMode(A0, INPUT);
    pinMode(A1, INPUT);
    pinMode(A6, INPUT);
    pinMode(A7, INPUT);
*/

//initiation of the max 7219
  maxAll(max7219_reg_displayTest, 0x00); // no display test
  maxAll(max7219_reg_scanLimit, 0x07);      
  maxAll(max7219_reg_decodeMode, 0x00);  // using an led matrix (not digits)
  maxAll(max7219_reg_shutdown, 0x01);    // not in shutdown mode
  for (e=1; e<=8; e++) {        // empty registers, turn all LEDs off
    maxAll(e,0);
  }
  maxAll(max7219_reg_intensity, 4 & 0x0f); // don't need it blazing
  delay(500);
      
}  

void loop () {

  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;  

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    // Alternate 1

    }
    else {
      ledState = LOW;

    // Alternate 2
    // set the LED with the ledState of the variable:
    // Timed process:
    
    worker();

    }

    digitalWrite(ledPin, ledState);

  }

}

In short (and on  a Pro Mini), some inputs tend to float down to ground, the analog inputs seem to do this more promptly, and some (such as 11 and 12 in my case) seem to just alternate (or if you like, pulsate).

* InputScanner.mp4 (1116 KB - downloaded 16 times.)
« Last Edit: December 30, 2013, 01:24:32 am by Paul__B » Logged

Peoria AZ
Offline Offline
Newbie
*
Karma: 2
Posts: 44
Professional Hobbyist with Minor Experience
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thats really interesting, That actually could be very useful information for another project I have,
I haven't set up the board for this circuit yet to test out what happens but I will in a few minutes, I have been busy working on my control system for my truck and that literally takes up all of the breadboard space i have and then some.
Logged

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. smiley-lol

Peoria AZ
Offline Offline
Newbie
*
Karma: 2
Posts: 44
Professional Hobbyist with Minor Experience
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From what I have gathered so far over the past weeks is that there generally is no problem with the way i designed my circuit and using a pin as an INPUT to go High-Z. but there is some issues with current leakage if using a battery or smaller power supply. So I did a little looking and found that a couple diodes in the circuit can reduce the amount of leakage  if placed after the resistors and before the LEDs. I haven't decided on a proper diode for my project but the one i found used 1.5v zeniers diodes.
Logged

Motivation comes in the form of knowing the wife is going to hurt me if I don't follow through with my projects after spending our entertainment budget on parts. smiley-lol

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4837
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Which is why I included the phrase "at large".
 
Believe me, the internet in general includes the datasheets and articles from manufacturers.


That's an evasion considering the garbage you web linked previously being the opposite of help.
Instead of taking the point, you go into a immature defense mode.

If you really want to learn how to find good answers then work WITH these guys instead of playing ego-CYA.
If you don't like MY attitude then consider how much of other people's time you've wasted in this thread alone as a sign of YOUR attitude.
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Pages: 1 [2]   Go Up
Jump to: