Skip to content

Commit

Permalink
Fix ghost channels (#2)
Browse files Browse the repository at this point in the history
- fix ghost channels when using for OUTPUT
  - add disable/enable in setChannel()
- add HC4053_performance.ino
- update readme.md
- update GitHub actions
- minor edits
  • Loading branch information
RobTillaart authored Apr 4, 2024
1 parent fb8f941 commit aefe47f
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 28 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# These are supported funding model platforms

github: RobTillaart
custom: "https://www.paypal.me/robtillaart"

3 changes: 2 additions & 1 deletion .github/workflows/arduino-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ on: [push, pull_request]
jobs:
runTest:
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/jsoncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ on:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
uses: limitusus/json-syntax-check@v2
with:
pattern: "\\.json$"

14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Change Log HC4051
# Change Log HC4053

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.1.0] - 2023-11-04
## [0.2.0] - 2024-04-03
- fix ghost channels when using for OUTPUT
- add disable/enable in setChannel()
- add HC4053_performance.ino
- update readme.md
- update GitHub actions
- minor edits

----

## [0.1.1] - 2023-11-04
- update readme.md

## [0.1.0] - 2023-01-25
Expand Down
6 changes: 4 additions & 2 deletions HC4053.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// FILE: HC4053.h
// AUTHOR: Rob Tillaart
// DATE: 2023-01-25
// VERSION: 0.1.1
// VERSION: 0.2.0
// PURPOSE: Arduino library for CD74HC4053 8 channel multiplexer and compatibles.
// URL: https://github.com/RobTillaart/HC4053



#include "Arduino.h"

#define HC4053_LIB_VERSION (F("0.1.1"))
#define HC4053_LIB_VERSION (F("0.2.0"))


class HC4053
Expand Down Expand Up @@ -44,9 +44,11 @@ class HC4053

void setChannel(uint8_t channel)
{
disable();
setChannelA(channel);
setChannelB(channel);
setChannelC(channel);
enable();
}


Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023-2023 Rob Tillaart
Copyright (c) 2023-2024 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,52 @@

# HC4053

HC4053 is an Arduino library for a HC4053 3x2 channel multiplexer.
HC4053 is an Arduino library for a HC4053 3 x 2 channel multiplexer.


## Description

HC4053 is a library to control the CD74HC4053 3x2 channel
HC4053 is a library to control the CD74HC4053 3 x 2 channel
multiplexer / demultiplexer and compatible devices.

The HC4053 is in fact three separate controllable switches in one,
and every switch can be set indepently in one of two positions.
This is functionaly different from both the 4051, 4052 and 4067
and every switch can be set independently in one of two positions.
This is functionally different from both the 4051, 4052 and 4067
in which there is only one channel selection

It is also possible to use the HC4053 to select an OUTPUT channel.
The signal pin can be connected to VCC (5V) or an IO pin set to OUTPUT.
Only the selected channel can show the HIGH level of the IO pin if set to HIGH.
Not selected pins will all be set to LOW.

The independent channel selection is done with three select lines **A, B, C**.

The device can be enabled/disabled by the enable line **INH**
The device can be enabled/disabled by the enable line **INH**.


#### Compatibles

to elaborate.
To elaborate.


#### Related to
#### Related

- https://github.com/RobTillaart/HC4051 (1x8 mux)
- https://github.com/RobTillaart/HC4052 (2x4 mux)
- https://github.com/RobTillaart/HC4053 (3x2 mux)
- https://github.com/RobTillaart/HC4067 (1x16 mux)
- https://github.com/RobTillaart/MAX14661 (2x16 mux, I2C)
- https://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-analog-multiplexerdemultiplexer/


## Hardware connection

Typical connection is to connect the three **select pins** to three IO Pins of your board.
Typical connection is to connect the three **select pins** to three IO pins of your board.

The optional **enablePin (INH)** must be connected to GND if not used.
This way the device is continuous enabled.
This way the device will be continuous enabled.

Example multiplexing 3x analog in.
Example multiplexing three times analog in.

```
processor HC4053
Expand Down Expand Up @@ -89,7 +96,7 @@ If the enablePin == 255 it is considered not used.
- **void setChannel(uint8_t channel)** sets A, B and C to channel in one call.
Think of it as a master switch.
Valid values 0, 1, this value is not checked, only last bit is used.
Note the channels will not change at the very same moment.
Note the three channels will not change at the very same moment.
- **void setChannelA(uint8_t channel)** sets A to channel.
Valid values 0, 1, this value is not checked, only last bit is used.
- **void setChannelB(uint8_t channel)** sets B to channel.
Expand All @@ -105,10 +112,10 @@ Valid values 0, 1, this value is not checked, only last bit is used.

These functions work only if enablePin is set in the constructor.

- **void enable()** idem.
- **void disable()** idem.
- **bool isEnabled()** idem.
Also returns true if enablePin is not set.
- **void enable()** enables the device to multiplex.
- **void disable()** disables the device, no channel is selected.
- **bool isEnabled()** returns the current status of the device.
Also returns true if the enablePin is not set in the constructor.


## Future
Expand Down
56 changes: 56 additions & 0 deletions examples/HC4053_performance/HC4053_performance.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// FILE: HC4053_performance.ino
// AUTHOR: Rob Tillaart
// PURPOSE: Demo for HC4053 3 x 2 channel (simple) multiplexer


#include "HC4053.h"

HC4053 mp(4, 5, 6, 8); // enable pin(8)

uint32_t start, stop;


void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("HC4053 LIBRARY VERSION: ");
Serial.println(HC4053_LIB_VERSION);
Serial.println();
delay(100);

mp.setChannel(1);

for (uint8_t ch = 0; ch < 2; ch ++)
{
start = micros();
mp.setChannel(ch);
stop = micros();
Serial.print("Channel ");
Serial.print(ch);
Serial.print(": \t");
Serial.println(stop - start);
delay(100);
}

mp.setChannel(1);
delay(100);

start = micros();
mp.setChannel(1);
stop = micros();

Serial.print("\nSetChannel: \t");
Serial.println(stop - start);
delay(100);

}


void loop()
{
}


// -- END OF FILE --
10 changes: 10 additions & 0 deletions examples/HC4053_performance/output_0.2.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

HC4053_performance.ino
HC4053 LIBRARY VERSION: 0.2.0

Channel 0: 24
Channel 1: 24

SetChannel: 12


4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "HC4053",
"keywords": "",
"description": "Arduino library for a HC4053 3x2 channel multiplexer.",
"description": "Arduino library for a HC4053 3 x 2 channel multiplexer.",
"authors":
[
{
Expand All @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/HC4053.git"
},
"version": "0.1.1",
"version": "0.2.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name=HC4053
version=0.1.1
version=0.2.0
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for a HC4053 3x2 channel multiplexer
sentence=Arduino library for a HC4053 3 x 2 channel multiplexer
paragraph=
category=Sensors
url=https://github.com/RobTillaart/HC4053
Expand Down

0 comments on commit aefe47f

Please sign in to comment.