Hi,
I need a microcontroller with a 24-bit counter which can connect up to a computer. I'm wanting to use Arduino or Rasberry Pi but they don't have 24-bit counters. What do I need to add to the microcontroller to make it able to have a 24-bit counter.
See the code for micros() how a 16 bit counter can be extended to 32 bits. The timer/counter overflow can trigger an interrupt that can be used to increment an extension variable to the counter.
SAMD21 (Arduino Zero, assorted MKR boards) has 24bit counters (TCC) and 16bit counters that can be combined into 32bits.
Plus the 24 bit sysTick counter.
millis() can be considered a 32bit counter.
As many have pointed out, it's pretty easy to extend an 8 or 16bit counter in software.
Sorry if I didn't explain this properly. I have a load cell with a 24-bit ADC Amplifier attached to it and I need a microcontroller to connect upto a computer as well as to supply a clock and process the 24-bit signal from the amplifier. Thank you so much.
Please read the forum guidelines, especially the part about how to supply the information that is needed to answer a question.
The explanation in reply #11 is still not nearly enough.
The choice of microcontroller for your application depends on a lot of things that you haven't explained about your circuit. Usually, the number of bits that some peripheral works with, is far, far down on the list of important things to know. So please supply more details about the role that the microcontroller plays and any other requirements.
There are simple things you could convey that would be helpful, such as part numbers. As you can see, asking the wrong question got you a lot of good answers that aren't useful to you.
/* This program takes 10 samples from LC + HX711B at
1-sec interval and then computes the average.
*/
unsigned long x = 0, y = 0;
unsigned long dataArray[10];
int j = 0;
void setup()
{
Serial.begin(9600);
pinMode(A1, INPUT); //data line //Yellow cable in my Setup
pinMode(A0, OUTPUT); //SCK line //Orange cable in my Set up
}
void loop()
{
for (int j = 0; j < 10; j++)
{
digitalWrite(A0, LOW);//SCK is made LL
while (digitalRead(A1) != LOW) //wait until Data Line goes LOW
;
{
for (int i = 0; i < 24; i++) //read 24-bit data from HX711
{
clk(); //generate CLK pulse to get MSB-it at A1-pin
bitWrite(x, 0, digitalRead(A1));
x = x << 1;
}
clk(); //25th pulse
Serial.println(x, HEX);
y = x;
x = 0;
delay(1000);
}
dataArray[j] = y;
}
Serial.println("===averaging process=========");
unsigned long C1 = 0; //C1 = Count-1 against no fuel in the Tank
for (j = 0; j < 10; j++)
{
C1 += dataArray[j];
}
Serial.print("Average Count = ");
C1 = C1 / 10;
Serial.println(C1, HEX);
}
void clk()
{
digitalWrite(A0, HIGH);
digitalWrite(A0, LOW);
}
The 24 bit integer types are not widely supported by functions, but are available. The only thing I've ever used it for was arrays of rgb data for LEDs.