Go Down

Topic: CD74HC154 Decoder - Why does it not follow Datasheet Truth Table? (Read 650 times) previous topic - next topic

RichKC24

Working with Peggy2 Board.

Using the Truth Table on page 2 of datasheet, I get pins turning on that do not match the datasheet table.


I have Atmegga328P connected to Decoder CD74HC154 as shown on attached schematic.


Converting Pin connections to Arduino Pins:


ATMEGA   Arduino   74HC154

         2              0            23
         3              1             22
         4              2             21
         5              3             20


74HC154 pins 18 and 19 are tied to ground.

Arduino code I am using to experiment with is:

int InputA0 = 0;
int InputA1 = 1;
int InputA2 = 2;
int InputA3 = 3;

void setup()
{

// initialize the control outputs

pinMode(InputA0, OUTPUT);
pinMode(InputA1, OUTPUT);
pinMode(InputA2, OUTPUT);
pinMode(InputA3, OUTPUT);


}

void loop()
{

digitalWrite(InputA0, LOW);
digitalWrite(InputA1, HIGH);
digitalWrite(InputA2, LOW);
digitalWrite(InputA3, LOW);

}


According to the datasheet table with A0,A1, A2 and A3 all set to L, H, L, L, output Y2 of CD74HC154 (pin 3) of  74HC154 should be low.  When I check the outputs with multimeter pin 4 is Low not 3.


If I change A0 - A3 to different settings from the Truth Table, different pins on chip are activated but not matching data sheet.

Been chasing this for hours.  I am sure there is a logical explanation.  I cannot find it.




larryd

Avoid pins D0 and D1 as they are for serial communications.


No technical PMs.
The last thing you did is where you should start looking.

RichKC24

I am using the Peggy2 board and it does connect Atmega Pin 2 (PD0) and Pin 3 (PD1) to  74HC154.  I cannot change this since it is a PCB.  The board has a jumper option to enable serial comm but I did not install that jumper.

The Peggy2 board does work with the programs and libraries written for it, but has the behaviour regarding the DataSheet truth table as mentioned.


larryd

With a DVM, confirm voltages on A0-A3 and pins 3 and 12, 24 and 19, 18 'ON the' 154.





No technical PMs.
The last thing you did is where you should start looking.

RichKC24

After running code above with:

A0 = Low
A1 = High
A3 = Low
A4 = Low

DVM readings on 74HC154:

  Pin        Voltage (V)
23  A0        3.53
22  A1        4.35
21  A2        0.0067
20  A3        0.0068

3    Y2        5.17
12  GND     0.0001
24  Vcc       5.17
16  Y14       5.17
18  E1         0.0001
19  E2         0.0001

Well A0 does not look Low.  That is interesting.  Any ideas?



RichKC24

If the chip sees A0 = High  and we have
A0 = High
A1 = High
A2 = Low
A3 = Low


Truth Table says that Y3 Pin 4 = Low

Using DVM

 Pin        Voltage (V)
1  Y0        5.17
2  Y1        5.17
3  Y2        5.17
4  Y3        0.0027

So the chip is working!  Just need to figure out why A0 is not Low.

RichKC24

I replaced the 74HC154 with another and turned on the board and A0 was low as it should be!

But then I reprogrammed the board and problem came back:  A0 = 3.53 Volts instead of Low.

PaulRB

From the peggy2 schematic:
Quote
Populate ONLY (JP1 and JP2) OR (JP3 and JP4).
Select: JP1 and JP2 to enable the "serial hack"
or
Select: JP3 and JP3 for exact compatibility with
Peggy 2.0.
I'm guessing you are using the "serial hack" to allow programming Arduino-style? If true, perhaps you have JP1 & 2 shorted and JP3 & 4 open? If so, then your code is using the wrong Arduino pins. As already mentioned, Arduino pins 0 & 1 are used for serial programming with Arduino. With those jumpers set, i think you should be using PC4 & PC5 which are A4 & A5 Arduino pins. Or maybe you don't have any of the jumpers shorted?

RichKC24

I have jumpers JP3 and JP4
JP1 and JP2 are open.

According to Evil Mad Scientist you can program with FTDI with either set of jumpers set. The "Serial" option is for 2 way communication to computer, I think:


https://forum.evilmadscientist.com/discussion/484/question-about-part-13-in-peggy-2-jumpers-optional-serial-hack


I do see what you are saying.   As I programmed via FTDI connector, the wrong LEDs were lit until I unplugged the programming connector and then the correct lights went on and A0 was low!

Then again I programmed via FTDI, different combination of HIGHs and LOWs, unplugged the programming connector and now A1 should be low but is not.

So is the Peggy2 board simply a bad design? Using FTDI programming lines intermingled with sending High Low levels to 74HC154 pins 22 and 23?



larryd

If you program through the ICSP pins, you get rid of the boot-loader.


No technical PMs.
The last thing you did is where you should start looking.

RichKC24

True and lets you stay away from PD0 and PD1 which set High/Low on A0 and A1 on 74HC154.

I just don't understand how my simple little program that is setting 4 pins High/Low does not work, but when I load a Peggy Sketch through TTL using FTDI cable it runs fine - complicated programs:  LEDs running patterns, shades of grey, etc.

Was hoping there was something wrong with my code....

PaulRB

Ok, I'll try to explain another way. Make this change to your test sketch:
Code: [Select]
int InputA0 = A4;
int InputA1 = A5;
int InputA2 = 2;
int InputA3 = 3;

RichKC24

LarryD - now I understand what you are saying.  

Drive High/Low on 74HC154 using Atmega pins 27 and 28 (Arduino A4 and A5)

This means I need to connect Jumpers JP1 and JP2 and disconnect Jumpers JP3 and JP4.

This will solve the intermingling of programming TTL pins 4 and 5 with Atmega output pins 2 and 3.




I wanted to connect a Real Time Clock DS3231 to Atmega pins 27 (SDA) and 28 (SCL).  
I would think I would not be able to do that if using these pins for outputs to HC154.

PaulRB

Quote
I wanted to connect a Real Time Clock DS3231 to Atmega pins 27 (SDA) and 28 (SCL). 
I would think I would not be able to do that if using these pins for outputs to HC154.
Correct. It's a design flaw in the peggy2 board. The are lots of other pins they could have used which don't also have special functions. On the other hand, even if you avoid using A4/A5, how are you going to connect the rtc to them? Soldering wires to the chip pins is not recommended. Unless you are an expert solderer, the heat can damage the chip. Perhaps you can solder fine wires to the socket pins on the rear of the board.

RichKC24

The Peggy board has some plated vias next to each Atmega pin.   I can solder to those easily and connect to RTC.




That connects my RTC to Atmega pins 27 and 28 (SDA and SCL) (need to remove Jumper JP 1 and JP2)

I also need to connect a second set for the A0 and A1 High/Low signals to 74HC154 pins 22 and 23  replacing the SDA and SCL connections.

I could use Atmega pins 23 and 24 (ADC0 PC0 and ADC1 PC1) which Peggy board has going to two buttons.  Could connect them to 74HC154 pins 22 and 23 and like you say connect to 74HC154  socket pins on back of board.

Are these two pins suitable? 

Thanks so much for your help.

Go Up