Show Posts
Pages: 1 ... 79 80 [81] 82 83 ... 100
1201  Using Arduino / LEDs and Multiplexing / Re: Programming for a custom LED matrix / display on: June 13, 2011, 09:26:09 pm


I wrote last week

"Apart from during initial testing after soldering, where some have failed, in the last 10,000 LEDs used I have not had one failure reported ( I might be sorry I said that :-) ) "

Stupid, stupid, stupid  smiley-evil

I had to fix a problem on Saturday on a LED sign on the roof of a hotel, and guess what, there was one string of LEDs unlit !
One LED was open circuit, and of course I didn't have a spare, so I just shorted it out, so the other 4 in the chain are going to be pushing the limit ( like the old Christmas tree lights once they start popping  smiley-confuse  )

Nobody has noticed yet, each segment has 20 LEDs so its not too obvious.

1202  Using Arduino / LEDs and Multiplexing / Re: scanning 25 bcd switches - wrong reading? on: June 13, 2011, 09:06:45 pm
Nice one Bob,    like with the remote control !   smiley

I think I have inadvertently fixed the problem ( I hate to say that too soon but it has been ok for the last 8 hours when I try it )

Just before I posted the code, I forgot I had tried putting in a delay right at the end of the scan function, so that the clock pulse to the cascaded counters had a bit of time at a high level.

Without it the next instruction was to take it low again.  I don't know how to work out how long that takes,  but the data sheet for the 4017 says the clock pulse at 5v should be minimum 200nS.     3.2 clock pulses @ 16Mhz?

The wiring to the  perf board and the 3 chips clock inputs has quite a bit of capacitance too, and there is a 22k resistor feeding each counter for the diode "anding"

I guess it was tripping over its own feet ?  I will test it again in the morning,  and perhaps reduce the delay to a couple of milliseconds, I can see it is noticeably slower with 20mS  x  20 loops.   nearly half a second.
1203  Using Arduino / LEDs and Multiplexing / Re: scanning 25 bcd switches - wrong reading? one more hassle on: June 13, 2011, 06:34:37 am
I have everything working fine, the radio range is brilliant, I walked two blocks away and the signal got through 4 houses and about 200 meters before I couldn't walk any more ( a dead end road )

But now and again, when the system has been on a time and I have been randomly checking it, It throws up a wrong display, sometimes all the displays go off and when I checked the Tx, I found that it was just sending zeros.

It is very intermittent though.  most times its fine.

Is there anything in the code below that might be filling up some memory or whatever ?     I am basically scanning the outputs of the 4017 to read  20 bcd switches, as in the sketch linked in a message above,  and transmitting it via VirtualWire....


Code:
//  FIRST TRY SCANNING USING 4017  serialprints commented out to speed up

#include <VirtualWire.h>    // Wireless transmitter/receiver library
#include <avr/sleep.h>      // powerdown library
#include <avr/interrupt.h>  // interrupts library

// ***********************************************************************

uint8_t SW[4]; // assign four data pins from bcd switches

int SW0 = 3;               // bits to read in unique address - LSB
int SW1 = 4;               // bits to read in unique address
int SW2 = 5;               // bits to read in unique address
int SW3 = 6;               // bits to read in unique address - MSB
int address = 0;         

int reset = 18;
int clock = 16;
int pwrup = 19;   // for powering cd4017 counters,  left hi in this example

int dpin0 = 0;              // apparently redefined by Serial as Serial Monitor works
int dpin1 = 1;              // apparently redefined by Serial as Serial Monitor works
int pin2 = 2;               // Int0 interrupt pin


// create an array to store data to be sent out
// ***********************************************************************
int switchbanks = 20; // CHANGE TO NUMBER OF SWITCHES +1 for pin dipswitch max 25
char msg [20]; // includes msg 0  which is PIN number from dip switches
// ***********************************************************************

// *  Name:        pin2Interrupt, "ISR" to run when interrupted in Sleep Mode
void pin2Interrupt()
{
  /* This brings us back from sleep. */
}
//   ********************************************************************                                                                                                                                                                                                                                                                                             66
void enterSleep()
{
  attachInterrupt(0, pin2Interrupt, LOW);
  delay(50); // need this?

  set_sleep_mode(SLEEP_MODE_PWR_DOWN);  // setting up for sleep ...
  sleep_enable();                       // setting up for sleep ...
  ADCSRA &= ~(1 << ADEN);
  PRR = 0xFF;
  sleep_mode();                         // now goes to Sleep and waits for the interrupt
  /* The program will continue from here after the interrupt. */
 
  detachInterrupt(0);                 //disable interrupts while we get ready to read the keypad
  // Power up functions
  PRR = 0x00;

  sleep_disable();   /* First thing to do is disable sleep. */
}

// ***********************************************************************

void setup()
{
  Serial.begin(9600);
 
  pinMode(pin2, INPUT);                 // sleep interrupt pin
  digitalWrite(pin2, HIGH);  //  sets pull up res

  pinMode ( clock, OUTPUT );  // starts the clock to the CD4017s to zero so first out = PIN number
  digitalWrite(clock, LOW);
 
    pinMode ( reset, OUTPUT );  //  resets the external cd4017 counters to 0
  digitalWrite(reset, HIGH);

 pinMode ( pwrup, OUTPUT );
   digitalWrite(pwrup, HIGH);  //  leave high for testing
 
//***************************************************************************

//  all data inputs SW0-3 have pull down 22k resistors
  pinMode(SW0, INPUT); // LSB of remote Address
  byte add0 = 0;
  pinMode(SW1, INPUT); // LSB+1
  byte add1= 0;
  pinMode(SW2, INPUT);  // LSB+2
  byte add2 = 0;
  pinMode(SW3, INPUT);  // MSB of address
   byte add3 = 0;

// *************************************************************************
  Serial.begin(9600);                
  Serial.println("TX setup");              // for debug only

  // ***********************************************************************t
  // Initialise the IO and ISR for VirtualWire
 
vw_set_tx_pin(9);
  vw_set_ptt_pin(11); //  should be set as default ?
  vw_setup(2400);                       // Bits per sec

}                                            // end of void Setup()

// *******************************************************************************************

void loop()
{
digitalWrite(reset, HIGH);
  Serial.println("Sleep");               // for debug only
    enterSleep();                             // call Sleep function to put us out
  //  THE PROGRAM CONTINUEs FROM HERE after waking up in enterSleep()
 
digitalWrite(reset, LOW);

  scan ();

   vw_send((uint8_t *)msg, switchbanks);     // send the character out
   vw_wait_tx();                             // Wait until the whole message is gone
}                                             // end of void loop

//********************************************************************************************
void scan ()
{
    for ( int r=0; r<= switchbanks; r++ )
  {
 digitalWrite(clock, LOW );

    address=0;

   add3 = digitalRead(SW3);
   add3 = add3 << 3;
   add2 = digitalRead(SW2);
   add2 = add2 << 2;
   add1 = digitalRead(SW1);
    add1 = add1 << 1;
   add0 = digitalRead(SW0);
   // now OR it together
   address = address|add3;
   address = address|add2;
   address = address|add1;
   address = address|add0;
 
        msg [r]  = address;

digitalWrite(clock, HIGH );  // move 4017 on to next switch
delay ( 20 );
  } // end of  for ( int x=2; x<= switchbanks; x==)
}  // end of scan function
1204  Using Arduino / Programming Questions / Re: Super-Low Power Arduino (for battery powered application) on: June 13, 2011, 03:27:41 am
I have blatantly copied Crossroads' sleep mode collection on my current project ( except I have a separate interrupt pushbutton to ground ), and I also power my transmitter and 3 cmos counter chips from an output pin ( make sure you switch all inputs to the cmos chips to low before powering them down or the protection diodes will short the input to ground via the vcc being low - I blew one micro that way )

 I am using a 9v battery and a micropower 5 volt regulator that is always on , and my unit draws 110 microamps in sleep mode, which with a 580mAh duracell should last about 5000 hours = about 7 months.
1205  Using Arduino / LEDs and Multiplexing / Re: Programming for a custom LED matrix / display on: June 11, 2011, 11:37:09 am
Thats nice to know Andrew,  I have downloaded the Kincad, and will check that when I catch up
1206  Using Arduino / LEDs and Multiplexing / Re: Programming for a custom LED matrix / display on: June 10, 2011, 10:11:34 am
Kicad also looks interesting, if anyones tried it?

1207  Using Arduino / LEDs and Multiplexing / Re: scanning 25 bcd switches - wrong reading? on: June 10, 2011, 03:22:45 am


Here's a link to the circuit of the 4017 cascade part of the circuit. I have used simple diode gating to save the AND gate suggested on the datasheet for cascading.

http://flic.kr/p/9S6oUy

I always use BAT85 schottky diodes as they only have about 250mV across them when on, as opposed to 650mV for a 1N4148.

You can repeat the middle chip as many times as you want, getting 8 more outputs for every chip.

I reset the chips with the first reset rather than the last 0 in the datasheet, so have 9 outputs from that chip as well.

This gives 26 outputs, I am using the first ( 0 ) for the PIN number on my system, and the other 25 are available for the BCD switches.



1208  Using Arduino / LEDs and Multiplexing / Re: Programming for a custom LED matrix / display on: June 10, 2011, 02:16:52 am
I have been using Sprint Layout for pcbs for a while now, it was only about $40 I recall, I didn't like auto-route on most packages I tried, so routed manually anyway, so this has been OK.
Its very basic in that when you move a component the trace doesnt move with it, but I have since downloaded http://www.designspark.com/pcb which looks interesting, and has some nice reviews .
 I havn't had a chance to even try it yet with so many projects on the go, but I like the price - its FREE.

If anyone has tried it I would like to hear how it works, as I hate wasting time learning a new program that will not work for me.

I hope to finish the remote this morning, and will put some pics up.

I hope to also finish a 4 digit version of this today, it uses the same scanning idea, but doesn't use the 4017s, just 4 pins of the micro to select the bcd switches in turn..
1209  Using Arduino / LEDs and Multiplexing / Re: Programming for a custom LED matrix / display on: June 09, 2011, 05:55:42 pm
@  Crossroads.   I got the BCD switch scanner going, and have posted a photo on the original thread at

http://arduino.cc/forum/index.php/topic,62859.msg457274.html#msg457274
1210  Using Arduino / LEDs and Multiplexing / Re: scanning 25 bcd switches - wrong reading? on: June 09, 2011, 05:51:26 pm
OK I finally got the 25 BCD switch scanner going, I am only using 19 switches for this project, see photo http://flic.kr/p/9RWEo6  of the test setup ( and the remote control box with all its filed rectangular holes and half the wiring done.)

I am using an Arduino board ( top right ) with only 3 switches connected to test it. The receiver has only little 3 displays for testing.  The 19 chips are TPIC6B595 daisychained shift registers with high current sinking for large common anode LED displays

The 3 x  CD4017 decade counters are on the vero/perf board in the middle of the pic, they are cascaded to give up to 25 outputs to the switchbanks.

I am running the RF link at 2400 ,  and all 19 displays update in less than half a second .

Hopefully I can get  it all boxed up by the weekend.

1211  Using Arduino / LEDs and Multiplexing / Re: Programming for a custom LED matrix / display on: June 09, 2011, 01:54:50 am
@   Crossoads    I was up till 3am soldering in the 19 shift registers, it seems to be working ok with the 2 Artduinos hooked up, but I want to see it in real action.

There is somethng funny with the Shiftout  function, but I will sort that out later today.

I will post some pics a bit later, the wiring in the remote is quite something !
1212  Using Arduino / LEDs and Multiplexing / Re: Programming for a custom LED matrix / display on: June 09, 2011, 12:19:24 am
IMHO

The actual base current will be less than one milliamp as the gain of the transistor is over 50 and the collector current supplies most of the 50 mA for the LEDs, but I would prefer to have the LEDs and their resistors in the collector circuit (common anode connected ) and save the half a volt base bias. ( minus the saturation voltage to be pedantic )

I don't know what colour LEDs you are using, but it sounds like there are different ones for the range of current you mention.

Some LEDs have 3 volts forward drop, which if added to the base/emitter drop of say .6 volt, only leaves you with 1.4 volts to drop across each resistor ( 56 ohm at 25mA ) which is fine, but its better to have more voltage to play with ( as with the common emitter configuration )  to match the differences of forward voltage and brightness in the pair of LEDs .


A  1k8 resistor from the chip to the base of the 2N2222, ground the emitter, and each LED in series with its own resistor ( again to separate V forward differences in the LEDs )

Incidentally, you wont perceive too much difference in overall display brightness by running the LEDs 10% less than their max current.
The reliability will depend on the heat of each LED, which can vary with local conditions, sunshine for instance,  and how well ventilated the LEDs are.

I mainly use red wide angle LEDs with a recommended  current of 20mA,  but I run them at 18mA.
Apart from during initial testing after soldering, where some have failed, in the last 10,000 LEDs used I have not had one failure reported ( I might be sorry I said that :-) )

It is a far different story with orange ones from my supplier, I don't use orange anymore !

1213  Using Arduino / LEDs and Multiplexing / Re: Momentary button as ON/OFF Switch on: June 08, 2011, 11:14:37 pm
I think the resistor is there to protect the chip if you plug in a pre-programmed chip, whose pin was set to output high, and a switch shorts it to ground ( before reprogramming the chip)
1214  Using Arduino / LEDs and Multiplexing / Re: scanning 25 bcd switches - wrong reading? on: June 03, 2011, 04:13:48 pm
Thanks Mike I will try that.
I have got the receiver listing all 19 switches, plus the PIN nunmber checking, next stage is to build it on veroboard, and shiftout to 19 displays.
I know shiftout is not that fast, but this project is to replace the Holtek chips I was using that took about 2 seconds to update.
1215  Using Arduino / LEDs and Multiplexing / Re: scanning 25 bcd switches - wrong reading? on: June 03, 2011, 10:51:58 am
OK, with hindsight and a couple of hours sleep I sorted out why I was getting 1000 reading from the switches when scanned - one of the pull-down resistor leads  had become open circuit ( read bad soldering by me )

But meantime I still had to go back to the longer "or" ing each bit to get it to work for some reason.

What does " invalid conversion from 'uint8_t*'to 'uint8_t' " mean?       

 is the * a pointer ?   or should I leave that closet closed until I have time to learn more?

The reason I want to only have two micro pins controlling the CD4017 counting, is that I want to later use another 7 pins for a 3x4 keyboard.

I should still have some spare pins for flexibility.

I hope to be able to send in one packet :-   the selected decimal number from up to 25 BCD switches, and one of 12 keypresses, plus a security number ( which I call PIN )  all in one 27 byte burst using VirtualWire.

Tonight I am on the receiver decoder, I love VirtualWire, with literally one wire ( the usb plugs do the ground ) I don't have to run the RF link for testing, which is a blessing for all my neighbours who are trying to open the complex gate with their remotes ( also on 433 Mhz )

Pages: 1 ... 79 80 [81] 82 83 ... 100