Either the on-board power supply of the Raspberry Pi Zero W, does not like my circuit board, or maybe the copper pour on the circuit board is shielding the wifi maintaining reliable connection to my router, either way I got frustrated with the Raspberry Pi and wired in an Arduino Pro-Mini.

Running the code below and then using the serial monitor, the 16 bit signed integer output of the up down counter of the HTCL-2017.
int QuadCount; // 32 bit signed integer
byte HighByte; // 8 bit byte
byte LowByte; // 8 bit byte
void setup(){
Serial.begin(9600);
Serial.println("start");
//setup three pins to control HCTL-2017 modes
pinMode(10, OUTPUT); //SEL
pinMode(11, OUTPUT); //OE
pinMode(12, OUTPUT); //RESET
//setup pins 2-9 as inputs from HCTL-2017 output bus
for (int i = 2; i < 10; i++)
{
pinMode(i, INPUT);
}
//RESET HCTL-2017. Reset counters to zero
digitalWrite(10, LOW); //SEL
digitalWrite(11, LOW); //OE
digitalWrite(12, LOW); //RESET
}
void loop(){
HighByte = 0;
LowByte = 0;
//Stop counting, load high byte onto output pins
digitalWrite(10, LOW); //SEL
digitalWrite(11, LOW); //OE
digitalWrite(12, HIGH); //RESET
delay(100);
//read 8-bits from HCTL-2017 high byte.
for (int i = 0; i < 8; i++)
{
if (digitalRead(i+2) == 1) {
HighByte |= (1<<i);
}
}
//load low byte onto output pins
digitalWrite(10, HIGH); //SEL
digitalWrite(11, LOW); //OE
digitalWrite(12, HIGH); //RESET
delay(100);
//read 8-bits from HCTL-2017 low byte.
for (int i = 0; i < 8; i++)
{
if (digitalRead(i+2) == 1) {
LowByte |= (1<<i);
}
}
//complete inhibit logic reset
digitalWrite(10, HIGH); //SEL
digitalWrite(11, HIGH); //OE
digitalWrite(12, HIGH); //RESET
delay(100);
//count for a second
delay(1000);
QuadCount = word(HighByte, LowByte);
Serial.print(QuadCount);
Serial.print(" ");
Serial.println(QuadCount, BIN);
}
Took a little bit of tweeking to get it working, but it seems to work just fine.

Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.