Skip to content

Commit 1f26ff8

Browse files
committed
0.1.0 74HC590
1 parent ea13c58 commit 1f26ff8

17 files changed

+687
-0
lines changed

libraries/74HC590/.arduino-ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
platforms:
2+
rpipico:
3+
board: rp2040:rp2040:rpipico
4+
package: rp2040:rp2040
5+
gcc:
6+
features:
7+
defines:
8+
- ARDUINO_ARCH_RP2040
9+
warnings:
10+
flags:
11+
12+
packages:
13+
rp2040:rp2040:
14+
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
15+
16+
compile:
17+
# Choosing to run compilation tests on 2 different Arduino platforms
18+
platforms:
19+
- uno
20+
# - due
21+
# - zero
22+
# - leonardo
23+
- m4
24+
- esp32
25+
- esp8266
26+
# - mega2560
27+
- rpipico
28+
29+
libraries:
30+
- "printHelpers"

libraries/74HC590/.github/FUNDING.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
github: RobTillaart
4+
custom: "https://www.paypal.me/robtillaart"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Arduino-lint
2+
3+
on: [push, pull_request]
4+
jobs:
5+
lint:
6+
runs-on: ubuntu-latest
7+
timeout-minutes: 5
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: arduino/arduino-lint-action@v1
11+
with:
12+
library-manager: update
13+
compliance: strict
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Arduino CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
runTest:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 20
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
- run: |
16+
gem install arduino_ci
17+
arduino_ci.rb
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: JSON check
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.json'
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 5
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: json-syntax-check
16+
uses: limitusus/json-syntax-check@v2
17+
with:
18+
pattern: "\\.json$"

libraries/74HC590/74HC590.h

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#pragma once
2+
//
3+
// FILE: 74HC590.h
4+
// AUTHOR: Rob Tillaart
5+
// DATE: 2025-04-30
6+
// VERSION: 0.1.0
7+
// PURPOSE: Arduino library for the 54HC590 / 74HC590 binary counter
8+
// URL: https://github.com/RobTillaart/74HC590
9+
10+
11+
#include "Arduino.h"
12+
13+
#define LIB_74HC590_VERSION (F("0.1.0"))
14+
15+
16+
17+
class DEV_74HC590
18+
{
19+
public:
20+
// OE output enable
21+
// CCLR counter clear
22+
// CCKEN counter clock enable
23+
// CCLK counter clock
24+
// RCLK register clock if set to 255 ==> RCLK == CCLK
25+
// RCO ripple carry out if set to 255 ==> no RCO (input)
26+
DEV_74HC590(uint8_t OE, uint8_t CCLR, uint8_t CCKEN, uint8_t CCLK, uint8_t RCLK = 255, uint8_t RCO = 255)
27+
{
28+
_OE = OE;
29+
_CCLR = CCLR;
30+
_CCKEN = CCKEN;
31+
_CCLK = CCLK;
32+
_RCLK = RCLK;
33+
_RCO = RCO;
34+
35+
pinMode(_OE, OUTPUT);
36+
pinMode(_CCLR, OUTPUT);
37+
pinMode(_CCKEN, OUTPUT);
38+
pinMode(_CCLK, OUTPUT);
39+
if (_RCLK != 255) pinMode(_RCLK, OUTPUT);
40+
if (_RCO != 255) pinMode(_RCO, INPUT);
41+
42+
digitalWrite(_OE, LOW);
43+
digitalWrite(_CCLR, LOW);
44+
digitalWrite(_CCKEN, LOW);
45+
digitalWrite(_CCLK, LOW);
46+
if (_RCLK != 255) digitalWrite(_RCLK, LOW);
47+
};
48+
49+
void enableOutput()
50+
{
51+
digitalWrite(_OE, LOW);
52+
};
53+
54+
void disableOutput()
55+
{
56+
digitalWrite(_OE, HIGH);
57+
};
58+
59+
// clears on RISING edge
60+
void clearCounter()
61+
{
62+
digitalWrite(_CCLR, LOW);
63+
digitalWrite(_CCLR, HIGH);
64+
};
65+
66+
void enableCounter()
67+
{
68+
digitalWrite(_CCKEN, LOW);
69+
};
70+
71+
void disableCounter()
72+
{
73+
digitalWrite(_CCKEN, HIGH);
74+
};
75+
76+
void pulseCounter()
77+
{
78+
digitalWrite(_CCLK, HIGH);
79+
digitalWrite(_CCLK, LOW);
80+
};
81+
82+
void pulseRegister()
83+
{
84+
if (_RCLK == 255) return;
85+
digitalWrite(_RCLK, HIGH);
86+
digitalWrite(_RCLK, LOW);
87+
};
88+
89+
uint8_t readRCO()
90+
{
91+
if (_RCO == 255) return 0;
92+
return digitalRead(_RCO);
93+
};
94+
95+
96+
protected:
97+
uint8_t _OE;
98+
uint8_t _CCLR;
99+
uint8_t _CCKEN;
100+
uint8_t _CCLK;
101+
uint8_t _RCLK;
102+
uint8_t _RCO;
103+
};
104+
105+
106+
// -- END OF FILE --
107+

libraries/74HC590/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Change Log 74HC590
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
9+
## [0.1.0] - 2024-04-30
10+
- initial version
11+
12+
13+

libraries/74HC590/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025-2025 Rob Tillaart
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

libraries/74HC590/README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
2+
[![Arduino CI](https://github.com/RobTillaart/74HC590/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
3+
[![Arduino-lint](https://github.com/RobTillaart/74HC590/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/74HC590/actions/workflows/arduino-lint.yml)
4+
[![JSON check](https://github.com/RobTillaart/74HC590/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/74HC590/actions/workflows/jsoncheck.yml)
5+
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/74HC590.svg)](https://github.com/RobTillaart/74HC590/issues)
6+
7+
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/74HC590/blob/master/LICENSE)
8+
[![GitHub release](https://img.shields.io/github/release/RobTillaart/74HC590.svg?maxAge=3600)](https://github.com/RobTillaart/74HC590/releases)
9+
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/74HC590.svg)](https://registry.platformio.org/libraries/robtillaart/74HC590)
10+
11+
12+
# 74HC590
13+
14+
Arduino library for the 74HC590 8 bit binary counter.
15+
16+
17+
## Description
18+
19+
**Experimental**
20+
21+
This library is to control the 74HC590 (and 54HC590) binary counter.
22+
23+
The library was written to get a better understanding of the possibilities
24+
the device has to offer. It has not been tested with hardware yet.
25+
26+
The 74HC590 is an 8 bit binary counter, with 8 output lines QA .. QH which
27+
can represent the values 0 .. 255.
28+
The internal counter can only count up, or can be reset to zero.
29+
Furthermore the device can control, by means of RCLK, when the internal counter
30+
is copied to the 8 output lines.
31+
This selective copying of the internal counter allows to skip through the
32+
binary numbers e.g. with step 5.
33+
34+
The 74HC590 has an RCO line which triggers a (LOW) pulse when the internal
35+
counter is going from 255 to 0.
36+
This can be used for cascading multiple devices (to investigate).
37+
38+
Read datasheet for details.
39+
40+
As always feedback is welcome.
41+
42+
43+
### Related
44+
45+
only slightly related
46+
- https://github.com/RobTillaart/FastShiftIn
47+
- https://github.com/RobTillaart/FastShiftInOut
48+
- https://github.com/RobTillaart/FastShiftOut
49+
- https://github.com/RobTillaart/ShiftInSlow
50+
- https://github.com/RobTillaart/ShiftOutSlow
51+
52+
53+
## Interface
54+
55+
```cpp
56+
#include "74HC590.h"
57+
```
58+
59+
### Constructor
60+
61+
- **74HC590(uint8_t OE, uint8_t CCLR, uint8_t CCKEN, uint8_t CCLK, uint8_t RCLK = 255, uint8_t RCO = 255)**
62+
- OE = output enable
63+
- CCLR = counter clear
64+
- CCKEN = counter clock enable
65+
- CCLK = counter clock
66+
- RCLK = register clock (if 255 ==> RCLK == CCLK)
67+
- RCO = register clock OUT (if 255 ==> no RCO)
68+
69+
### Control
70+
71+
- **void enableOutput()** idem.
72+
- **void disableOutput()** idem.
73+
- **void clearCounter()** set the internal counter to zero.
74+
- **void enableCounter()** enable the increment the internal counter on the RISING edge of CCLK.
75+
- **void disableCounter()** disable the increment the internal counter on the RISING edge of CCLK.
76+
77+
78+
### Pulse
79+
80+
- **void pulseCounter()** increment the internal counter.
81+
- **void pulseRegister()** copy internal counter to output register.
82+
If RCLK is not set, pulseRegister() does nothing.
83+
The user can e.g. connect the CCLK and RCLK so they update in sync,
84+
or uses another way to trigger the RCLK line.
85+
86+
87+
### Cascading
88+
89+
- **uint8_t readRCO()** read back the value of the RCO pin.
90+
Could be connected to an interrupt pin to know when 256 pulses arrived.
91+
92+
93+
## Future
94+
95+
#### Must
96+
97+
- improve documentation
98+
- get hardware to test
99+
100+
#### Should
101+
102+
- derived class 54HC590?
103+
- CCLK optional / external?
104+
105+
#### Could
106+
107+
- investigate applications (examples / separate classes)
108+
- counter for external pulses? RPM? - no CCLK connected.
109+
- pulse divider by 2,4,8,16,32,64,128 with reset to zero control.
110+
- control a DAC / R2R network?
111+
- PIR sensor pulse counter
112+
- use the output as fast timer
113+
- 1MHz input counts micros().
114+
- 1kHz input counts millis().
115+
- optimize pulseCounter() for AVR (most used). See fastShiftOut class.
116+
- optimize pulseRegister() for AVR (most used).
117+
118+
#### Wont
119+
120+
121+
## Support
122+
123+
If you appreciate my libraries, you can support the development and maintenance.
124+
Improve the quality of the libraries by providing issues and Pull Requests, or
125+
donate through PayPal or GitHub sponsors.
126+
127+
Thank you,
128+
129+

0 commit comments

Comments
 (0)